有时候根据具体需求,我们可能要改变窗口的形状。使用API函数SetWindowRgn可以改变一个窗体的可见范围。使用API函数CreateRoundRectRgn()函数可以创建一个圆角矩形区域。
- void OnSize(UINT nType, int cx, int cy)
- {
- CDialog::OnSize(nType, cx, cy);
- // TODO: 在此处添加消息处理程序代码
- CRgn MyRgn;
- CRect rect;
- GetWindowRect(&rect);
- rect -= rect.TopLeft();
- MyRgn.CreateRoundRectRgn(rect.left,rect.top, rect.right, rect.bottom, 3,3);
- SetWindowRgn(MyRgn,TRUE);
- }