Windows programming full screen window creation summary.

Source: Internet
Author: User

From: http://blog.csdn.net/leolee82/article/details/6992615

Windows programming full screen window creation Summary
First: a simple method
In showwindow (hwnd, sw_shownormal );
Updatewindow (hwnd); Add the followingCode:

[CPP] View plain Copy Print ?
  1. LongStyle = getwindowlong (hwnd, gwl_style );// Obtain the window style
  2. Style = &~ Ws_caption &~ Ws_sizebox;// The window is displayed in full screen and cannot be changed.
  3. Setwindowlong (hwnd, gwl_style, style );// Set the window style
  4. IntScreenx = getsystemmetrics (sm_cxscreen );// Obtain the X coordinate at the bottom right corner of the screen
  5. IntScreeny = getsystemmetrics (sm_cyscreen );// Y coordinate of the screen
  6. Setwindowpos (hwnd, null, 0, 0, screenx, screeny, swp_nozorder );// Change the window position, size, and Z-order
  7. Showcursor (false );// Hide the mouse when displaying
Long style = getwindowlong (hwnd, gwl_style); // obtain the window Style = &~ Ws_caption &~ Ws_sizebox; // The window is displayed in full screen and cannot be changed. setwindowlong (hwnd, gwl_style, style); // set the window style int screenx = getsystemmetrics (sm_cxscreen ); // obtain the X coordinate int screeny = getsystemmetrics (sm_cyscreen) in the lower right corner of the screen; // screen y coordinate setwindowpos (hwnd, null, screenx, screeny, swp_nozorder ); // change the window position, size, and Z-order showcursor (false); // hide the mouse during display

 

Type 2: enable full screen after pressing ESC

[CPP] View plain Copy Print ?
  1. Switch(Message)
  2. {
  3. CaseWm_keydown:
  4.  Switch(Wparam)
  5. {
  6.  CaseVk_escape:
  7. {
  8. HwndHdesk;
  9. Rect RC;
  10. Hdesk = getasktopwindow ();
  11. Getwindowrect (hdesk, & rc );
  12. Setwindowlong (hwnd, gwl_style, ws_border );
  13. Setwindowpos (hwnd, hwnd_topmost, 0, 0, RC. Right, RC. Bottom,
  14. Swp_showwindow );
  15. }
  16. Break;
  17. }
  18.  Return0;
  19. }
 
Switch (Message) {Case wm_keydown: Switch (wparam) {Case vk_escape: {hwnd hdesk; rect RC; hdesk = get1_topwindow (); getwindowrect (hdesk, & rc ); setwindowlong (hwnd, gwl_style, ws_border); setwindowpos (hwnd, hwnd_topmost, 0, 0, RC. right, RC. bottom, swp_showwindow);} break;} return 0 ;}

 

Third: add the code to the message

[CPP] View plain Copy Print ?
  1. Static IntCX, Cy, cxdib, cydib;
  2. HDC =: getdc (null );
  3. Switch(Message)
  4. {
  5. CaseWm_create:
  6. Cx = getdevicecaps (HDC, horzres) +
  7. Getsystemmetrics (sm_cxborder );
  8. Cy = getdevicecaps (HDC, vertres) +
  9. Getsystemmetrics (sm_cyborder );
  10. : Releasedc (0, HDC );
  11. // Remove the title and border
  12. Setwindowlong (hwnd, gwl_style,
  13. Getwindowlong (hwnd, gwl_style )&
  14. (~ (Ws_caption | ws_border )));
  15. // Set the dialog box to the top and expand to the screen
  16. : Setwindowpos (hwnd, hwnd_topmost,
  17. -(Getsystemmetrics (sm_cxborder) + 1 ),
  18. -(Getsystemmetrics (sm_cyborder) + 1 ),
  19. + 1, Cy + 1, swp_nozorder );
  20. }
 
Static int CX, Cy, cxdib, cydib; HDC =: getdc (null); Switch (Message) {Case wm_create: Cx = getdevicecaps (HDC, horzres) + getsystemmetrics (sm_cxborder); Cy = getdevicecaps (HDC, vertres) + getsystemmetrics (sm_cyborder);: releasedc (0, HDC); // remove the title and border setwindowlong (hwnd, gwl_style, getwindowlong (hwnd, gwl_style )&(~ (Ws_caption | ws_border); // set the dialog box to the top and expand it to the entire screen: setwindowpos (hwnd, hwnd_topmost,-(getsystemmetrics (sm_cxborder) + 1 ), -(getsystemmetrics (sm_cyborder) + 1), + 1, Cy + 1, swp_nozorder );}

Note that the menu items in the above methods are registered in the window class. If the menu is not displayed, set lpszmenuname to null. Otherwise, the menu will be displayed in the full screen window.

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.