Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CALLING A NEW DIALOG

CALLING A NEW DIALOG

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studiohelp
12 Posts 7 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Le Quang Long
    wrote on last edited by
    #1

    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,

    A M D 3 Replies Last reply
    0
    • L Le Quang Long

      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,

      A Offline
      A Offline
      Albert Holguin
      wrote on last edited by
      #2

      How are you trying to call the dialog? ...you have to show some applicable code.

      J 1 Reply Last reply
      0
      • L Le Quang Long

        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,

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        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.

        C L 3 Replies Last reply
        0
        • L Le Quang Long

          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,

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          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 new CDialog-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

          L 3 Replies Last reply
          0
          • M Maximilien

            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.

            C Offline
            C Offline
            Chris Meech
            wrote on last edited by
            #5

            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]

            1 Reply Last reply
            0
            • D David Crow

              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 new CDialog-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

              L Offline
              L Offline
              Le Quang Long
              wrote on last edited by
              #6

              I talking about adding a new dialog the same dialog-based. Thanks,

              1 Reply Last reply
              0
              • D David Crow

                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 new CDialog-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

                L Offline
                L Offline
                Le Quang Long
                wrote on last edited by
                #7

                I talking about adding a new dialog the same dialog-based. I can not call this new dialog! Thanks,

                1 Reply Last reply
                0
                • D David Crow

                  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 new CDialog-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

                  L Offline
                  L Offline
                  Le Quang Long
                  wrote on last edited by
                  #8

                  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,

                  L 1 Reply Last reply
                  0
                  • L Le Quang Long

                    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,

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    • M Maximilien

                      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.

                      L Offline
                      L Offline
                      Le Quang Long
                      wrote on last edited by
                      #10

                      Thank you so much! Please give me your email!

                      1 Reply Last reply
                      0
                      • M Maximilien

                        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.

                        L Offline
                        L Offline
                        Le Quang Long
                        wrote on last edited by
                        #11

                        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

                        1 Reply Last reply
                        0
                        • A Albert Holguin

                          How are you trying to call the dialog? ...you have to show some applicable code.

                          J Offline
                          J Offline
                          JohnCz
                          wrote on last edited by
                          #12

                          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

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups