Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/articles/mfc-tutorials/)
-   -   Display Bitmap in a Picture Box using MFC from a file (http://www.go4expert.com/articles/display-bitmap-picture-box-using-mfc-t350/)

shabbir 5Feb2007 11:17

Re: Display Bitmap in a Picture Box using MFC from a file
 
Quote:

Originally Posted by lplover2k
it's not generated... i am getting error that it is missing :(

If its not generated delete the line wallpaper.h

lplover2k 9Feb2007 02:09

Re: Display Bitmap in a Picture Box using MFC from a file
 
when u say "Add a picture Box to your application"
is it the "picture" control??

the types available for are "frame","icon","bitmap","rectangle"Enhanced metafile"... still don't see "ownerdrawn"..... and where do i inlcude "picture.h" in my dialog class?

shabbir 9Feb2007 09:28

Re: Display Bitmap in a Picture Box using MFC from a file
 
Quote:

Originally Posted by lplover2k
when u say "Add a picture Box to your application"
is it the "picture" control??

Yes.

Quote:

Originally Posted by lplover2k
the types available for are "frame","icon","bitmap","rectangle"Enhanced metafile"... still don't see "ownerdrawn"..... and where do i inlcude "picture.h" in my dialog class?

Go through the tabs of the property window and you will see a checkbox of ownerdraw.

lplover2k 9Feb2007 15:12

Re: Display Bitmap in a Picture Box using MFC from a file
 
there's no "ownerdraw"... neither in styles nor extended styles too...:(

http://img213.imageshack.us/img213/3672/frmwu4.gif


thanks for quick responses btw

shabbir 9Feb2007 15:36

Re: Display Bitmap in a Picture Box using MFC from a file
 
You dont need to convert the style to owner draw and it will work perfectly fine. I have edited the article for the errors. Thanks for pointing that out.

lplover2k 9Feb2007 23:27

Re: Display Bitmap in a Picture Box using MFC from a file
 
thanks very much!!! i have finally managed to use it!!! this is a great piece of code !!! it's the simplest method to load bitmap!!! thanks !!!

i am glad i was helpful for your code correction :)

one question is there a way to load jpeg??

shabbir 10Feb2007 09:36

Re: Display Bitmap in a Picture Box using MFC from a file
 
Quote:

Originally Posted by lplover2k
one question is there a way to load jpeg??

You need GDI for that. I am planning to write one article on that but its lack of time at this moment.

lplover2k 10Feb2007 11:51

Re: Display Bitmap in a Picture Box using MFC from a file
 
cool i am impatient :) and thaNKs again

abdul_khathar 9Aug2007 12:58

how Display jpeg Picture in MFC dialog?
 
hi Shabbir!

In MFC application (Dialog based or Cform view), if i load bitmap image in the background, its taking more memory.. here is my coding..
Code:

void CDlg_Splash::OnPaint()
{
        CPaintDC dc(this); // device context for painting
       
        HBITMAP m_Bmap;
        CRect rect;
        HDC memdc;
       
        CString m_ifilename1;
       
        m_ifilename1 = "C:\\test.bmp";
       
        GetClientRect(&rect);
       
        m_Bmap=(HBITMAP)::LoadImage(NULL,m_ifilename1,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
        memdc=::CreateCompatibleDC(dc.m_hDC);
        ::SelectObject(memdc,m_Bmap);
       
        BitBlt(dc.m_hDC,0,0,rect.right,rect.bottom,memdc,0,0,SRCCOPY);
        DeleteObject(m_Bmap);
        DeleteObject(memdc);
}

is it correct ? and also let me know is there any memory leakage?
is it possible to load jpeg image in MFC dialog? (to avoid more memory usage)

Thanks in Advance...





Abdul Khathar A

shabbir 9Aug2007 14:22

Re: Display Bitmap in a Picture Box using MFC from a file
 
You don't need to load the image in the Paint but can have the image loaded in the constructor and just display / Paint in the OnPaint


All times are GMT +5.5. The time now is 08:03.