code path for DoModal
-
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 ?
-
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 ?
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.
-
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.
-
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 ?
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
-
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 ?
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
-
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
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
-
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
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 thanCDialog::OnOK()
(which internally callsCDialog::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