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
-
Regarding Visual Basic Programme
by manjunathsl2007 (0 replies)
-
how do you hide all in VB6
by CapnJack (1 replies)
-
Problem with Input File
by novavb6 (3 replies)
-
How to produce a txt file with a table??
by novavb6 (1 replies)
-
VB6 compatability from XP to Vista
by bronx (1 replies)
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.