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. OnInitDialog?

OnInitDialog?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 3 Posters 0 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, 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!

    M D 2 Replies Last reply
    0
    • L Le Quang Long

      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!

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

      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.

      L 1 Reply Last reply
      0
      • L Le Quang Long

        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!

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

        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 see OnInitDialog 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

        L 1 Reply Last reply
        0
        • M Maximilien

          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.

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

          Thanks to your help!

          1 Reply Last reply
          0
          • D David Crow

            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 see OnInitDialog 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

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

            Thanks to your help!

            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