不在 CWnd 上绘制粗框
我有一个应用程序窗口,在其中添加 WS_THICKFRAME 样式,并删除了 WS_CAPTION 样式。当窗口最大化时,我想隐藏 WS_THICKFRAME,但保留 Aero-Snap 功能,因此我更改了 WS_NCCALCSIZE 的处理程序,以返回相对于窗口边框大小的膨胀矩形。
也就是说,WS_NCCLIENTSIZE 处理程序代码的重要部分如下所示:
...
CRect rc( lpncsp->rgrc[0] );
if (IsZoomed())
{
int borderSize = GetSystemMetrics(SM_CYSIZEFRAME);
rc.InflateRect(borderSize,topOff+borderSize,borderSize,borderSize);
}
else
rc.InflateRect(0,topOff+0,0,0);
lpncsp->rgrc[0] = rc;
...
该代码有效地隐藏了 WS_THICKFRAME。
唯一的问题是,当窗口失去焦点或重新获得焦点(最大化时)时,WS_THICKFRAME 会在边界内绘制。当设置/取消设置窗口焦点时,是否有一条消息可以返回 Inflate 矩形,或者至少重新调整窗口大小以再次隐藏 WS_THICKFRAME?
I've got an application window in which I'm adding the WS_THICKFRAME style and I have removed the WS_CAPTION style. When the window maximizes, I want to hide the WS_THICKFRAME, but retain the Aero-Snap feature, so I have altered my handler for WS_NCCALCSIZE to return an inflated rect with respect to the size of the window borders.
That is, the important part of the WS_NCCLIENTSIZE handler code looks like this:
...
CRect rc( lpncsp->rgrc[0] );
if (IsZoomed())
{
int borderSize = GetSystemMetrics(SM_CYSIZEFRAME);
rc.InflateRect(borderSize,topOff+borderSize,borderSize,borderSize);
}
else
rc.InflateRect(0,topOff+0,0,0);
lpncsp->rgrc[0] = rc;
...
That code effectively makes the WS_THICKFRAME hidden.
Only problem is that when the window loses focus or regains focus (while maximized) the WS_THICKFRAME gets drawn within the boundary. Is there a message in which I can return the Inflated rect back or at least re-adjust the window size to hide the WS_THICKFRAME again when the window focus is set/unset?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,那是行不通的。实现 WM_GETMINMAXINFO 的消息处理程序以允许窗口边框脱离屏幕。请注意,如果您没有设置链接器的 /SUBSYSTEM 选项来说明您的程序是为 Vista 或 Win7(版本 6,0)编写的,那么当您使用 GetWindowRect() 时,Aero 就会对您撒谎。您获得的价值基于细(旧)边框。
Yeah, that won't work. Implement a message handler for WM_GETMINMAXINFO to allow the borders of the window to fall off the screen. Beware that if you didn't set the linker's /SUBSYSTEM option to say that your program is made for Vista or Win7 (version 6,0) then Aero will lie to you when you use GetWindowRect(). The value you get back is based on thin (legacy) borders.