1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How adjust image to a picture box ?

Discussion in 'MFC' started by xara, Dec 3, 2007.

  1. xara

    xara New Member

    Dec 3, 2007
    Likes Received:
    Trophy Points:

    I am trying to display an image into a PDA but I have no experience programming for PDA's neither working with images. I followed more or less the instructions given in a post from this forum: "Display Bitmap in a Picture Box using MFC from a file". I am working in Microsoft eMbedded C++ 4.0. First, I created a dialog based MFC project and added a Picture Control. Then I added the variable CStatic and load the bitmap. The problem is that it does not fit into the Picture Control place, I mean, the whole image is not displayed. I know that I need the StretchBlt function for adjusting it but I am doing anything wrong and it does not work. I would be very grateful if somebody could help me with this because I have been trying to solve this for a long time and I am desperate. This is the code that I have in OnInitDialog:
    HBITMAP hBmp; 
     if((hBmp = SHLoadImageFile(_T("\\1_eli.jpg")))!=0x00000000)
      // Get the dimensions of the bitmap
      CBitmap bmp;
      BITMAP bm;
      // dimensions of the control
      RECT rectScaled;
      int rectW=rectScaled.right-rectScaled.left;
      int rectH=rectScaled.bottom-rectScaled.top;
      HDC hdc=::GetDC(m_imagen.m_hWnd);
      HDC memdc=CreateCompatibleDC(hdc);
     HBITMAP hBmp2=(HBITMAP)SelectObject(memdc,hBmp);
      //HBITMAP hBmp2=CreateCompatibleBitmap(memdc,rectW,rectH);
    Thanks for your time.
    Last edited by a moderator: Dec 3, 2007

Share This Page