unit1.pas
来自「Delphi实效编程百例的随书源代码 这是其中的程序控制部分」· PAS 代码 · 共 55 行
PAS
55 行
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
const
CM_RESTORE = WM_USER + $1000;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure CreateParams(var Params: TCreateParams); override;
Procedure RestoreRequest(var message: TMessage); message CM_RESTORE;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.CreateParams(var Params: TCreateParams);
//初始化参数
begin
inherited CreateParams(Params);
Params.WinClassName := '我的Delphi程序';
end;
procedure TForm1.RestoreRequest(var message: TMessage);
//判断程序是否已经运行
begin
if IsIconic(Application.Handle) = TRUE then
Application.Restore
else
Application.BringToFront;
end;
procedure TForm1.FormCreate(Sender: TObject);
//得到程序的句柄
begin
Label2.Caption := inttohex(Application.Handle, 8);
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?