I was able to add a scroll bar to a combobox but the problem being that that scroll bar remebers its position next time it is dropped down hwo would you reset the position of the scroll bar ??
Printable View
I was able to add a scroll bar to a combobox but the problem being that that scroll bar remebers its position next time it is dropped down hwo would you reset the position of the scroll bar ??
What code did you use to add the scroll bar?
A combination of 3 apis
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lparam As Any) As Long
Private Declare Function ShowScrollBar Lib "user32" (ByVal hwnd As Long, ByVal wBar As Long, ByVal bShow As Long) As Long
Private Declare Function GetComboBoxInfo Lib "user32.dll" (ByVal hwndCombo As Long, CBInfo As COMBOBOXINFO) As Long
Private Const SB_BOTH = 3
Private Const SB_HORZ = 0
Private Const SB_VERT = 1
Private Const SB_CTL = 2
Private Const CB_SETHORIZONTALEXTENT = &H15E
Private Const CB_GETHORIZONTALEXTENT = &H15D
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type COMBOBOXINFO
lSize As Long
rcItem As RECT
rcButton As RECT
lButton As Long
lHwndCombo As Long
lHwndEdit As Long
lHwndList As Long
End Type
Dim lHList As Long
Private Sub cboTest2_DropDown()
Dim lDropdownWidth As Long
lHList = GetComboListHandle(cboTest2)
ShowScrollBar lHList, SB_HORZ, 1
SendMessage cboTest2.hwnd, CB_SETHORIZONTALEXTENT, 400, ByVal 0
End Sub
Private Function GetComboListHandle(ctl As ComboBox) As Long
Dim CBI As COMBOBOXINFO
CBI.lSize = Len(CBI)
Call GetComboBoxInfo(ctl.hwnd, CBI)
GetComboListHandle = CBI.lHwndList
End Function