Adding third choice to OK and CANCEL buttons in dialog window
-
Using Visual C++ 6.0 MFC in SDI application I created a dialog window. After the user enters data, he can select OK or CANCEL and the window automatically closes. I wanted to add a button called "TEST" to this same dialog. When the user clicks on the "TEST" button, I want to automatically close this dialog window just as it happens when he clicks OK or CANCEL. But I don't know how to set things up to do that. Thanks!
-
Using Visual C++ 6.0 MFC in SDI application I created a dialog window. After the user enters data, he can select OK or CANCEL and the window automatically closes. I wanted to add a button called "TEST" to this same dialog. When the user clicks on the "TEST" button, I want to automatically close this dialog window just as it happens when he clicks OK or CANCEL. But I don't know how to set things up to do that. Thanks!
In your test button handler call
CDialog::OnOK();
Then your dialog will be closed automatically. :) Actually the
CDialog::OnOK()
callsUpdateData()
to update data from controls to member variables and callsEndDialog()
to close the dialog. Regards, Jijo._____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
-
In your test button handler call
CDialog::OnOK();
Then your dialog will be closed automatically. :) Actually the
CDialog::OnOK()
callsUpdateData()
to update data from controls to member variables and callsEndDialog()
to close the dialog. Regards, Jijo._____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
Thanks a lot. That was incredibly simple! Thanks again!
-
In your test button handler call
CDialog::OnOK();
Then your dialog will be closed automatically. :) Actually the
CDialog::OnOK()
callsUpdateData()
to update data from controls to member variables and callsEndDialog()
to close the dialog. Regards, Jijo._____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.
or CDialog::OnCancel if the datas don't have to be saved :P
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.
-
or CDialog::OnCancel if the datas don't have to be saved :P
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.
-
Using Visual C++ 6.0 MFC in SDI application I created a dialog window. After the user enters data, he can select OK or CANCEL and the window automatically closes. I wanted to add a button called "TEST" to this same dialog. When the user clicks on the "TEST" button, I want to automatically close this dialog window just as it happens when he clicks OK or CANCEL. But I don't know how to set things up to do that. Thanks!
Well you can insert a button to your dialog box and insert OnOK() or EndDialog() on this button.