MouseIcon Property Example

This example illustrates how the MouseIcon property sets a custom mouse icon. To try the example, create a ListBox control on a form, and then set the MultiSelect property to 1 or 2. At run time, select one or more items. Different icons will appear, depending on whether you selected a single item or multiple items.

Private Sub Form_Load ()
   ' Put some items in the ListBox.
   List1.AddItem "Selection 1"
   List1.AddItem "Selection 2"
   List1.AddItem "Selection 3"
   List1.AddItem "Selection 4"
   List1.AddItem "Selection 5"
End Sub

Private Sub List1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
   ' Set the custom mouse icon for multiple items.
   If List1.SelCount > 1 Then
      List1.MouseIcon = LoadPicture("ICONS\COMPUTER\MOUSE04.ICO")
      List1.MousePointer = 99
   Else   ' Set the custom mouse icon for a single item.
      List1.MouseIcon = LoadPicture("ICONS\COMPUTER\MOUSE02.ICO")
      List1.MousePointer = 99
   End If
End Sub