Disable Minimize, Maximize, Close buttons in Win32

喜夏-厌秋 提交于 2021-01-29 17:26:19

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/36113675/disable-minimize-maximize-close-buttons-in-win32

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!