Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   How adjust image to a picture box ? (http://www.go4expert.com/forums/adjust-image-picture-box-t7687/)

xara 3Dec2007 18:17

How adjust image to a picture box ?

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:

 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.

All times are GMT +5.5. The time now is 14:04.