Reflecting WM_CTLCOLORSTATIC from Composite Control to child? 
Author Message
 Reflecting WM_CTLCOLORSTATIC from Composite Control to child?

Hello.

I've got a Composite control with a bunch of statics in it. I want to
change the background color of these statics. I've got this to work by
handling the  WM_CTLCOLORSTATIC in my Compcontrol, and then
explicitally calling my Static-class, that changes the color.

But, I'm just not keen on this solution, and want to change it, so
that the static receives the CTLCOLOR message itself. I understand I
have to use the REFLECT_NOTIFICATIONS macro in the parent, but I just
can't get it to work. No CTLCOLOR-messages (WM_* or OCM_*) seems to be
posted to my Static control from the parent composite control... I
must me missin' something???

In composite control parent:

BEGIN_MSG_MAP(CMapOverlayEditCtrl)
        CHAIN_MSG_MAP(CComCompositeControl<CMapOverlayEditCtrl>)
        MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
        MESSAGE_HANDLER(WM_SIZE, OnSize)
        ....
        REFLECT_NOTIFICATIONS()
END_MSG_MAP()

In Static child:

class CClrStatic : public ATLControls::CStatic  
{
public:
BEGIN_MSG_MAP(CClrStatic)
        MESSAGE_HANDLER(OCM_CTLCOLORSTATIC, OnCtlColor)
END_MSG_MAP()
        ....
        LRESULT OnCtlColor(UINT uMsg, WPARAM wParam,
                           LPARAM lParam, BOOL& bHandled);

Can anybody tell me what I'm doing wrong???

Thanks   / Robbjo



Fri, 29 Apr 2005 22:17:13 GMT  
 Reflecting WM_CTLCOLORSTATIC from Composite Control to child?
You need a class derived from CWindowImpl for a message map to have any
effect. As in

class CClrStatic : public CWindowImpl<CClrStatic, ATLControls::CStatic>
{
    // ...

Quote:
};

Then you need to create an instance of CClrStatic class and use either
Create (to create a new control) or SubclassWindow (to attach the
instance to existing control).
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> Hello.

> I've got a Composite control with a bunch of statics in it. I want to
> change the background color of these statics. I've got this to work by
> handling the  WM_CTLCOLORSTATIC in my Compcontrol, and then
> explicitally calling my Static-class, that changes the color.

> But, I'm just not keen on this solution, and want to change it, so
> that the static receives the CTLCOLOR message itself. I understand I
> have to use the REFLECT_NOTIFICATIONS macro in the parent, but I just
> can't get it to work. No CTLCOLOR-messages (WM_* or OCM_*) seems to be
> posted to my Static control from the parent composite control... I
> must me missin' something???

> In composite control parent:

> BEGIN_MSG_MAP(CMapOverlayEditCtrl)
> CHAIN_MSG_MAP(CComCompositeControl<CMapOverlayEditCtrl>)
> MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
> MESSAGE_HANDLER(WM_SIZE, OnSize)
>         ....
> REFLECT_NOTIFICATIONS()
> END_MSG_MAP()

> In Static child:

> class CClrStatic : public ATLControls::CStatic
> {
> public:
> BEGIN_MSG_MAP(CClrStatic)
> MESSAGE_HANDLER(OCM_CTLCOLORSTATIC, OnCtlColor)
> END_MSG_MAP()
> ....
> LRESULT OnCtlColor(UINT uMsg, WPARAM wParam,
>                            LPARAM lParam, BOOL& bHandled);

> Can anybody tell me what I'm doing wrong???

> Thanks   / Robbjo



Sat, 30 Apr 2005 01:08:40 GMT  
 Reflecting WM_CTLCOLORSTATIC from Composite Control to child?
Thanks Igor. This of course works a lot better, but still not
perfect...

The problem at hand now is that the parent will not reflect CTLCOLOR
if I havn't declared REFLECT_NOTIFICATIONS _first_ in parents
messagemap. (And if I do that, other children, like buttons won't
work) It seems that the REFLECT_NOTIFICATIONS should be the last line
in the parents messagemap, but for some the reason the
WM_CTLCOLORSTATIC msg is processed somewhere else, so that it isn't
reflected. I have no other message handler in the map, that should
interfere with the CTLCOLOR msg...

/ Robbjo

Quote:

> You need a class derived from CWindowImpl for a message map to have any
> effect. As in

> class CClrStatic : public CWindowImpl<CClrStatic, ATLControls::CStatic>
> {
>     // ...
> };

> Then you need to create an instance of CClrStatic class and use either
> Create (to create a new control) or SubclassWindow (to attach the
> instance to existing control).
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > Hello.

> > I've got a Composite control with a bunch of statics in it. I want to
> > change the background color of these statics. I've got this to work by
> > handling the  WM_CTLCOLORSTATIC in my Compcontrol, and then
> > explicitally calling my Static-class, that changes the color.

> > But, I'm just not keen on this solution, and want to change it, so
> > that the static receives the CTLCOLOR message itself. I understand I
> > have to use the REFLECT_NOTIFICATIONS macro in the parent, but I just
> > can't get it to work. No CTLCOLOR-messages (WM_* or OCM_*) seems to be
> > posted to my Static control from the parent composite control... I
> > must me missin' something???

> > In composite control parent:

> > BEGIN_MSG_MAP(CMapOverlayEditCtrl)
> > CHAIN_MSG_MAP(CComCompositeControl<CMapOverlayEditCtrl>)
> > MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
> > MESSAGE_HANDLER(WM_SIZE, OnSize)
> >         ....
> > REFLECT_NOTIFICATIONS()
> > END_MSG_MAP()

> > In Static child:

> > class CClrStatic : public ATLControls::CStatic
> > {
> > public:
> > BEGIN_MSG_MAP(CClrStatic)
> > MESSAGE_HANDLER(OCM_CTLCOLORSTATIC, OnCtlColor)
> > END_MSG_MAP()
> > ....
> > LRESULT OnCtlColor(UINT uMsg, WPARAM wParam,
> >                            LPARAM lParam, BOOL& bHandled);

> > Can anybody tell me what I'm doing wrong???

> > Thanks   / Robbjo



Sat, 30 Apr 2005 17:46:51 GMT  
 Reflecting WM_CTLCOLORSTATIC from Composite Control to child?
You do, too. Move

CHAIN_MSG_MAP(CComCompositeControl<CMapOverlayEditCtrl>)

to the bottom of your message map. CComCompositeControl handles some
WM_CTLCOLOR* messages in order to honor the host's BackColor ambient
property.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> The problem at hand now is that the parent will not reflect CTLCOLOR
> if I havn't declared REFLECT_NOTIFICATIONS _first_ in parents
> messagemap. (And if I do that, other children, like buttons won't
> work) It seems that the REFLECT_NOTIFICATIONS should be the last line
> in the parents messagemap, but for some the reason the
> WM_CTLCOLORSTATIC msg is processed somewhere else, so that it isn't
> reflected. I have no other message handler in the map, that should
> interfere with the CTLCOLOR msg...



Sat, 30 Apr 2005 22:28:24 GMT  
 Reflecting WM_CTLCOLORSTATIC from Composite Control to child?
Aha, yes I do, too. Thanks Igor. Works like a charm now.

/ Robbjo

Quote:

> You do, too. Move

> CHAIN_MSG_MAP(CComCompositeControl<CMapOverlayEditCtrl>)

> to the bottom of your message map. CComCompositeControl handles some
> WM_CTLCOLOR* messages in order to honor the host's BackColor ambient
> property.
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > The problem at hand now is that the parent will not reflect CTLCOLOR
> > if I havn't declared REFLECT_NOTIFICATIONS _first_ in parents
> > messagemap. (And if I do that, other children, like buttons won't
> > work) It seems that the REFLECT_NOTIFICATIONS should be the last line
> > in the parents messagemap, but for some the reason the
> > WM_CTLCOLORSTATIC msg is processed somewhere else, so that it isn't
> > reflected. I have no other message handler in the map, that should
> > interfere with the CTLCOLOR msg...



Sun, 01 May 2005 14:42:30 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. WM_CTLCOLORSTATIC in composite control

2. why my Composite Control can't capture the command message send by child common control

3. Getting the HWND of a child control of a composite control

4. A composite control calling another composite control in web browser

5. Composite control hosted by a composite control.

6. Handling Messages for MFC child dilaogs in an ATL Composite Control

7. Handling Messages for MFC child dilaogs in an ATL Composite Control

8. Reflecting? timer messages to children

9. Using Rich Edit Control or ip address control in a composite control

10. Get an Item.ItemIndex of controls other than supporting CommandName inside composite controls

11. ATL Full Control - mouse activation problems in Composite Control

12. How to enumerate every control in a composite Control

 

 
Powered by phpBB® Forum Software