Link to home
Start Free TrialLog in
Avatar of tds195
tds195

asked on

Managing Multiple Dialog Control Event Functions

My dialog application has many button controls, each of which I have assigned a BN_CLICKED event handler function.
As a result, I have a very cluttered amount of functions in my Dlg class. Is there a method for reducing the amount of functions? Is it possible to group button controls that call a single event function with an index to which button was clicked? I could then use a switch-case to process individual button controls. I am interested in any sensible alternative to having one function for each button control.
Avatar of tds195
tds195

ASKER

Adjusted points to 50
The problem here is probably not one of mapping a function to a button, but the layout of your dialog.  How many buttons are we talking about?  I am sure if you meditate on the buttons' functions and any natural grouping or heirarchy within that you will find a better way than to have all those buttons in the first place.
Avatar of tds195

ASKER

I am creating a kind of scientific calculator that must have about 30 - 40 buttons on the dialog at any one time.
ASKER CERTIFIED SOLUTION
Avatar of warmcat
warmcat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I was a bit late. The following is my answer.

ON_CONTROL_RANGE
ON_CONTROL_RANGE( wNotifyCode, id1, id2, memberFxn )

Parameters

wNotifyCode   The notification code to which your handler is responding.

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.

Remarks

Use this macro to map a contiguous range of control IDs to a single message handler function for a specified Windows notification message, such as BN_CLICKED. The range of IDs starts with id1 and ends with id2. The handler is called for the specified notification coming from any of the mapped controls.

ClassWizard does not support message map ranges, so you must place the macro yourself. Be sure to put it outside the message map //{{AFX_MSG_MAP delimiters.


Sorry chensu, I hate it when that happens.  I wonder if EE have considered allowing multiple answers to questions which then take part in a 'beauty contest' by the proposer, perhaps with the option to share points?
Avatar of tds195

ASKER

Thanks very much, I'll go and remove all those functions.
warmcat,

It is OK.