HughLerwill
Programmer
1. Vista Utimate SP1
2. Vb6 SP6
3. A pretty common routine to increase/ specify the dropped down height of a Combo box;
Public 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
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Sub ComboHeightSet(oComboBox As ComboBox, ByVal Nrows%, Optional onframe As Boolean = False)
Dim OldScaleMode%, Rowheight%
Dim lNewHeight&
Const CB_GETITEMHEIGHT = &H154
With oComboBox
' Change the ScaleMode on the parent to Pixels.
OldScaleMode = .Parent.ScaleMode
.Parent.ScaleMode = vbPixels
Rowheight = SendMessage(.hWnd, CB_GETITEMHEIGHT, 0, 0)
lNewHeight = Nrows * Rowheight + .Height + 2
' Resize the combo box window.
If Not onframe Then
MoveWindow .hWnd, .Left, .Top, .Width, lNewHeight, True
Else
'frame is always dimensioned in Twips so..
MoveWindow .hWnd, .Left / Screen.TwipsPerPixelX, .Top / Screen.TwipsPerPixelY, .Width / Screen.TwipsPerPixelX, lNewHeight, True
End If
' Replace the old ScaleMode
.Parent.ScaleMode = OldScaleMode
End With
End Sub
The above works in on previous versions of Windows and in the IDE on Vista however when running a compiled app on Vista the Combo dropdown always seems to end up with 30 rows (if it has =>30 entries) regardless of the Nrows parameter.
Can anyone else reproduce this qwirk/ suggest a fix?
2. Vb6 SP6
3. A pretty common routine to increase/ specify the dropped down height of a Combo box;
Public 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
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Sub ComboHeightSet(oComboBox As ComboBox, ByVal Nrows%, Optional onframe As Boolean = False)
Dim OldScaleMode%, Rowheight%
Dim lNewHeight&
Const CB_GETITEMHEIGHT = &H154
With oComboBox
' Change the ScaleMode on the parent to Pixels.
OldScaleMode = .Parent.ScaleMode
.Parent.ScaleMode = vbPixels
Rowheight = SendMessage(.hWnd, CB_GETITEMHEIGHT, 0, 0)
lNewHeight = Nrows * Rowheight + .Height + 2
' Resize the combo box window.
If Not onframe Then
MoveWindow .hWnd, .Left, .Top, .Width, lNewHeight, True
Else
'frame is always dimensioned in Twips so..
MoveWindow .hWnd, .Left / Screen.TwipsPerPixelX, .Top / Screen.TwipsPerPixelY, .Width / Screen.TwipsPerPixelX, lNewHeight, True
End If
' Replace the old ScaleMode
.Parent.ScaleMode = OldScaleMode
End With
End Sub
The above works in on previous versions of Windows and in the IDE on Vista however when running a compiled app on Vista the Combo dropdown always seems to end up with 30 rows (if it has =>30 entries) regardless of the Nrows parameter.
Can anyone else reproduce this qwirk/ suggest a fix?