gpt4 book ai didi

forms - Delphi应用程序表单在启动时显示而不是隐藏

转载 作者:行者123 更新时间:2023-12-03 15:50:30 24 4
gpt4 key购买 nike

我有一个程序,它不会最小化启动并在桌面上显示一个非常小的窗口。

图片:/image/aFc6o.jpg

代码:

程序:

program Project4;

uses
Forms,
Unit4 in 'Unit4.pas' {Form4};

{$R *.res}

begin
Application.Initialize;
Application.MainFormOnTaskbar := false;
Application.ShowMainForm:=false;
Application.CreateForm(TForm4, Form4);
Application.Run;
end.

单位:

unit Unit4;

interface

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

type
TForm4 = class(TForm)
TrayIcon1: TTrayIcon;
ApplicationEvents1: TApplicationEvents;
PopupMenu1: TPopupMenu;
Exit1: TMenuItem;
procedure TrayIcon1DblClick(Sender: TObject);
procedure ApplicationEvents1Minimize(Sender: TObject);
procedure ApplicationEvents1Restore(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
procedure Exit1Click(Sender: TObject);
private
{ Private declarations }
fCanClose: Boolean;
public
{ Public declarations }
end;

var
Form4: TForm4;

implementation

{$R *.dfm}

procedure TForm4.ApplicationEvents1Minimize(Sender: TObject);
begin
Hide();
WindowState := wsMinimized;
end;

procedure TForm4.ApplicationEvents1Restore(Sender: TObject);
begin
Show();
WindowState := wsNormal;
application.Bringtofront;
end;

procedure TForm4.Exit1Click(Sender: TObject);
begin
fcanclose:=true;
close;
end;

procedure TForm4.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if not fCanClose then
begin
hide;
windowstate:=wsminimized;
CanClose:=false;
end
else
CanCLose:=True;
end;

procedure TForm4.FormCreate(Sender: TObject);
begin
fCanClose:=FALSE;
end;

procedure TForm4.TrayIcon1DblClick(Sender: TObject);
begin
if (windowstate = wsminimized) then
begin
Show;
windowstate := wsnormal;
application.BringToFront;
end
else
begin
hide;
windowstate:=wsminimized;
end;
end;

end.

最佳答案

我创建了您的项目并遇到了同样的问题,直到我将以下代码行更改为True:

Application.MainFormOnTaskbar := True;

现在,该应用程序似乎工作得很好,在隐藏之前没有最小化到桌面的左下角。

关于forms - Delphi应用程序表单在启动时显示而不是隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14227927/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com