void CSelRectDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this);
CRect rc;
this->GetWindowRect(rc);
int y = rc.Height()/4;
CPen pen, *oldpen;
oldpen = dc.SelectObject(&pen);
dc.MoveTo(0, y);
dc.LineTo(0, y);
for(int i=1;i<255;i++)
{
pen.DeleteObject();
pen.CreatePen(PS_SOLID, 2, RGB(255, i, 0));
dc.SelectObject(&pen);
dc.LineTo(i, y);
}
dc.MoveTo(0, y*2);
dc.LineTo(0, y*2);
for(int m=1;m<255;m++)
{
pen.DeleteObject();
pen.CreatePen(PS_SOLID, 2, RGB(0, 255,m));
dc.SelectObject(&pen);
dc.LineTo(m, y*2);
}
dc.MoveTo(0, y*3);
dc.LineTo(0, y*3);
for(int n=1;n<255;n++)
{
pen.DeleteObject();
pen.CreatePen(PS_SOLID, 2, RGB(n, 0, 255));
dc.SelectObject(&pen);
dc.LineTo(n, y*3);
}
pen.DeleteObject();
dc.SelectObject(oldpen);
CDialog::OnPaint();
}
}
原文链接: https://www.cnblogs.com/pythonschool/archive/2012/11/23/2781126.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/70390
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!