How to load a picture when the program is running?

I want to use VC++6.0 to develop a program, which can display pictures on an object, such as a button. These pictures are loaded after the program is run, so I can replace them while running. How to do this?
99525Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MichaelSCommented:
How to do what? Load picture, show it on button, write a program or use VC++ 6.0? Can you be more specific?
0
Laminamia063099Commented:
If you want to place an image on a button or on the screen, you can get the file name from the user with a Win 32 API call to:
   OPENFILENAME ofn;  //open file name structure
   GetOpenFileName (&ofn);
   //the name of the file chosen in this dialog box will
   //returned in the ofn.lpstrTitle field of the structure.
   HANDLE IconOrPicture = LoadImage(hInst, ofn.lpstrTitle,
    IMAGE_BITMAP,   //or IMAGE_CURSOR, IMAGE_ICON
    cxDesired,          // desired width
    cyDesired,      // desired height
    LR_LOADFROMFILE|LR_DEFAULTSIZE // will load from file
                                   // with default size.
   );      
   //Then use the following:
   hdc = GetWindowDC ( hwnd );  //hwnd = button or window.
   DrawIcon (hdc, x, y, IconOrPicture);  
   ReleaseDC (hwnd, hdc);  //That should do it!
Laminamia
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MichaelSCommented:
of course if the file is .bmp
0
99525Author Commented:
I have tried this answer, and it works. Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.