If you want full-screen functionality as implemented in most applications, that's it: in full screen-view you have to remove caption as well as the menu bar.
Here is a brief example how to toggle between normal and full-screen view:
Code:LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; // ... switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case ID_VIEW_FULLSCREEN: // toggle full screen if(g_bFullScreen) _ViewNormal(hWnd); else _ViewFullScreen(hWnd); break; //... //... //...Code:void _ViewFullScreen(HWND hWnd) { // keep in mind normal window rectangle ::GetWindowRect(hWnd, &g_rcNormal); // remove caption and border styles DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE); DWORD dwNewStyle = dwOldStyle & ~(WS_CAPTION | WS_THICKFRAME); ::SetWindowLong(hWnd, GWL_STYLE, dwNewStyle); // remove the menu bar ::SetMenu(hWnd, NULL); // resize to full screen view // NOTE: use SWP_FRAMECHANGED to force redraw non-client const int x = 0; const int y = 0; const int cx = ::GetSystemMetrics(SM_CXSCREEN); const int cy = ::GetSystemMetrics(SM_CYSCREEN); ::SetWindowPos(hWnd, HWND_TOPMOST, x, y, cx, cy, SWP_FRAMECHANGED); // set full screen indicator g_bFullScreen = TRUE; }Further, to keep some functionality provided by the menu or the title bar buttons when in full-screen view mode, you can use accelerators and/or context menus.Code:void _ViewNormal(HWND hWnd) { // put caption and border styles back DWORD dwOldStyle = ::GetWindowLong(hWnd, GWL_STYLE); DWORD dwNewStyle = dwOldStyle | WS_CAPTION | WS_THICKFRAME; ::SetWindowLong(hWnd, GWL_STYLE, dwNewStyle); // put back the menu bar ::SetMenu(hWnd, g_hMenu); // resize to normal view // NOTE: use SWP_FRAMECHANGED to force redraw non-client const int x = g_rcNormal.left; const int y = g_rcNormal.top; const int cx = g_rcNormal.right - g_rcNormal.left; const int cy = g_rcNormal.bottom - g_rcNormal.top; ::SetWindowPos(hWnd, HWND_NOTOPMOST, x, y, cx, cy, SWP_FRAMECHANGED); // reset full screen indicator g_bFullScreen = FALSE; }
I have attached here a simple demo application.




Reply With Quote
