救救我吧,屏幕为什么总是闪烁?!!

mazhahn 2003-09-02 11:55:40
主对话框中的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
}

子对话框放置在主对话框的某个区域,单击某个按钮可以使该固定的区域显示对话框
但是总是在单击按钮的过程中闪烁!

有没有大侠告知我解决的办法,急急急急!!
...全文
29 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yifengling0 2003-09-02
  • 打赏
  • 举报
回复
不要在OnPaint()中写

映射WM_ERASEBKGND 消息。

添加你的代码,return true;
lygfqy 2003-09-02
  • 打赏
  • 举报
回复
主窗口加入WS_CLIPCHILDREN风格试试看

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