GENERATE_INTERCEPT_HEADER(GetWindowLongA, LONG, WINAPI, _In_ HWND hWnd, _In_ int nIndex) { SDLOG(2, "DetouredGetWindowLongA hwnd: %p -- index: %s\n", hWnd, WindowLongOffsetToString(nIndex)); if(nIndex == GWL_WNDPROC && Settings::get().getInterceptWindowProc()) { SDLOG(2, " -> return from table\n"); if(prevWndProcs.count(hWnd)>0) return (LONG)prevWndProcs[hWnd]; } return TrueGetWindowLongA(hWnd, nIndex); }
void WindowManager::toggleBorderlessFullscreen() { borderlessFullscreen = !borderlessFullscreen; HWND hwnd = ::GetActiveWindow(); if(borderlessFullscreen) { SDLOG(1, "WindowManager::toggleBorderlessFullscreen A hwnd: %p\n", hwnd); // store previous rect TrueGetClientRect(hwnd, &prevWindowRect); // set styles LONG lStyle = TrueGetWindowLongA(hwnd, GWL_STYLE); prevStyle = lStyle; lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU); TrueSetWindowLongA(hwnd, GWL_STYLE, lStyle); LONG lExStyle = TrueGetWindowLongA(hwnd, GWL_EXSTYLE); prevExStyle = lExStyle; lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE); TrueSetWindowLongA(hwnd, GWL_EXSTYLE, lExStyle); SDLOG(1, "WindowManager::toggleBorderlessFullscreen B\n", hwnd); // adjust size & position HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); MONITORINFO info; info.cbSize = sizeof(MONITORINFO); GetMonitorInfo(monitor, &info); int monitorWidth = info.rcMonitor.right - info.rcMonitor.left; int monitorHeight = info.rcMonitor.bottom - info.rcMonitor.top; ::SetWindowPos(hwnd, NULL, info.rcMonitor.left, info.rcMonitor.top, monitorWidth, monitorHeight, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER); BringWindowToTop(hwnd); SDLOG(1, "WindowManager::toggleBorderlessFullscreen C\n", hwnd); } else { // restore previous window ::SetWindowLong(hwnd, GWL_STYLE, prevStyle); ::SetWindowLong(hwnd, GWL_EXSTYLE, prevExStyle); RECT desiredRect = prevWindowRect; ::AdjustWindowRect(&desiredRect, prevStyle, false); int wWidth = desiredRect.right - desiredRect.left, wHeight = desiredRect.bottom - desiredRect.top; ::SetWindowPos(hwnd, NULL, prevWindowRect.left, prevWindowRect.top, wWidth, wHeight, SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER); } }