darbid73
asked on
Help with WinAPI Signatures in VB.NET for SetWindowSubclass
I am having trouble setting up the signatures to subclass a window in VB.NET
Then how do I call the SetWindowSubclass - in particular how do I pass in the dwRefData as the last parameter?
Finally my callback looks like this
I normally use pinvoke.net but it does not seem to have these.
<DllImport("comctl32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Shared Function SetWindowSubclass(ByVal hWnd As IntPtr, ByVal pfnSubclass As WndProcDelegate, ByVal uIdSubclass As IntPtr, ByVal dwRefData As IntPtr) As IntPtr
End Function
<DllImport("comctl32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Shared Function GetWindowSubclass(ByVal hWnd As IntPtr, ByVal pfnSubclass As IntPtr, ByVal uIdSubclass As IntPtr, _
pdwRefData As IntPtr) As IntPtr
End Function
<DllImport("comctl32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Shared Function RemoveWindowSubclass(ByVal hWnd As IntPtr, ByVal pfnSubclass As WndProcDelegate, ByVal uIdSubclass As IntPtr) As IntPtr
End Function
<DllImport("comctl32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Shared Function DefSubclassProc(ByVal hWnd As IntPtr, ByVal uMsg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function
Public Delegate Function WndProcDelegate(ByVal hWnd As IntPtr, ByVal msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr, ByVal dwRefData As IntPtr) As IntPtr
Then how do I call the SetWindowSubclass - in particular how do I pass in the dwRefData as the last parameter?
SetWindowSubclass(aHwnd, AddressOf WndProc, New IntPtr(10), "WHAT GOES HERE")
Finally my callback looks like this
Public Function WndProc(ByVal hWnd As IntPtr, ByVal msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr, ByVal dwRefData As IntPtr) As IntPtr
Select Case msg
Case WM_NCDESTROY
Diagnostics.Debug.Print("######")
StopListener(hWnd)
End Select
'Diagnostics.Debug.Print(msg.ToString)
WndProc = NativeMethods.DefSubclassProc(hWnd, msg, wParam, lParam)
End Function
I normally use pinvoke.net but it does not seem to have these.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER