unitfrmmain.pas

来自「《Delphi实用程序100例》配套书源码盘」· PAS 代码 · 共 56 行

PAS
56
字号
unit unitFrmMain;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    rgExit: TRadioGroup;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  case rgexit.itemindex of
    0: exitwindowsex(ewx_logoff, 0); //注销当前用户并重新登录
    1: exitwindowsex(ewx_reboot, 0); //关闭Windows并重新启动
    2: exitwindowsex(ewx_shutdown, 0); //关闭Windows
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Close;
end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  if messagedlg('是否允许关闭?', mtconfirmation, mbokcancel, 0) = mrok then
    Canclose := True
  else
    Canclose := False;
end;
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?