|
-
Mar 4th, 2024, 02:16 AM
#1
Thread Starter
Addicted Member
[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!
-
Mar 4th, 2024, 01:19 PM
#2
Hyperactive Member
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
Last edited by Dry Bone; Mar 4th, 2024 at 01:26 PM.
-
Mar 4th, 2024, 05:00 PM
#3
Thread Starter
Addicted Member
Re: ComboBox dropdown scrollbar height
 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.
-
Mar 4th, 2024, 06:58 PM
#4
Hyperactive Member
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
-
Mar 5th, 2024, 08:51 AM
#5
Thread Starter
Addicted Member
Re: ComboBox dropdown scrollbar height
 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!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|