CALLING A NEW DIALOG
-
Dear all everyone, Please help me calling a dialog in project, I am using visual studio 2005(MFC, detail as below: - My project have 2 dialogs(1 dialog to show data, 1 dialog login( user name and password) to protect data dialog) - I created 1 dialog to show data is ok, but when I add a new dialog into this project and can not call dialog). So please help me! Thanks and Best regards,
-
Dear all everyone, Please help me calling a dialog in project, I am using visual studio 2005(MFC, detail as below: - My project have 2 dialogs(1 dialog to show data, 1 dialog login( user name and password) to protect data dialog) - I created 1 dialog to show data is ok, but when I add a new dialog into this project and can not call dialog). So please help me! Thanks and Best regards,
How are you trying to call the dialog? ...you have to show some applicable code.
-
Dear all everyone, Please help me calling a dialog in project, I am using visual studio 2005(MFC, detail as below: - My project have 2 dialogs(1 dialog to show data, 1 dialog login( user name and password) to protect data dialog) - I created 1 dialog to show data is ok, but when I add a new dialog into this project and can not call dialog). So please help me! Thanks and Best regards,
I would do something like : pre-requisite. CLoginDialog: your login dialog. CDataDialog; your main application dialog The CDataDialog is the main application dialog (for example created via the wizard). When the CDataDialog is created, you can call/create the login dialog in the OnInitDialog; if the login is valid, just continue, if it is invalid, you can either close the main application, or better continue but disable some stuff or not load the data. For example ...
BOOL Ctest_dialogDlg::OnInitDialog()
{
CDialog::OnInitDialog();/// ....
LoginDialog dlg;
if ( dlg.DoModal() == IDCANCEL)
{
PostQuitMessage(42);
return FALSE;
}
return TRUE; // return TRUE unless you set the focus to a control
}Watched code never compiles.
-
Dear all everyone, Please help me calling a dialog in project, I am using visual studio 2005(MFC, detail as below: - My project have 2 dialogs(1 dialog to show data, 1 dialog login( user name and password) to protect data dialog) - I created 1 dialog to show data is ok, but when I add a new dialog into this project and can not call dialog). So please help me! Thanks and Best regards,
Le Quang Long wrote:
...but when I add a new dialog into this project...
Are you talking about adding a new dialog template in the project's
.rc
file, or adding a newCDialog
-based class?Le Quang Long wrote:
...and can not call dialog).
Why not? Isn't it just like the other (first) dialog?
"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
-
I would do something like : pre-requisite. CLoginDialog: your login dialog. CDataDialog; your main application dialog The CDataDialog is the main application dialog (for example created via the wizard). When the CDataDialog is created, you can call/create the login dialog in the OnInitDialog; if the login is valid, just continue, if it is invalid, you can either close the main application, or better continue but disable some stuff or not load the data. For example ...
BOOL Ctest_dialogDlg::OnInitDialog()
{
CDialog::OnInitDialog();/// ....
LoginDialog dlg;
if ( dlg.DoModal() == IDCANCEL)
{
PostQuitMessage(42);
return FALSE;
}
return TRUE; // return TRUE unless you set the focus to a control
}Watched code never compiles.
Maximilien wrote:
PostQuitMessage(42);
:thumbsup::thumbsup::thumbsup: Best way to end an application ever. :)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
-
Le Quang Long wrote:
...but when I add a new dialog into this project...
Are you talking about adding a new dialog template in the project's
.rc
file, or adding a newCDialog
-based class?Le Quang Long wrote:
...and can not call dialog).
Why not? Isn't it just like the other (first) dialog?
"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
I talking about adding a new dialog the same dialog-based. Thanks,
-
Le Quang Long wrote:
...but when I add a new dialog into this project...
Are you talking about adding a new dialog template in the project's
.rc
file, or adding a newCDialog
-based class?Le Quang Long wrote:
...and can not call dialog).
Why not? Isn't it just like the other (first) dialog?
"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
I talking about adding a new dialog the same dialog-based. I can not call this new dialog! Thanks,
-
Le Quang Long wrote:
...but when I add a new dialog into this project...
Are you talking about adding a new dialog template in the project's
.rc
file, or adding a newCDialog
-based class?Le Quang Long wrote:
...and can not call dialog).
Why not? Isn't it just like the other (first) dialog?
"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
I talking about adding a new dialog the same dialog-based. I can not call this new dialog( second dialog)! Pls give me a source code(ex)? Thanks,
-
I talking about adding a new dialog the same dialog-based. I can not call this new dialog( second dialog)! Pls give me a source code(ex)? Thanks,
How can we give you source code when we have no idea what your program is doing? If you cannot call a dialog in your program then you need to give a much better explanation, including showing the code that does not work, and explaining what happens when you try.
Binding 100,000 items to a list box can be just silly regardless of what pattern you are following. Jeremy Likness
-
I would do something like : pre-requisite. CLoginDialog: your login dialog. CDataDialog; your main application dialog The CDataDialog is the main application dialog (for example created via the wizard). When the CDataDialog is created, you can call/create the login dialog in the OnInitDialog; if the login is valid, just continue, if it is invalid, you can either close the main application, or better continue but disable some stuff or not load the data. For example ...
BOOL Ctest_dialogDlg::OnInitDialog()
{
CDialog::OnInitDialog();/// ....
LoginDialog dlg;
if ( dlg.DoModal() == IDCANCEL)
{
PostQuitMessage(42);
return FALSE;
}
return TRUE; // return TRUE unless you set the focus to a control
}Watched code never compiles.
Thank you so much! Please give me your email!
-
I would do something like : pre-requisite. CLoginDialog: your login dialog. CDataDialog; your main application dialog The CDataDialog is the main application dialog (for example created via the wizard). When the CDataDialog is created, you can call/create the login dialog in the OnInitDialog; if the login is valid, just continue, if it is invalid, you can either close the main application, or better continue but disable some stuff or not load the data. For example ...
BOOL Ctest_dialogDlg::OnInitDialog()
{
CDialog::OnInitDialog();/// ....
LoginDialog dlg;
if ( dlg.DoModal() == IDCANCEL)
{
PostQuitMessage(42);
return FALSE;
}
return TRUE; // return TRUE unless you set the focus to a control
}Watched code never compiles.
Dear Maximilien, Thank for your feedback! I want to show CLoginDialog(first). After input userID and password successfully, conntinue show CDataDialog(second) and I can type data on this CDataDialog. Best Regards, LQL
-
How are you trying to call the dialog? ...you have to show some applicable code.
I am not sure why check for valid password in OnInitDlg, while it seems that it should be checked before main dialog is invoked. No need for posting any messages to the thread. Besides, log in dialog should not be checked for cancel only but validate password and/or username. This code snippet shows how this can be done:
CLoginDlg loginDlg; loginDlg.DoModal(); INT\_PTR nResponse = loginDlg.DoModal(); if(nResponse == IDCANCEL) { return FALSE; // canceled exit app, terminate } if(loginDlg.m\_csUser.CompareNoCase(lpszUser)) { return FALSE; // no match exit app, terminate } if(loginDlg.m\_csPassword.Compare(lpszPassword)) { return FALSE; // no match exit app, terminate } CMainDlg dlg; m\_pMainWnd = &dlg; INT\_PTR nResponse = dlg.DoModal();
.
.
.JohnCz