The first is to consider the timing of full screen processing, whether it is done when the window is created or displayed. If it is the former, you can:
Bool initinstance (hinstance, int ncmdshow)
{
Hwnd;
Hinst = hinstance; // store the 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;
}
For processing in the display window:
Bool initinstance (hinstance, int ncmdshow)
{
Hwnd;
Hinst = hinstance; // store the 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 = getasktopwindow ();
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;
}
It also allows users to control the full screen time, such as pressing the "ESC" key to enter the full screen
Bool initinstance (hinstance, int ncmdshow)
{
Hwnd;
Hinst = hinstance; // store the 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;
}
The ESC key is processed in the window handler:
Switch (Message)
{
Case wm_keydown:
Switch (wparam)
{
Case vk_escape:
{
Hwnd hdesk;
Rect RC;
Hdesk = getasktopwindow ();
Getwindowrect (hdesk, & rc );
Setwindowlong (hwnd, gwl_style, ws_border );
Setwindowpos (hwnd, hwnd_topmost, 0, 0, RC. Right, RC. Bottom, swp_showwindow );
}
Break;
}
Return 0;
}