Icon Property

See Also5UWI06T                 ExampleHRDY89>Low

Applies To

Form14TJ2LN, MDI form1ILMZQ7.


Determines the icon529QBG displayed for a form at run time when the form is minimized.




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 icon13Z8KW6 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 Library1NQWYI (in the ICONS subdirectory) as a source for icons.  When you create an executable fileSFUXPY, 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 BorderStyle43RNRL property must be set to either 1 (Fixed Single) or 2 (Sizable).  The MinButton1B9HLHD property must be set to True.

At run time, you can assign an object's Icon property to another object's DragIcon3G3M07O or Icon property.  You can also assign an icon returned by the LoadPicture1F02FRP 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


See Also


Assigning an Icon to a Form42XO904

LoadPicture Function1F02FRP


Programmer's Guide:

Chapter 15, "Creating Graphics for Applications"

Appendix B, "Icon Library"

Icon Property Example

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.
  End If
End Sub