1.9w+
社区成员
if(FAILED(pPic->Render(*pDC,0,0,(DWORD)cx,(DWORD)cy,0,cySrc,cxSrc,-cySrc,NULL)))
AfxMessageBox("Failed To Render The picture!");
pPic->Release();
void CDispPicView::PicChangeImmediate(CString &str,IPicture *pPic)
{
CClientDC *pDC=new CClientDC(this);
IStream *pStm;
CFileStatus status;
LONG cb;
CFile file;
if(file.Open(str,CFile::modeRead) && file.GetStatus(str,status)&&((cb=status.m_size)!=-1))
{
HGLOBAL hGlobal=GlobalAlloc(GMEM_MOVEABLE,cb);
LPVOID pvData=NULL;
if(hGlobal!=NULL)
{
if((pvData=GlobalLock(hGlobal))!=NULL)
{
file.ReadHuge(pvData,cb);
GlobalUnlock(hGlobal);
CreateStreamOnHGlobal(hGlobal,TRUE,&pStm);
if(SUCCEEDED(OleLoadPicture(pStm,status.m_size,TRUE,IID_IPicture,(LPVOID*)&pPic)))
{
pPic->get_Width(&cxSrc);
pPic->get_Height(&cySrc);
cx= (double)pDC->GetDeviceCaps(HORZRES)*(double)cxSrc/((double)pDC->GetDeviceCaps(HORZSIZE)*100.0);
cy= (double)pDC->GetDeviceCaps(VERTRES)*(double)cySrc/((double)pDC->GetDeviceCaps(VERTSIZE)*100.0);
if(FAILED(pPic->Render(*pDC,0,0,(DWORD)cx,(DWORD)cy,0,cySrc,cxSrc,-cySrc,NULL)))
AfxMessageBox("Failed To Render The picture!");
pPic->Release();
}
else
AfxMessageBox("Error Loading Picture From Stream!");
}
}
}
else
AfxMessageBox("Can't Open Image File!");
if(pDC)
{
pDC->DeleteDC();
}
}