[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 243
  • Last Modified:

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?
0
99525
Asked:
99525
  • 2
1 Solution
 
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
 
MichaelSCommented:
of course if the file is .bmp
0
 
99525Author Commented:
I have tried this answer, and it works. Thanks.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now