?
Solved

Confused for adding message handler for runtime created static controls?

Posted on 2004-04-26
5
Medium Priority
?
339 Views
Last Modified: 2013-11-20
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

0
Comment
Question by:Hanqian
  • 2
  • 2
5 Comments
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 150 total points
ID: 10919095
The command range uses COMMAND ID's.  They are not the ID's of your controls.
you need
ON_CONTROL_RANGE
ON_CONTROL_RANGE( wNotifyCode, id1, id2, memberFxn )
Parameters
wNotifyCode
The notification code to which your handler is responding.   ****** here is the LBUTTONDOWN

id1
Command ID at the beginning of a contiguous range of control IDs.

id2
Command ID at the end of a contiguous range of control IDs.

memberFxn
The name of the message-handler function to which the controls are mapped.

0
 
LVL 3

Expert Comment

by:akalmani
ID: 10919136
You can as well use ON_NOTIFY_RANGE( wNotifyCode, id, idLast, memberFxn )

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)
0
 
LVL 3

Expert Comment

by:akalmani
ID: 10919176
oops please ignore my comments..AndyAinscow is right. Seems i am saturated for today
0
 

Author Comment

by:Hanqian
ID: 10919461
When I compile, it complains:

On_NOTIFY_RANGE' : undeclared identifier
0
 

Author Comment

by:Hanqian
ID: 10919475
ON_CONTROL_RANGE( wNotifyCode, id1, id2, memberFxn )
 works well.

Thanks.

Hanqian
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month16 days, 4 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question