我估计原因与北京图片有关,我在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);
}
/***************************************************/
// 背景
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);
}
/***************************************************/
BeginPaint(&ps);
//就在ps.hdc上画吧
....
EndPaint(&ps);