CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2012
    Posts
    13

    Picturebox load image

    Hallo i want to know how i can open a image in picture box i want to work that way: when i start the application i have nothing in the picuter box i click a button and it loads a picture how i do that
    i want the picture to load after so for example i can have 3 different buttons standig for different pictures so if i click button 1 it opens a bunny if i click button 2 it opens a dog and etc

  2. #2
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Picturebox load image

    I am not sure if by picture box you are referring to the static control described as Picture Control in Visual studio.
    If this is the case, choose appropriate format for the control (bitmap for example), do not change any other styles. Change IDC_STATIC id to something else and use wizard to inset variable.
    This wills subclass control for you.
    Use LoadImage to load bitmap, and use SetBitmap member of the static control, passing handle returned by the LoadImage call.

    Control will take care for drawing image and will resize itself to accommodate image size.
    If you are not using Picture Control, you will have to give more details.
    Most likely, you will have to load image and handle drawing and resizing of the control by yourself.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured