📄 ubase.pas
字号:
unit UBase;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, UPublic;
type
TFBase = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShortCut(var Msg: TWMKey; var Handled: Boolean);
procedure NumKeyPress(Sender: TObject; var Key: Char);
procedure FloatKeyPress(Sender: TObject; var Key: Char);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure NoKeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
private
{ Private declarations }
public
{ Public declarations }
end;
var
FBase: TFBase;
implementation
{$R *.DFM}
procedure TFBase.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
Release;
end;
procedure TFBase.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
begin
{ if ActiveControl=nil then Exit;
if (Msg.CharCode=38) and ((ActiveControl is TEdit) or
(ActiveControl is TDBEdit) or (ActiveControl is TMaskEdit)) then
SelectNext(ActiveControl,False,True); }
if ActiveControl=nil then Exit;
if (Msg.CharCode=40) and (ActiveControl is TCustomComboBox) then
with (ActiveControl as TCustomComboBox) do
if ItemIndex=Items.Count-1 then
begin
ItemIndex:= 0;
Handled:= True;
Exit;
end else if not (ActiveControl as TCustomComboBox).DroppedDown then
(ActiveControl as TCustomComboBox).DroppedDown := True;
if (Msg.CharCode=107) {or ((Msg.CharCode=38) and not (ActiveControl is TCustomComboBox))} then
begin
SelectNext(ActiveControl,False,True);
Handled:= True;
end;
if (Msg.CharCode=13)and not(ActiveControl is TButton) then SelectNext(ActiveControl,True,True)
else if (Msg.CharCode=43)and(ActiveControl is TCustomComboBox) then
begin
SelectNext(ActiveControl,False,True);
Msg.CharCode:=0;
end;
end;
procedure TFBase.NumKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) and (Key<>#8) then Key := #0;
end;
procedure TFBase.FloatKeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in ['0'..'9']) and (Key<>'.') and (Key<>#8) then Key := #0;
end;
procedure TFBase.FormKeyPress(Sender: TObject; var Key: Char);
begin
if (Key=#13)and not(ActiveControl is TButton) then SelectNext(ActiveControl,True,True)
else if (Key='+')and(ActiveControl is TCustomComboBox) then
begin
SelectNext(ActiveControl,False,True);
key:= #0;
end;
end;
procedure TFBase.NoKeyPress(Sender: TObject; var Key: Char);
begin
Key:= #0;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -