Make your own free website on Tripod.com

Quick Select/UnSelect All Items In List Box

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Add 1 List Box and 2 Command Buttons to your form.
'Set List1 MultiSelect property to 1-Simple.
'Insert the following code to your module:

Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const LB_SETSEL = &H185&

'Insert the following code to your form:

Private Sub Command1_Click()
Call SendMessageLong(List1.hwnd, LB_SETSEL, True, -1)
End Sub

Private Sub Command2_Click()
Call SendMessageLong(List1.hwnd, LB_SETSEL, False, -1)
End Sub

Sub Form_Load()
'add this code to the form load to fill
'List1 with some (15) of the system's
'screen fonts.
Dim i As Integer
Dim max As Integer
max = Screen.FontCount
If max > 15 Then max = 15
For i = 1 To max
List1.AddItem Screen.Fonts(i)
Next
End Sub

Go Back