📄 ubasemain.pas
字号:
unit uBaseMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ActnList, ImgList, ComCtrls, IniFiles;
type
TBaseMain = class(TForm)
SysActionList: TActionList;
actClose: TAction;
actArrangeIcons: TAction;
actCascade: TAction;
actTile: TAction;
actCloseAll: TAction;
MainMenu: TMainMenu;
MP31: TMenuItem;
N2: TMenuItem;
W1: TMenuItem;
H1: TMenuItem;
N3: TMenuItem;
actHelp: TAction;
A1: TMenuItem;
C1: TMenuItem;
T1: TMenuItem;
C2: TMenuItem;
N1: TMenuItem;
Img_Base: TImageList;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure OnExecute(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
procedure Save;
procedure Restore;
protected
procedure DoExecute(Sender: TObject); virtual;
procedure InitVars;virtual;
procedure InitObjects;virtual;
procedure CreateObjects;virtual;
procedure FreeObjects;virtual;
procedure SaveToIniFile(IniFile:TIniFile); virtual;
procedure RestoreFromIniFile(IniFile:TIniFile);virtual;
{ Private declarations }
public
end;
TExecuteFunction=procedure of Object ;
var
BaseMain: TBaseMain;
implementation
uses uActionExecute, uGlobal;
{$R *.dfm}
procedure TBaseMain.DoExecute(Sender: TObject);
var
AExecute:TExecuteFunction;
AAddress:pointer;
sMethodName:string;
begin
if (Sender=nil) or (not (Sender is TAction)) then
exit;
AExecute:=nil;
sMethodName:='Do' + Copy(TAction(Sender).Name,4,Length(TAction(Sender).Name));
try
AAddress:= ActionExecute.MethodAddress(sMethodName);
if AAddress<>nil then
begin
@AExecute:= AAddress;
AExecute;
end;
finally
end;
end;
procedure TBaseMain.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
if Application.MainForm.MDIChildCount > 0 then
begin
if Application.MessageBox('请确认是否退出本系统', '提示信息', MB_ICONQUESTION + mb_YesNo) = id_no then
begin
CanClose := False;
end;
end;
end;
procedure TBaseMain.InitObjects;
begin
end;
procedure TBaseMain.InitVars;
begin
end;
procedure TBaseMain.OnExecute(Sender: TObject);
begin
DoExecute(Sender);
end;
procedure TBaseMain.FormCreate(Sender: TObject);
begin
InitVars;
Restore;
CreateObjects;
InitObjects;
end;
procedure TBaseMain.Restore;
var
IniFile:TIniFile;
begin
IniFile :=TIniFile.Create(GetSysIniFileName) ;
try
RestoreFromIniFile(IniFile);
finally
IniFile.free;
end;
end;
procedure TBaseMain.RestoreFromIniFile(IniFile: TIniFile);
begin
if IniFile=nil then Abort;
end;
procedure TBaseMain.Save;
var
IniFile:TIniFile;
begin
IniFile :=TIniFile.Create(GetSysIniFileName) ;
try
SaveToIniFile(IniFile);
finally
IniFile.Free;
end;
end;
procedure TBaseMain.SaveToIniFile(IniFile: TIniFile);
begin
if IniFile=nil then Abort;
end;
procedure TBaseMain.FormDestroy(Sender: TObject);
begin
try
Save;
FreeObjects;
finally
inherited;
end;
end;
procedure TBaseMain.CreateObjects;
begin
end;
procedure TBaseMain.FreeObjects;
begin
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -