Dialog Box Problems
-
Hello, I want to make a dialog based application that requires the user to enter a username and password to enter. So in the constructor of the Dialog box class of my application I create a child dialog login box. What I want to do is that if the user presses Cancel on the child login box, then the Application ends. So to do this do I need to call the OnCancel method of the parent dialog box? if yes then how do I call it? Is there a better way to do this? Thanks, Mike.
-
Hello, I want to make a dialog based application that requires the user to enter a username and password to enter. So in the constructor of the Dialog box class of my application I create a child dialog login box. What I want to do is that if the user presses Cancel on the child login box, then the Application ends. So to do this do I need to call the OnCancel method of the parent dialog box? if yes then how do I call it? Is there a better way to do this? Thanks, Mike.
You need to get the value that returns the Dialog. In DoModal returns the Identificator of the button that the user presed. For Ok returns IDOK for Cancel returns IDCANCEL. You must to put this function in the OnInitDialog().... Is easy.... Best Regards!!!! Carlos Antollini.
-
Hello, I want to make a dialog based application that requires the user to enter a username and password to enter. So in the constructor of the Dialog box class of my application I create a child dialog login box. What I want to do is that if the user presses Cancel on the child login box, then the Application ends. So to do this do I need to call the OnCancel method of the parent dialog box? if yes then how do I call it? Is there a better way to do this? Thanks, Mike.
You should do that in OnInitDialog() instead, because at that time the first dialog is created but not yet shown.
BOOL CMainDialog::OnInitDialog()
{
CPasswordDialog pwdDlg;if ( IDCANCEL == pwdDlg.DoModal() )
EndDialog(IDCANCEL);
...
}--Mike-- http://home.inreach.com/mdunn/ #include "witty_sig.h" :love: your :bob: with :vegemite: and :beer:
-
You should do that in OnInitDialog() instead, because at that time the first dialog is created but not yet shown.
BOOL CMainDialog::OnInitDialog()
{
CPasswordDialog pwdDlg;if ( IDCANCEL == pwdDlg.DoModal() )
EndDialog(IDCANCEL);
...
}--Mike-- http://home.inreach.com/mdunn/ #include "witty_sig.h" :love: your :bob: with :vegemite: and :beer:
Shall I create the child dialog box in the constructor of the Main Dialog box or in the OnInitDialog? When I created it in the OnInitDialog then after I closed the Main Dialog Box I could still see the image of the child dialog box (not the box though). This does not happen when I create the child dialog box in the constructor of the Main Dialog Box. Any explanations?