在对话框中显示图象的具体步骤是什么,那位大侠能提供一下这样的例程。先谢了

解决方案 »

  1.   

    一般的bmp图的话,vc工具箱里面有控件的。
    如果要显示gif,jpg之类的图片的话,就需要一些类了,比如:CPictureEx
      

  2.   

    你想放入图片就是tonybaobao说的
    你想在对话框里画图就是wyz_csdn说的啊用dc画
      

  3.   

    我想楼主你想放入bitmap吧
    那看看我这样的行不行了
    首先加入一个picture控件
    然后把他的properity里面的type选为bitmap
    这时image Properity就可用了
     再后就是选image为你的Bitmap的ID了
    好的
    下面的还是楼主你自个看看吧
      

  4.   

    /************************************************************************/
    /* 显示图片函数                                                         */
    /************************************************************************/
    BOOL CXTReportApp::ShowPIC(CDC *pDC, CString strPath, CRect rect,int ShowType)
    {
    CPen newpen(PS_DOT,1,RGB(255,255,255));
    CPen *pOldPen=pDC->SelectObject(&newpen);
    pDC->Rectangle(rect);
    pDC->SelectObject(pOldPen);

    //显示BMP JPG GIF等格式的图片
        IStream *pStm;  
        CFileStatus fstatus;
        CFile file;  
        LONG cb;  

    HGLOBAL hGlobal;
        //打开文件并检测文件的有效性
        if (file.Open(strPath,CFile::modeRead)&&
            file.GetStatus(strPath,fstatus)&& 
            ((cb = fstatus.m_size) != -1)) 
        {  

            hGlobal = GlobalAlloc(GMEM_MOVEABLE, cb); 
            LPVOID pvData = NULL;  
            if (hGlobal != NULL)  
            {  
                pvData = GlobalLock(hGlobal);
                if (pvData != NULL)  
                {  
                    file.ReadHuge(pvData, cb);  
                    GlobalUnlock(hGlobal);  
                    CreateStreamOnHGlobal(hGlobal, TRUE, &pStm);  
                } 
            } 
        }
        else
        {
            return false;
        } 
    //打开文件结束
        

        //显示JPEG和GIF格式的图片,GIF只能显示一帧,还不能显示动画,
    //要显示动画GIF请使用ACTIVE控//件。

        IPicture *pPic; 
        //load image from file stream

        if(SUCCEEDED(OleLoadPicture(pStm,fstatus.m_size,TRUE,IID_IPicture,(LPVOID*)&pPic))) 
        { 
            OLE_XSIZE_HIMETRIC hmWidth;  
            OLE_YSIZE_HIMETRIC hmHeight; 
            pPic->get_Width(&hmWidth);  
            pPic->get_Height(&hmHeight);
            double fX,fY;  
            //得到图片的高度与宽度
            fX = (double)pDC->GetDeviceCaps(HORZRES)*(double)hmWidth/
    ((double)pDC->GetDeviceCaps(HORZSIZE)*100.0);  
            fY = (double)pDC->GetDeviceCaps(VERTRES)*(double)hmHeight/
    ((double)pDC->GetDeviceCaps(VERTSIZE)*100.0);  

    long nwidth,nheight,nleft,ntop;
    int Rx,Ry;
    Rx=rect.Width();
    Ry=rect.Height();
    nheight=Ry;
    nwidth=Rx;
    nleft=rect.left;
    ntop=rect.top;
    //检测显示模式
    //是否拉伸充满区域显示
    if(ShowType==1)
    {
    nheight=Ry;
    nwidth=Rx;
    nleft=rect.left;
    ntop=rect.top;
    }
    //是否居中且按正常比例显示
    else if(ShowType==2)
    {
    if(fX<Rx) nwidth=(long)fX;
    if(fY<Ry)     nheight=(long)fY;

    if((fY>Ry)||(fX>Rx))
    {
    double temp,temp2;
    temp=Ry/fY;
    temp2=Rx/fX;
    if(temp<temp2)
    {
    nwidth=(long)(fX*temp);
    nleft=(Rx-nwidth)/2+rect.left;
    }
    else if(temp>=temp2)
    {
    nheight=(long)(fY*temp2);
    ntop=(Ry-nheight)/2+rect.top;
    }
    }
    }


            //用 Render函数显示图片
            //if(FAILED(pPic->Render(*pDC,rect.left,rect.top ,rect.Width(),rect.Height(),0,
    if(FAILED(pPic->Render(*pDC,nleft,ntop,nwidth,nheight,0,
    hmHeight,hmWidth,-hmHeight,NULL)))  
            {
                pPic->Release();
                return false;
            }
               pPic->Release();  
        }  

        else  
        {
            return false;  
        }
    //释放内存
        GlobalUnlock(hGlobal);  
    GlobalFree(hGlobal);      return true;}