⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 base.pas

📁 Barcode And LabelPrint
💻 PAS
字号:
unit Base;


interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, Mask, DBCtrls;

type
  TfrmBase = class(TForm)
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  protected
    iModuleID: Integer;
    sFunctionName: string;
    function IsTEdit(): Boolean; virtual;
  public
    constructor CreateWithFunction(AOwner: TComponent; ModuleID: Integer; FunctionName: string);
    { Public declarations }
  end;

var
  frmBase: TfrmBase;

implementation


{$R *.dfm}

constructor TfrmBase.CreateWithFunction(AOwner: TComponent; ModuleID: Integer; FunctionName: string);
begin
  iModuleID := ModuleID;
  sFunctionName := FunctionName;
  inherited Create(AOwner);
end;

function TfrmBase.IsTEdit: Boolean; //是否是编辑框
begin
  if (ActiveControl is TCustomEdit) or
    (ActiveControl is TCustomComboBox) or
    (ActiveControl is TDateTimePicker)
    then Result := True
  else
    Result := False;
end;

procedure TfrmBase.FormKeyPress(Sender: TObject; var Key: Char);
begin
//截获回车键,等效于Tab
  if key = #13 then
  begin
    if IsTEdit then
    begin
      Key := #0;
      Perform(WM_NEXTDLGCTL, 0, 0);
    end
    {else if (ActiveControl is TDBGrid) then
         with TDBGrid(ActiveControl) do
              if selectedIndex < (FieldCount - 1) then
                selectedIndex := selectedIndex + 1
              else
                selectedIndex := 0;
         end;}
  end;
end;

procedure TfrmBase.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := cafree;
end;

end.

⌨️ 快捷键说明

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