How to add Event handler to dynamically created Button
-
Hi, I have created Button on my Dialog Box using following code.
CButton *m_myButton;
m_myButton = new CButton();
m_myButton->Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(800,y1,900,(y1+25)),this, 1);How should I add Event handler to this button.
-
Hi, I have created Button on my Dialog Box using following code.
CButton *m_myButton;
m_myButton = new CButton();
m_myButton->Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(800,y1,900,(y1+25)),this, 1);How should I add Event handler to this button.
-
Hi, I have created Button on my Dialog Box using following code.
CButton *m_myButton;
m_myButton = new CButton();
m_myButton->Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(800,y1,900,(y1+25)),this, 1);How should I add Event handler to this button.
one easy way is to create a button at design time, and double click on it to add the handler to know what all is needed.. Otherwise also, it is not a mammoth task. You have to declare a function, define it and add an entry for the button click to the message map. Also you may be interested ON_CONTROL_RANGE
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
modified on Tuesday, April 14, 2009 4:02 AM
-
one easy way is to create a button at design time, and double click on it to add the handler to know what all is needed.. Otherwise also, it is not a mammoth task. You have to declare a function, define it and add an entry for the button click to the message map. Also you may be interested ON_CONTROL_RANGE
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
modified on Tuesday, April 14, 2009 4:02 AM
-
I think you can use CMyButton instead of CButton:
class CMyButton: public CButton{
};you can add Event handler(massage handler) to this class.
Do I need to insert a class for an event?no.
Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )
-
Hi, I have created Button on my Dialog Box using following code.
CButton *m_myButton;
m_myButton = new CButton();
m_myButton->Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(800,y1,900,(y1+25)),this, 1);How should I add Event handler to this button.
You can insert this code on your code and then if you want you can make your button. #define IDC_DYNAMICBUTTON 3000 BEGIN_MESSAGE_MAP(CMFCDlg, CDialog) ON_BN_CLICKED(IDC_DYNAMICBUTTON,&CMFCDlg::OnBnClickedbutton) END_MESSAGE_MAP() void CMFCDlg::OnBnClickedbutton() { } //header file public: afx_msg void OnBnClickedbutton();
Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )