Returns or sets the index value of an icon or small icon associated with a ListItem object in an ImageList control.
Returns or sets the icon for a Form's title bar or a TrayIcon's taskbar icon.
Listitem.Icon [= index%]
ListItem.SmallIcon [= index%]
Form.Icon [= pic]
TrayIcon.Icon [= pic]
Form.SmallIcon [= pic]
ListItem:ListItem Object
Form:Form Object
index:iexp or sexp
pic:Picture Object
For a ListItem object index specifies an integer that identifies an icon or small icon in an associated ImageList control. An ImageList control is associated by setting the ListView's Icons or SmallIcons property.
For a Form the Icon is 32x32 pixel bitmap and SmallIcon a 16x16 bitmap. The small icon is displayed in the title bar of the Form and the large icon when <Alt-Tab> is pressed. Only one needs to be set. See LoadPicture on how to load an icon file. Icon and SmallIcon can be set at design time, as well at run time.
For the TrayIcon property Icon the picture must be an ICO-picture. The taskbar supports 16x16 icons only. When the Icon property is assigned a picture at design time a 32x32 icon is loaded. The icon is then shrinked when placed in the taskbar. It is advised to load a 16x16 icon in code using:
Set tic1.Icon = LoadPicture(":ticSym", 16, 16, 16)
// Pre-save required icon
Dim p As Picture
Set p = CreatePicture(LoadIcon(Null, IDI_APPLICATION), False)
SavePicture p, App.Path & "\app.ico"
// The example
OpenW 1
Print "Press any key to change the Window icon"
While InKey = "" : Wend
Cls
Set p = Win_1.Icon
Win_1.Icon = LoadPicture(App.Path & "\app.ico")
Print "Press any key to change it back"
While InKey <> "" : Wend : While InKey = "" : Wend
Cls
Win_1.SmallIcon = p
Print "Please close window to end example"
Do : Sleep : Until Win_1 Is Nothing
Form, ListItem, LoadPicture, TrayIcon
{Created by Sjouke Hamstra; Last updated: 10/10/2014 by James Gaite}