message BN_CLICKED for button in flexgrid
-
I create a button in a flexgrid, and want to get the BN_CLICKED message of the button. though I add the ON_BN_CLICKED in MESSAGE_MAP,still can't run into onbutton1(). is it the only way that Override OnCommand()? .h class class CProjDlg : public CDialog { ... public: CMSFlexGrid m_FlexGrid; private: CButton m_btn; .... afx_msg void OnButton1(); } #define IDC_MYBUTTON 1999 .cpp creat button BEGIN_MESSAGE_MAP(CProg5Dlg, CDialog) //{{AFX_MSG_MAP(CProg5Dlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BUTTON1, OnButton1) //}}AFX_MSG_MAP END_MESSAGE_MAP() create the button from the flexgrid void CProg5Dlg::InitControls() { .... m_btn.Create("btn",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,CRect(100,40,140,120),&m_FlexGrid,1999); .. } void CProjDlg::OnButton1() { // TODO: Add your control notification handler code here AfxMessageBox("button click"); }