Jump to content
dormky

How do I close a modal form without ModalResult being set to mrCancel ?

Recommended Posts

1 hour ago, dormky said:

Then please explain ? I delphi, I write to a variable that is then monitored to close the form. In Window, I call a function. Those two things are completely different.

Imagine if you would read documentation. Like that for EndDialog. And imagine if the documentation for EndDialog said this:

 

 

 

EndDialog does not destroy the dialog box immediately. Instead, it sets a flag and allows the dialog box procedure to return control to the system. The system checks the flag before attempting to retrieve the next message from the application queue. If the flag is set, the system ends the message loop, destroys the dialog box, and uses the value in nResult as the return value from the function that created the dialog box.

 

 

 

So yeah, it's exactly the same as the Delphi mechanism. Because that's how modal dialog are implemented in Windows. 

  • Like 2

Share this post


Link to post
2 hours ago, dormky said:

There's a reason Delphi is a dead language

Not that again!

 

Just remove the f*ck*** call to Close and be done with it.

  • Haha 2

Share this post


Link to post
16 minutes ago, dummzeuch said:

Not that again!

 

Just remove the f*ck*** call to Close and be done with it.

But, the language is dead because he doesn't have to call Close. If he removes the call to Close and suddenly everything works the way it was designed to, then the language may come back to life. Sounds dangerous. 

Edited by Brandon Staggs

Share this post


Link to post
15 hours ago, David Heffernan said:

Imagine if you would read documentation. Like that for EndDialog. And imagine if the documentation for EndDialog said this:

 

 

 

EndDialog does not destroy the dialog box immediately. Instead, it sets a flag and allows the dialog box procedure to return control to the system. The system checks the flag before attempting to retrieve the next message from the application queue. If the flag is set, the system ends the message loop, destroys the dialog box, and uses the value in nResult as the return value from the function that created the dialog box.

 

 

 

So yeah, it's exactly the same as the Delphi mechanism. Because that's how modal dialog are implemented in Windows. 

Yes, but the difference is that the flag is internal. We do not have access to it, nor is it the same as the value returned by ShowModal call.

Again, to close in Windows I call function. In Delphi I set a flag. Fundamentally different things.

Share this post


Link to post
25 minutes ago, dormky said:

Again, to close in Windows I call function. In Delphi I set a flag. Fundamentally different things.

Yes, yes, we see now. How could we have been so blind? Totally different things. Totally!

Now, run along.

  • Thanks 1

Share this post


Link to post
2 hours ago, Anders Melander said:

Yes, yes, we see now. How could we have been so blind? Totally different things. Totally!

Instead of running away from this terrible problem. Anders you should write a class helper to help to solve this gigantic bug in the design. I mean how can we live and use Delphi knowing that it has this very poorly design in the fundamental part of the VCL.

Share this post


Link to post
Just now, Lajos Juhász said:

Instead of running away from this terrible problem. Anders you should write a class helper to help to solve this gigantic bug in the design. I mean how can we live and use Delphi knowing that it has this very poorly design in the fundamental part of the VCL.

I dunno. I think it's pointless. I mean, properties? Pfft! What's the point?

Delphi is dead anyway and if there's one thing the past 30 years has shown it is that the design is flawed beyond repair but we were just too ignorant to notice. If only we had been told about this before. The shame is unbearable.

  • Haha 1

Share this post


Link to post

Hey, bad design doesn't mean it's not useful. I still use a car whose AC is less powerful then a fart lol.

Share this post


Link to post

Luckily Delphi isn't the only IDE out there. Freedom of choice is a thing.

Share this post


Link to post
23 hours ago, dormky said:

Heavy disagree. A message/event driven environment should, you know, actually use events instead of mixing in state monitoring.

The VCL has to work in the API environment that Windows provides. So aim your criticism at Microsoft ;).

Share this post


Link to post
5 hours ago, dormky said:

Yes, but the difference is that the flag is internal. We do not have access to it, nor is it the same as the value returned by ShowModal call.

Again, to close in Windows I call function. In Delphi I set a flag. Fundamentally different things.

Windows API can't expose a flag directly so has to provide a function to set it. You are incapable of learning, no wonder this is so hard for you. 

Share this post


Link to post
24 minutes ago, David Heffernan said:

You are incapable of learning, no wonder this is so hard for you. 

OK, now we go into the domain of personal insults.

Share this post


Link to post

Yeah, I feel the question has been answered. Everybody should now move on...nothing to see here.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×