|
-
Jul 29th, 2017, 03:21 PM
#1
Thread Starter
PowerPoster
"AddressOf" workaround for VB4
Hey team,
I am working on a VB4 (yes 4) legacy project, and I'm trying to use the SetWindowLong API, which takes an "AddressOf WinProc" as a parameter. The code I am trying to implement assumes one is using VB6 (or at least 5). For VB4, AddressOf is a no-go. I attempted to get an answer via Googling, to no avail. The closest I came was a post on the "Xtreme VB Talk" forum, where it looked like there was a promising download, however they only let you download if you are registered, and the registration/activation email has not been forthcoming for hours.
Anyway, following is the the code I am trying to implement with the offending line in bold:
Code:
Public Declare Function SetWindowLong& Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
Public 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
Public Const GWL_WNDPROC = (-4)
Public WinProcOld As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Public Function WinProc(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If wMsg = WM_NCLBUTTONDOWN Then
Form1.label1.Caption = "mouse down"
End If
WinProc = CallWindowProc(WinProcOld&, hWnd&, wMsg&, wParam&, lParam&)
End Function
Sub SubClassWnd(hWnd As Long)
WinProcOld& = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WinProc)
End Sub
Sub UnSubclassWnd(hWnd As Long)
SetWindowLong hWnd, GWL_WNDPROC, WinProcOld&
WinProcOld& = 0
End Sub
Any help to get over this hurdle would be greatly appreciated ...
"It's cold gin time again ..."
Check out my website here.
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
|
Click Here to Expand Forum to Full Width
|