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. code path for DoModal

code path for DoModal

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
7 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    My Cdialog (modeless) is looking for some user input Therefore the modal dialog I want to save and process the input so to get the info I do a DoModal I save the info in the modal CDialog Class (created on the stack) when myokhandler returns (this is only when the user press "X" in the right hand window corner) It return to the CDialog procedure that called the DoModal however the data doesn't seem to be valid Isn't the storage for modal dialog still intact till I do the EndDialog ?

    V 1 Reply Last reply
    0
    • F ForNow

      My Cdialog (modeless) is looking for some user input Therefore the modal dialog I want to save and process the input so to get the info I do a DoModal I save the info in the modal CDialog Class (created on the stack) when myokhandler returns (this is only when the user press "X" in the right hand window corner) It return to the CDialog procedure that called the DoModal however the data doesn't seem to be valid Isn't the storage for modal dialog still intact till I do the EndDialog ?

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      ForNow wrote:

      ... this is only when the user press "X" in the right hand window corner

      When the user press "X" in the right hand window corner no data from dialog controls are read in the control data variables. It is by design. If you'd like to change this default behavior then you had to override the OnCancel method.

      F 1 Reply Last reply
      0
      • V Victor Nijegorodov

        ForNow wrote:

        ... this is only when the user press "X" in the right hand window corner

        When the user press "X" in the right hand window corner no data from dialog controls are read in the control data variables. It is by design. If you'd like to change this default behavior then you had to override the OnCancel method.

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        The data was saved in the Class/Object storage in my Onok handler Does it not remain intact till I do the EndDialog which I do from the routine which did the the DoModal ?

        L D 2 Replies Last reply
        0
        • F ForNow

          The data was saved in the Class/Object storage in my Onok handler Does it not remain intact till I do the EndDialog which I do from the routine which did the the DoModal ?

          L Offline
          L Offline
          leon de boer
          wrote on last edited by
          #4

          The Data is probably still there you have blown the stack I suspect. Read the documentation again CDialog::OnCancel[^] Read it carefully because it is very specific.

          If you implement the Cancel button in a modeless dialog box, you must override the OnCancel method and call DestroyWindow inside it. Do not call the base-class method, because it calls EndDialog, which will make the dialog box invisible but not destroy it.

          So your Dialog when cancelled will be invisible and not destroyed and I suspect your stack just got toasted hence the reason for the big warning. So do what it asks override the OnCancel method calling DestroyWindow inside it because there is a reason the framework requires that and I am guessing not doing it will be a very bad idea. I can't tell you why it has to do that it is something to do with the framework implementation.

          In vino veritas

          1 Reply Last reply
          0
          • F ForNow

            The data was saved in the Class/Object storage in my Onok handler Does it not remain intact till I do the EndDialog which I do from the routine which did the the DoModal ?

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

            ForNow wrote:

            The data was saved in the Class/Object storage in my Onok handler

            So the OnOK() method is being called when you click the "X" in the upper-right corner?

            "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

            "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

            L 1 Reply Last reply
            0
            • D David Crow

              ForNow wrote:

              The data was saved in the Class/Object storage in my Onok handler

              So the OnOK() method is being called when you click the "X" in the upper-right corner?

              "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

              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

              L Offline
              L Offline
              leon de boer
              wrote on last edited by
              #6

              No David its a Modeless dialog pressing the Ok button doesn't close the dialog like on a normal modal dialog. To close the dialog right now he is using the "X" in the upper-right corner. He is probably going to put some other button on screen to exit but its a stock standard modeless dialog. His comment above makes perfect sense in that light, he put data in a structure shouldn't it still be there and the answer is normally yes. The problem is his exit he is doing isn't as per what the framework manual specifies for modeless dialogs. The framework specifies the exit for a reason, hence its a good guess the problem is ... and bad things are happening :-)

              In vino veritas

              D 1 Reply Last reply
              0
              • L leon de boer

                No David its a Modeless dialog pressing the Ok button doesn't close the dialog like on a normal modal dialog. To close the dialog right now he is using the "X" in the upper-right corner. He is probably going to put some other button on screen to exit but its a stock standard modeless dialog. His comment above makes perfect sense in that light, he put data in a structure shouldn't it still be there and the answer is normally yes. The problem is his exit he is doing isn't as per what the framework manual specifies for modeless dialogs. The framework specifies the exit for a reason, hence its a good guess the problem is ... and bad things are happening :-)

                In vino veritas

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

                leon de boer wrote:

                No David its a Modeless dialog pressing the Ok button doesn't close the dialog like on a normal modal dialog.

                As long as that method calls DestroyWindow() rather than CDialog::OnOK() (which internally calls CDialog::EndDialog()), the dialog will close just fine.

                leon de boer wrote:

                He is probably going to put some other button on screen to exit but its a stock standard modeless dialog.

                There is no standard that dictates what UI element is used to close a modeless dialog. It could be Esc, the "X", Alt+F4, or a Cancel/Close button. Instead, it's what the code behind those elements do that's important. I'm well aware of how modal and modeless dialogs behave. My question was not because I wanted to know the answer to something; it was instead asked to make the OP reconsider his design. Clicking the "X" button should call OnCancel() method.

                "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

                "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                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