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

📄 commonfunc.pas

📁 这是一个本人初定的小制作
💻 PAS
字号:
unit CommonFunc;

interface
uses StdCtrls, DB;

procedure ForbitInValidNum(var AKey: Char);
procedure LCShowMessage(AMessage: string; ACaption: string='提示');
function LCConfirmDlg(AMessage: string; ACaption: string='提示'): integer;
function CheckInput(Sender: TObject): boolean;
function GetApplicationPath: string;
function LCConfirmEx(AId, AMsg: string; ACaption: string = '提示'):integer;
procedure PostError(DataSet: TDataSet; E: EDatabaseError;
      var Action: TDataAction);

implementation

uses Windows, Forms, SysUtils, notshowagainfrm;

procedure ForbitInValidNum(var AKey: Char);
begin
  if not((AKey='1') or (AKey='2') or (AKey='') or (AKey='3') or (AKey='4')
    or (AKey='5') or (AKey='6') or (AKey='7') or (AKey='8') or (AKey='9')
    or (AKey='0') or (AKey='.') )then
  begin
    AKey := #0;
  end;
end;
procedure LCShowMessage(AMessage: string; ACaption: string='提示');
begin
  MessageBox(Application.Handle, PChar(AMessage), PChar(ACaption), MB_OK);
end;

function LCConfirmDlg(AMessage: string; ACaption: string='提示'): integer;
begin
  result := MessageBox(Application.Handle, PChar(AMessage),
    PChar(ACaption), MB_YesNo);
end;


function CheckInput(Sender: TObject): boolean;
begin
  result := true;
  if Trim((Sender as TCustomEdit).Text) = '' then
  begin
    LCShowMessage('此栏必须填写', '错误');
    (Sender as TCustomEdit).SetFocus;
    result := false;
  end;
end;

function GetApplicationPath: string;
begin
  result := ExcludeTrailingPathDelimiter(
    ExtractFilePath(Application.ExeName))+'\';
end;

function LCConfirmEx(AId, AMsg: string; ACaption: string = '提示'): integer;
var
  LDlg: TNotShowAgainDlg;
begin
  LDlg := TNotShowAgainDlg.Create(nil);
  LDlg.Caption := ACaption;
  LDlg.Id := AId;
  LDlg.Msg := AMsg;
  result := LDlg.ShowModal;
  FreeAndNil(LDlg);
end;

procedure PostError(DataSet: TDataSet; E: EDatabaseError;
      var Action: TDataAction);
begin
    LCShowMessage(E.Message+'编码重复!');
end;

end.

⌨️ 快捷键说明

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