链接:对话框上全图显示图像的两种做法    
     在对话框上显示图像的一个简便方法是:
1、首先添加想要显示的图片资源,ID为IDB_BITMAP1.
2、直接使用picture control->设置属性->杂项->type,选择Bitmap类型
然后属性中就会出现IMAGE项,直接从种选择要显示的图片的IDB_BITMAP1,完毕!
    但是这种做法有严重弊端——不能全图显示,就是在实际中图片很大,而对话框很少,使用这种做法就不能达到全图预览的效果,如下图,图片把其它控件都遮挡住了,但还是不能全图显示。   结合网上的代码,找到了两种全图显示的办法。
第一种是使用GDI+,同样需要使用到picture control,不过这次需要设置属性->杂项->type,选择Owner Draw类型。然后从CStatic类中派生出一个新类:CGdiPlusImgCtrl。重载DrawItem函数来实现绘制图像,代码如下:
void CGdiPlusImgCtrl::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
    if (NULL!=m_hBitmap)
    {
CRect rtClient;
GetClientRect(&rtClient);
Bitmap *pImg = Bitmap::FromHBITMAP(m_hBitmap,NULL);
        Graphics MyGraph(this->GetSafeHwnd());
        
RectF destRect(REAL(rtClient.left), REAL(rtClient.top), REAL(rtClient.Width()), REAL(rtClient.Height())),
srcRect;
        Unit  units;
pImg->GetBounds(&srcRect,&units);
MyGraph.DrawImage(pImg, destRect, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, UnitPixel, NULL);
        return;
    }
if (_T("")!=m_strImgFile)
{
CRect rtClient;
GetClientRect(&rtClient);
Image *pImg = Image::FromFile(m_strImgFile.c_str());
Graphics MyGraph(this->GetSafeHwnd()); RectF destRect(REAL(rtClient.left), REAL(rtClient.top), REAL(rtClient.Width()), REAL(rtClient.Height())),
srcRect;
Unit  units;
pImg->GetBounds(&srcRect,&units);
MyGraph.DrawImage(pImg, destRect, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, UnitPixel, NULL);
}
}   
     可能你觉得使用GDI+麻烦,需要对GDI+环境进行初始化,打包程序又得附带gdiplus.dll。那么我介绍的第二种方法使用GDI就没这么麻烦了。
第一种是使用GDI,同样需要使用到picture control,不过这次需要设置属性->杂项->type,选择Owner Draw类型。然后从CStatic类中派生出一个新类:CGdiImgCtrl。重载DrawItem函数来实现绘制图像,代码如下:void CGdiImgCtrl::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
if (NULL==m_hBitmap)
   return;
CRect rtPreview;
GetClientRect(&rtPreview);
HDC hDest = GetDC()->GetSafeHdc();
BITMAP bm;
GetObject(m_hBitmap,sizeof(BITMAP),&bm);
HDC dcmem = ::CreateCompatibleDC(hDest);
HBITMAP old = (HBITMAP)SelectObject(dcmem,m_hBitmap);
double dbRatio = min((rtPreview.Width()+1)/(double)(bm.bmWidth),(rtPreview.Height()+1)/(double)(bm.bmHeight));
dbRatio = min(1.0,dbRatio);
int nWidthDest = ((int)(bm.bmWidth*dbRatio));
int nHeightDest = ((int)(bm.bmHeight*dbRatio));
int nXOriginDest = (int)(rtPreview.CenterPoint().x-nWidthDest/2);
int nYOriginDest = (int)(rtPreview.CenterPoint().y-nHeightDest/2);
::StretchBlt(hDest,nXOriginDest,nYOriginDest,nWidthDest,nHeightDest,dcmem,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
SelectObject(dcmem,old);
DeleteDC(dcmem);
}    效果图如下:源码下载:PUDN下载