我编码的MFC应用程序需要允许垂直窗口大小调整并防止水平调整大小。 什么是最简单的方法来做到这一点?
I'm coding an MFC application that needs to allow vertical window resizing and prevent horizontal resizing. What's the simplest way to do this?
最满意答案
你想抓住WM_SIZING和WM_GETMINMAXINFO强制适当的宽度,( WM_NCHITTEST过滤掉任何导致用户试图改变宽度的反应(可能不需要...))。
如果没有多监视器设置, WM_GETMINMAXINFO就足够了。
也可以看一下GetSystemMenu() ,以便定制你的系统菜单。
顺便说一句:这个答案不是特定于MFC的。
You want to catch WM_SIZING and WM_GETMINMAXINFO to force the proper width, (WM_NCHITTEST to filter out any responses leading to the user trying to change the width (Might not be needed...)).
If there were no multi-monitor setups, WM_GETMINMAXINFO alone would suffice.
Also take a look at GetSystemMenu(), for possibly tailoring your system menu.
BTW: This answer is not MFC-specific.
只允许垂直窗口大小调整的最简单方法是什么?(What's the easiest way to allow only vertical window resizing?)我编码的MFC应用程序需要允许垂直窗口大小调整并防止水平调整大小。 什么是最简单的方法来做到这一点?
I'm coding an MFC application that needs to allow vertical window resizing and prevent horizontal resizing. What's the simplest way to do this?
最满意答案
你想抓住WM_SIZING和WM_GETMINMAXINFO强制适当的宽度,( WM_NCHITTEST过滤掉任何导致用户试图改变宽度的反应(可能不需要...))。
如果没有多监视器设置, WM_GETMINMAXINFO就足够了。
也可以看一下GetSystemMenu() ,以便定制你的系统菜单。
顺便说一句:这个答案不是特定于MFC的。
You want to catch WM_SIZING and WM_GETMINMAXINFO to force the proper width, (WM_NCHITTEST to filter out any responses leading to the user trying to change the width (Might not be needed...)).
If there were no multi-monitor setups, WM_GETMINMAXINFO alone would suffice.
Also take a look at GetSystemMenu(), for possibly tailoring your system menu.
BTW: This answer is not MFC-specific.
发布评论