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

📄 notshowagainfrm.pas

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

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, 
  Buttons, ExtCtrls, IniFiles, CommonFunc;


type
  TNotShowAgainDlg = class(TForm)
    BtnOK: TButton;
    BtnNo: TButton;
    LMsg: TLabel;
    CBNotShowAgain: TCheckBox;
    procedure BtnOKClick(Sender: TObject);
    procedure BtnNoClick(Sender: TObject);
  private
    { Private declarations }
    FConfig: TIniFile;
    FMsg: string;
    FId: string;
    procedure FSetMsg(AValue: string);
    procedure FSetId(AValue: string);
    function IsNeedShow: boolean;
    function GetDefault: integer;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent);override;
    destructor Destroy;override;
    function ShowModal: integer;override;
  published
    property Msg: string read FMsg write FSetMsg;
    property Id: string read FId write FSetId;

  end;

var
  NotShowAgainDlg: TNotShowAgainDlg;

implementation

{$R *.dfm}
const
  CINIFILE ='NotShowAgain.ini';//inifile name
  CISNEEDSHOW = 'IsNeedShow';
  CDEFAULT = 'Default';

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;


constructor TNotShowAgainDlg.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FConfig := TIniFile.Create(GetApplicationPath + CINIFILE);
end;

destructor TNotShowAgainDlg.Destroy;
begin
  FreeAndNil(FConfig);
  inherited Destroy;
end;


function TNotShowAgainDlg.ShowModal: integer;
begin
  if IsNeedShow then
  begin
    result := inherited ShowModal;
  end
  else
  begin
    result := GetDefault;
  end;
end;

procedure TNotShowAgainDlg.FSetMsg(AValue: string);
begin
  FMsg := AValue;
  LMsg.Caption := AValue;
end;

procedure TNotShowAgainDlg.FSetId(AValue: string);
begin
  FId := AValue;
end;

function TNotShowAgainDlg.IsNeedShow: boolean;
begin
  result := FConfig.ReadBool(FId, CISNEEDSHOW, true);
end;

function TNotShowAgainDlg.GetDefault: integer;
begin
   result := FConfig.ReadInteger(FId, CDEFAULT, mrYes);
end;


procedure TNotShowAgainDlg.BtnOKClick(Sender: TObject);
begin
  if CBNotShowAgain.Checked then
  begin
    FConfig.WriteBool(FId, CISNEEDSHOW, false);
    FConfig.WriteInteger(FId, CDEFAULT, (Sender as TButton).ModalResult);
  end;
end;

procedure TNotShowAgainDlg.BtnNoClick(Sender: TObject);
begin
  if CBNotShowAgain.Checked then
  begin
    FConfig.WriteBool(FId, CISNEEDSHOW, false);
    FConfig.WriteInteger(FId, CDEFAULT, (Sender as TButton).ModalResult);
  end;

end;

end.

⌨️ 快捷键说明

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