[Lazarus] How to minimize application showing modal form(s)

Frank Poretzky poretzky at nym.mixmin.net
Sun Apr 13 00:02:27 CEST 2014

Hi Howard,

on Sat, 12 Apr 2014 18:13:08 +0100, you wrote:

>On 12/04/2014 17:06, Frank Poretzky wrote:
>> Is there a way to modify my modal form to get it minimized as well?
>Create your modal form with the main form as its owner, and give it a 
>unique Name at creation.
>In your main form's declaration set up two Application handlers, 
>OnMinimize and OnRestore (of type TNotifyEvent), and hook them up in 
>your main form's OnCreate code.
>In the OnMinimize and OnRestore handler implementations use 
>FindComponent (or some other means) to locate your previously named 
>modal form, and either Hide it or Show it as appropriate.

Apart from FindComponent, which makes an application with lots of
modal windows very complex, I tried various versions of

procedure TFormMain.AppOnRestore( Sender: TObject);
    posit : integer;
    for posit := 0 to Screen.FormCount - 1 do
        if Screen.Forms[ posit].WindowState = wsMinimized
        // if Screen.Forms[ posit].FormState <> [fsFirstShow]
            Screen.Forms[ posit].WindowState := wsNormal;
            // Screen.Forms[ posit].Show; //

with a corresponding AppOnMinimize() procedure. None of them worked
well, especially with the modal sub-sub-form scenario described above.

Many thanks


More information about the Lazarus mailing list