My goal is to "wrap" a common control and provide my own functionality
that augments/changes that of the common control. After reading about
subclassing extensively, it is clear that with the Get/SetWindowLong
functions you can easily handle ONE DIRECTION of message flow; namely,
the flow of messages INTO the control (i.e. you catch messages on the
way in and either handle them, forward them on to the underlying
control window proc, or both).
But what about the messages coming OUT of the "wrapped" control (like
WM_NOTIFY messages). WM_NOTIFY messages are sent to the parent window,
but I sure would like my "subclass" window procedure to see them, and
then be able to handle them or pass them "up" to the parent myself; i.e.
flow of messages the other way.
This is really a very useful idea. For example, I would like to
have a treeview control that displays a certain image for an "expanded"
tree as "default" behavior -- by that I mean that the writer of an app
using my treeview just has to create it as a child to one of his windows,
but doesn't have to worry about handling the WM_NOTIFY message that
contains the TVM_EXPANDED message -- I would like my custom control to
catch the WM_NOTIFY that is on its way back to the parent. That way, I
can do the image changing and THEN forward that message to the parent
so he can do what he wants in addition to the image changing...
I think that this behavior (full wrapping of a control) can be done
by creating a "container" window that is the parent of the subclassed
control, correct? Is this the right way to do it? It seems like it might
be a pain -- how do I make sure that the container never gets
in the way; i.e. that it is always the same size, position, as
the child, etc? If this is the way to do it, can someone give me
very general direction?
I was hoping that it could be done without having to explicitly
create another window just to be a container and "upward message
catcher" for the wrapped control -- it seemed like subclassing
might get me there, but the subclassed window talks directly back
to the parent instead of to my new window proc. Is there a way
to make subclassing work?