更新时间:2016-01-08 21:46:22浏览次数:1+次
看看源代码:
void CInsertRectDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CDC *pDC=GetDC();
SetRect(&rect,50,50,150,150);
pDC->InvertRect(&rect);
ReleaseDC(pDC);
CDialogEx::OnLButtonDown(nFlags, point);
}
void CInsertRectDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 用于绘制的设备上下文
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 使图标在工作区矩形中居中
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 绘制图标
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDC *pDC=BeginPaint(&ps);
pDC->SelectObject(GetStockObject(LTGRAY_BRUSH));
pDC->Rectangle(10,10,110,110);
EndPaint(&ps);
CDialogEx::OnPaint();
}
}
原文链接《使用InvertRect快速实现指定矩形范围的颜色反色翻转》 相关资讯