How to allow secondary forms of Delphi behind the main form

If Delphi 2010 or XE Application.MainFormOnTaskbar is set to true, all secondary forms are always in front of the main window. It doesn't matter why the Popupmode or PopupParent properties are set. However, I have secondary windows that I want to show behind the main form.

If I set MainFormOnTaskbar to false, this works, but then the functions of Windows 7 are broken (Alt-tab, Windows panel icon, etc.).

How can I maintain the functionality of Windows 7 while keeping secondary forms hidden behind the main form?

+5
source share
3 answers

, . MainFormOnTaskBar Vista. , .., , z-. D2007 readme:

The property controls how Window TaskBar buttons are handled by VCL. This property can be applied to older applications, but it affects the Z-order of your MainForm, so you should ensure that you have no dependencies on the old behavior.


. , , .

+4

, "" , :

  • , (: = FALSE), "flash" .

  • , , , ( OnClose).

  • - , "" , "- ". , , "" Show, ShowModal.

.

unit FlashForm;
interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;

type
  TFlash = class(TForm)
    lblTitle: TLabel;
    lblCopyright: TLabel;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  public
    procedure CloseApp;
  end;

var
  Flash: TFlash;

implementation

{$R *.dfm}

uses Main;

procedure TFlash.CloseApp;  // Call this from the Main.Form1.OnClose or CanClose (OnFormCloseQuery) event handlers
begin
   close
end;

procedure TFlash.FormCreate(Sender: TObject);  // You can get rid of the standard border icons if you want to
begin
   lblCopyright.Caption := 'Copyright (c) 2016  AT Software Engineering Ltd';
   Refresh;
   Show;
   BringToFront;
end;


procedure TFlash.Timer1Timer(Sender: TObject);
begin
   Application.MainFormOnTaskBar := FALSE;  // This keeps the taskbar icon alive
   if assigned(Main.MainForm) then
   begin
       visible := FALSE;
       Main.MainForm.Show;
       Timer1.Enabled := FALSE;
   end else Timer1.Interval := 10;  // The initial time is longer than this (flash showing time)
end;

end.

// Finally, make this the FIRST form created by the application in the project file.
0

I found a way to solve this problem.

on the *.dpr

change Application.MainFormOnTaskbar := true; inApplication.MainFormOnTaskbar := false;

this will allow you to form the baby form behind the main form.

0
source

All Articles