Solved

Picture Box in VC++

Posted on 2001-07-02
5
606 Views
Last Modified: 2013-12-03
I guess this is simple but how do you load an image into a picture box in VC++?
I've got a dialog form with an OK and Cancel button and I've loaded a picture box from the Controls toolbox. In the properties dialog of the picture box box there are 2 drop down combos. One allows me to pick Bitmap for the type of image but the other one (for picking the actual image) is blank. Do I have to load images into the project somehow?
0
Comment
Question by:ianch
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
hakob earned 50 total points
ID: 6247340
Hello,

If you choose "Bitmap" in the first combo box, the second combo box shows all bitmaps, which are contained in the project resource yet, with their resource id. This ids will be shows on the combo to choose the bitmap. It does not trace the directories to find bitmap files, etc.

With Visual C++ you can either create new bitmap in the project resources or insert existing bitmap into there.

To create new bitmap, choose the menu
"Insert" -> "Resource", select "Bitmap" and press "New".
This will create bitmap file with the resource id like IDB_BITMAP1, which will be shown in the second combo box.
You can draw now this bitmap.

To load the existing bitmap into the project, choose the menu "Insert" -> "Resource", select "Bitmap" and press "Import". This will show the directory tree in your PC and you should choose "All files" in the "Files of type" combo box therein. Then select the bitmap you want (for example, choose c:\windows\setup.bmp). Then press "Import". This will add the selected bitmap to your project resources with the id f.e. IDB_BITMAP2.

So, now, your second combo box will show the IDs of 2 bitmap files: IDB_BITMAP1 and IDB_BITMAP2. You can choose between them.

Thank you
0
 

Author Comment

by:ianch
ID: 6250816
Excellent Hakob,
I loaded the image OK but it is now covering up the 2 buttons on the dialog form.
I'll increase the points to 100 if you can tell me:
1. How to bring the buttons back on top
2. How to change the color and font size of the text in the static text box I have put on the dialog form.

ianch
0
 
LVL 30

Expert Comment

by:Axter
ID: 6250827
>>How to bring the buttons back on top
Use the TAB option.  You'll find this under the main menu.
[Layout]->[Tab Order]

Change the tab order to reflect which control you want on top.
0
 
LVL 30

Expert Comment

by:Axter
ID: 6250828
>>How to change the color and font size of the text in the
>>static text box I have put on the dialog
>>form.
You would have to create your own CStatic control to do this.
An easier way to do it would be to make a bitmap with the desired colored text.
0
 

Author Comment

by:ianch
ID: 6251088
Thanks Axter but I have to give the points to hakob
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now