Owner Draw in ATL/WTL Window Controls 
Author Message
 Owner Draw in ATL/WTL Window Controls

Hello All,

Does anyone know the best way to create a *self contained* owner draw window
control (not ActiveX) with the ATL/WTL framework?  Or a good example I can
look at?

My situation:  I have a legacy MFC app, and am wanting to extend some
controls (ListView, Header, ComboBox, Edit, ListBox and more) which will
work in the MFC app and in an ActiveX wrapper (I want to directly access the
controls in the MFC app for less overhead).  I love ATL, and so I want to
write the controls in this framework.

This is my understanding of the situation: The WM_DRAWITEM message gets sent
to the owner window, and needs to be reflected back to the original window.
ATL has the REFLECT_NOTIFICATIONS( ) macro to send all unsupported messages
back to the original window.  But this is not exactly what I want, as the
MFC app doesn't support this macro.

MFC has a ON_WM_DRAWITEM_REFLECT( ) macro which "seems" to make the control
self contained (ie. Parent window doesn't have to reflect the messages), but
I don't really know what's happening under the MFC layers.

I have thought about using an extra window for the control, so that it
controls the contained window - something like how the ActiveX Control
containment works.  Is this a good idea?  Is it a large overhead for a
simple window?

Another question - Is there a large difference in overhead between using an
ActiveX wrapper over the window, other than just using the window itself in
an MFC app?

Any help is appreciated,
Luke



Mon, 14 Apr 2003 09:20:17 GMT  
 Owner Draw in ATL/WTL Window Controls

Default window proc for CWnd in MFC always reflects messages, thus the
control always gets the reflected message unless you handle it explicitly in
your parent window and do not pass it down to default proc.

ATL reflects only if you explicitly put REFLECT_NOTIFICATIONS( ) in the
message map of parent window. Also, if you use ATL hosing support, AxWin (a
window created under every ActiveX control) reflects messages by default
(you can turn it off).

Reflecting a message means adding an offset to the message ID and sending it
back to the originating window. Unfortunately, the offsets are different for
MFC and ATL. MFC adds WM_REFLECT_BASE == 0xBC00, ATL adds OCM__BASE ==
(WM_USER+0x1c00) == 0x2000 (as per ActiveX Control specification).

I don't quite understand what you are trying to do, but hope this helps.
--
With best wishes,
    Igor Tandetnik


Quote:
> Hello All,

> Does anyone know the best way to create a *self contained* owner draw
window
> control (not ActiveX) with the ATL/WTL framework?  Or a good example I can
> look at?

> My situation:  I have a legacy MFC app, and am wanting to extend some
> controls (ListView, Header, ComboBox, Edit, ListBox and more) which will
> work in the MFC app and in an ActiveX wrapper (I want to directly access
the
> controls in the MFC app for less overhead).  I love ATL, and so I want to
> write the controls in this framework.

> This is my understanding of the situation: The WM_DRAWITEM message gets
sent
> to the owner window, and needs to be reflected back to the original
window.
> ATL has the REFLECT_NOTIFICATIONS( ) macro to send all unsupported
messages
> back to the original window.  But this is not exactly what I want, as the
> MFC app doesn't support this macro.

> MFC has a ON_WM_DRAWITEM_REFLECT( ) macro which "seems" to make the
control
> self contained (ie. Parent window doesn't have to reflect the messages),
but
> I don't really know what's happening under the MFC layers.

> I have thought about using an extra window for the control, so that it
> controls the contained window - something like how the ActiveX Control
> containment works.  Is this a good idea?  Is it a large overhead for a
> simple window?

> Another question - Is there a large difference in overhead between using
an
> ActiveX wrapper over the window, other than just using the window itself
in
> an MFC app?

> Any help is appreciated,
> Luke



Mon, 14 Apr 2003 22:15:57 GMT  
 Owner Draw in ATL/WTL Window Controls

Thanks so much Igor, I think I am really trying to catch the reflected MFC
message in my ATL control.
If you have any knowledge of doing this, I'd really appreciate it.

Cheers,
Luke


Quote:
> Default window proc for CWnd in MFC always reflects messages, thus the
> control always gets the reflected message unless you handle it explicitly
in
> your parent window and do not pass it down to default proc.

> ATL reflects only if you explicitly put REFLECT_NOTIFICATIONS( ) in the
> message map of parent window. Also, if you use ATL hosing support, AxWin
(a
> window created under every ActiveX control) reflects messages by default
> (you can turn it off).

> Reflecting a message means adding an offset to the message ID and sending
it
> back to the originating window. Unfortunately, the offsets are different
for
> MFC and ATL. MFC adds WM_REFLECT_BASE == 0xBC00, ATL adds OCM__BASE ==
> (WM_USER+0x1c00) == 0x2000 (as per ActiveX Control specification).

> I don't quite understand what you are trying to do, but hope this helps.
> --
> With best wishes,
>     Igor Tandetnik



Tue, 15 Apr 2003 15:34:47 GMT  
 Owner Draw in ATL/WTL Window Controls

I think when MFC hosts ActiveX controls, it follows ActiveX Control Spec,
that is, it reflects with an offset of OCM__BASE. Try handling OCM_* (e.g.
OCM_COMMAND or OCM_DRAWITEM) message where you usually expect WM_* message.
--
With best wishes,
    Igor Tandetnik


Quote:
> Thanks so much Igor, I think I am really trying to catch the reflected MFC
> message in my ATL control.
> If you have any knowledge of doing this, I'd really appreciate it.

> Cheers,
> Luke



> > Default window proc for CWnd in MFC always reflects messages, thus the
> > control always gets the reflected message unless you handle it
explicitly
> in
> > your parent window and do not pass it down to default proc.

> > ATL reflects only if you explicitly put REFLECT_NOTIFICATIONS( ) in the
> > message map of parent window. Also, if you use ATL hosing support, AxWin
> (a
> > window created under every ActiveX control) reflects messages by default
> > (you can turn it off).

> > Reflecting a message means adding an offset to the message ID and
sending
> it
> > back to the originating window. Unfortunately, the offsets are different
> for
> > MFC and ATL. MFC adds WM_REFLECT_BASE == 0xBC00, ATL adds OCM__BASE ==
> > (WM_USER+0x1c00) == 0x2000 (as per ActiveX Control specification).

> > I don't quite understand what you are trying to do, but hope this helps.
> > --
> > With best wishes,
> >     Igor Tandetnik



Tue, 15 Apr 2003 22:08:19 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Need help with Owner Drawn Button Class in ATL composite Control

2. Newbie to owner drawn: Scroll Bars in Owner drawn ListCtrl

3. Sample owner-draw radio button with ATL

4. Owner drawn listbox in ATL

5. Owner-Draw Child Window

6. owner drawn tab to change font and windows 2000

7. Owner drawn list control

8. how to do an owner draw slider control ?

9. Owner drawn tab control

10. owner draw tab control

11. How To Get the Caption and Control Id of Owner Drawn PushButton

12. Owner Drawn Control Help!!

 

 
Powered by phpBB® Forum Software