David Heffernan 2366 Posted Monday at 12:09 PM 3 hours ago, dormky said: Yes, and I established that it does it _internally_ and that you don't have a single flag serving two purposes, as you do in Delphi. Well, you don't know how Windows is implemented internally. Not that it matters. Conceptually it's the same mechanism. Share this post Link to post
dormky 3 Posted Monday at 03:21 PM 3 hours ago, David Heffernan said: Well, you don't know how Windows is implemented internally. Not that it matters. Conceptually it's the same mechanism. If they implemented it in the same way (a single flag serving two purposes), I would levy the same critique. With the caveat that it least it doesn't make the API more confusing since it's internal. Whereas as far as I'm aware, Delphi had no obligation to implement it in the same way, although it might have been a volition at the time to do a one-to-one of Windows. Which could be critiqued in itself, of course. Share this post Link to post
Attila Kovacs 637 Posted Monday at 03:46 PM If the "flag" were internal, how would I know its value in the OnCloseQuery() event? Share this post Link to post
David Heffernan 2366 Posted Monday at 08:01 PM 4 hours ago, dormky said: If they implemented it in the same way (a single flag serving two purposes), I would levy the same critique. With the caveat that it least it doesn't make the API more confusing since it's internal. Whereas as far as I'm aware, Delphi had no obligation to implement it in the same way, although it might have been a volition at the time to do a one-to-one of Windows. Which could be critiqued in itself, of course. This makes no sense. It's logically identical. Share this post Link to post
David Schwartz 440 Posted 7 hours ago (edited) On 2/1/2025 at 4:02 AM, David Heffernan said: On 2/1/2025 at 1:33 AM, David Schwartz said: Setting ModalResult can be overridden Really, how ? procedure TMain_form.WebFormClose(Sender: TObject; var Action: TCloseAction); begin Action := caNone; end; Clearly obvious to even the most casual observer, right? Edited 7 hours ago by David Schwartz Share this post Link to post
David Schwartz 440 Posted 7 hours ago On 2/3/2025 at 12:28 AM, dormky said: Of course, I never would have chosen Delphi for a new project. But there's a lot of old 90's projects out there for which it's not cost-effective to move to a more efficient platform, so Delphi sticks around. I use TMS WEB Core to build web apps in Delphi. They run in the browser, and don't require any knowledge of javascript. I'm also learning how to use Latenode to build proxies to 3rd-party services that I can call from my client app so I don't need to implement them in a dedicated back-end service. It's similar to Zapier and Make, but I think more powerful and generalized. Share this post Link to post
dormky 3 Posted 3 hours ago On 2/3/2025 at 9:01 PM, David Heffernan said: This makes no sense. It's logically identical. Sure, and using assembly is logically identical to using C. But for the vast majority of purposes one has a better API wouldn't you say ? Bit of an overkill comparison, but the point stand. The Windows API in this case is better than the Delphi one for reasons already outlined. Share this post Link to post
David Heffernan 2366 Posted 3 hours ago 1 minute ago, dormky said: The Windows API in this case is better than the Delphi one for reasons already outlined. I seem to have lost track. In Delphi you write ModalResult := mrOk; In Windows you write EndDialog(hDlg, ID_OK); Explain why this is better. Because I cannot see it. Mostly I see you having not read the documentation and trying to blame the API design. Share this post Link to post
dormky 3 Posted 3 hours ago 3 hours ago, David Schwartz said: procedure TMain_form.WebFormClose(Sender: TObject; var Action: TCloseAction); begin Action := caNone; end; Clearly obvious to even the most casual observer, right? To note ; the OnFormClose event isn't called when calling Close. However I just discovered there is a CloseModal function, which doesn't set the ModalResult to cancel in the case where the form is modal. It does set ModalResult to 0 in the case where the Action is set to caNone. Again, just a badly designed API. OnFormClose should be called no matter how you close the form. There shouldn't be 3 separates ways of closing the form, there should be one (taking arguments if you do want to manipulate some behavior). And said way should not be manipulating the value I want to return to the caller, as that is app data. This is like having 3 locks on your door, each looking the door in a different way and you can only lock one at a time. Also the second and third lock each turn on a different porch light when you use them after 22:00. Share this post Link to post
David Heffernan 2366 Posted 2 hours ago 1 hour ago, dormky said: Again, just a badly designed API I suggest you try to design a GUI framework that can everything that the VCL can. 1 hour ago, dormky said: To note ; the OnFormClose event isn't called when calling Close. Well, not for modal forms. Which makes David's post hard to fathom. It is called when closing modeless forms. Modal and modeless are very different. Again something that you see in the Windows API. 1 hour ago, dormky said: This is like having 3 locks on your door, each looking the door in a different way It's more like needing different keys to lock your house and your car. Different problems tend to lead to different solutions. The bottom line here is that modal forms run in a dedicated message loop, and modeless forms run in the message loop of their owner. I don't think you appreciate this yet. Writing a raw Win32 program in C in the Petzold style might help you. Share this post Link to post