首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >MFC Windows 程序设计->控制窗口大小 WM_GETMINMAXINFO

MFC Windows 程序设计->控制窗口大小 WM_GETMINMAXINFO

作者头像
井九
发布2024-10-12 08:44:15
发布2024-10-12 08:44:15
2300
举报
文章被收录于专栏:四楼没电梯四楼没电梯

A final aspect of Clock that deserves scrutiny is its OnGetMinMaxInfo handler. As a window is being resized, it receives a series of WM_GETMINMAXINFO messages with lParam pointing to a MINMAXINFO structure containing information about the window's minimum and maximum "tracking" sizes. You can limit a window's minimum and maximum sizes programmatically by processing WM_GETMINMAXINFO messages and copying the minimum width and height to the x and y members of the structure's ptMinTrackSize field and the maximum width and height to the x and y members of the ptMaxTrackSize field. Clock prevents its window from being reduced to less than 120 pixels horizontally and vertically with the following OnGetMinMaxInfo handler:

void CMainWindow::OnGetMinMaxInfo (MINMAXINFO* pMMI) { pMMI->ptMinTrackSize.x = 120; pMMI->ptMinTrackSize.y = 120; }

The tracking dimensions copied to MINMAXINFO are measured in device units, or pixels. In this example, the window's maximum size is unconstrained because pMMI->ptMaxTrackSize is left unchanged. You could limit the maximum window size to one-half the screen size by adding the statements

pMMI->ptMaxTrackSize.x = ::GetSystemMetrics (SM_CXSCREEN) / 2; pMMI->ptMaxTrackSize.y = ::GetSystemMetrics (SM_CYSCREEN) / 2;

to the message handler.

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-10-11,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档