IPicture 使用 OnPaint 绘制图片,窗口最小化后,图片消失问题
CPicture 就是封装的IPicture类 ,m_spIPicture就是 IPicture 实例
//绘图
BOOL CPicture::Render(CDC* pDC, CRect rc, LPCRECT prcMFBounds) const
{
ASSERT(pDC);
if (rc.IsRectNull()) {
CSize sz = GetImageSize(pDC);
rc.right = sz.cx;
rc.bottom = sz.cy;
}
long hmWidth ;
long hmHeight ; // HIMETRIC units
GetHIMETRICSize(hmWidth, hmHeight);
m_spIPicture->Render(*pDC, rc.left, rc.top, rc.Width(), rc.Height(),
0, hmHeight, hmWidth, -hmHeight, prcMFBounds);
return TRUE;
}
//事件
void CTestDlg::OnPaint()
{
CRect crt;
CRect rc;
m_img.GetClientRect(&crt);
rc.IntersectRect(&crt,&crt);
m_qr_pic.Render(m_qr_img_pDC,rc);
CDialog::OnPaint();
}
此代码,可正常情况下,可绘制图片,但是,当窗口被最小化后,再恢复
显示的图片就会丢失
我在 onsyscommand 窗口缩小时,绘制窗口,也只是缩小的时候,图片不丢失,窗口恢复,依然丢失
请指正