# Posting messages through a hierarchy

This topic is 4856 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, i've been working on this control library, and recently decided that I want to have multiple levels...such as a parent window can have many children (like buttons, labels, scrollboxs) and then those controls can also have children..(like nested windows ) and so forth.. so I up my base class somewhat like this
class CControl
{
public:
CControl * m_Parent;
CControl * m_ChildControls;
CControl * m_NextSibling;
CControl * m_PrevSibling;
};

where my problem comes is posting messages (such as like mouse click events) to all my controls...in my WndProc I have the following
//global
CControl * g_Window;

//later on
LRESULT CALLBACK WndProc(blahblahblah)
{
g_Window->PostMessageToAll(msg, wparam, lparam, data)
}

the part that I cannot come up with is the PostMessageToAll function...it shouldn't be that hard, but I keep on confusing myself when trying to think of how to do it..so i'm wondering if anyone of you have an idea how to do this.. where it would post in a top down manner...whereas the parent gets the message first, then the children and sibling..then the grandchildren ...then after that I think I need to be able to post the messages in reverse too for painting I'm sorry if I explained that really bad, but if anyone has an idea what i'm talking about please respond.. Thanks