Hi all,

I'm using microsoft visual C++ 6.0 with SP4 and SP5..
I had a program which content a CScrollView..

Now I would like to add in a image into CScrollView..
but my image is buffer..not from resource..
I can save my image, bitmap form, into local drive..
but I do not know how to insert those images into CScrollView..

Can anyone know about that..??

Please advise..

Thank you
Shizu..

OMG, can't even believe that so many people are unable to search the internet....

google("CScrollView show bitmap");
select2nd("topic");

Hi Adatapost and jencas..

Thanks for help..
I found the solution to paste my buffer image into CScrollView..

1st, I save my image into local drive..
then..

CBitmap bmp, *pOldBitmap;
BITMAP bmpInfo;
CRect rect;

if(bmp.m_hObject != NULL)
 bmp.DeleteObject();

HBITMAP hImage = (HBITMAP) LoadImage(NULL, "C:\\a.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);

if(hImage)
{
 if(bmp.Attach(hImage))
 {
  bmp.GetBitmap(&bmpInfo);

  CDC dcMemory;
  dcMemory.CreateCompatibleDC(pDC);

  pOldBitmap = dcMemory.SelectObject(&bmp);
  GetClientRect(&rect);
  int nX = rect.left + (rect.Width() - bmpInfo.bmWidth) / 2;
  int nY = rect.top + (rect.Height() - bmpInfo.bmHeight) / 2;

  pDC->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight,   
            &dcMemory, 0, 0, SRCCOPY);

  dcMemory.SelectObject(pOldBitmap);
 }
}

Thank you..
shizu..

Edited 3 Years Ago by Reverend Jim: Fixed formatting

This question has already been answered. Start a new discussion instead.