Click here to Skip to main content
16,005,038 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralStrange problem with an MFC application Pin
Arvind Pai14-Nov-00 7:58
Arvind Pai14-Nov-00 7:58 
GeneralRe: Strange problem with an MFC application Pin
Erik Funkenbusch14-Nov-00 10:21
Erik Funkenbusch14-Nov-00 10:21 
GeneralRe: Strange problem with an MFC application Pin
28-Nov-00 13:35
suss28-Nov-00 13:35 
GeneralKeyboard dialog Pin
Roger14-Nov-00 4:33
Roger14-Nov-00 4:33 
GeneralRe: Keyboard dialog Pin
14-Nov-00 5:34
suss14-Nov-00 5:34 
GeneralRe: Keyboard dialog Pin
Roger14-Nov-00 8:07
Roger14-Nov-00 8:07 
GeneralRe: Keyboard dialog Pin
Erik Funkenbusch14-Nov-00 10:25
Erik Funkenbusch14-Nov-00 10:25 
GeneralRe: Keyboard dialog Pin
SudhaShriram17-Nov-00 0:41
SudhaShriram17-Nov-00 0:41 
You can create a message map entry as below

ON_CONTROL_RANGE(BN_CLICKED, IDC_BUTTON1, IDC_BUTTON10, OnButtonClicked)

instead of the ON_BN_CLICKED message map entry. Here IDC_BUTTONis is the first button in a set of button having consequtive IDS. and IDC_BUTTON10 is last among them.

The corresponding hadler will look like

void CMyDialog::OnButtonClicked( UINT nID )
{
int nButton = nID - IDC_BUTTON1;
ASSERT( nButton >= 0 && nButton < 10 );
// ...
}

If you dont have the button ids as consequtive integers You can try one more method.

Let me explain that.
Map All the button to one Command Handler. You can do this using the class wizard itself. For all the buttons give the function name the same. Say (OnButtonClicked)

Later inside OnButtonClicked you can code as below;
void CMyDialog::OnButtonClicked()
{
const MSG *x = GetCurrentMessage();
CString ToDisp;
int nID=(int)x->wParam;//WParam gives the command id of the button.
ToDisp.Format("The Id of the button is %d...",nID);
MessageBox(ToDisp);
}

HTH

Sundaravalli Shriram
Tektronix Engineering Development India Ltd,
Bangalore - 560001,
India.
GeneralListCtrl w/ list view style Pin
Thomas Freudenberg14-Nov-00 2:54
Thomas Freudenberg14-Nov-00 2:54 
GeneralCopying vector arrays problem Pin
14-Nov-00 1:08
suss14-Nov-00 1:08 
GeneralRe: Copying vector arrays problem Pin
Erik Funkenbusch14-Nov-00 10:28
Erik Funkenbusch14-Nov-00 10:28 
GeneraliThis's gonna kill the server!! Pin
Baling13-Nov-00 23:39
Baling13-Nov-00 23:39 
GeneralRe: iThis's gonna kill the server!! Pin
14-Nov-00 4:22
suss14-Nov-00 4:22 
GeneralRe: iThis's gonna kill the server!! Pin
David Cunningham14-Nov-00 8:57
cofounderDavid Cunningham14-Nov-00 8:57 
GeneralRe: iThis's gonna kill the server!! Pin
21-Nov-00 3:24
suss21-Nov-00 3:24 
GeneralNTML/Proxy/WinInet/WinSock Pin
13-Nov-00 20:42
suss13-Nov-00 20:42 
Generalnot really a C++ question Pin
13-Nov-00 15:33
suss13-Nov-00 15:33 
GeneralRe: not really a C++ question Pin
14-Nov-00 5:36
suss14-Nov-00 5:36 
GeneralRe: not really a C++ question Pin
14-Nov-00 13:59
suss14-Nov-00 13:59 
GeneralIE favorites and Visual C++ Pin
13-Nov-00 11:27
suss13-Nov-00 11:27 
Generalc++ killer assignment please help Pin
Jimbo Jones13-Nov-00 9:57
Jimbo Jones13-Nov-00 9:57 
GeneralRe: c++ killer assignment please help Pin
Christian Graus13-Nov-00 13:51
protectorChristian Graus13-Nov-00 13:51 
GeneralRe: c++ killer assignment please help Pin
Jimbo Jones13-Nov-00 18:17
Jimbo Jones13-Nov-00 18:17 
GeneralMulti Platform Compatibility Pin
Arvind Pai13-Nov-00 7:42
Arvind Pai13-Nov-00 7:42 
GeneralRe: Multi Platform Compatibility Pin
Anders Molin13-Nov-00 9:47
professionalAnders Molin13-Nov-00 9:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.