1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| '
Public Sub refresh()
Set pItems = New Collection
If Not (className = "ListBox" Or className = "ComboBox") Then GoTo ERROR_HANDLE
'loops through items
Dim index As Integer: For index = 0 To count - 1
Dim strBuffer As String: strBuffer = VBA.Space$(1024)
#If VBA7 Then
Dim strLength As LongPtr
Dim lRet As LongPtr
#Else
Dim strLength As Long
Dim lRet As Long
#End If
Select Case className
Case "ListBox":
strLength = API.SendMessage(hwnd:=pHwnd, wMsg:=API.LB_GETTEXTLEN, wParam:=index, lParam:=0&)
lRet = API.SendMessage(hwnd:=pHwnd, wMsg:=API.LB_GETTEXT, wParam:=index, lParam:=ByVal strBuffer)
Case "ComboBox":
strLength = API.SendMessage(hwnd:=pHwnd, wMsg:=API.CB_GETLBTEXTLEN, wParam:=index, lParam:=0&)
lRet = API.SendMessage(hwnd:=pHwnd, wMsg:=API.CB_GETLBTEXT, wParam:=index, lParam:=ByVal strBuffer)
End Select
pItems.add item:=VBA.left$(strBuffer, VBA.CLng(strLength))
Next index
Exit Sub
ERROR_HANDLE:
End Sub |
Partager