Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to load a picture when the program is running?

Posted on 1999-07-02
4
Medium Priority
?
239 Views
Last Modified: 2010-04-02
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
Comment
Question by:99525
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Expert Comment

by:MichaelS
ID: 1198986
How to do what? Load picture, show it on button, write a program or use VC++ 6.0? Can you be more specific?
0
 
LVL 3

Accepted Solution

by:
Laminamia063099 earned 300 total points
ID: 1198987
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
 
LVL 6

Expert Comment

by:MichaelS
ID: 1198988
of course if the file is .bmp
0
 

Author Comment

by:99525
ID: 1198989
I have tried this answer, and it works. Thanks.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question