如题,我是在Dialog上的Picture控件上画的图,我把重绘代码写在OnPaint()函数的else里怎么没有用(if里也没有用)?!但是我把重绘代码放在其它控件的Click事件里时,当点击此控件就可以重绘了,为什么?请高手出马搞定.void CFeng_FiveDlg::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
{
for(int i = 2; i< FIVE_X-1; i++)
for(int j = 2; j< FIVE_Y-1; j++){
if(Five_Chess[i][j].haveDOT)
DrawBitmap(Five_Chess[i][j].Dot_Color,i,j);
} CDialog::OnPaint();
}
}
void CFeng_FiveDlg::LossButton_Click()
{
if(IDYES == AfxMessageBox("确定要投降吗?",MB_YESNO)){

GetDlgItem(IDC_LOSS)->ShowWindow(SW_HIDE); //隐藏“认输”按钮
GetDlgItem(IDC_PEACE)->ShowWindow(SW_HIDE); //隐藏“和棋”按钮
GetDlgItem(IDC_START)->ShowWindow(SW_SHOW); //显示“开始”按钮 GameState = Game_Over;
}
else{
for(int i = 2; i< FIVE_X-1; i++)
for(int j = 2; j< FIVE_Y-1; j++){
if(Five_Chess[i][j].haveDOT)
DrawBitmap(Five_Chess[i][j].Dot_Color,i,j);
}
return;
}
}

解决方案 »

  1.   

    试了``没问题``是不是FIVE_X-1、FIVE_Y-1或是别的变量的值有问题?或者你这样写试试:
    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);
    }    for(int i = 2; i< FIVE_X-1; i++)
            for(int j = 2; j< FIVE_Y-1; j++){
                if(Five_Chess[i][j].haveDOT)
                    DrawBitmap(Five_Chess[i][j].Dot_Color,i,j);
        }    CDialog::OnPaint();
      

  2.   

    picture控件的notify属性设置为true
      

  3.   

    按 wuchi(风云) 的办法试试,应该可以。
      

  4.   

    TO: CrazyAzreal(卖血上网) and   wuchi(风云):
    好象没有效果啊,还是一样.
      

  5.   

    是不是把notify 那项给勾上就行了?但是勾上后就不能响应其他的事件了.
      

  6.   

    问题依旧,自己先顶一下了。
    我是做一个五子棋游戏,棋盘、认输按钮、和棋按钮分别用一个Picture控件把已经画好的Bitmap装入。我分别在三个Picture控件上都定义了Click事件。