对话框中有没有类似OnPrepareDC
对话框中有没有类似OnPrepareDC的函数啊?
问题是这样的,http://blog.csdn.net/sunnyjones/article/details/1565824我看了这篇文章,然后想把放大功能放在对话框中实现,但是对话框里没有OnPrepareDC函数,打开对话框时图片就不能显示,请问怎么解决?
[解决办法]
void CMyView::OnPrepareDC (CDC* pDC, CPrintInfo* pInfo)
{
CView::OnPrepareDC(pDC, pInfo);
// If we are printing, set the mapmode and the window
// extent properly, then set viewport extent. Use the
// SetViewportOrg member function in the CDC class to
// move the viewport origin to the center of the view.
if(pDC->IsPrinting()) // Is the DC a printer DC.
{
CRect rect;
GetClientRect (&rect);
pDC->SetMapMode(MM_ISOTROPIC);
CSize ptOldWinExt = pDC->SetWindowExt(1000, 1000);
ASSERT(ptOldWinExt.cx != 0 && ptOldWinExt.cy != 0);
CSize ptOldViewportExt = pDC->SetViewportExt(rect.Width(), -rect.Height());
ASSERT(ptOldViewportExt.cx != 0 && ptOldViewportExt.cy != 0);
CPoint ptOldOrigin = pDC->SetViewportOrg(rect.Width()/2, rect.Height()/2);
}
}