程序代码:
Option Explicit 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 Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Const CB_GETITEMHEIGHT = &H154 Private Sub Combo1_GotFocus() SetComboHeight Combo1, 50 End Sub Private Sub Form_Load() Dim i& For i = 0 To 333 Combo1.AddItem i Next End Sub Private Sub SetComboHeight(cboNegPressureList As ComboBox, ByVal nListCount As Long) Dim ListHeight As Long With cboNegPressureList ListHeight = SendMessage(.hWnd, CB_GETITEMHEIGHT, 0,byval 0&) MoveWindow .hWnd, Me.ScaleX(.Left, Me.ScaleMode, vbPixels), Me.ScaleY(.Top, Me.ScaleMode, vbPixels), Me.ScaleX(.Width, Me.ScaleMode, vbPixels), ListHeight * nListCount, 1 End With End Sub