头文件 afx_msg void OnBnClickedYourBt(); BEGIN_MESSAGE_MAP(CDataView, CFormView) ON_BN_CLICKED(10000, OnBnClickedYourBt) ON_BN_CLICKED(10001, OnBnClickedYourBt) ON_BN_CLICKED(10002, OnBnClickedYourBt) ..............//大概不能使用循环 END_MESSAGE_MAP()void CXXX::OnBnClickedYourBt() { int id = GetFocus()->GetDlgCtrlID(); switch(id) { case 10000: ... case 10001: ...}}
参考ON_COMMAND_RANGE:如: afx_msg void OnIndexComp(UINT wParam, LONG lParam); ON_COMMAND_RANGE(IDM_VIEW_SETTING_CHART1, IDM_VIEW_SETTING_CHART39, OnIndexComp)
ON_COMMAND_RANGE ON_COMMAND_RANGE( id1, id2, memberFxn )Parametersid1Command ID at the beginning of a contiguous range of command IDs.id2Command ID at the end of a contiguous range of command IDs.memberFxnThe name of the message-handler function to which the commands are mapped.ResUse this macro to map a contiguous range of command IDs to a single message handler function. The range of IDs starts with id1 and ends with id2. Use ON_COMMAND_RANGE to map a range of command IDs to one member function. Use ON_COMMAND to map a single command to a member function. Only one message-map entry can match a given command ID. That is, you can’t map a command to more than one handler. For more information on mapping message ranges, seeHandlers for Message-Map Ranges in Visual C++ Programmer’s
afx_msg void OnBnClickedYourBt();
BEGIN_MESSAGE_MAP(CDataView, CFormView)
ON_BN_CLICKED(10000, OnBnClickedYourBt)
ON_BN_CLICKED(10001, OnBnClickedYourBt)
ON_BN_CLICKED(10002, OnBnClickedYourBt)
..............//大概不能使用循环
END_MESSAGE_MAP()void CXXX::OnBnClickedYourBt()
{
int id = GetFocus()->GetDlgCtrlID();
switch(id)
{
case 10000:
...
case 10001:
...}}
afx_msg void OnIndexComp(UINT wParam, LONG lParam);
ON_COMMAND_RANGE(IDM_VIEW_SETTING_CHART1, IDM_VIEW_SETTING_CHART39, OnIndexComp)
ON_COMMAND_RANGE( id1, id2, memberFxn )Parametersid1Command ID at the beginning of a contiguous range of command IDs.id2Command ID at the end of a contiguous range of command IDs.memberFxnThe name of the message-handler function to which the commands are mapped.ResUse this macro to map a contiguous range of command IDs to a single message handler function. The range of IDs starts with id1 and ends with id2. Use ON_COMMAND_RANGE to map a range of command IDs to one member function. Use ON_COMMAND to map a single command to a member function. Only one message-map entry can match a given command ID. That is, you can’t map a command to more than one handler. For more information on mapping message ranges, seeHandlers for Message-Map Ranges in Visual C++ Programmer’s