Cannot change window style
Hey!
Can you tell me why my code is not working? I want to change the window style for my DirectX application. In fullscreen mode, it should be WS_POPUP but in windowed mode I want it to be WS_SYSMENU | WS_MINIMIZEBOX.
But this is not working, the style isnt changing:
windowClass.lpfnWndProc = MsgProc;
windowClass.lpszClassName = "Main";
RegisterClass(&windowClass);
windowHandle = CreateWindow("Main", 0, WS_POPUP | WS_VISIBLE, 0, 0, 0, 0, 0, 0, 0, 0);
SetWindowLong(windowHandle, GWL_STYLE, WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE);
SetWindowPos(windowHandle, HWND_NOTOPMOST, 0, 0, 640, 480, SWP_FRAMECHANGED);
What am I doing wrong?
Thanks!
Greets
[743 byte] By [
Ako44] at [2007-11-20 11:38:24]

# 4 Re: Cannot change window style
Yes I know!
All I want is not to destroy the window, create a new window, reset the device...
I want to CHANGE the window style and reset the device.
But why my code isnt working?
Greets
Ako44 at 2007-11-10 22:27:47 >

# 6 Re: Cannot change window style
Hmmm... interesting!
Just a little aside note (including for myself :)).
I always said: "unlike popup or child windows (having WS_POPUP or WS_CHILD style set) which can have or can have not a caption, an overlapped window (with neither WS_POPUP nor WS_CHILD style) has always a caption."
I'm not the first and not the only one saying that and that's correct as long as we are creating an overlapped window, as for example...
::CreateWindow(szWindowClass, NULL,
WS_OVERLAPPED|WS_SYSMENU|WS_MINIMIZEBOX,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
NULL, NULL, hInstance, NULL);
... creates a window WITH a caption (note that WS_OVERLAPPED has a value of 0 so can be removed from above code as well).
However, as observed working around the OP problem, adding WS_POPUP style to an overlapped window can remove the caption (if no WS_CAPTION set) but once having a popup window with no caption, the caption is not added by removing WS_POPUP. At least on my XP system.
So you have to "force" it with WS_CAPTION style (as kirants already stated).
[ Late edit ]
It seems that WS_CAPTION style is automatically added when creating an overlapped window (like in code above). So... no longer mystery... :D
And... have to reformulate the first "religious" sentence in which I believed until now.
Replace with: "when creating an overlapped window (having neither WS_POPUP nor WS_CHILD styles set), the system automatically adds WS_CAPTION style" and "a window has a caption if and only if it has the WS_CAPTION style set".
;)