IStream *pStream;
IPicture *pPicture;
CFile file;
CFileStatus fStatus;
if( file.Open( filePath, CFile::modeRead ) && file.GetStatus(fStatus) && fStatus.m_size != -1 )
{
HGLOBAL hGlobal = GlobalAlloc( GMEM_MOVEABLE , fStatus.m_size );
LPVOID lpVoid = GlobalLock(hGlobal);
if( file.Read(lpVoid, fStatus.m_size) )
{
CreateStreamOnHGlobal( hGlobal, true, &pStream );
GlobalUnlock( hGlobal );
file.Close();
if( S_OK == OleLoadPicture( pStream, fStatus.m_size, true, IID_IPicture, (LPVOID*)&pPicture ) )
{
OLE_XSIZE_HIMETRIC lx;
OLE_YSIZE_HIMETRIC ly;
pPicture->get_Width( &lx );
pPicture->get_Height( &ly );
CDC *pDC = m_showPic.GetDC();
pPicture->Render( pDC->GetSafeHdc(), 0, 0, 100, 100, 0, ly, lx, -ly, NULL);
pPicture->Release();
}
}
}