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. Dialog Box Problems

Dialog Box Problems

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 4 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
    Lost User
    wrote on last edited by
    #1

    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.

    C M 2 Replies Last reply
    0
    • L Lost User

      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.

      C Offline
      C Offline
      Carlos Antollini
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • L Lost User

        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.

        M Offline
        M Offline
        Michael Dunn
        wrote on last edited by
        #3

        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:

        M 1 Reply Last reply
        0
        • M Michael Dunn

          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:

          M Offline
          M Offline
          mvworld
          wrote on last edited by
          #4

          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?

          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