聲明:
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (
ByVal hwnd As Long, ByVal Msg As Long,
ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const CB_GETDROPPEDWIDTH = &H15F
Private Const CB_SETDROPPEDWIDTH = &H160
Private Const CB_ERR = -1
函數(shù):
’ 取得 Combo 下拉的寬度
’ 可以利用該函數(shù)比例放大或縮小寬度
Public Function GetDropdownWidth(cboHwnd As Long) As Long
Dim lRetVal As Long
lRetVal = SendMessage(cboHwnd, CB_GETDROPPEDWIDTH, 0, 0)
If lRetVal <> CB_ERR Then
GetDropdownWidth = lRetVal
’單位為 pixels
Else
GetDropdownWidth = 0
End If
End Function
’設(shè)置 Combo 下拉的寬度
’單位為 pixels
Public Function SetDropdownWidth(cboHwnd As Long, NewWidthPixel As Long)
As Boolean
Dim lRetVal As Long
lRetVal = SendMessage(cboHwnd, CB_SETDROPPEDWIDTH, NewWidthPixel, 0)
If lRetVal <> CB_ERR Then
SetDropdownWidth = True
Else
SetDropdownWidth = False
End If
End Function
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (
ByVal hwnd As Long, ByVal Msg As Long,
ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const CB_GETDROPPEDWIDTH = &H15F
Private Const CB_SETDROPPEDWIDTH = &H160
Private Const CB_ERR = -1
函數(shù):
’ 取得 Combo 下拉的寬度
’ 可以利用該函數(shù)比例放大或縮小寬度
Public Function GetDropdownWidth(cboHwnd As Long) As Long
Dim lRetVal As Long
lRetVal = SendMessage(cboHwnd, CB_GETDROPPEDWIDTH, 0, 0)
If lRetVal <> CB_ERR Then
GetDropdownWidth = lRetVal
’單位為 pixels
Else
GetDropdownWidth = 0
End If
End Function
’設(shè)置 Combo 下拉的寬度
’單位為 pixels
Public Function SetDropdownWidth(cboHwnd As Long, NewWidthPixel As Long)
As Boolean
Dim lRetVal As Long
lRetVal = SendMessage(cboHwnd, CB_SETDROPPEDWIDTH, NewWidthPixel, 0)
If lRetVal <> CB_ERR Then
SetDropdownWidth = True
Else
SetDropdownWidth = False
End If
End Function