本文介绍了在 Win32 中禁用最小化、最大化、关闭按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经进行了研究,但还没有找到解决我的问题的方法.有什么好的方法可以禁用 Win32 中的最小化、最大化和关闭按钮吗?我希望它们仍然存在和动画但不敏感.我还希望能够通过拖动框架来调整窗口大小.

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.

推荐答案

简单地捕获相关事件(WM_SYSCOMMAND 和 WM_CLOSE),并通过返回 0 告诉 Windows 忽略它们.请注意,在 WM_SYSCOMMAND 的情况下,您应该只做这用于您真正想要阻止的事件,即事件代码 SC_MINIMIZE、SC_MAXIMIZE 等.应该允许所有其他事件正常通过.请参阅 https://msdn.microsoft.com/en-us/library/windows/desktop/ms646360%28v=vs.85%29.aspx 了解更多信息.

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.

但是,请注意,如果您提供按钮,用户会希望它们起作用.隐藏它们可能是更好的选择.这是您可以通过调用 SetWindowLong (https://msdn.microsoft.com/en-us/library/ms633591%28v=vs.85%29.aspx),并更改 GWL_STYLE 属性,使其不再包含 WS_MINIMIZEBOX、WS_MAXIMIZEBOX 等标志.

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.

这篇关于在 Win32 中禁用最小化、最大化、关闭按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 13:06