See Also Example
Applies To
Form, MDI form
Description
Determines the icon
Usage
[form.]Icon
Remarks
Use this property to specify a custom icon for any form that the user can minimize at run time. For example, you can assign a unique icon to a form to indicate the form's function. Specify the icon by loading it using the Properties window at design time. The file you load must have the .ICO file-name extension and format. If you don't specify a custom icon, the Visual Basic default icon for forms will be used.
You can use Visual Basic's Icon Library When you create an executable file , you can assign an icon to the application by using the Icon property of any form in that application.
Note To see a form's icon, the form must be minimized. The BorderStyle property must be set to either 1 (Fixed Single) or 2 (Sizable). The MinButton property must be set to True.
At run time, you can assign an object's Icon property to another object's DragIcon You can also assign an icon returned by the LoadPicture function. Using LoadPicture with no argument assigns an empty (null) icon to the form, which enables you to draw on the icon at run time.
Data Type
Integer
Help:
Assigning an Icon to a Form
LoadPicture Function
Programmer's Guide:
Chapter 15, "Creating Graphics for Applications"
Appendix B, "Icon Library"
The example creates a blank icon for a form and draws colored dots on the icon as long as the form is minimized. To try this example, paste the code into the Declarations section of a form. Then press F5 and minimize the form.
Sub Form_Resize ()
Dim X, Y ' Declare variables.
If Form1.WindowState = 1 Then
Form1.Icon = LoadPicture() ' Load a blank icon.
Do While Form1.WindowState = 1 ' While form is minimized.
Form1.DrawWidth = 10 ' Set size of dot.
' Choose random color for dot
Form1.ForeColor = QBColor(Int(Rnd * 15))
' Set random location on icon
X = Form1.Width * Rnd
Y = Form1.Height * Rnd
PSet (X, Y) ' Draw dot on icon.
DoEvents ' Allow other events.
Loop
End If
End Sub