[RESOLVED] ComboBox dropdown scrollbar height
Hi there,
I have some issue with the ComboBox Scrollbar height after adding items to it, instead of max. 8 items, it shows me almost all with a long vertical scrollbar.
Here is the sample code:
Code:
Dim itCnt As Integer
For itCnt = 0 To 59
cboMin.AddItem Format(itCnt, "00")
Next itCnt
In the IDE, while running the code is working as it should, but after compiling the code, the vertical scrollbar height increases to 30 items.
p.s. I'm using "mainfest" from the Resource file.
How could I fix this issue?
Thank you for suggestions! ;)
Re: ComboBox dropdown scrollbar height
Since you are using a manifest for visual-styles, if you want to turn it off for a specific control, do it like this:
Code:
Private Declare Function SetWindowTheme Lib "uxtheme.dll" (ByVal hwnd As Long, ByVal pszSubAppName As Long, ByVal pszSubIdList As Long) As Long
Private Sub Form_Load()
Call SetWindowTheme(cboMin.hwnd, 0, StrPtr(""))
End Sub
Re: ComboBox dropdown scrollbar height
Quote:
Originally Posted by
Dry Bone
Since you are using a manifest for visual-styles, if you want to turn it off for a specific control, do it like this:
Code:
Private Declare Function SetWindowTheme Lib "uxtheme.dll" (ByVal hwnd As Long, ByVal pszSubAppName As Long, ByVal pszSubIdList As Long) As Long
Private Sub Form_Load()
Call SetWindowTheme(cboMin.hwnd, 0, StrPtr(""))
End Sub
Thanks Bone for the suggestion, but, yes, it will remove the visual style, but the height of the dropdown is still the same (showing all items), even worse, because now there is no scrollbar in it.
Re: ComboBox dropdown scrollbar height
Well well well. This was a tough one.
But the answer is oh so simple.
You definitely DON'T need to remove the visual style.
Instead, use CB_SETMINVISIBLE message to set the desired number of items you want the user see.
This message works only with visual styles.
Code:
Private Const CB_SETMINVISIBLE = &H1701&
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
SendMessage cboMin.hWnd, CB_SETMINVISIBLE, 8, 0
Re: ComboBox dropdown scrollbar height
Quote:
Originally Posted by
Dry Bone
Well well well. This was a tough one.
But the answer is oh so simple.
You definitely DON'T need to remove the visual style.
Instead, use CB_SETMINVISIBLE message to set the desired number of items you want the user see.
This message works
only with visual styles.
Code:
Private Const CB_SETMINVISIBLE = &H1701&
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
SendMessage cboMin.hWnd, CB_SETMINVISIBLE, 8, 0
Oh, somehow it worked! ;)
Thanks alot!