Ya guys,
i used an old VB6 algorithm to subclass a window and made a few changes at the 'hook method' to make it work in .NET.
everything is working now, but only at certain windows. i can only subclass windows from the process where my program is located. this is what i conclude from the following helpmessage:Code:Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hWnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As delWindowProc) As Integer Private Delegate Function delWindowProc(ByVal hwnd As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Private lpPrevWndProc As Integer Public Sub New() Dim procAddress As delWindowProc = AddressOf WindowProc lpPrevWndProc = SetWindowLong(gHW, GWL_WNDPROC, procAddress) End Sub Public Function WindowProc(ByVal hwnd As Integer, ByVal uMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer If uMsg = ..... Then Return CallWindowProc(lpPrevWndProc, hwnd, WM_CANCELMODE, wParam, lParam) Else Return CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam) End If End Function
SetWindowLong:
GWL_WNDPROC: Sets a new address for the window procedure.
Windows NT/2000/XP: You cannot change this attribute if the window does not belong to the same process as the calling thread.
now all the fun of subclassing is gone. how can I make it work on other windows?
Thanks,







Reply With Quote