|
-
Can someone explain what is happening with this code...
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks