Windows full screen processing in Win32 SDK

Source: Internet
Author: User

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;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.