给你我的代码:显示JPEG的是从清华水木上来的.
void CChatView::OnPaint() 
{
CPaintDC dc(this); // device context for painting

// TODO: Add your message handler code here
IPicture * pic;
IStream *pstream;
CFileStatus fstatus;
CFile file;
long cb;
if (file.Open ("e:\\chat\\coco.jpg",CFile::modeRead)&&file.GetStatus ("e:\\chat\\coco.jpg",fstatus)&&((cb=fstatus.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,&pstream);
if (SUCCEEDED(OleLoadPicture(pstream,fstatus.m_size ,TRUE,IID_IPicture,(LPVOID*)&pic)))
{
OLE_XSIZE_HIMETRIC hmwidth;
OLE_YSIZE_HIMETRIC hmheight;
pic->get_Width (&hmwidth);
pic->get_Height (&hmheight);
double fx,fy;
fx=(double)dc.GetDeviceCaps (HORZRES)*(double)hmwidth/((double)dc.GetDeviceCaps (HORZSIZE)*100.0);
fy=(double)dc.GetDeviceCaps (VERTRES)*(double)hmheight/((double)dc.GetDeviceCaps (VERTSIZE)*100.0);
if (FAILED(pic->Render (dc,0,0,(DWORD)fx,(DWORD)fy,0,hmheight,hmwidth,-hmheight,NULL)))
pic->Release();

}
}
}
}
// Do not call CScrollView::OnPaint() for painting messages
}