Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does anyone know how to set a Window to full screen (without the menu and title bar)? My code isn't using any .net stuff, it's all just C++ native Win32 code. I have found the answer for mobile platforms, but can't find it for normal apps.
Posted

You have to handle the WM_GETMINMAXINFO message and then use SetWindowPos to resize the window to the size of the screen.
To get the size of the screen, use SystemParametersInfo with SPI_GETWORKAREA.
You will need to hide the menu and status bar also.
 
Share this answer
 
Comments
weylspinor 10-Sep-10 0:29am    
DWORD dwStyle = ::GetWindowLong(h_main, GWL_STYLE);
DWORD dwRemove = WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
DWORD dwNewStyle = dwStyle & ~dwRemove;
::SetWindowLong(h_main, GWL_STYLE, dwNewStyle);
::SetWindowPos(h_main, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
| SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
HDC hDC = ::GetWindowDC(NULL);
::SetWindowPos(h_main, NULL, 0, 0, ::GetDeviceCaps(hDC, HORZRES), ::GetDeviceCaps(hDC, VERTRES), SWP_FRAMECHANGED);

Thanks! Two more quick things: my menu bar is still visible, and the border is still visible as well. Is there a quick way to fix that. And how do I enable someone to Esc back to a regular maximized window?
First, see my answer to the bolded part of the question question here:
http://www.codeproject.com/Messages/3408829/Re-Remove-Title-Bar.aspx[^]
Next move the window to the screen size:
// move to full screen (main monitor)
HDC hDC = ::GetWindowDC(NULL); 
::SetWindowPos(hWnd, NULL, 0, 0, ::GetDeviceCaps(hDC, HORZRES), ::GetDeviceCaps(hDC, VERTRES), SWP_FRAMECHANGED);

For multiple monitors handling, some homework needed :)
cheers,
AR

Reverted to original as the edit was stupid :(
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900