Win32 Plus Extra Height of Caption Bar

本文介绍了如何通过处理WM_NCCALCSIZE消息来调整非客户端区域大小,并提供了一个简单像素边框实现的示例。通过修改默认处理程序的返回值,可以在窗口创建过程中自定义非客户端绘制。

you set the size of the non-client area by handling the WM_NCCALCSIZE message. But don't do this unless you plan to do all of the non-client drawing as well by handling WM_NCPAINT

Edit: here are two code fragments, one that handles WM_NCCALCSIZE and provides a simple n pixel border, and another than adds some extra pixels after DefWindowProc has done the default handling.

 1 case WM_NCCALCSIZE:
 2   {
 3   lRet = 0;
 4   const int cxBorder = 2;
 5   const int cyBorder = 2;
 6   InflateRect((LPRECT)lParam, -cxBorder, -cyBorder);
 7   }
 8 
 9 case WM_NCCALCSIZE: 
10   {
11   LPNCCALCSIZE_PARAMS pncc = (LPNCCALCSIZE_PARAMS)lParam;
12   //pncc->rgrc[0] is the new rectangle
13   //pncc->rgrc[1] is the old rectangle
14   //pncc->rgrc[2] is the client rectangle
15 
16   lRet = DefWindowProc (hwnd, WM_NCCALCSIZE, wParam, lParam);
17   pncc->rgrc[0].top += ExtraCaptionHeight;
18   }

 

You can learn a lot by passing WM_NCCALCSIZE to DefWindowProc and looking at the values of the NCCALCSIZEPARAM before and after.

转载于:https://www.cnblogs.com/gabo/p/3801268.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值