Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everyone!

I would like to start by saying thanks to everyone who takes some time to view this thread and try to help.

I have a main window, with a child static control ( for further discussion we shall label it as S1 ). That static control is parent to another static control ( for further discussion we shall label it as S2 ).

Both static controls have SS_NOTIFY style set, and need to do something when user clicks on them.

I have no problem catching notification message from first control ( S1 ) since it sends its messages to parent, in this case main window.

However, I don't know how to catch child static control's ( S2 ) notifications in main window.

Is it possible to do this?

Or do I need to subclass something? Maybe parent static control ( S1 )?



I work in MS Visual Studio Express 2008, on Windows XP, in C++, using WIN32 API.

If any other information is required ( source code or something similar ), please ask for it, I will more than gladly supply it.
Posted
Comments
Richard MacCutchan 14-May-13 15:07pm    
I have not tried this myself, but I assume that the notifications are sent to S1, so you need to catch them there, probably by subclassing.
MyOldAccount 14-May-13 15:40pm    
Can you offer some pseudo-code/code/written instructions?
I have never done subclassing before...
Thank you.
Richard MacCutchan 14-May-13 17:00pm    
I'm afraid I don't have anything that I can offer at the moment. I suggest you take a look at the subclassing section on MSDN. The basic idea is that you add your own window procedure into the chain for the control in question, which allows you to see all the messages/notifications for that control. All you need to do in your code is process the messages you are interested in, and pass the rest down to the control.
MyOldAccount 14-May-13 19:07pm    
I have stumbled upon that article too!
I will give it a try, and report my results.

Use Spy++ to catch the messages going to your windows. This tool will give a you an inside view where the messages are going and will give you insight into how to catch them.
 
Share this answer
 
Comments
MyOldAccount 14-May-13 15:48pm    
I don't have original Visual Studio, I use Express Edition, and I was unable to find Spy++.

However, it is pretty logical that messages go to the parent ( why would'n they? ) which is S1.

I guess I need to subclass it, but I don't know how.

I would welcome some code examples/pseudo-code/links...
Hi,

actually I think that if the parent of S2 is S1, the main windiiw shall not receive the notification from S2. Instead, S1 shall receive the notification from S2.

Which meanse that:
- S1 sends its notification to its parent, which is MainWindow
- S2 sends its notification to its parent, which is S2

If you wand to catch notification from S2 in MainWnd as well, you shall perhaps use redirect them by e.g. subclassing S2.

Hope this helps

Best regards,
J. K.
 
Share this answer
 
I have solved it!

I have subclassed S1, and it works like a charm!

Example that helped was from Richard Simon's book " Windows NT Win32 API SuperBible ".

For those with similar problem, just check out description of function CallWindowProc() in his book, and at the very bottom you will find a simple example.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900