從網路上找的...
void CXXXDlg::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
{
/* Setup Dialog Back Color */
CRect rect;
CPaintDC dc(this);
GetClientRect(rect);
dc.FillSolidRect(rect,RGB(30,48,147));
CDialog::OnPaint();
}
}