pafal
December 14th, 1999, 09:03 AM
A combobox, type 2-Dropdown-list, automatically invokes a vertical scrollbar when the number of listitems exceeds 8. Is there a way to prohibit this behaviour forcing it to show the entire list or a number of my choice?
Regards
Patrik
Aaron Young
December 14th, 1999, 01:39 PM
You can increase the size of the Drop Down List using the SetWindowPos API, eg.
private Type RECT
Left as Long
Top as Long
Right as Long
Bottom as Long
End Type
private Declare Function GetWindowRect Lib "user32" (byval hwnd as Long, lpRect as RECT) as Long
private Declare Function SetWindowPos Lib "user32" (byval hwnd as Long, byval hWndInsertAfter as Long, byval x as Long, byval y as Long, byval cx as Long, byval cy as Long, byval wFlags as Long) as Long
private Const SWP_FRAMECHANGED = &H20
private Const SWP_NOMOVE = &H2
private Const SWP_NOZORDER = &H4
private Sub SetComboDropSize(byval lHwnd as Long, byval lHeight as Long)
Dim tRECT as RECT
Call GetWindowRect(lHwnd, tRECT)
SetWindowPos lHwnd, 0, 0, 0, tRECT.Right - tRECT.Left, lHeight, SWP_NOMOVE Or SWP_NOZORDER Or SWP_FRAMECHANGED
End Sub
private Sub Form_Load()
'set Drop Height to display 16 Items..
Call SetComboDropSize(Combo1.hwnd, 240)
for i = 1 to 16
Combo1.AddItem "Item" & i
next
End Sub
Aaron Young
Analyst Programmer
adyoung@win.bright.net
aarony@redwingsoftware.com
pafal
December 15th, 1999, 02:59 AM
Bullseye!
Thanks a lot Aaron. May Santa reward you generously.
Regards
Patrik Fällman, Luleå, Sweden