'以下在.bas
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
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 Const WM_CTLCOLORLISTBOX = &H134
Public Const GWL_WNDPROC = (-4)
Public preWinProc As Long
Private hwndList As Long
Private EverChange As Boolean
Public AddOnWidth As Long
Public Function wndproc(ByVal hwnd As Long, ByVal Msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
'以下程式会设定ListBox的大小,再将之送往原来的Window Procedure
If Msg = WM_CTLCOLORLISTBOX Then
'请处理Mouse Move的动作
If Not EverChange Then
Dim rect5 As RECT
hwndList = lParam '当收到WM_CTLCOLORLISTBOX时,lParam是ListBox的hwmd
EverChange = True
Call GetWindowRect(hwndList, rect5)
x = rect5.Left
y = rect5.Top
dx = rect5.Right - rect5.Left + AddonWidth
dy = rect5.Bottom - rect5.Top
Call MoveWindow(hwndList, x, y, dx, dy, 1)
End If
End If
'将之送往原来的Window Procedure
wndproc = CallWindowProc(preWinProc, hwnd, Msg, wParam, lParam)
End Function
|