DelMultiSelect




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&
'_________________________________________________________


'add this code to the form load to fill a list with

'some (15) of the system's screen fonts.

Sub Form_Load()
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
'_________________________________________________________


Private Sub cmdClear_Click()
Dim r As Long
r = SendMessageLong(List1.hwnd, LB_SETSEL, False, -1)
End Sub
'_________________________________________________________


Private Sub cmdSelAll_Click()
Dim r As Long
r = SendMessageLong(List1.hwnd, LB_SETSEL, True, -1)
End Sub
'_________________________________________________________


'Comments

'When lParam equals -1, setting wParam to False deselects all selections,

'and setting to True selects all entries. Setting lParam to any other number

'selects or deselects the index specified, as per the wParam setting. This

'message can also be applied against a standard FileList box.

Ever wanted a one-line API to select or deselect all itemx in
a listbox?. Add a listbox and two command buttons to a form,
and set the listbox multiselect property to either Simple or
Extended. Run the app, and select several items. Click the
cmdClear to remove the selections, or cmdSelAll to select all.
Place the following API declare code into the general
declarations area of a bas module:










( delmultiselect.html )- by Paolo Puglisi - Modifica del 17/12/2023