Archived

This topic is now archived and is closed to further replies.

simbiant

hooking a window! agh!

Recommended Posts

let's say I had a list of window's hwnd values (and pretend for now that these hwnd values won't change and the windows wont be closing).. i want these windows to be under constant watch and for my program to notify me if any of them get minimized. right now I simply have a loop that constantly runs through each hwnd value, uses Win32 api to check the IsIconic value of it, and return the value.. but i think this loop is probably inefficient (i dunno the technical crap - maybe on memory or 'cpu cycles'?) since it has to keep reiterating, and also while the loop is currently at one window and checking it, a different one might be minimized at the same time.. you might think "ok the loop will see that window in less than a second, who cares", but I need instantaneous checking, if possible. is this possible by setting a hook for every single specified window hwnd in my list, and checking for a minimize message? if so, how can this be done? [edited by - simbiant on August 7, 2003 1:10:10 AM]

Share this post


Link to post
Share on other sites
well i know it has to do with a dll and SetWindowsHookEx along with this..
WH_CALLWNDPROC
Installs a hook procedure that monitors messages before the system sends them to the destination window procedure. For more information, see the CallWndProc hook procedure.

however I never was able to get a system wide hook because I know jack about dll''s besides wrapping, I would like to see that DLL even if they wouldnt

Share this post


Link to post
Share on other sites
quote:
from MSDN
The WM_ACTIVATE message is sent to both the window being activated and the window being deactivated. If the windows use the same input queue, the message is sent synchronously, first to the window procedure of the top-level window being deactivated, then to the window procedure of the top-level window being activated. If the windows use different input queues, the message is sent asynchronously, so the window is activated immediately



If all of your windows listen for that message and report back to you application as soon as they receive that message you might be able to do what you want?

There''s also a Message called MW_APP which you can use to define private messages.

So you could have all of your windows listen for WM_ACTIVATE, and upon receival send a custom MW_APP with their handle in it for example. Your main application will only have to listen for those WM_APP messages then.

Share this post


Link to post
Share on other sites
Prehaps a systemwide hook that listens for all WM_minimize ?

Tut on systemwide hooks -> http://www.codeguru.com/shell/iconizer.html
MSDN info -> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.asp



/Please excuse my bad spelling - My native language is binary not english
|Visit me
\Take my advice - I don''''t use it...

Share this post


Link to post
Share on other sites
You could look at...

www.vbaccelerator.com

You''ll find loads of hooking / sub classing dlls (inc ones that allow you to debug in the IDE whilst subclassed and handle multiple subclassed attempts!!!)

Excellent site.

Cheers,
Paul Cunningham

Share this post


Link to post
Share on other sites