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

Display Bitmap in a Picture Box using MFC from a file

Discussion in 'MFC' started by shabbir, Jun 9, 2005.

  1. Tajin

    Tajin New Member

    Joined:
    Sep 9, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Shabbir,
    I'm new to code in VC++. Please verify my code according to your suggestion.

    1.Add a picture Box to your application

    Is it ok?
    CPictureBox pic;

    How can I do the following?

    3. Add a variable to the picture box. By default it will be CStatic. I call it picPreview
    4. Change the CStatic to CPictureBox. Don't forget to add the header files at the top.

    Please Help!!
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    If you are using the MFC Wizard you will need to use the Class wizard to add the variable or else you should be adding the variable in dialog class and the DDX of the control into the message maps and then you are done.

    Now when you have the variable in the header file you will need to change it type from CStatic to CPictureBox.
     
  3. parvez.yu

    parvez.yu New Member

    Joined:
    Feb 14, 2008
    Messages:
    100
    Likes Received:
    0
    Trophy Points:
    0
    i m always confused with files but thanksyour explanation and code was good
     
  4. pandyajayn

    pandyajayn New Member

    Joined:
    May 8, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi, I am getting error during calling Invalidate() in the given file so please provide me the solution.
     
  5. mcbals

    mcbals New Member

    Joined:
    Jun 23, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi, i got an error on this line of code:
    m_statPic.Create("", WS_CHILD|WS_VISIBLE|SS_BITMAP|SS_CENTERIMAGE, rectBackGrnd ,this);

    m_statPic is a Control variable for text control.
    This line works on a single window mfc, but when tried on a child window it is erroneus.

    please need some advice.

    thanks.
     
  6. ramrao

    ramrao New Member

    Joined:
    Aug 31, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    ok thank you.....
     
  7. Black Betty

    Black Betty New Member

    Joined:
    Sep 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Wondering if you ever got round to doing JPG sample.
    Thanks
     

Share This Page