Skip to content

Instantly share code, notes, and snippets.

@moebiussurfing
Last active November 18, 2022 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moebiussurfing/0be02fc2458d4c3b49aea4537db69c0a to your computer and use it in GitHub Desktop.
Save moebiussurfing/0be02fc2458d4c3b49aea4537db69c0a to your computer and use it in GitHub Desktop.
openFrameworks / Windows / setBorderless window app
#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