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(); } }