Library code snippets
Set the Combo Drop height and width
You can set the drop down height and width by sending a message, and using the MoveWindow Windows API function. Use the following code to set its height and width:
' Declare functions
' Move Window is for SetDropHeight
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
' SendMessage is for Set Drop Width
Private Declare Function SendMessageLong Lib "user32" Alias
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal
wParam As Long, ByVal lParam As Long) As Long
' Constant for SetDropWidth
Private Const CB_SETDROPPEDWIDTH = &H160
' SetDropWidth
Private Sub SetDropWidth(lngWidth As Long)
Dim lRet As Long
lRet = SendMessageLong(Combo1.hwnd, CB_SETDROPPEDWIDTH,
lngWidth, 0)
End Sub
' SetDropHeight
Private Sub SetDropHeight(lngHeight As Long)
Dim lRet As Long
Dim iScaleMode As Integer
iScaleMode = Combo1.Parent.ScaleMode
Combo1.Parent.ScaleMode = vbPixels
lRet = MoveWindow(Combo1.hwnd, Combo1.Left, Combo1.Top,
Combo1.Width, lngHeight, 1)
Combo1.Parent.ScaleMode = iScaleMode
End Sub
Related articles
Related discussion
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
-
Can you describe Above simple VB6 code?
by pramodmca09 (0 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
I have a tab on it a frame and on this several comboboxes.
How do I change the code so I can manipulate the height of each combobox?
The code works with only combo1.
'************************************************************************
Private Sub Form_Load()
Dim i%
For i = 1 To 10
Combo1.AddItem "This is the entry number " & Trim$(i)
Next
Option1(0) = 1
' SubClass ComboBox.hwnd, BOOL, Width, Height, Alignment
' Width and Height values in Pixel
' Alignment: 0 = left, 1 = right, 2 = centered
'SubClass Combo1.hwnd, True, 145, 0, 0 '# don't change height
SubClass Combo1.hwnd, True, 145, -1, 0 '# adapt height to the entry number
'SubClass Combo1.hwnd, True, 145, 200, 0 '# change height
End Sub
'************************************************************************
Private Sub Form_Unload(Cancel As Integer)
'# Optional, but recommended
SubClass Combo1.hwnd, False
End Sub
'************************************************************************
'# for demo purposes
Private Sub Option1_Click(Index As Integer)
Call SetAlignment(Index)
End Sub
'************************************************************************
Thanks a lot!
if anyone interested found a much better solution...
on following the following site...
http://artima1.inetu.net/pipermail/software-keyholes/2003-July/000063.html
If you are looking 4 the answer to your question how to change drop down height in a frame then follow the link below... And download vb example... Works in a frame and in on tabs...
A complete site for windows API Calls...
Combo API Example
http://www.mentalis.org/vbexamples/vbexample.php?vbexample=COMBO&category=SOURCE
If the combo box belongs to some frame control, how to change the height?
This thread is for discussions of Set the Combo Drop height and width.