6

如果在 Delphi 2010 或 XE Application.MainFormOnTaskbar 中设置为 true,则所有辅助窗体始终位于主窗口的前面。Popupmode 或 PopupParent 属性设置为什么并不重要。但是,我希望能够在主窗体后面显示辅助窗口。

如果我将 MainFormOnTaskbar 设置为 false 它可以工作,但是 Windows 7 功能被破坏(Alt-tab、Windows 栏图标等)。

如何保持 Windows 7 功能正常工作,同时仍允许辅助窗体隐藏在主窗体后面?

4

3 回答 3

4

基本上你不能。关键MainFormOnTaskBar是要有Vista的兼容性。如果你不设置它,兼容性就消失了..,如果你设置它,z-order就完成了。以下摘自 D2007 的自述文件:

The property controls how Window's 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.


但是请参阅此QC 报告,它描述了完全相同的问题(并以AsDesigned的形式关闭)。该报告指出了一种解决方法,涉及覆盖CreateParams表单以将其设置WndParent为“0”。它还描述了此解决方法导致的一些问题以及这些问题的可能解决方法。请注意,要找到并解决所有并发症并不容易/不可能。请参阅 Steve Trefethen 的文章以了解可能涉及的内容。

于 2010-11-22T01:03:43.580 回答
0

我原以为一种方法是使用“幕后”主要形式,它仅用于以下目的:

  1. 选择并显示其他表单之一作为主要表单,然后像老式的“flash”屏幕一样永久隐藏自身(Visible:=FALSE)。

  2. 当它选择作为主窗体的窗体关闭时充当应用程序终止器(只需连接适当的 OnClose 事件)。

  3. 代表指定的伪主窗体打开其他窗体,使得隐藏的真正主窗体是其他窗体的“所有者”,而不是“伪主窗体”。如果您的所有其他表单都具有“非”弹出式样式并且通过 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.
于 2016-11-08T02:46:46.090 回答
0

我找到了解决这个问题的方法。

*.dpr

改为 Application.MainFormOnTaskbar := true; _ Application.MainFormOnTaskbar := false;

这将允许您在主窗体后面的子窗体。

于 2019-10-04T03:03:37.150 回答