Adds a bitmap, icon, or cursor to a control.
To add a picture to |
Use |
---|---|
A PictureListBox or TreeView control |
|
A Toolbar control |
Adds a bitmap, icon, or cursor to the main image list.
PictureListBox and TreeView controls
controlname.AddPicture ( picturename )
Argument |
Description |
---|---|
controlname |
The name of the control to which you want to add an icon, cursor, or bitmap to the main image list |
picturename |
The name of the icon, cursor, or bitmap you want to add to the main image list |
Integer. Returns the picture index number if it succeeds and -1 if an error occurs.
The picture is assigned an index in the order in which it is added to the control.
Adding pictures during execution does not update the PictureName property array. Because the picture is added at the end of the list, the return value from AddPicture is the number of pictures associated with the control.
Before you add pictures, you can specify scaling for the pictures by setting the PictureWidth and PictureHeight properties. The dimensions in effect when you add the first picture determine the scaling for all pictures. Changing the property values after you add pictures has no effect.
If you do not specify values for PictureWidth and PictureHeight before you add pictures, the dimensions of the first image determine the scaling for all pictures you add.
When a you add a bitmap, specify the color in the bitmap that will be transparent by setting the PictureMaskColor property before calling AddPicture. You can change the PictureMaskColor property between calls.
This example adds a picture to a TreeView control and associates it with a new TreeView item:
long ll_tvi
integer li_picture
li_picture = &
tv_list.AddPicture("c:\apps_pb\staff.ico")
ll_tvi = tv_list.FindItem(RootTreeItem!, 0)
tv_list.InsertItemFirst(ll_tvi, "Dept.", li_picture)
Adds a picture to the array of pictures available to the Toolbar control.
Toolbar controls
Integer controlname.AddPicture ( picturename )
Argument |
Description |
---|---|
controlname |
The name of the toolbar control |
picturename |
String for the name of the picture that you want to add for use by the toolbar |
Integer. Returns 1 for success and -1 if an error occurs.
The following example adds a picture to the array of pictures available to be matched with items in the toolbar:
Integer li_rtn
li_rtn = tlbr_myToolBar.AddPicture &
("\program files\pic1.bmp")