Sams Teach Yourself Visual Basic 6 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Introduction
- Who Should Read This Book
- What This Book Will Do for You
- Can This Book Really Teach Visual Basic in 24 Hours?
- What You Need
- Files on the Visual Basic Distribution CD-ROM
- Conventions Used in This Book
- Enough! Time Is Ticking!
- Part I: Introducing Visual Basic
- Hour 1. Visual Basic at Work
- Hour 2.Analyzing Visual Basic Programs
- Hour 3.Controls and Properties
- Hour 4.Examining Labels, Buttons, and Text Boxes
- Part II: Coding the Details
- Hour 5.Putting Code into Visual Basic
- Hour 6.Message and Input Boxes
- Hour 7.Making Decisions
- Hour 8.Visual Basic Looping
- Part III:Putting Code to Work
- Hour 9.Combining Code and Controls
- Hour 10.List Boxes and Data Lists
- Hour 11.Additional Controls
- Hour 12.Dialog Box Basics
- Part IV:Programming with Data
- Hour 13.Modular Programming
- Hour 14.Built-In Functions Save Time
- Hour 15.Visual Basic Database Basics
- Hour 16.Printing with Visual Basic
- Part V:Sprucing Up Programs
- Hour 17.Menus and Visual Basic
- Hour 18.The Graphic Image Controls
- Hour 19.Toolbars and More Graphics
- Hour 20.Writing Correct Applications
- Part VI:Advancing Visual Basic Applications
- Hour 21.Visual Basic and ActiveX
- Hour 22.Object Basics
- Hour 23.Distributing Your Applications
- Hour 24.Online Visual Basic
- Part VII:Appendixes
- Appendix A.Operator Precedence
- Appendix B.Answers
- Appendix C.Using the CD-ROM
The Image List Control
As you know, a toolbar is a row of buttons with icons on them. The Toolbar control has one slight limitation: It cannot keep track of each image that you place on a toolbar button. Instead, the Toolbar control only works with a special control called an Image List control. Fortunately, the Image List control appears on the toolbox when you add the Microsoft Windows Common Controls 6.0 control set, as you did in the previous section.
Therefore, you might want to practice adding a toolbar to a Form window by opening a new project and then placing an Image List control on the Form window. Expand the Form window slightly so that the Form window is wide enough for a toolbar (approximately 6,645 twips wide).
The Image List control doesn't look like much. Just like the Timer control and the Common Dialog Box control, the Image List control's placed size and location don't matter much because the user will never directly see the Image List control on the form. The user will, instead, see images that the Image List control keeps track of. The Image List control works a lot like a graphic image array. The Image List control holds images from files, and when you're using it for toolbars, the Image List control holds toolbar icons such as the ones in Microsoft Visual Studio's \Program Files\Microsoft Visual Studio\Common\Graphics\Icons folder.
An image list is a list of images in an array-like control called the Image List control.
The easiest way to add images to the Image List control is by clicking the Image List control's Custom property to display Figure 19.3's custom property pages. This dialog box organizes the Image List control's figures and lets you manage each figure's properties separately.
Figure 19.3 Specifying Image List control properties in the Property Pages dialog box.
Click the Images tab to display the Images page. Here you will build a list of images that will ultimately end up on your application's toolbar. To add some images for this lesson's sample toolbar, click the Insert Picture button and select the icon file named Disk04 located in the \Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Computer folder. The image will appear in the image list, and its index value will be set to 1, as Figure 19.4 shows.
Figure 19.4 The Image List control now has one image.
Keep inserting images in the following order (from the same folder to keep things simple): Key04, Mouse02, Trash01, and W95mbx01. As you insert the images one at a time, you'll notice that Visual Basic automatically updates the image's Index text box value. After you add the final image, your image list should look like Figure 19.5's list of icons.
Figure 19.5 The Image List control now contains five icon images.
Click OK to close the Property Pages dialog box and name the Image List control imlToolBar (using the Properties window) so the Toolbar control can reference the images you just stored in the Image List control.
Finalizing the Toolbar | Next Section

Account Sign In
View your cart