The first is to consider the timing of full-screen processing, whether you are creating a window or displaying a window, and if the former, you can:
BOOL InitInstance (hinstance hinstance, int ncmdshow)
{
HWND hwnd;
Hinst = hinstance; To store an instance handle in a global variable
UINT width = getsystemmetrics (sm_cxscreen);
UINT height = getsystemmetrics (sm_cyscreen);
Create a window
Hwnd=createwindow (
Szwindowclass,
SzTitle,
Ws_popup,
0,0,
Width,height,
Null,null,
HINSTANCE,
NULL);
if (!hwnd)
{
return FALSE;
}
ShowWindow (HWnd, ncmdshow);
UpdateWindow (HWND);
return TRUE;
}
If you are working on the display window:
BOOL InitInstance (hinstance hinstance, int ncmdshow)
{
HWND hwnd;
Hinst = hinstance; To store an instance handle in a global variable
HWnd = CreateWindow (Szwindowclass, SzTitle, Ws_overlappedwindow,
Cw_usedefault, 0, cw_usedefault, 0, NULL, NULL, HINSTANCE, NULL);
if (!hwnd)
{
return FALSE;
}
HWND Hdesk;
RECT RC;
Hdesk = GetDesktopWindow ();
GetWindowRect (Hdesk, &RC);
SetWindowLong (HWnd, Gwl_style, Ws_border);
SetWindowPos (hWnd, hwnd_topmost, 0, 0, rc.right, Rc.bottom, Swp_showwindow);
ShowWindow (HWnd, ncmdshow);
UpdateWindow (HWND);
return TRUE;
}
You can also allow users to control the full screen time, such as press the "ESC" key to enter the full screen
BOOL InitInstance (hinstance hinstance, int ncmdshow)
{
HWND hwnd;
Hinst = hinstance; To store an instance handle in a global variable
HWnd = CreateWindow (Szwindowclass, SzTitle, Ws_overlappedwindow,
Cw_usedefault, 0, cw_usedefault, 0, NULL, NULL, HINSTANCE, NULL);
if (!hwnd)
{
return FALSE;
}
ShowWindow (HWnd, ncmdshow);
UpdateWindow (HWND)
return TRUE;
}
To handle the ESC key in a window-handling function:
Switch (message)
{
Case WM_KEYDOWN:
Switch (WParam)
{
Case Vk_escape:
{
HWND Hdesk;
RECT RC;
Hdesk = GetDesktopWindow ();
GetWindowRect (Hdesk, &RC);
SetWindowLong (HWnd, Gwl_style, Ws_border);
SetWindowPos (hWnd, hwnd_topmost, 0, 0, rc.right, Rc.bottom, Swp_showwindow);
}
Break
}
return 0;
}