?
Solved

DEFPUSHBUTTONs

Posted on 2003-03-30
2
Medium Priority
?
191 Views
Last Modified: 2013-11-20
Hello experts,

I have a number of pushbuttons that I want to (eventually) respond to the same function, but I want to somehow signal the function to recognize which button was pushed.

Is there a way I could do this (through manipulating the message map or some other ingenious way?) (I do not want to make each button respond to a separate function and have them called the desired function since I have a large amount of buttons.)

Thanks,
0
Comment
Question by:n_fortynine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
LarryKing earned 260 total points
ID: 8236189
Yes,MFC provide ways to map a range of messages to a single message handler function.
ON_COMMANDE_RANGE,ON_CONTROL_RANGE,ON_NOTIFY_RANGE....

You may need ON_CONTROL_RANGE HERE

Ensure that your controls' ID is continous.
Add the following message entry to the message map.

ON_CONTROL_RANGE(BN_CLICKED, IDC_BUTTON1, IDC_BUTTON10,OnButtonClicked)

The handler function goes like this, here nID is the control ID of the button.
void CMyDialog::OnButtonClicked( UINT nID )
{
    int nButton = nID - IDC_BUTTON1;
    ASSERT( nButton >= 0 && nButton < 10 );
    // ...
}


0
 
LVL 4

Author Comment

by:n_fortynine
ID: 8236653
It's working. Thanx, I really appreciate your help Larry.
=)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

801 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