好象是设置这个icon?这个icon是什么?void CMyTestDlg::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
{
CDialog::OnPaint();
}
}

解决方案 »

  1.   

    void CMyTestDlg::OnPaint() 
    {
    if (IsIconic())//如果对话框最小化了
    {
    CPaintDC dc(this); // 取得对话框的PaintDC
                       //向该对话框发送WM_ICONERASEBKGND消息,该消息的详细含义可以通过
                      //MSDN获得
    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;//计算ICON左上角的X坐标
    int y = (rect.Height() - cyIcon + 1) / 2;//计算ICON左上角的Y坐标 // Draw the icon
    dc.DrawIcon(x, y, m_hIcon);//绘制图标
    }
    else//在对话框非最小化的时候调用
    {
    CDialog::OnPaint();
    }
    }
    希望对你有所帮助!
      

  2.   

    这里:
             CRect rect;
    GetClientRect(&rect);    //获取客户区域吧 最小化了客户区是哪个??;
    int x = (rect.Width() - cxIcon + 1) / 2;  
    int y = (rect.Height() - cyIcon + 1) / 2;    //这两句什么用?x y是那里坐标?