Einzelnen Beitrag anzeigen

Bodenseematze

Registriert seit: 10. Jul 2023
76 Beiträge
 
#25

AW: Hintergrundform abdunkeln, wenn andere Form Modal geöffnet wird?

  Alt 26. Mai 2025, 15:15
Try a handler for the Screen.OnActiveFormchange event, that may work for your purpose.
I tried this - but it has two problems...
Code:
procedure  TMyForm.ScreenActiveFormChange(
                                    sender_              : TObject );
var
   frmActive        : TCustomForm;
   bIsModal         : Boolean;
   ctrlForeground   : TWinControl;
begin
   ctrlForeground         := FindControl(
                                    Windows.GetForegroundWindow() );

   frmActive              := nil;
   bIsModal               := false;
   if ( Assigned(ctrlForeground) and
        (ctrlForeground is TCustomForm) ) then begin
      frmActive           := TCustomForm( ctrlForeground );
      bIsModal            := ( fsModal in frmActive.FormState );
   end;
...
1.) how do I get if the foreground window is modal?
I find the correct foreground Form in the above code snippet but the FormState never contains fsModal - only fsVisible...
2.) the procedure will not be called if a dialog pops up (e.g. a TPrinterSetupDialog)

EDIT: I even tried to use Screen.OnActiveControlChange - with same result (will also not be called if the modal foreground dialog e.g. is a TPrinterSetupDialog).

Geändert von Bodenseematze (26. Mai 2025 um 15:21 Uhr)
  Mit Zitat antworten Zitat