Naja, mit Sicherheit kann ich natürlich nicht sagen, ob es auch einfacher geht.
Ich habe vorher versucht, eine Funktion zu schreiben, die das Handle der internen Listbox abfragt und dieses dann mittels API MoveWindow verschiebt. Das hat auch funktioniert, allerdings wusste ich nicht, wo ich die Funktion aufrufen sollte, denn der Aufruf aus dem DropDown-Ereignis der Combobox funktionierte nicht. Die einzige Möglichkeit ist, diese Funktion aus einem Timer heraus aufzurufen.
Ist halt nicht so schön, weil ständig ein Timer laufen muss, aber hier die Funktion:'combobox
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type COMBOBOXINFO
cbSize As Long
rcItem As RECT
rcButton As RECT
stateButton As Long
hwndCombo As Long
hwndItem As Long
hwndList As Long
End Type
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) _
As Long
Private Const CB_GETCOMBOBOXINFO As Long = &H164& 'wParam: not used; lParam:
' pointer to COMBOBOXINFO
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect _
As RECT) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x _
As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal _
bRepaint As Long) As Long
Public Function SetComboboxListLeft(hCombo As Long, lngDifference As Long) As _
Boolean
Dim cbi As COMBOBOXINFO
Dim rcList As RECT
Dim rcCombo As RECT
SetComboboxListLeft = False
cbi.cbSize = Len(cbi)
If SendMessage(hCombo, CB_GETCOMBOBOXINFO, 0&, cbi) <> 0 Then
If GetWindowRect(cbi.hwndCombo, rcCombo) <> 0 Then
If GetWindowRect(cbi.hwndList, rcList) <> 0 Then
rcList.Left = rcCombo.Left + lngDifference
If MoveWindow(cbi.hwndList, rcList.Left, rcList.Top, rcList.Right - _
rcList.Left, rcList.Bottom - rcList.Top, -1) <> 0 Then _
SetComboboxListLeft = True
End If
End If
End If
End Function mfg mst547 |