Compartir a través de


Picture Property (Visual FoxPro)

Specifies an image to display on a control or object. Available at design time and run time.

Note

At design time, if you set the Picture property to a file that does not exist, Visual FoxPro displays the appropriate message, but the property remains set to the file specified. At run time, if the Picture property is set to a file that does not exist, Visual FoxPro disregards the Picture property.

Control.Picture [ = cFileName ]
-Or
Control.Picture(nIndex) [ = cFileName ]

Parameters

  • cFileName
    Specifies the name of a graphics file.

    Note

    Visual FoxPro supports all graphics file formats handled by Graphics Device Interface+ (GDI+). Visual FoxPro supports animated .gif files for the Picture property only on an Image control. For more information about valid graphics file formats, see Graphics Support in Visual FoxPro.

  • nIndex
    Specifies an integer corresponding to the order in which items are displayed in the control. For the first item in a control, nIndex = 1.

Remarks

Applies To: CheckBox Control | CommandButton Control | ComboBox Control | Container Object | Control Object | Custom Object | Form Object | Header Object | Image Control | ListBox Control | OptionButton Control | Page Object | _SCREEN System Variable |

On controls, images appear centered. On forms, the image displays as a background for a form. If the RowSourceType property is set to 7 (Files), pictures are not supported.

For CommandButton and OptionButton controls, the specified image is used whether a button is available, selected, or unavailable. You can specify a different image for each button state by setting the DownPicture and DisabledPicture properties.

For CommandButton, CheckBox, and OptionButton controls, you must set the Style property for the corresponding control. The following table lists the values you must set for the Style property for the corresponding control.

Control

Style property

CommandButton

0 (Standard)

CheckBox, OptionButton

1 (Graphical)

For Header objects, if the header does not contain a caption, the image appears in the center of the header. If the header contains a caption, the Header Alignment property determines how the image aligns with caption text. If Header Alignment is set to left or center, the image appears to the right of the caption. If Alignment is set to right, the image appears to the left of the caption.

For ToolBar objects, the recommended image dimensions are 16 x 15 pixels (width x height).

For ComboBox and ListBox controls, you can use the Picture property as single-value property or as an array. If you use Picture as a single-value property, all items in the control show the same image. If you use Picture as an array, which stores an image for each item in the list, each item can have a different image. For example:

oCombobox.AddItem("Home")
oCombobox.AddItem("Community")
oCombobox.AddItem("Web Services")
oCombobox.Picture[1] = 'home.bmp'
oCombobox.Picture[2] = 'community.bmp'
oCombobox.Picture[3] = 'websvc.bmp'

For Image, CheckBox, and CommandButton controls, the Picture property respects the transparency of the image.

Note

For high resolution Transparent GIF images, the transparency aspect of the image is only supported for the Image control. Because Visual FoxPro stores only one instance of that image as a resource for use internally, it is possible to use this image on another control such as a CommandButton and have it retain transparency. To do this, you first need to load the image into an Image control and persist that control (maybe hidden). Once the image has been loaded as a resource by the Image control, it can then be used by the CommandButton.

See Also

Tasks

How to: Add Pictures to Items in a List

Reference

DisabledPicture Property

DownPicture Property

PictureVal Property

Style Property

Other Resources

Properties (Visual FoxPro)