OnInitDialog?
-
Dear All, I am practicing about creating login Dialog as below: void Login::OnBnClickedOk() { if (m_username == "test" && m_password == "test123"") { AfxMessageBox("You login successfully!"); UpdateData(true); CWnd*pWnd; pWnd = GetDlgItem(IDC_USER); pWnd->SetFocus(); return; } AfxMessageBox("You login incorrectly!"); UpdateData(false); } Please help me write "BOOL Login::OnInitDialog()" function!( because I want to call this login dialog) Thanks!
-
Dear All, I am practicing about creating login Dialog as below: void Login::OnBnClickedOk() { if (m_username == "test" && m_password == "test123"") { AfxMessageBox("You login successfully!"); UpdateData(true); CWnd*pWnd; pWnd = GetDlgItem(IDC_USER); pWnd->SetFocus(); return; } AfxMessageBox("You login incorrectly!"); UpdateData(false); } Please help me write "BOOL Login::OnInitDialog()" function!( because I want to call this login dialog) Thanks!
Huh ? Well, your
Login
dialog should/could be called in the OnInitDialog of the "other" dialog (which I assume is the one that needs to have permission), the one that will call the Login dialog. If you have the "other" dialog : // use the OnInitDialog that will be automatically generated.BOOL COtherDialog::OnInitDialog()
{
BOOL result = CDialog::OnInitDialog();Login loginDialog;
if ( loginDialog.DoModal() == IDOK )
{
// success continue...
}
else
{
// login failed (either bad user/password or user canceled the login dialog.
// for example disable some UI or close the application or something else.
}return result;
}Watched code never compiles.
-
Dear All, I am practicing about creating login Dialog as below: void Login::OnBnClickedOk() { if (m_username == "test" && m_password == "test123"") { AfxMessageBox("You login successfully!"); UpdateData(true); CWnd*pWnd; pWnd = GetDlgItem(IDC_USER); pWnd->SetFocus(); return; } AfxMessageBox("You login incorrectly!"); UpdateData(false); } Please help me write "BOOL Login::OnInitDialog()" function!( because I want to call this login dialog) Thanks!
In this context, calling
UpdateData()
is not serving any useful purpose.Le Quang Long wrote:
Please help me write "BOOL Login::OnInitDialog()" function!
It should have been done for you automatically. If not, right-click the
Login
class and select Properties. In the Properties window, click the Overrides button. Do you seeOnInitDialog
in the list?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Huh ? Well, your
Login
dialog should/could be called in the OnInitDialog of the "other" dialog (which I assume is the one that needs to have permission), the one that will call the Login dialog. If you have the "other" dialog : // use the OnInitDialog that will be automatically generated.BOOL COtherDialog::OnInitDialog()
{
BOOL result = CDialog::OnInitDialog();Login loginDialog;
if ( loginDialog.DoModal() == IDOK )
{
// success continue...
}
else
{
// login failed (either bad user/password or user canceled the login dialog.
// for example disable some UI or close the application or something else.
}return result;
}Watched code never compiles.
Thanks to your help!
-
In this context, calling
UpdateData()
is not serving any useful purpose.Le Quang Long wrote:
Please help me write "BOOL Login::OnInitDialog()" function!
It should have been done for you automatically. If not, right-click the
Login
class and select Properties. In the Properties window, click the Overrides button. Do you seeOnInitDialog
in the list?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
Thanks to your help!