Message Handling - Controls - ATL Composite Controls 
Author Message
 Message Handling - Controls - ATL Composite Controls

Hi,

1)
I created a ListBox Class derived from the CListBox Class
in the ATLControls.h (available in samples).
How can I add MessageHandlers for the some Window messages
of interest?

I tried to add MessageMaps to it. I could not get the
Messages in it.
I am attaching the section of the code for reference.
Am I missing something?

2)I wanted to handle the MouseMoves on a owner draw List
Box on top of a ATL Composite Control. So I added the
WM_MOUSEMOVE handler. I am not getting notifications when
the mouse is on top of any control including the list
control which is of my interest. What could be the reason?

3) Later I used SetWindowLong to get the messages in my
WindowProcedure. Here I was able to get Mouse Move
messages for the particular ListBox Window
Can you suggest a scheme to make this handler as part of
my class(mentioned in 1) and access the instance specific
data?

Thanks in Advnace
Satheesh Thomas

class CMyListBox:public ATLControls::CListBox
{
public:
BEGIN_MSG_MAP(CMyListBox)
        MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
        MESSAGE_HANDLER(MSG_LIST_TEST, OnMsg)
END_MSG_MAP()
        LRESULT OnMouseMove(UINT uMsg, WPARAM wParam,
LPARAM lParam, BOOL& bHandled)
        {
                return 0;
        }
        LRESULT OnMsg(UINT uMsg, WPARAM wParam, LPARAM
lParam, BOOL& bHandled)
        {
        }

Quote:
};



Tue, 26 Apr 2005 21:53:41 GMT  
 Message Handling - Controls - ATL Composite Controls

Quote:
> 1)
> I created a ListBox Class derived from the CListBox Class
> in the ATLControls.h (available in samples).
> How can I add MessageHandlers for the some Window messages
> of interest?

> I tried to add MessageMaps to it. I could not get the
> Messages in it.
> I am attaching the section of the code for reference.
> Am I missing something?

You need to derive your class as follows:

// Specify the styles you want your list box to have by default
typedef CWinTraits<WS_CHILD|WS_VISIBLE|LBS_SORT> CMyListBoxTraits;
class CMyListBox : public CWindowImpl<CMyList, ATLControls::CListBox,
CMyListBoxTraits>
{
    // ...

Quote:
};
> 2)I wanted to handle the MouseMoves on a owner draw List
> Box on top of a ATL Composite Control. So I added the
> WM_MOUSEMOVE handler. I am not getting notifications when
> the mouse is on top of any control including the list
> control which is of my interest. What could be the reason?

This is by design. Mouse messages are posted to the window under mouse
cursor. When the mouse is over a child window, the child gets mouse
messages and the parent doesn't.

Quote:
> 3) Later I used SetWindowLong to get the messages in my
> WindowProcedure. Here I was able to get Mouse Move
> messages for the particular ListBox Window
> Can you suggest a scheme to make this handler as part of
> my class(mentioned in 1) and access the instance specific
> data?

Your message map will start working if you follow my earlier advise.
--
With best wishes,
    Igor Tandetnik

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



Wed, 27 Apr 2005 01:59:06 GMT  
 Message Handling - Controls - ATL Composite Controls
Thank You,

1) I did as per ur advise and it worked for me.
Do I need to CHAIN the messages in CMyListBox? or Chaining
is required only if I derive another class from the
CMyListBox?.
My intention is to make the default handler to handle the
other messages, which I am not handling in my class. From
its behavior I have observed,  the messages are reaching
the default handler, without chaining.

1.a) Actually I wanted to draw the Listbox items in the
custom way, atleast in the cases of mouse movements on top
of it.
I added WM_DRAWITEM handler in the Composite Control.
However, I feel, If I could draw the items from CMyListBox
based on the properties set for the instance of the
CMyListBox, it would be good. One scheme I thought was to
call the method of the appropriate CMyListBox object using
a switch case statement in the WM_DRAWITEM handler in the
composite control. Is there a better scheme, where I get
notifications for draw item in the CMyListBox itself?

