Prvni verze
This commit is contained in:
90
frmInputNum.pas
Normal file
90
frmInputNum.pas
Normal file
@ -0,0 +1,90 @@
|
||||
unit frmInputNum;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
||||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
|
||||
|
||||
type
|
||||
TformInputNum = class(TForm)
|
||||
edtNum: TEdit;
|
||||
edtNum2: TEdit;
|
||||
btnOK: TButton;
|
||||
btnZrusit: TButton;
|
||||
lblPopis2: TLabel;
|
||||
lblPopis1: TLabel;
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
procedure edtNumKeyPress(Sender: TObject; var Key: Char);
|
||||
procedure btnOKClick(Sender: TObject);
|
||||
procedure btnZrusitClick(Sender: TObject);
|
||||
procedure edtNum2KeyPress(Sender: TObject; var Key: Char);
|
||||
private
|
||||
{ Private declarations }
|
||||
public
|
||||
value, value2: Extended;
|
||||
edtPopis, edtPopis2, titulek: string;
|
||||
end;
|
||||
|
||||
var
|
||||
formInputNum: TformInputNum;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.dfm}
|
||||
|
||||
procedure TformInputNum.btnOKClick(Sender: TObject);
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
|
||||
procedure TformInputNum.btnZrusitClick(Sender: TObject);
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TformInputNum.edtNum2KeyPress(Sender: TObject; var Key: Char);
|
||||
begin
|
||||
if (Key=#13) then
|
||||
btnOKClick(Sender);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TformInputNum.edtNumKeyPress(Sender: TObject; var Key: Char);
|
||||
begin
|
||||
if (Key=#13) then
|
||||
if (edtNum2.CanFocus) then
|
||||
edtNum2.SetFocus;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TformInputNum.FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
begin
|
||||
edtNum.Text:= Trim(edtNum.Text);
|
||||
edtNum2.Text:= Trim(edtNum2.Text);
|
||||
if not(TryStrToFloat(edtNum.Text, value)) then
|
||||
value:= -1;
|
||||
if not(TryStrToFloat(edtNum2.Text, value2)) then
|
||||
value2:= -1;
|
||||
Action:= caFree;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TformInputNum.FormShow(Sender: TObject);
|
||||
begin
|
||||
Self.Caption:= titulek;
|
||||
lblPopis1.Caption:= edtPopis;
|
||||
edtNum.Text:= '';
|
||||
lblPopis2.Caption:= edtPopis2;
|
||||
edtNum2.Text:= '';
|
||||
edtNum.SetFocus;
|
||||
end;
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user