如题,我是在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;
}
}
{
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;
}
}
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();
好象没有效果啊,还是一样.
我是做一个五子棋游戏,棋盘、认输按钮、和棋按钮分别用一个Picture控件把已经画好的Bitmap装入。我分别在三个Picture控件上都定义了Click事件。