Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Const GWL_STYLE = (-16) Private Const WS_HSCROLL = &H100000 Private Const WS_VSCROLL = &H200000Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long Private Const SWP_NOSIZE = &H1 Private Const SWP_NOZORDER = &H4 Private Const SWP_FRAMECHANGED = &H20 ' The frame changed: send WM_NCCALCSIZE Private Const SWP_NOMOVE = &H2 Private Sub ModifyStyle() Dim lStyle As Long lStyle = GetWindowLong(File1.hwnd, GWL_STYLE) ' 垂直 水平 需要谁加谁 SetWindowLong File1.hwnd, GWL_STYLE, lStyle Or WS_HSCROLL Or WS_VSCROLL SetWindowPos File1.hwnd, 0&, 0&, 0&, 0&, 0&, SWP_NOSIZE Or SWP_NOZORDER Or SWP_FRAMECHANGED Or SWP_NOMOVE End SubPrivate Sub Form_Load() ModifyStyle End Sub
'Put into a module Public Const LB_SETHORIZONTALEXTENT = &H194 Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongE.g., SendMessage yourListBox.hwnd, LB_SETHORIZONTALEXTENT, 800, 0 '800 is the new width
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_HSCROLL = &H100000
Private Const WS_VSCROLL = &H200000Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_FRAMECHANGED = &H20 ' The frame changed: send WM_NCCALCSIZE
Private Const SWP_NOMOVE = &H2
Private Sub ModifyStyle()
Dim lStyle As Long
lStyle = GetWindowLong(File1.hwnd, GWL_STYLE)
' 垂直 水平 需要谁加谁
SetWindowLong File1.hwnd, GWL_STYLE, lStyle Or WS_HSCROLL Or WS_VSCROLL
SetWindowPos File1.hwnd, 0&, 0&, 0&, 0&, 0&, SWP_NOSIZE Or SWP_NOZORDER Or SWP_FRAMECHANGED Or SWP_NOMOVE
End SubPrivate Sub Form_Load()
ModifyStyle
End Sub
Public Const LB_SETHORIZONTALEXTENT = &H194
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongE.g.,
SendMessage yourListBox.hwnd, LB_SETHORIZONTALEXTENT, 800, 0
'800 is the new width