Click to See Complete Forum and Search --> : Subclassing another thread's windows
Clearcode
August 14th, 2001, 09:37 AM
Hi,
When I try to use SetWindowLong to subclass another thread's window it fails, but it works if the window is in the same thread as the call to SetWindowLong.
The MSDN documentation does not mention that limitation, and I have seen programs that seem to subclass other programs so there must be a way.
Any ideas?
Thanks in advance,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
sotoasty
August 14th, 2001, 10:28 AM
According to the MSDN
"Remarks
The SetWindowLong function fails if the window specified by the hWnd parameter does not belong to the same process as the calling thread."
I have heard of people "injecting" a DLL into another process, but am unsure how this works. What do you need to do with the subclassing? You can intercept messages (keyboard/mouse input) with setwindowshook.
Clearcode
August 14th, 2001, 10:37 AM
I am preventing my own windows being resized outside certain restrictions by intercepting the WM_GETMINMAXINFO message, copying my min/max info in and sending it back but now a client wants a similar thing done with an explorer window.
I tried installing a WH_CALLWNDPROC but that returns The parameter was incorrect if I set the thread to be explorer.
Ho well, back to the drawing board.
(Nobody knows about this injecting dlls thing?)
Thanks,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
sotoasty
August 14th, 2001, 12:31 PM
Ok, you might be able to try using SetWindowsHookEx with the WH_GETMESSAGE parameter to monitor messages sent to the window. If I recall correctly, you will need to place this in a .DLL in order for it to work. I don't have anything for working with windows messages, but here is a link for working with keystrokes. The source for the C++ .DLL is included so you might be able to change the code to fit your purposes. Or try the C++ forum and search the archives. You could probably find something in there.
Hope this helps.
sotoasty
August 14th, 2001, 12:34 PM
Can you belive it, some moron forgot the link!
http://www.vbnotes.com/KeyHook.zip
Polkabora
August 14th, 2001, 05:00 PM
If you are running under Win 2000, you can't subclass another's application using SetWindowsLong. Win 2000 Prevents it. SetWindowLngPtr(Listed in the MSDN), I think might be able to do it, but I can' find any documentation on it (C++ or VB Api).
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.