locked
fullscreen windows RRS feed

  • Question

  • I am writing a program that will require the use of a fullscreen window. I am programming in C using the Windows API functions, but have no clue how to make a fullscreen window with the API. I searched the MSDN thoroughly, but found no results for anything but Windows CE. Can anyone explain how to make a window created with CreateWindow () a fullscreen window?
    Saturday, January 24, 2009 1:17 AM

Answers

All replies

  • Create a borderless window.  Display it with ShowWindow() SW_MAXIMIZE.  The taskbar will honor your request and get out of the way.
    Hans Passant.
    • Marked as answer by xixpsychoxix Saturday, January 24, 2009 2:28 AM
    • Unmarked as answer by xixpsychoxix Saturday, January 24, 2009 4:34 AM
    • Marked as answer by Ji.ZhouModerator Thursday, January 29, 2009 11:01 AM
    Saturday, January 24, 2009 2:08 AM
    Moderator
  • Thanks alot. That should be perfect!

     

    umm.. i cant seem to find the style for no border. I tried using 0, but that didnt work. I also tried some of the other styles that had nothing to do with a border, but none worked. What is the style for no border?

     

    Nevermind, i figured it out. I just specified WS_POPUP. I do have another question however. I am trying to use a window with a black background to simulate a DOS window, and on maximize go to full screen simulated DOS prompt. It just has to look like a DOS style prompt, because basically I'm experimenting with designing a mini virtual machine and i need something that looks like the screen at startup, in other words, with BIOS teletype fonts and everything. The code i have to make such a window so far is:

    1
    #include <windows.h> 
    2
    #include <fstream> 
    3
     
    4
    using namespace std; 
    5
     
    6
    char *mem = (char *) malloc ((80*2)*25); 
    7
    LPLOGFONT to_save; 
    8
     
    9
    BOOL CALLBACK SaveFont (LPLOGFONT lplf, LPNEWTEXTMETRIC lpntm, DWORD FontType, LPVOID aFontCount) 
    10
    11
        to_save = lplf; 
    12
        return false
    13
    14
     
    15
    LRESULT CALLBACK WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) 
    16
    17
        PAINTSTRUCT ps; 
    18
        HDC hdc; 
    19
        int cur_line = 0, cur_pos = 0; 
    20
        char *out = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzab"
    21
     
    22
        switch (msg) 
    23
        { 
    24
        case WM_PAINT: 
    25
     
    26
            hdc = BeginPaint (hwnd, &ps); 
    27
     
    28
            EnumFontFamilies (hdc, "Fixedsys", (FONTENUMPROC) SaveFont, 0); 
    29
            to_save->lfHeight = 12; 
    30
            to_save->lfWidth  = 8; 
    31
     
    32
            SelectObject (hdc, (HGDIOBJ) CreateFontIndirect (to_save)); 
    33
             
    34
            SetBkColor (hdc, RGB(0,0,0)); 
    35
            SetTextColor (hdc, RGB(200,200,200)); 
    36
             
    37
            TextOut (hdc, 0, 0, out, 80); 
    38
     
    39
            EndPaint (hwnd, &ps); 
    40
            UpdateWindow (hwnd); 
    41
     
    42
            break
    43
     
    44
        case WM_CLOSE: 
    45
     
    46
            DestroyWindow (hwnd); 
    47
            break
    48
     
    49
        case WM_DESTROY: 
    50
     
    51
            PostQuitMessage (0); 
    52
            break
    53
     
    54
        default
    55
             
    56
            return DefWindowProc (hwnd, msg, wParam, lParam); 
    57
        } 
    58
        return 0; 
    59
    60
     
    61
    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) 
    62
    63
        HWND window; 
    64
        MSG Msg; 
    65
        WNDCLASSEX wc; 
    66
     
    67
        MessageBox (NULL, mem, "Memory Contents:", MB_OK); 
    68
     
    69
        wc.cbSize        = sizeof(WNDCLASSEX); 
    70
        wc.style         = 0; 
    71
        wc.lpfnWndProc   = WindowProc; 
    72
        wc.cbClsExtra    = 0; 
    73
        wc.cbWndExtra    = 0; 
    74
        wc.hInstance     = hInstance; 
    75
        wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION); 
    76
        wc.hCursor       = LoadCursor(NULL, IDC_ARROW); 
    77
        wc.hbrBackground = CreateSolidBrush (RGB (0,0,0)); 
    78
        wc.lpszMenuName  = NULL; 
    79
        wc.lpszClassName = "WindowClass"
    80
        wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION); 
    81
         
    82
        if (!RegisterClassEx (&wc)) 
    83
            return -1; 
    84
     
    85
        window = CreateWindow ("WindowClass"
    86
            "Hello all"
    87
            WS_POPUP, 
    88
            10, 
    89
            10, 
    90
            80*8, 
    91
            25*12, 
    92
            NULL, 
    93
            NULL, 
    94
            hInstance, 
    95
            NULL); 
    96
     
    97
        if (!window) 
    98
            return -1; 
    99
     
    100
        ShowWindow   (window, SW_MAXIMIZE); 
    101
        UpdateWindow (window); 
    102
     
    103
        while (GetMessage (&Msg, NULL, 0, 0) > 0) 
    104
        { 
    105
            TranslateMessage (&Msg); 
    106
            DispatchMessage  (&Msg); 
    107
        } 
    108
     
    109
        return 0; 
    110

    So now my question is how do i line up the text to look like what i want? Im not sure what to add to this to make what i need. Any finger pointed in the right direction would be GREATLY appreciated!

     So i searched for a method to set the font ratio to the correct amount to look right, and here is a formula that i found that i think should do what i want:

    DeviceUnits = (DesignUnits/unitsPerEm) * (PointSize/72) * DeviceResolution

    How would i use this in my application to define the correct font size? Im not sure where it fits.

     

    Saturday, January 24, 2009 2:28 AM
  • Hello,

    I think we can use the SelectFont and TextOut API to do so,

    See if the following link is what you want,

    http://msdn.microsoft.com/en-us/library/dd162956(VS.85).aspx

    http://msdn.microsoft.com/en-us/library/dd145133(VS.85).aspx

    Since the original question is answered by Hans, I am closing this thread. Any help needed, please raise new thread.

     

    Thanks,

    Colbert


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Thursday, January 29, 2009 11:01 AM
    Moderator