Read WndProc of other windows
-
Hello, I'm writing a program that needs to know when a user do things to windows of another process (activate, drag/drop, whatever). I think I'd need to read the WndProc function of those windows, but how do I achieve that? Also, how to notify my program in case some specific messages happens? For instance, if WM_ACTIVATE is sent to the window of another program, how can it triggers some function in my program? Any lead is appreciated :p Regards, Tony
-
Hello, I'm writing a program that needs to know when a user do things to windows of another process (activate, drag/drop, whatever). I think I'd need to read the WndProc function of those windows, but how do I achieve that? Also, how to notify my program in case some specific messages happens? For instance, if WM_ACTIVATE is sent to the window of another program, how can it triggers some function in my program? Any lead is appreciated :p Regards, Tony
Tony_P, this can be accomplished by doing the following: - get the HWND of the application's window you want to hook to - use GetWindowLong to get the windows WndProc and store it - create a WndProc method in your app - use SetWindowLong to inject your Wndproc into the other window - after doing what you want in *your* WndProc, use CallWindowProc to pass control to the windows original WndProc (you stored it previously) Please bear in mind that this is not possible in .NET without using DllImport to coredll.dll in order to have access to certain Win32 functions like SetWindowLong, GetWindowLong, GetWindow, CallWindowProc, etc. Hope this helps. Marcelo
-- Marcelo Emmerich Software Development - Computer Graphics - Mobile Computing http://bytethings.blogspot.com
-
Tony_P, this can be accomplished by doing the following: - get the HWND of the application's window you want to hook to - use GetWindowLong to get the windows WndProc and store it - create a WndProc method in your app - use SetWindowLong to inject your Wndproc into the other window - after doing what you want in *your* WndProc, use CallWindowProc to pass control to the windows original WndProc (you stored it previously) Please bear in mind that this is not possible in .NET without using DllImport to coredll.dll in order to have access to certain Win32 functions like SetWindowLong, GetWindowLong, GetWindow, CallWindowProc, etc. Hope this helps. Marcelo
-- Marcelo Emmerich Software Development - Computer Graphics - Mobile Computing http://bytethings.blogspot.com
I see. Don't worry I've already worked with DLLImports of the win32 api. Thank you!