Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

subclass a hierarchy of windows

Posted on 2004-10-26
12
Medium Priority
?
229 Views
Last Modified: 2010-08-05
I want to intercept (via subclassing or hooking) all messages that are destined to some window and all of it's descendent windows (children, grand children, etc.)
Is there a way of doing it without hooking the entire desktop or subclassing every child window recuresively?
0
Comment
Question by:AssafLavie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
12 Comments
 
LVL 13

Accepted Solution

by:
SteH earned 500 total points
ID: 12409697
Unless all the childs, etc are not getting there messages directly there is no simple way. To speed things up messages can be routed directly to controls and don't need to go via the main dialog in which case you will loose them. An approach may be to peek into the main application queue and find get the corresponding messages from there. Only be aware of performance issues with that approach.
0
 
LVL 4

Author Comment

by:AssafLavie
ID: 12724660
Sorry for taking so long to reply.
No, I'm afraid I can't just monitor the application window. For one thing, I'm not talking about a single application for which I want to intercept messages. I'm talking about child window in general - not just controls on dialogs.
I want to be able choose a window arbitrarily in Windows (ignoring for the moment process permission issues) and be able to get notification for every messages that passes to it or to any of its children. One way of doing this is to go and sublcass each child in the hierachy.. but this isn't a good solution for several reasons. That's why I'm wondering it there's a proper way of doing this.
0
 
LVL 13

Expert Comment

by:SteH
ID: 12724882
In that case you can hook to the global message queue and filter all messages for a window, or a set of windows and process them before the application sees them.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:AssafLavie
ID: 12730365
Yes, well I'm aware of that option, but:
1. a global hook is somewhat of a radical solution which I don't like to implement unless I really have no alternative.
2. If I do use a global hook I still need to decide for each window if it's a descendent of the given window, for example by repeatedly calling GetParent.

But mainly I want to refrain from using a global hook. It's overkill.
0
 
LVL 4

Author Comment

by:AssafLavie
ID: 12730377
(I just noticed that I already posted my objection to using global hooks in my original post...)
Still, thanks for helping out.
0
 
LVL 13

Expert Comment

by:SteH
ID: 12734482
I fear you need to go the unwanted route.

>2. If I do use a global hook I still need to decide for each window if it's a descendent of the given window, for example by repeatedly calling GetParent.
Here it should be easier to get all childs of a window once and put them into a list/vector/array. In hook handler you just go through this list.
0
 
LVL 4

Author Comment

by:AssafLavie
ID: 12735724
Sure, but then if new children are created I would be unware, unless I re-enumerate them periodically.
0
 
LVL 13

Expert Comment

by:SteH
ID: 12736499
You could try api hooking to get informed if windows are closed or created. Or since you hooked the global queue you could check in addition to messages with a certain HWND all WM_CREATE and WM_CLOSE. That way you should be aware of newly created windows and when windows of interest get destroyed.  
0
 
LVL 4

Author Comment

by:AssafLavie
ID: 12738705
Yes, I know. But this only demonstrates why I don't like the idea of global hooking. What I'm looking for is a way to subclass a hierarchy of windows by performing some action on its root window - without having to resort to global hooking.
But thanks again for your input. I guess the answer to my question is basically "no".
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question