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
?
-
- LongStyle = getwindowlong (hwnd, gwl_style );// Obtain the window style
-
- 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
- IntScreenx = getsystemmetrics (sm_cxscreen );// Obtain the X coordinate at the bottom right corner of the screen
-
- IntScreeny = getsystemmetrics (sm_cyscreen );// Y coordinate of the screen
-
- Setwindowpos (hwnd, null, 0, 0, screenx, screeny, swp_nozorder );// Change the window position, size, and Z-order
-
- 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
?
-
- Switch(Message)
-
- {
-
- CaseWm_keydown:
- Switch(Wparam)
-
- {
-
- CaseVk_escape:
-
- {
-
- HwndHdesk;
-
- 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;
-
- }
-
- Return0;
- }
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
?
-
- Static IntCX, Cy, cxdib, cydib;
-
- HDC =: getdc (null );
- Switch(Message)
-
- {
-
- CaseWm_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 to the screen
-
- : Setwindowpos (hwnd, hwnd_topmost,
-
- -(Getsystemmetrics (sm_cxborder) + 1 ),
-
- -(Getsystemmetrics (sm_cyborder) + 1 ),
-
- + 1, Cy + 1, swp_nozorder );
- }
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.