我定义了个按钮数组CMyButton m_bts[10];
CMyButton中有m_Index标志在数组中的序号,但是怎么响应按钮的Click事件啊,我想这10个按钮都
响应到BT_Click()函数中,谢谢各位

解决方案 »

  1.   

    在BT_Click事件中如何得到是哪个按钮被Click了
      

  2.   

    ON_CONTROL_RANGE
    ON_CONTROL_RANGE( wNotifyCode, id1, id2, memberFxn )ParameterswNotifyCodeThe notification code to which your handler is responding.id1Command ID at the beginning of a contiguous range of control IDs.id2Command ID at the end of a contiguous range of control IDs.memberFxnThe name of the message-handler function to which the controls are mapped.
    ON_CONTROL_RANGE(BN_CLICKED,ID1,ID10,BT_Click)
    BT_Click(UINT nID)这个nID就是按下按钮的ID
      

  3.   

    首先,这些button的id必须是连续的。(在resource.h可以编辑)//xxx.h
    afx_msg void OnBtn(UINT nID);//xxx.cpp
    BEGIN_MESSAGE_MAP(CXXX, CDialog) //{{AFX_MSG_MAP(CXXX)
    //}}AFX_MSG_MAP ON_CONTROL_RANGE(BN_CLICKED, IDC_BTN01, IDC_BTN10, OnBtn)END_MESSAGE_MAP()void CXXX::OnBtn(UINT nID){
        if (nID == IDC_BTN01)
        {
            //BTN1之响应操作 
        }
    }