用NCPAINT实现对话框的平面效果

来源:互联网 发布:画图软件下载 编辑:程序博客网 时间:2024/06/06 05:40

一个Resizing对话框要改为平面效果,在不改动原工程的情况下,通过NCPAINT消息实现其平面效果。

void CDlg::OnNcPaint()
{
 // TODO: Add your message handler code here
 CRect rect;
 GetWindowRect(&rect);

 CRect rt;
 rt.left=rt.top=0;
 rt.right=rect.Width();
 rt.bottom=rect.Height();
 CWindowDC dc(this);

 CBrush brush,brush2;
 brush.CreateSolidBrush(RGB(0,100,200));
 brush2.CreateSolidBrush(RGB(231,237,253));
 dc.FrameRect(&rt,&brush);
// for(int i=0;i<10;i++)
 {
 rt.InflateRect(-1,-1);

 dc.FrameRect(&rt,&brush2);
 }
 rt.InflateRect(-1,-1);
 dc.FrameRect(&rt,&brush2);
// rt.InflateRect(-1,-1);
// dc.FrameRect(&rt,&brush2);

 brush.DeleteObject();
 brush2.DeleteObject();

 // Do not call CDialog::OnNcPaint() for painting messages
}

原创粉丝点击