Thanks again
Satheesh Thomas

Quote:
>-----Original Message-----


>> 1)
>> I created a ListBox Class derived from the CListBox
Class
>> in the ATLControls.h (available in samples).
>> How can I add MessageHandlers for the some Window
messages
>> of interest?

>> I tried to add MessageMaps to it. I could not get the
>> Messages in it.
>> I am attaching the section of the code for reference.
>> Am I missing something?

>You need to derive your class as follows:

>// Specify the styles you want your list box to have by
default
>typedef CWinTraits<WS_CHILD|WS_VISIBLE|LBS_SORT>
CMyListBoxTraits;
>class CMyListBox : public CWindowImpl<CMyList,

ATLControls::CListBox,

- Show quoted text -

Quote:
>CMyListBoxTraits>
>{
>    // ...
>};

>> 2)I wanted to handle the MouseMoves on a owner draw List
>> Box on top of a ATL Composite Control. So I added the
>> WM_MOUSEMOVE handler. I am not getting notifications
when
>> the mouse is on top of any control including the list
>> control which is of my interest. What could be the
reason?

>This is by design. Mouse messages are posted to the
window under mouse
>cursor. When the mouse is over a child window, the child
gets mouse
>messages and the parent doesn't.

>> 3) Later I used SetWindowLong to get the messages in my
>> WindowProcedure. Here I was able to get Mouse Move
>> messages for the particular ListBox Window
>> Can you suggest a scheme to make this handler as part of
>> my class(mentioned in 1) and access the instance
specific
>> data?

>Your message map will start working if you follow my
earlier advise.
>--
>With best wishes,
>    Igor Tandetnik

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

>.



Wed, 27 Apr 2005 19:52:03 GMT  
 Message Handling - Controls - ATL Composite Controls

Quote:
> 1) I did as per ur advise and it worked for me.
> Do I need to CHAIN the messages in CMyListBox? or Chaining
> is required only if I derive another class from the
> CMyListBox?.
> My intention is to make the default handler to handle the
> other messages, which I am not handling in my class. From
> its behavior I have observed,  the messages are reaching
> the default handler, without chaining.

The chaining is required if you derive another class and want a message
map in the base class to get a stab at handling the messages. In the
end, all messages not specifically handled by your message map (or any
other message maps you might be chaining or forwarding to) are forwarded
to the default window proc, which in the case of superclassing (that's
the official name for the technique you are using) is the original proc
for the window class yours is based on (list box in your case).

Quote:
> 1.a) Actually I wanted to draw the Listbox items in the
> custom way, atleast in the cases of mouse movements on top
> of it.
> I added WM_DRAWITEM handler in the Composite Control.
> However, I feel, If I could draw the items from CMyListBox
> based on the properties set for the instance of the
> CMyListBox, it would be good. One scheme I thought was to
> call the method of the appropriate CMyListBox object using
> a switch case statement in the WM_DRAWITEM handler in the
> composite control. Is there a better scheme, where I get
> notifications for draw item in the CMyListBox itself?

Put REFLECT_NOTIFICATIONS entry at the end of your composite control's
message map. This sends certain messages, such as WM_DRAWITEM, right
back to the child window, offsetting the message ID to avoid conflicts.
In your list box class, add a handler for OCM_DRAWITEM message and
handle it as you would WM_DRAWITEM.
--
With best wishes,
    Igor Tandetnik

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



Fri, 29 Apr 2005 23:50:12 GMT  
 
 [ 4 post ] 

 Relevant Pages 

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

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

3. Events of Flex grid not being handled in ATL composite control

4. ATL Composite Control input handling

5. Not receiving On...Click() messages in ATL Composite Control

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

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

8. Using ActiveX controls in ATL Composite control

9. How to invoke methods of contained ActiveX control from ATL Composite Control

10. mfc control in atl composite control wont destruct

11. Standard Windows Controls in ATL Composite Control

12. mfc control instantiated in atl composite control using CAxWindow wont destruct

 

 
Powered by phpBB® Forum Software