void xxxxDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<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);
Graphics graph(dc);
RECT rc;
SolidBrush titleBrush(Color(20, 150, 250));
SolidBrush bottomBrush(Color(20, 150, 250));
// 获取对话框大小
GetClientRect(&rc);
// 绘制标题栏
graph.FillRectangle(&titleBrush, rc.left, rc.top, rc.right-rc.left, 23);
//绘制底部边框
graph.FillRectangle(&bottomBrush, rc.left, rc.bottom-5, rc.right-rc.left, 5);
dc.SetBkColor(RGB(20, 150, 250));
//设置标题栏文字
dc.SetTextColor(RGB(255, 255, 255));
dc.TextOut(4,4,_T("EDIDCreator"));
DeleteObject(&titleBrush);
DeleteObject(&bottomBrush);
ReleaseDC(&dc);
CDialog::OnPaint();
}
}