[Lazarus] Modal forms: block parent form or application

cobines cobines at gmail.com
Sun Jan 30 00:13:40 CET 2011


2011/1/29 Paul Ishenin <webpirat at mail.ru>:
> 29.01.2011 15:29, cobines wrote:
>>
>> Hello,
>>
>> I have two forms Form1 and Form2. Form1 is MainForm with
>> ShowInTaskbar=stDefault and Form2 has ShowInTaskbar=True, so they both
>> have taskbar buttons, I treat them as separate windows. I show a modal
>> form from Form2 which blocks the whole application. Is it possible to
>> have it block only Form2, so I can still activate and work in Form1?
>
> Yes. You don't need a modal form then.
>
> 1. Change your modal form to be a regular form with PopupParent = Form2.
> 2. Disable Form2 when you show your popup form.
>
> Of course the logic requires a small reimplementation because you can't use
> ModalResult and Show is not a blocking method as ShowModal.

OK, I can do this for some of my forms. I thought maybe there was some
switch so that modal forms do not block application.

But what about dialog boxes with buttons requiring user input? Usually
you want to have result which button was pressed and such dialog boxes
are shown as modal with ModalResult returned. Showing OpenFile dialog,
showing messages with ShowMessage or asking user for input with
InputQuery, all such cases result in all windows in the application
being blocked.

Maybe there should be a change how modal forms are treated and allow
blocking only parent. Or is this also how Delphi does it?

--
cobines




More information about the Lazarus mailing list