Hanqian
asked on
Confused for adding message handler for runtime created static controls?
I have a 10 runtime create static controls with resource ID; like 100, 101, 102, 103, 104,105,106
107,108,109. I want to have a function to do something for each control when the control is clicked with mouse left button down. What I have done is to add this line to MESSAGE_MAP
ON_COMMAND_RANGE(100, 109, OnClick)and add afx_msg void OnClick(UINT nID) to header file.
It works.
The one thing that I am little confused about it is how ON_COMMAND_RANGE knows only
to work when left button is clicked which is exactly what I want! why not work when
RBUTTONDOWN, or MOUSEMOVE, or LBUTTONUP................. .......... ...
Even ON_COMMAND_RANGE(100, 109, OnClick) works for me, is it correct to use it?
If not , what is correct message that I should use.
Thanks.
Hanqian
107,108,109. I want to have a function to do something for each control when the control is clicked with mouse left button down. What I have done is to add this line to MESSAGE_MAP
ON_COMMAND_RANGE(100, 109, OnClick)and add afx_msg void OnClick(UINT nID) to header file.
It works.
The one thing that I am little confused about it is how ON_COMMAND_RANGE knows only
to work when left button is clicked which is exactly what I want! why not work when
RBUTTONDOWN, or MOUSEMOVE, or LBUTTONUP.................
Even ON_COMMAND_RANGE(100, 109, OnClick) works for me, is it correct to use it?
If not , what is correct message that I should use.
Thanks.
Hanqian
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oops please ignore my comments..AndyAinscow is right. Seems i am saturated for today
ASKER
When I compile, it complains:
On_NOTIFY_RANGE' : undeclared identifier
On_NOTIFY_RANGE' : undeclared identifier
ASKER
ON_CONTROL_RANGE( wNotifyCode, id1, id2, memberFxn )
works well.
Thanks.
Hanqian
works well.
Thanks.
Hanqian
Specify any of these values of your interest for wNotifyCode
NM_CLICK User clicked left mouse button in the control
NM_DBLCLK User double-clicked left mouse button in the control
NM_RCLICK User clicked right mouse button in the control
NM_RDBLCLK User double-clicked right mouse button in the control
id The first ID of the static control
id last ...The last ID of the static control
On_NOTIFY_RANGE(NM_CLICK, 100, 110, OnClick)