Picture Property

See AlsoVEI4HS                 Example 1116DQZ1>Low              Example 2116DQZ2>Low

Applies To

Form14TJ2LN, image9A4FCA, OLE control2HQDVVU, picture box31MYIWX.

Description

Determines a graphic to be displayed in a control.  For OLE control: not available at design time and read-only at run time.

Usage

[form.][image. | ole. | picturebox.]Picture[ = picture ]

Setting

The Picture property settings are:

Setting                          Description

 

(none)                           (Default) No picture.

(Bitmap, icon, metafile)  Specifies a graphic.  You can load the graphic from the Properties window at design time.  At run time, you can also set this property using the LoadPicture1F02FRP function on a bitmap1MF6V4R, icon529QBG, or metafile13MILUI.

 

Remarks

At design time, you can transfer a graphic with the ClipboardW4LZLB using the Copy, Cut, and Paste commands on the Edit menu.  At run time, you can use Clipboard methods such as GetDataZIOQ42, SetData3EBYPZ, and GetFormatNGJXI2 with the non-text Clipboard formats CF_BITMAP, CF_METAFILE, and CF_DIB, as defined in CONSTANT.TXT, a Visual Basic file that specifies system defaults.

When setting the Picture property at design time, the graphic is saved and loaded with the form.  If you create an executable file, the file contains the image.  When you load a graphic at run time, the graphic is not saved with the application.  Use the SavePicture2U07NJP statement to save a graphic from a form or picture box into a file.

 

Note At run time, the Picture property can be set to any other object's DragIcon3G3M07O, Icon2S1DMPP, Image6AEZWAR, or Picture property, or you can assign it the graphic returned by the LoadPicture function.

 

Data Type

IntegerDOKXHY


See Also

Help:

AutoRedraw Property1UY7ZM3

Icon Property2S1DMPP

LoadPicture Function1F02FRP

SavePicture Statement2U07NJP

 

Programmer's Guide:

Chapter 15, "Creating Graphics for Applications"


Picture Property Example 1

The example loads icons from the Visual Basic Icon Library1NQWYI into two of three picture boxes.  When you click the form, the third picture box is used to switch the bitmaps.  You can use any two icons.  Paste the code into the Declarations section of a form that has three small picture boxes (for Picture3, set Visible = False).  Press F5 to run the program and then click the form.

Sub Form_Load ()
  ' Load the bitmaps.
  Picture1.Picture = LoadPicture("icons\computer\trash02a.ico")
  Picture2.Picture = LoadPicture("icons\computer\trash02b.ico")
End Sub


Sub Form_Click ()
  ' Swap the bitmaps.
  Picture3.Picture = Picture1.Picture
  Picture1.Picture = Picture2.Picture
  Picture2.Picture = Picture3.Picture
  ' Set the picture to none (not necessary if not visible).
  Picture3.Picture = LoadPicture()
End Sub


Picture Property Example 2

The example pastes a bitmap from the Clipboard into a picture box. To find the value of the CF_formats, look at the CONSTANT.TXT file or load it into a module.  To try this example, paste the code into the Declarations section of a form that has a picture box.  Press F5 and then in another application, copy a picture onto the Clipboard, switch to Visual Basic, and click the form.

Sub Form_Click ()
  Const CF_BITMAP = 2
  Picture1.Picture = Clipboard.GetData(CF_BITMAP)
End Sub