?
Solved

Picture box with multiple images..

Posted on 2003-03-17
11
Medium Priority
?
328 Views
Last Modified: 2011-09-20
I have a single picture box which holds little gif's for whichever die was rolled when my roll function is called.  The picture is updated according to whichever die was last rolled.  This works fine and dandy, but my pictures always have to be in a certain folder for it to work.  Is there anyway to embed the pictures into the program when it's compiled?  Actually there must be a way because my teacher's program doesn't have any seperate gif's and it still works.  

Thanks in advance.
0
Comment
Question by:BradHarris
[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
  • 3
  • 3
  • 3
  • +1
11 Comments
 
LVL 1

Expert Comment

by:JH0401
ID: 8153659
You need to have the picture file in the location that is specified by your code or that you choose in design mode when you set the picture box picture property.  Your program will look to this location to find the specified picture to display!!!
0
 
LVL 2

Accepted Solution

by:
Jacamar earned 100 total points
ID: 8153872
Well, there are some very non-elegant ways to do this.  One way to do it is to have invisible image controls that you can use to load the images in to the picture boxes.  

or.

Depending on how many options there are, you could have numerous picture boxes on top of each other, each pre-loaded with an image, and when the dice is rolled, you can bring whichever one you want to the top (visible), and when you want to have it blank, bring a blank picture box to the top.

Well, there are probably better ways, but this way will work.
0
 
LVL 1

Expert Comment

by:timd_jones
ID: 8153927
Jacamar's solution is good. You can also look at using resource files, and learn how to use the requisite API calls to retrieve the images. Look at the image list control as well.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:BradHarris
ID: 8154678
I had thought of those ways already but I don't see how that will help with my problem.  What I want to be able to do is just send out the EXE and the images should already be loaded along with it.  I don't want to send multiple files... that's how my teacher did it.  Tim's suggestion sounds good but could you direct me towards a specific source or tutorial?  Thanks
0
 
LVL 1

Expert Comment

by:JH0401
ID: 8154710
Once you create a installation package with your package & deployment wizard (or other packaging program), the dependency files will be installed with the exe as long as you choose to include these files in the packaging!!!
0
 
LVL 1

Expert Comment

by:timd_jones
ID: 8154750
If you use the invisible image controls method, or multiple layered picture boxes, each with the appropriate graphic loaded in it, then the graphic binary is stored in the form's .frx file and will be compiled into the .exe.

For example:

Start a standard exe project and place on the form a picture box (Picture1), six image controls (Image1) and a command button (cmdRoll). Set the Index property for the image controls for index 0 through 5, and set each image controls Visible property to False

Private Sub cmdRoll()
    Dim lngRoll as Long

    'generate your random roll
    lngRoll = Int(Rnd * 6) + 1

    Picture1.Picture = Image1(lngRoll - 1).Picture
End Sub
0
 
LVL 2

Expert Comment

by:Jacamar
ID: 8154823
Exactly.  All the pictures are already there, just like the command buttons or the labels don't need files to go along with them.  They are saved as part of the exe.
0
 

Author Comment

by:BradHarris
ID: 8154880
Ok that seems to be a good explanation except for the fact that I can't find an image control... I'm using VB .NET .....
0
 
LVL 2

Expert Comment

by:Jacamar
ID: 8154903
use different picture boxes then
0
 
LVL 1

Expert Comment

by:timd_jones
ID: 8154908
Whoops! Sorry, this code would work fine for VB5 or VB6, but not VB.Net. I don't have the expertise in VB.NET yet, else I would offer more!
0
 

Author Comment

by:BradHarris
ID: 8154937
Thanks for spending the extra time and comments to help me get through this one.  I appreciate it!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 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