救救我吧,屏幕为什么总是闪烁?!!
主对话框中的ONPAINT()函数
void CAutoTokenDlg::OnPaint()
{
CPaintDC dc(this);
GetClientRect(m_DRect);
if(m_pImageDC->GetSafeHdc()==NULL)
{
BITMAP bm;
// CClientDC dc(this);
m_pImageDC->CreateCompatibleDC(&dc);
m_pBitmap->LoadBitmap(IDB_MAIN);
m_pImageDC->SelectObject(m_pBitmap);
m_pBitmap->GetObject(sizeof(bm),&bm);
m_SRect.SetRect(0,0,bm.bmWidth,bm.bmHeight);
int OldBltMode=dc.SetStretchBltMode(COLORONCOLOR);
dc.StretchBlt(m_DRect.left, m_DRect.top, m_DRect.Width(), m_DRect.Heig
ht(), m_pImageDC,\
m_SRect.left, m_SRect.top, m_SRect.Width(), m_SRect.Height(), SRCC
OPY);
dc.SetStretchBltMode(OldBltMode);
}
//Invalidate(false);
//ValidateRect(m_MainShowDlgPos);
}
子对话框的ONPAINT()函数
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
GetClientRect(m_DRect);
if(m_pImageDC->GetSafeHdc()==NULL)
{
BITMAP bm;
// CClientDC dc(this);
m_pImageDC->CreateCompatibleDC(&dc);
m_pBitmap->LoadBitmap(IDB_MAP1);
m_pImageDC->SelectObject(m_pBitmap);
m_pBitmap->GetObject(sizeof(bm),&bm);
m_SRect.SetRect(0,0,bm.bmWidth,bm.bmHeight);
}
TRACE("INITDIALOG:Source:\nleft=%ld\nright=%ld\ntop=%ld\nbottom=%ld\n",m_S
Rect.left,m_SRect.right,m_SRect.top,m_SRect.bottom);
// TRACE("bm:\nwidth=%ld\nheight=%ld\n",bm.bmWidth,bm.bmHeight);
TRACE("INITDIALOG:Destine:\nleft=%ld\nright=%ld\ntop=%ld\nbottom=%ld\n",m_
DRect.left,m_DRect.right,m_DRect.top,m_DRect.bottom);
int OldBltMode=dc.SetStretchBltMode(COLORONCOLOR);
dc.StretchBlt(m_DRect.left, m_DRect.top, m_DRect.Width(), m_DRect.Height()
, m_pImageDC,\
m_SRect.left, m_SRect.top, m_SRect.Width(), m_SRect.Height()
, SRCCOPY);
dc.SetStretchBltMode(OldBltMode);
//ValidateRect(m_DRect);
// Do not call CDialog::OnPaint() for painting messages
}
子对话框放置在主对话框的某个区域,单击某个按钮可以使该固定的区域显示对话框
但是总是在单击按钮的过程中闪烁!
有没有大侠告知我解决的办法,急急急急!!