Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

Picture, DownPicture, DisabledPicture

These properties let you associate images with various aspects of certain controls. The meaning of Picture varies according to the control—in fact, for a couple of controls, it’s an array property.

Usage

oObject.Picture = cPictureFile
lstList.Picture( nIndex )= cPictureFile
cboCombo.Picture( nIndex )= cPictureFile
cPictureFile = oObject.Picture
               | lstList.Picture( nIndex )
               | cboCombo.Picture( nIndex )

In VFP 3, these properties accept only BMP files. In VFP 5, ICO was added. In VFP 6 and later versions, they’re even more flexible, accepting those two types as well as GIFs and JPGs.

Picture is truly a case of polymorphism at work. The table below shows how to interpret Picture for each class that has it.

Class

Meaning

CheckBox, OptionButton

If Style is 1-Graphical, picture is displayed above caption. If Style is 0-Standard, Picture is ignored.

ComboBox, ListBox

Picture is an array property. Each element corresponds to one item in the list and is displayed next to that item. The array is indexed in ListIndex (not ListItemId) order.

CommandButton

Picture is displayed above caption on button.

Custom

Picture is displayed in Class Designer and Form Designer to identify object, invisible at runtime.

Form, Page, Container, Control

Picture is tiled to form wallpaper.

Image

Picture is displayed in control.

The pictures for lists and combos can only be specified at runtime and are reset whenever the list or combo’s Requery method is called. In addition, the pictures only “take” when you’re using one of the RowSourceTypes where the list or combo really owns the data—0 (None), 1 (Value), 5 (Array), or surprisingly, 8 (Structure).

Example

* Let the user assign a picture to each item in a list.
* This code might be in the Init for the list. More
* realistically, the data might have pointers to the appropriate
* picture files. The user won't appreciate having to point to
* all the pictures.
LOCAL nCnt

FOR nCnt = 1 TO This.ListCount
   This.Picture[ nCnt ] = GETPICT("BMP;ICO;GIF;JPG", ;
                                  "Choose a picture")
ENDFOR

Usage

oObject.DownPicture = cPictureFile
oObject.DisabledPicture = cPictureFile
cPictureFile = oObject.DownPicture | oObject.DisabledPicture

Check boxes and both kinds of buttons have three states: enabled but not chosen, chosen (or down), and disabled. You can assign a separate bitmap for each state. Picture is the enabled, but not chosen, bitmap. DownPicture is used when the control is chosen. DisabledPicture appears on a disabled control.

Usually, you’ll choose similar but slightly different pictures for the three. DisabledPicture may be a gray version of Picture. DownPicture might indicate the result of the choice. For example, if Picture shows a book, DownPicture could be an open book.

Example

* Set up a graphical check box.
This.Style = 1
This.Picture = HOME(4)+"BITMAPS\OUTLINE\CLOSED.BMP"
This.DownPicture = HOME(4)+"BITMAPS\OUTLINE\OPEN.BMP"

See Also

Icon, ListIndex, Style