Closed jpark37 closed 3 years ago
When you initially create the window, if you don't provide WS_POPUP
and just use '0', you end up with a title bar which we don't want in the full-screen case. Same thing happens with WS_OVERLAPPED
because that is defined to 0.
You're right that passing 0 causes the style to actually be set to WS_CLIPSIBLINGS | WS_CAPTION.
I'm a little weirded out with WS_POPUP though because GetWindowLongPtr returns WS_POPUP | WS_CLIPSIBLINGS after CreateWindowEx. SetWindowLongPtr(hWnd, GWL_STYLE, 0) adjusts that to just WS_CLIPSIBLINGS. Maybe WS_POPUP is harmless? I don't know much about window styles, but having an extra flag on initial fullscreen vs. on-the-fly fullscreen triggers my OCD.
Windows styles are a definitely a bit 'magic', but I didn't find any other windows style that did what I wanted...
Maybe the guidance should be to leave the CreateWindowEx call alone, but to set the styles immediately afterward. Something like:
HWND hwnd = CreateWindowExW(0, L"Direct11WindowClass", g_szAppName, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInstance,
nullptr);
// TODO: Apply these styles to default to fullscreen. Must apply style afterward because creating with a style of 0 will add a title bar.
// SetWindowLongPtr(hwnd, GWL_STYLE, 0);
// SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_TOPMOST);
I was trying for the simplest instructions :)
That's fine if having the extra WS_POPUP bit is a NOP, but I wonder if that alters window behavior in some way.
Consistency can also be achieved by setting WS_POPUP instead of 0 in the WndProc I think?
Sorry for all the messages over this relatively minor issue.
That's fine. Happy to take feedback.
Fixed in this commit
The comment next to the CreateWindowExW call says to use WS_POPUP for fullscreen, but the WM_SYSKEYDOWN handler seems to set GWL_STYLE to 0 instead. Is this a mistake?