2

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.

hegendroffer
  • 123
  • 1
  • 13

2 Answers2

5
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

Choi
  • 76
  • 1
  • 5
4

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.

H. Guijt
  • 3,325
  • 11
  • 16
  • I could go along with that if that were the entire answer, but actually I provided no less than two working solutions. The uncertainty relates to the finetuning of one of those two solutions for his exact preferences, not about the overal approach. – H. Guijt Mar 20 '16 at 13:00
  • Thank you for your response. The first solution works but not in a way I expected. It disables the buttons, but at the same time I cannot change the size of a window by dragging the frame or I cannot minimize it from toolbar of my Windows. I am also not sure how exactly should I implement SetWindowLong ? Sorry I am still a novice. – hegendroffer Mar 20 '16 at 13:02
  • You're probably blocking all of WM_SYSCOMMAND, instead of the specific relevant event codes. I've added some clarifications. – H. Guijt Mar 20 '16 at 13:06
  • H. Guijt - THANK YOU IT IS WORKING ! Great job ! – hegendroffer Mar 20 '16 at 13:38