addmodu.pas

来自「《Delphi开发人员指南》配书原码」· PAS 代码 · 共 67 行

PAS
67
字号
unit AddModU;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls;

type
  TAddModAction = (amaAdd, amaModify);

  TAddModForm = class(TForm)
    OkBtn: TButton;
    CancelBtn: TButton;
    OpenDialog: TOpenDialog;
    Panel1: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    PathEd: TEdit;
    NameEd: TEdit;
    BrowseBtn: TButton;
    procedure BrowseBtnClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

function AddModWiz(AAction: TAddModAction; var WizName, WizPath: String): Boolean;

implementation

{$R *.DFM}

function AddModWiz(AAction: TAddModAction; var WizName, WizPath: String): Boolean;
{ called to invoke dialog to add and modify registry entries }
const
  CaptionArray: array[TAddModAction] of string[31] =
    ('Add new expert', 'Modify expert');
begin
  with TAddModForm.Create(Application) do       // create dialog
  begin
    Caption := CaptionArray[AAction];            // set caption
    if AAction = amaModify then                  // if modify...
    begin
      NameEd.Text := WizName;                   // init name and
      PathEd.Text := WizPath;                   // path
    end;
    Result := ShowModal = mrOk;                 // show dialog
    if Result then                              // if Ok...
    begin
      WizName := NameEd.Text;                   // set name and
      WizPath := PathEd.Text;                   // path
    end;
    Free;
  end;
end;

procedure TAddModForm.BrowseBtnClick(Sender: TObject);
begin
  if OpenDialog.Execute then
    PathEd.Text := OpenDialog.FileName;
end;


end.

⌨️ 快捷键说明

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