Can someone explain what these API function are doing, and basically what
the flow of this is. I'm not really familiar with Subclassing...


This is the form1 code:
Private Sub Form_Load()
With Combo1
.AddItem "A"
.AddItem "B"
.AddItem "C"
End With

Call SubClass(Form1.Combo1.hWnd)
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call UnSubClass(Form1.Combo1.hWnd)
End Sub

This is the .bas module code:
Private lpfnOld 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 Declare Function CallWindowProc Lib "user32" _
Alias "CallWindowProcA" _
(ByVal lpPrevWndFunc As Long, _
ByVal hWnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Public Const GWL_WNDPROC = (-4)
Public Const MOUSE_MOVE = &H134

Public Function SubClass(hWnd As Long) As Boolean
lpfnOld = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WndProc)
End Function

Public Function UnSubClass(hWnd As Long) As Boolean
UnSubClass = SetWindowLong(hWnd, GWL_WNDPROC, lpfnOld)
End Function

Public Function WndProc(ByVal hWnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

Select Case uMsg
Case MOUSE_MOVE
Form1.Label1 = Form1.Combo1.List(Form1.Combo1.ListIndex)
End Select

WndProc = CallWindowProc(lpfnOld, hWnd, uMsg, wParam, lParam)
End Function

Thanks!