This is an example that shows you how to select all of the list items in a listbox. How to Select All Item on Listbox on VB6. This code should work for any listbox window. Just make sure the listbox's multiselect property is set to "1 - Simple" in the properties window. Put something like this in your Module:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function SendMessageLong& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Public Const LB_GETCOUNT = &H18B
Public Const LB_SETSEL = &H185
Then put something like this in a button:
Dim listItems As Long
listItems = SendMessage(List1.hwnd, LB_GETCOUNT, 0&, vbNullString) - 1
Call SendMessageLong(List1.hwnd, LB_SETSEL, listItems, True)
0 comments:
Posting Komentar