📄 ubaseform.pas
字号:
unit uBaseForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
{页面类型}
TFormType = (Std_Form, Qry_Form, CMD_Form);
TBaseForm = class(TForm)
private
FAsChild: Boolean;
FFormType: TFormType;
procedure SetFormType(const Value: TFormType); {页面类型}
{ Private declarations }
protected
{ Protected declarations}
procedure CreateParams(var Params: TCreateParams); override;
procedure Loaded; override;
procedure InitComponent; dynamic;
public
{ Public declarations }
constructor Create(AOwner: TComponent); overload; override;
constructor Create(AOwner: TComponent; AsChild: Boolean); reintroduce; overload;
function CloseForm: Boolean;
procedure DoExecSQL; virtual; abstract; {运行SQL}
procedure DoPrint; virtual; abstract; {打印}
procedure DoPreview; virtual; abstract; {预览}
procedure DoSave; virtual; abstract; {保存}
procedure DoExport; virtual; abstract; {导出}
procedure DoSelectRow; virtual; abstract; {选择显示的列}
procedure DoPrintSetup; virtual; abstract; {打印机设置}
procedure DoPageSetup; virtual; abstract; {页面设置}
property FormType: TFormType read FFormType write SetFormType;
end;
var
BaseForm: TBaseForm;
implementation
{$R *.dfm}
{ TFBaseForm }
procedure TBaseForm.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
if FAsChild then
Params.Style := Params.Style or WS_CHILD;
end;
procedure TBaseForm.Loaded;
begin
inherited;
if FAsChild then
begin
align := alClient;
BorderStyle := bsNone;
BorderIcons := [];
Position := poDefault;
end;
end;
constructor TBaseForm.Create(AOwner: TComponent);
begin
FAsChild := False;
inherited Create(AOwner);
InitComponent;
end;
constructor TBaseForm.Create(AOwner: TComponent; AsChild: Boolean);
begin
FAsChild := AsChild;
inherited Create(AOwner);
InitComponent;
end;
procedure TBaseForm.InitComponent;
begin
with Font do
begin
Name := '宋体';
Charset := GB2312_CHARSET;
Size := 9;
end;
end;
function TBaseForm.CloseForm: Boolean;
var
CloseAction: TCloseAction;
begin
result := False;
if fsModal in FFormState then
begin
ModalResult := mrCancel;
result := true;
end else
if CloseQuery then
begin
if FormStyle = fsMDIChild then
if biMinimize in BorderIcons then
CloseAction := caMinimize else
CloseAction := caNone
else
CloseAction := caFree;
DoClose(CloseAction);
if CloseAction <> caNone then
if Application.MainForm = Self then Application.Terminate
else if CloseAction = caHide then hide
else if CloseAction = caMinimize then WindowState := wsMinimized
else begin Free; result := True; end;
end;
end;
procedure TBaseForm.SetFormType(const Value: TFormType);
begin
FFormType := Value;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -