我估计原因与北京图片有关,我在OnPaint()函数上给对话框动态添加一个背景图片。代码如下: /***************************************************/
// 背景
CWnd *pWnd = GetDlgItem(IDC_P);
CRect rect;
pWnd->GetClientRect(&rect);
CClientDC dc(this);
IStream*    pIn;
CFileStatus fstatus;
CFile       file;
IPicture*   ppicture;
CString     path = ".\\res\\000.bmp";
if ( (file.Open(path, CFile::modeRead)) &&
 (file.GetStatus(path, fstatus))   &&
 (fstatus.m_size != -1) )
{
HGLOBAL hg = GlobalAlloc(GMEM_MOVEABLE, fstatus.m_size);
void* pdata = NULL;
if ( (hg != NULL) && ((pdata = GlobalLock(hg)) != NULL) )
{
file.ReadHuge(pdata, fstatus.m_size);
GlobalUnlock(hg);
CreateStreamOnHGlobal(hg, TRUE, &pIn);
}
}
if (  SUCCEEDED( OleLoadPicture(pIn, fstatus.m_size, TRUE, IID_IPicture, (void**)&ppicture) )  )
{
OLE_XSIZE_HIMETRIC hmWidth;
OLE_YSIZE_HIMETRIC hmHeight;
ppicture->get_Width(&hmWidth);
ppicture->get_Height(&hmHeight);
ppicture->Render(dc.m_hDC, 10, 0, rect.Width(), rect.Height(), 0, hmHeight, hmWidth, -hmHeight, NULL);
}
/***************************************************/

解决方案 »

  1.   

    记得以前有人说要将基类的OnPaint去掉
      

  2.   

    把下面的代码改造一下应该就可以满足你        PAINTSTRUCT ps;
    BeginPaint(&ps);
            //就在ps.hdc上画吧
              ....
    EndPaint(&ps);
      

  3.   

    你上面的代码是放在OnPaint函数中?GlobalAlloc函数只要刷新就要调用?
      

  4.   

    每当我遇到这种破事的时候,我直接去WM_ERASEBKGND,就是画背景的那个函数里折腾.记得return true;再不行干掉OnPaint