0
votes

I have done research and I haven't found solution for my problem. Is there any good way, to disable minimize, maximize and close buttons in Win32 ? I want them to be still present and animating but not sensitive. I want also to be able to resize the window by dragging the frame.

2

2 Answers

3
votes

Simply capture the relevant events (WM_SYSCOMMAND and WM_CLOSE), and tell Windows to ignore them by returning 0. Please note that in case of WM_SYSCOMMAND, you should only do this for events you really want to block, i.e. event codes SC_MINIMIZE, SC_MAXIMIZE, etc. All others should be allowed to pass through normally. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms646360%28v=vs.85%29.aspx for more information.

However, please consider that if you provide the buttons, users will expect them to work. Just hiding them may be a better choice. This is something you can do by calling SetWindowLong (https://msdn.microsoft.com/en-us/library/ms633591%28v=vs.85%29.aspx), and change the GWL_STYLE attribute so it no longer includes WS_MINIMIZEBOX, WS_MAXIMIZEBOX, etc. flags.

1
votes
SetWindowLong(hwnd, GWL_STYLE,
               GetWindowLong(hwnd, GWL_STYLE) & ~WS_MINIMIZEBOX); 

You can put that code where your window initialize. Check out https://devblogs.microsoft.com/oldnewthing/20100604-00/?p=13803