unit U_InputMark;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,
  U_LNG, siComp, siLngLnk, RzButton, Mask, RzEdit, ExtCtrls, RzPanel;

type
  TF_InputMark = class(TForm)
    lng_Forms: TsiLangLinked;
    RzPanel1: TRzPanel;
    pnOkCancel: TRzPanel;
    btOk: TRzBitBtn;
    btCancel: TRzBitBtn;
    lbPrompt: TLabel;
    edValue: TRzEdit;
    btSkip: TRzBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    
  private
    GForm: TForm;
  public
    Constructor Create(AOwner: TComponent; AForm: TForm);
    Destructor Destroy; override;
    function Execute(const ACaption, APrompt: String): Integer;
  end;

  function InputMark(const ACaption, APrompt: String; var AVal: String): Integer;

var
  F_InputMark: TF_InputMark;

implementation

{$R *.dfm}

constructor TF_InputMark.Create(AOwner: TComponent; AForm: TForm);
begin
  GForm := AForm;
  inherited Create(AOwner);
end;

destructor TF_InputMark.Destroy;
begin
  inherited;
end;

function TF_InputMark.Execute(const ACaption, APrompt: String): Integer;
begin
  Result := -1;
  Caption := ACaption;
  if APrompt <> '' then
    lbPrompt.Caption := APrompt;
  Result := ShowModal;
end;

procedure TF_InputMark.FormCreate(Sender: TObject);
begin
  edValue.Text := '';
end;

procedure TF_InputMark.FormShow(Sender: TObject);
begin
  edValue.SetFocus;
end;

function InputMark(const ACaption, APrompt: String; var AVal: String): Integer;
begin
  if F_InputMark = nil then
    F_InputMark := TF_InputMark.Create(Application, nil);

  F_InputMark.edValue.Text := AVal;
  Result := F_InputMark.Execute(ACaption, APrompt);
  if Result = mrOk then
    AVal := F_InputMark.edValue.Text;
end;

end.