在打开模式窗体时,按照Windows Show desktop命令最小化应用程序

时间:2015-07-30 06:23:20

标签: delphi modal-dialog delphi-2009

我有一个多表单应用程序,并使用ShowModal打开我的一个表单。有没有办法在Windows中显示Show Desktop命令时最小化整个应用程序?

P.S。 Delphi 2009,Win 7

我的代码:

unit Unit1;

interface

uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
     Form2.ShowModal;
end;

end.
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm2 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

end.

DPR:

program Project1;

uses
  ExceptionLog,
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Unit2 in 'Unit2.pas' {Form2};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.Run;
end.

1 个答案:

答案 0 :(得分:1)

我只是在D2007和Win 8.1上尝试过它无论是否按下按钮都表现得如此。也许你的Windows本身存在问题。我注意到你在dpr文件中有使用ExceptionLog 。 - 这将是罪魁祸首。