The Picture Property
The most important property of both the image control
and picture box control is the Picture
property. This property returns or sets a graphic
to be displayed. At design time, you can double click
the Properties window's Picture property to display
File Open dialog box and select a graphics file that
has one of the required filename extensions.
You can use the LoadPicture()
internal function to load a graphic at runtime.
LoadPicture([filename], [size], [colordepth],[x,y])
The first argument specifies the graphics file name.
If no filename is specified LoadPicture()
clears the Image or Picture box control. The size
arguments specifies the image's size for icons and
cursors. The setting for size
are:
Value |
Constant |
Description |
0 |
vbLPSmall |
System small
icon. |
1 |
vbLPLarge |
System large
icon size, as determined by the video driver. |
2 |
vbLPSmallShell |
Shell small
icon size, as determined by the Caption Buttons
size setting on the Appearance tab in the Control
Panel Display Properties dialog box. |
3 |
vbLPLargeShell |
Shell large icon
size, as determined by the Icon size setting
on the Appearance tab in the Control Panel Display
Properties dialog box. |
4 |
vbLPCustom |
Custom size,
values provided by x and y arguments |
The following table lists the settings for the colordepth
argument:
Value |
Constant |
Description |
0 |
vbLPDefault |
Best available
match if the specified file is used. |
1 |
vbLPMonochrome |
2 colors |
2 |
vbLPVGAColor |
16 colors |
3 |
vbLPColor |
256 colors |
The x, y values are required if you use either the
vbLPSmallShell or vbLPLargeShell shell.
The following code segment shows how to use the LoadPicture()
function:
picViewer. Picture = LoadPicture("c:\Photos\Hello.jpg")
|