glyFX Guides : Microsoft Visual Basic 6
Using glyFX icons in Microsoft Visual Basic 6
This document outlines the basic procedure on how to use the glyFX toolbar images with Microsoft Visual Basic 6. A similar procedure applies to earlier versions, however there are differences in the user interface. The terminology used in this article would apply to all versions.
There are two main mechanisms for adding icons on your controls, image lists and embedding into controls.
Image Lists allow you to have a single object that contains all of your icons. This allows you to edit the images without having to modify each individual control within your application. If you use the same icon on more than one control, it stores a single copy of that icon, rather than duplicate the image. This guide is broken up into 4 seperate parts;
- Part 1 - Adding an Image List
- Part 2 - Setting ImageList properties
- Part 3 - Adding icons to the Image List
- Part 4 - Using the Image List
Embedding an image into a control is a quick way of adding an icon to your user interface. The selected control will directly store the icon resource. This method is very quick, but not as efficient as using Image Lists, although necessary since some controls are not compatible with Image Lists. This guide has just 1 part;
A default installation of Visual Basic 6 does not display the Image List component. It is part of the Microsoft Common Controls, which are installed on every version of Windows. If your Toolbox panel does not contain the Image List, you will need to add it to your project (otherwise, please continue to Step 4).
Right click on any empty space in your Toolbox panel, and select Components from the drop down menu.
Using the Components dialog, scroll down to Microsoft Windows Common Controls and tick the box. Depending on your operating system, you may have more than one set of these controls listed. To check the differences between the different versions, please visit the Microsoft MSDN web site. Once you have selected the control, click the OK button.
Your Toolbox panel should now show the new controls.
Select the Image List control from the Toolbox panel and drag it onto your form.
Right click the Image List control and select Properties from the drop down menu. This will display the property dialog for the control.
From the General tab, select or enter the size of the images that you want to use in this Image List. Depending on which sets you own, this may be 16x16, 24x24, 32x32, 48x48 or 64x64). Make sure that the UseMaskColor box is checked.
Click the Color tab, and select MaskColor from the Properties list. This tells the Image List what colour should be made transparent in the icons. Using the Color Palette list, scroll down until you find Magenta and select it and then click the Apply button.
Select the Images tab in the Image List Property Pages dialog. Click the Insert Picture button, which will display a standard Windows Open File dialog, where you may select a bitmap (.BMP) image from one of the glyFX folders.
Once you have selected an image (or multiple images), the Image List Property Pages dialog will display the icon you have added. You can continue adding as many images as you need (you can always edit the contents of the ImageList at a later stage).
This part demonstrates how to use the Image List with a standard toolbar control. The procedure is very similar for other controls that support the Image List. This includes third party controls from other vendors.
Select the Tool Bar control from the Toolbox panel. Click on the form to insert the control.
Right click on the Tool Bar control, and click Properties from the drop down menu to display the Tool Bar Property Pages dialog.
On the General tab, click the ImageList drop down and select the Image List control you have added.
Select the Buttons tab, so that you can add button controls to your Tool Bar. Now click Insert Button to create a new tool button. Set the Image property to the index of the image you want to use (in our case, it is the first image) and click OK.
The final result - a Tool Bar control, with a button using a high quality glyFX icon!
This example shows how to add an image directly to a Command Button control. The method is similar for other controls that support images, including ones from third party vendors.
Select the Command Button control in the Toolbox panel, and drag it to your form.
In the Properties panel, click the Picture editor button. This will display a standard Windows Open File dialog, where you need to select a bitmap (.BMP) or gif (.GIF) image from one of the glyFX folders.
Click the MaskColor drop down in the Properties panel, to display the colour editor and select the Magenta colour. Alternatively you can enter &H00FF00FF& directly into the text box. Now scroll down to the UseMaskColor property and set it to true. This will allow Visual Basic to make the background colour of the icons transparent.
Set the buttons Style property to Graphical - this allows it to display the icon.
The final result - a Command Button containing a high quality glyFX icon!