Please, fix this:
void ToggleFullScreen() {
static DWORD savedExStyle, savedStyle, screenWidth, screenHeight;
static long OverLayVisible, AnimationVisible, AudioVisible; // PAT: 12-05-2019
static RECT rcSaved;
static HRGN oldRgn = 0, newRgn = 0;
long K = 0, nLeft = 0, nTop = 0;
WINDOWPLACEMENT wp = { 0 };
gP.bIsFullScreen = !gP.bIsFullScreen;
if (GetWindowPlacement(gP.hMain, &wp)) { // 04-20-2015
if (wp.showCmd == SW_SHOWMAXIMIZED) {
//ShowWindow(gP.hMain, SW_RESTORE);
skRestore(gP.hMain);
}
}
if (gP.bIsFullScreen) { // Moving to full screen mode.
long wasFPS = gP.bUseFPS; if (gP.bUseFPS) { gP.bUseFPS = FALSE; }
GetWindowRgn(gP.hMain, oldRgn);
GetWindowRect(gP.hMain, &rcSaved);
AnimationVisible = IsWindowVisible(GetDlgItem(gP.hMain, IDC_ANIMATION));
AudioVisible = IsWindowVisible(GetDlgItem(gP.hMain, IDC_AUDIO)); // PAT: 12-05-2019
if (IsWindowVisible(gP.hHelp)) { HideHelp(); } // PAT: 12-28-2018
for (K = IDC_FIRST; K <= IDC_LAST; K++) {
ShowWindow(GetDlgItem(gP.hMain, K), SW_HIDE);
}
ShowWindow(gP.hSplitter, SW_HIDE); // PAT: 16-12-2018
OverLayVisible = IsWindowVisible(gP.hOverlay);
MONITORINFO tmi = { 0 };
RECT rw = { 0 };
HMONITOR hMonitor = MonitorFromWindow(gP.hMain, MONITOR_DEFAULTTONEAREST);
tmi.cbSize = sizeof(tmi);
GetWindowRect(gP.hMain, &rw);
GetMonitorInfo(hMonitor, &tmi);
screenWidth = abs(tmi.rcMonitor.right - tmi.rcMonitor.left);
screenHeight = abs(tmi.rcMonitor.bottom - tmi.rcMonitor.top);
nLeft = skGetSystemMetrics(SK_CXFRAMELEFT);
nTop = skGetSystemMetrics(SK_CYCAPTION) + skGetSystemMetrics(SK_CYMENU);
//rw.left = tmi.rcMonitor.left - nLeft + 1; // Pat: 01-05-2016
rw.left = tmi.rcMonitor.left - nLeft; // Pat: 03-23-2016
rw.top = tmi.rcMonitor.top - nTop; // Pat: 01-05-2016
long RightPanelSize = ClientW - ClientWGL;
// PAT: 02-06-2018 without minus Overlay, no way to let it work correctly
// Windows do not like when an application take full control of the whole view port...
rw.right = screenWidth + nLeft + skGetSystemMetrics(SK_CXFRAMERIGHT) + RightPanelSize; //- OverLayVisible; // PAT: 02-12-2018
rw.bottom = screenHeight + nTop + skGetSystemMetrics(SK_CYFRAMEBOTTOM);
MoveWindow(gP.hMain, rw.left, rw.top, rw.right, rw.bottom, FALSE);
// PAT: 02-12-2018
SetWindowLongPtr(gP.hGL, GWL_STYLE, WS_POPUP | WS_VISIBLE); // PAT: 02-12-2018
MoveWindow(gP.hGL, 0, 0, screenWidth, screenHeight + 1, FALSE); // PAT: 02-12-2018
SetWindowPos(gP.hOverlay, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); // PAT: 02-12-2018
if (IsWindow(go.hTip)) { SetWindowPos(go.hTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } // PAT: 02-12-2018
//newRgn = CreateRectRgn(nLeft - 1, nTop, nLeft + screenWidth - OverLayVisible, nTop + screenHeight); // Pat: 01-05-2016
newRgn = CreateRectRgn(nLeft, nTop, nLeft + screenWidth, nTop + screenHeight); // PAT: 02-06-2018
if (newRgn) { SetWindowRgn(gP.hMain, newRgn, TRUE); }
gP.bUseFPS = wasFPS;
CheckMenuItem(gP.hSubMenu, MENU_VIEW_FULLSCREEN, MF_CHECKED); // MLL 10-28-2018:
popupToastWindow(L"Full Screen", L"Press ESC or SPACEBAR to exit the full screen mode."); // MLL 11-15-2018:
} else { // Moving back to windowed mode.
HideToast(); // MLL 11-15-2018:
// PAT: 02-12-2018
SetWindowLongPtr(gP.hGL, GWL_STYLE, WS_CHILD | WS_VISIBLE); // PAT: 02-12-2018
SetWindowPos(gP.hOverlay, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); // PAT: 02-12-2018
for (K = IDC_FIRST; K <= IDC_LAST; K++) {
if ((K == IDC_ANIMATION) && (!AnimationVisible)) { continue; }
if ((K == IDC_AUDIO) && (!AudioVisible)) { continue; } // PAT: 12-05-2019
ShowWindow(GetDlgItem(gP.hMain, K), SW_SHOW);
}
ShowWindow(gP.hSplitter, SW_SHOW); // PAT: 16-12-2018
if (OverLayVisible) { ShowWindow(gP.hOverlay, SW_SHOW); }
screenWidth = rcSaved.right - rcSaved.left;
screenHeight = rcSaved.bottom - rcSaved.top;
SetWindowRgn(gP.hMain, oldRgn, FALSE);
SetWindowPos(gP.hMain, HWND_NOTOPMOST, rcSaved.left, rcSaved.top, screenWidth, screenHeight, SWP_SHOWWINDOW);
if (oldRgn) { SetWindowRgn(gP.hMain, oldRgn, TRUE); }
if (newRgn) { DeleteObject(newRgn); }
PostMessage(gP.hMain, WM_SIZE, 0, MAKLNG(screenWidth, screenHeight));
CheckMenuItem(gP.hSubMenu, MENU_VIEW_FULLSCREEN, MF_UNCHECKED); // MLL 10-28-2018:
}
SetFocus(gP.hGL); // MLL 10-28-2018: Z rotation support
}