Tech Support > Microsoft Windows > Development Resources > How to circumvent WH_CALLWNDPROC limitation?
How to circumvent WH_CALLWNDPROC limitation?
Posted by Lucian Wischik on June 25th, 2003


John K. wrote:
I have no real experience of these issues but...
could you just give all windows the WS_EX_NOACTIVATE style? Then, when
any of them receive a click, you can put in your own logic for
deciding whether to activate them and where to put them in the Z
order.

Ah. This wouldn't work on 98 or ME.

--
Lucian

Posted by John K. on June 25th, 2003



Hi all,
I need to intercept WM_WINDOWPOSCHANGING and modify one of its parameters,
specifically I have (depending on a flag set somewhere in my program) to
allow or disallow the change in Z order of any window.
Please note that there's no other way for me, if I just needed one window
to remain on top, it would be easy.. but I instead need that if the user
clicks on a window, this gets the keyboard focus but does not change the
Z orders at all (of course I need to provide this "feature" only in certain
situations, depending on the forementioned flag set by my application).

The most natural way would be to use a system-wide WH_CALLWNDPROC hook,
intercept WM_WINDOWPOSCHANGING, and "or" lParam->flags with SWP_NOZORDER.

Very frustratingly, there's the usual exception to the rule that makes
my life as Win32 programmer always much more complicated than it should
be. Namely, the MSDN docs say:

"The hook procedure can examine the message; it cannot modify it".

This is a specific limitation placed by Microsoft on WH_CALLWNDPROC.

So a WH_CALLWNDPROC hook is totally useless for me. :/

I could use a WH_GETMESSAGE hook instead .. but some messages, namely
the one that I need to intercept/modify, do not pass through GetMessage,
but is sent directly to the target window proc.

Would a WH_CBT hook solve my problem? I don't think so, since I could
not see anything Z order related in the list of HCBT_* we can specify,
but I sure hope to be wrong!

So, what are my last options?

# find/intercept all WndProc procedures in the system, and hook them
with my code? [looks overkill]

# place a global/kernel API hook at SendMessageA and SendMessageW?

but both would work only if the user has administrator privileges,
right? ( I want 9x/and NT/2000/XP compatibility. I could give up
95 and NT.. but not 98,ME,2000 and XP.

Please help.. I need some clever hints.

Greets,
John



Similar Posts