-
-
Save moebiussurfing/0be02fc2458d4c3b49aea4537db69c0a to your computer and use it in GitHub Desktop.
openFrameworks / Windows / setBorderless window app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if defined(TARGET_WIN32) | |
//-------------------------------------------------------------- | |
void setBorderless(bool b) { | |
bNoBorder = b; | |
// https://stackoverflow.com/questions/2398746/removing-window-border | |
if (bNoBorder) | |
{ | |
// Hide borders | |
HWND W = GetActiveWindow(); | |
LONG lStyle = GetWindowLong(W, GWL_STYLE); | |
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU); | |
SetWindowLong(W, GWL_STYLE, lStyle); | |
LONG lExStyle = GetWindowLong(W, GWL_EXSTYLE); | |
lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE); | |
SetWindowLong(W, GWL_EXSTYLE, lExStyle); | |
SetWindowPos(W, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); | |
} | |
else | |
{ | |
// Show borders | |
HWND W = GetActiveWindow(); | |
LONG lStyle = GetWindowLong(W, GWL_STYLE); | |
lStyle = WS_OVERLAPPEDWINDOW | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;SetWindowLong(W, GWL_STYLE, lStyle); | |
SetWindowLong(W, GWL_STYLE, lStyle); | |
LONG lExStyle = GetWindowLong(W, GWL_EXSTYLE); | |
lExStyle &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE); | |
SetWindowLong(W, GWL_EXSTYLE, lExStyle); | |
SetWindowPos(W, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); | |
ShowWindow(W, SW_SHOW); | |
} | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment