Board index » Visual Studio » add a picture to MFC view

add a picture to MFC view

Visual Studio317
Hi,

Anybody know how to add a existing picture to MFC view, the picture

already in c:\, thanks a lot!



-ja


-
 

Re:add a picture to MFC view

Hi,



// First load image;



HANDLE hImage = ::LoadImage(

AfxGetInstanceHandle(), lpszFileName, IMAGE_BITMAP, 0, 0,

LR_LOADFROMFILE);



// Then, pass it to CBitmap;



CBitmap bmp;

bmp.Attach(hImage);



// Get sizes;

BITMAP b;

bmp.GetObject(sizeof (b), &b);



// Create in-memory device for client area of the view

CDC mdc;

mdc.CreateCompatibleDC(NULL);



// Now use bmp, b, mdc and your view's dc to draw the picture.







--

======

Arman





"ja" wrote:



Quote
Hi,

Anybody know how to add a existing picture to MFC view, the picture

already in c:\, thanks a lot!



-ja







-

Re:add a picture to MFC view

Quote
Anybody know how to add a existing picture to MFC view, the picture

already in c:\, thanks a lot!





Look at CPicture class here:



msdn.microsoft.com/msdnmag/issues/01/10/c/">msdn.microsoft.com/msdnmag/issues/01/10/c/



---

Ajay



-

Re:add a picture to MFC view

Cool, thanks a lot!



"Arman Sahakyan" <armancho_x@rambler.ru(donotspam)>дÈëÏûÏ¢ÐÂÎÅ:8BE3E65F-E377-4681-87DB-15951F3F7369@microsoft.com...

Quote
Hi,



// First load image;



HANDLE hImage = ::LoadImage(

AfxGetInstanceHandle(), lpszFileName, IMAGE_BITMAP, 0, 0,

LR_LOADFROMFILE);



// Then, pass it to CBitmap;



CBitmap bmp;

bmp.Attach(hImage);



// Get sizes;

BITMAP b;

bmp.GetObject(sizeof (b), &b);



// Create in-memory device for client area of the view

CDC mdc;

mdc.CreateCompatibleDC(NULL);



// Now use bmp, b, mdc and your view's dc to draw the picture.







--

======

Arman





"ja" wrote:



>Hi,

>Anybody know how to add a existing picture to MFC view, the picture

>already in c:\, thanks a lot!

>

>-ja

>

>

>





-