|
弱弱的问一下,我增加了OnPaint() ,但是调试的时候发现,就不执行OnPaint()....
本人比较菜,请问 为什么?
这是网上找的,我加到程序里,但没执行到。。。
void CIImageDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rcWnd;
GetWindowRect(&rcWnd);
// TODO: Add your message handler code here
IImage * m_pImage;
IImage * m_pThum;
IImagingFactory * m_pImagingFactory;
ImageInfo IimageInfo;
HBITMAP hBitmap;
HDC hdcMem;
HGDIOBJ hOldSel;
HRESULT hr;
//COM初始化
if (FAILED(hr = CoInitializeEx(NULL, COINIT_MULTITHREADED)))
{
goto END;
}
//创建COM实例
if(FAILED(hr = CoCreateInstance(CLSID_ImagingFactory,NULL,CLSCTX_INPROC_SERVER,IID_IImagingFactory,(void**) &m_pImagingFactory)))
{
goto END;
}
if(PathName==L"")return;
//从文件中创建图片
if(FAILED(hr = m_pImagingFactory->CreateImageFromFile(PathName, &m_pImage)))
{
goto END;
}
//绘制图片
//获取图片属性
m_pImage->GetImageInfo(&IimageInfo);
//创建一个内存DC,用来存储图片数据
hBitmap = CreateCompatibleBitmap(dc,IimageInfo.Width,IimageInfo.Height);
hdcMem = CreateCompatibleDC(dc);
hOldSel = SelectObject(hdcMem,hBitmap);
/* m_pImage->GetThumbnail(100,100,&m_pThum);//这个用来显示缩略图
if(FAILED(hr = m_pThum->Draw(dc,CRect(0,0,480,272),NULL)))&rcWnd
{
goto END;
}*/
if(FAILED(hr = m_pImage->Draw(dc,&rcWnd,NULL))) //原图
{
goto END;
}
END:
//释放资源
if(m_pImage != NULL)
{
m_pImage->Release();
m_pImage = NULL;
}
if(m_pImagingFactory != NULL)
{
m_pImagingFactory->Release();
m_pImagingFactory = NULL;
}
CoUninitialize();
} |
|