Discussion:
Remove WS_SYSMENU style and disable resize icon at same time
(too old to reply)
Nabil
2018-04-22 10:07:02 UTC
Permalink
Hi,


I have the following styles (WS_CAPTION, WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_SYSMENU, WS_THICKFRAME, WS_OVERLAPPED, WS_MAXIMIZEBOX, WS_MINIMIZEBOX) applied to my window and I can resize which is expected.

My aim is to remove WS_SYSMENU and disable resizing.

So I then remove WS_THICKFRAME and window resizing is disabled as expected. I then have to also remove WS_SYSMENU as well but window resizing comes back. My final set of styles are (WS_CAPTION, WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_OVERLAPPED, WS_MAXIMIZEBOX, WS_MINIMIZEBOX).

I am a win32 beginner so this inconsistency is confusing me. Is anyone able to explain why? WPF is creating the window so I do not have access to the CreateWindow code.

Many thanks
Nabil
JJ
2018-04-22 17:09:01 UTC
Permalink
Post by Nabil
Hi,
I have the following styles (WS_CAPTION, WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_SYSMENU, WS_THICKFRAME, WS_OVERLAPPED, WS_MAXIMIZEBOX, WS_MINIMIZEBOX) applied to my window and I can resize which is expected.
My aim is to remove WS_SYSMENU and disable resizing.
So I then remove WS_THICKFRAME and window resizing is disabled as expected. I then have to also remove WS_SYSMENU as well but window resizing comes back. My final set of styles are (WS_CAPTION, WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_OVERLAPPED, WS_MAXIMIZEBOX, WS_MINIMIZEBOX).
I am a win32 beginner so this inconsistency is confusing me. Is anyone able to explain why? WPF is creating the window so I do not have access to the CreateWindow code.
Many thanks
Nabil
WS_MAXIMIZEBOX and WS_MINIMIZEBOX (including the close box) requires
WS_SYSMENU. It's by design. i.e. it's hard coded. That rule can not be
changed.

WS_SYSMENU is basically the icon and the close box on the window title bar.
If you don't want any, you have to exclude the WS_SYSMENU style, draw the
minimize/maximize boxes, and handle the input events for those boxes area
manually. This is basically a partial skinning.
n***@shuhaiber.com
2018-04-22 19:38:56 UTC
Permalink
Post by JJ
Post by Nabil
Hi,
I have the following styles (WS_CAPTION, WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_SYSMENU, WS_THICKFRAME, WS_OVERLAPPED, WS_MAXIMIZEBOX, WS_MINIMIZEBOX) applied to my window and I can resize which is expected.
My aim is to remove WS_SYSMENU and disable resizing.
So I then remove WS_THICKFRAME and window resizing is disabled as expected. I then have to also remove WS_SYSMENU as well but window resizing comes back. My final set of styles are (WS_CAPTION, WS_VISIBLE, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_OVERLAPPED, WS_MAXIMIZEBOX, WS_MINIMIZEBOX).
I am a win32 beginner so this inconsistency is confusing me. Is anyone able to explain why? WPF is creating the window so I do not have access to the CreateWindow code.
Many thanks
Nabil
WS_MAXIMIZEBOX and WS_MINIMIZEBOX (including the close box) requires
WS_SYSMENU. It's by design. i.e. it's hard coded. That rule can not be
changed.
WS_SYSMENU is basically the icon and the close box on the window title bar.
If you don't want any, you have to exclude the WS_SYSMENU style, draw the
minimize/maximize boxes, and handle the input events for those boxes area
manually. This is basically a partial skinning.
That is what I am doing. I am skinning but as custom chrome in WPF. Thanks for the suggestion I will also remove WS_MAXIMIZEBOX and WS_MINIMIZEBOX. However I still have the problem where I need to somehow disable resizing. Will removing WS_MAXIMIZEBOX and WS_MINIMIZEBOX disable resizing?
JJ
2018-04-23 11:44:40 UTC
Permalink
Post by n***@shuhaiber.com
That is what I am doing. I am skinning but as custom chrome in WPF. Thanks
for the suggestion I will also remove WS_MAXIMIZEBOX and WS_MINIMIZEBOX.
However I still have the problem where I need to somehow disable
resizing. Will removing WS_MAXIMIZEBOX and WS_MINIMIZEBOX disable
resizing?
No. That's solely for minimize/maximize buttons.

Use WS_POPUP. Don't include WS_POPUPWINDOW, WS_OVERLAPPED or WS_THICKFRAME.
Christian Astor
2018-04-23 13:55:03 UTC
Permalink
Post by Nabil
My aim is to remove WS_SYSMENU and disable resizing.
This works for me on a standard Win32 app, on Windows 10 :

SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) &
~(WS_SYSMENU | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME));
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN |
RDW_UPDATENOW);

Loading...