From b49e053edd6e14e2d4500644e9d7fb4a29c47e80 Mon Sep 17 00:00:00 2001 From: jacky400 Date: Wed, 5 Dec 2012 14:31:41 +0800 Subject: [PATCH] Update Windows/WndMainWindow.cpp --- Windows/WndMainWindow.cpp | 60 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index c0d40527bb..a80e17345c 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -35,6 +35,9 @@ #include "XPTheme.h" #endif +BOOL g_bFullScreen = FALSE; +RECT rc = {0}; + namespace MainWindow { HWND hwndMain; @@ -81,7 +84,7 @@ namespace MainWindow wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_PPSSPP); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH); + wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wcex.lpszMenuName = (LPCSTR)IDR_MENU1; wcex.lpszClassName = szWindowClass; wcex.hIconSm = (HICON)LoadImage(hInstance, (LPCTSTR)IDI_PPSSPP, IMAGE_ICON, 16,16,LR_SHARED); @@ -465,8 +468,12 @@ namespace MainWindow g_Config.bIgnoreBadMemAccess = !g_Config.bIgnoreBadMemAccess; UpdateMenus(); break; - //case ID_OPTIONS_FULLSCREEN: - // break; + case ID_OPTIONS_FULLSCREEN: + if(g_bFullScreen) + _ViewNormal(hWnd); + else + _ViewFullScreen(hWnd); + break; case ID_OPTIONS_DISPLAYRAWFRAMEBUFFER: g_Config.bDisplayFramebuffer = !g_Config.bDisplayFramebuffer; @@ -670,6 +677,53 @@ namespace MainWindow { InvalidateRect(hwndDisplay,0,0); } + 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, menu); + + // resize to normal view + // NOTE: use SWP_FRAMECHANGED to force redraw non-client + const int x = rc.left; + const int y = rc.top; + const int cx = rc.right - rc.left; + const int cy = rc.bottom - rc.top; + ::SetWindowPos(hWnd, HWND_NOTOPMOST, x, y, cx, cy, SWP_FRAMECHANGED); + + // reset full screen indicator + g_bFullScreen = FALSE; + } + +void _ViewFullScreen(HWND hWnd) +{ + // keep in mind normal window rectangle + ::GetWindowRect(hWnd, &rc); + + // 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; +} + void SetPlaying(const char *text) {