📄 u_basefrm.pas
字号:
{ 基础类窗口 Copyright 2004-2008 by 王志红
1、对于 VK_RETURN、 VK_ESCAPE、CTRL+Q 进行处理
}
unit U_Basefrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB;
type
TFrmBase = class(TForm)
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure Formclose(sender: TObject; var Action: TCloseAction);
procedure Formdestory(sender: TObject);
private
{ Private declarations }
FAsChild:Boolean;
FTempParent:TWinControl;
protected
Procedure CreateParams(var Params:TCreateParams);override;
procedure Loaded;override;
public
constructor Create(AOwner:TComponent);overload;override;
constructor Create(AOwner:TComponent;AParent:TWinControl);reintroduce;overload;
//下面的方法必须覆盖,要么返回窗体主菜单,要么返回nil
// function GetFormMenu:TMainMenu;virtual;abstract;
function CanChange:Boolean;virtual;
{ Public declarations }
end;
var
FrmBase: TFrmBase;
implementation
{$R *.dfm}
function TFrmBase.CanChange: Boolean;
begin
result:=true;
end;
constructor TFrmBase.Create(AOwner: TComponent);
begin
FAsChild:=false;
inherited Create(AOwner);
end;
constructor TFrmBase.Create(AOwner: TComponent; AParent: TWinControl);
begin
FAsChild:=true;
FTempParent:=aParent;
inherited Create(AOwner);
end;
procedure TFrmBase.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
if FAsChild then
begin
Params.Style:=Params.Style or WS_CHILD;
end;
end;
//所有子类窗休都继承此方法 ,但有对像不能成功执行,到目前没有找到原因2005-08-10
procedure TFrmBase.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then begin
key:=#0;
perform(wm_NEXTDLGCTL,0,0);
end;
end;
procedure TFrmBase.Loaded;
begin
inherited;
If FAsChild then
begin
align:=alClient;
BorderStyle:=bsNone;
BorderIcons:=[];
Parent:=FTempParent;
Position:=poDefault;
end;
end;
//2005-10-10加上的
procedure TFrmBase.Formclose(sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TFrmBase.Formdestory(sender: TObject);
begin
FrmBase := nil;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -