Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

DEFPUSHBUTTONs

Posted on 2003-03-30
2
Medium Priority
?
192 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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

580 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