unit Unit9;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.WinXPickers,
Vcl.StdCtrls,
Vcl.Buttons;
type
TForm9 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
function MyInpQry(
var ADate: TDate;
var AName:
string): Boolean;
public
end;
var
Form9: TForm9;
implementation
{$R *.dfm}
function TForm9.MyInpQry(
var ADate: TDate;
var AName:
string): Boolean;
var
dlg: TForm;
dp: TDatePicker;
lbl1: TLabel;
lbl2: TLabel;
edt: TEdit;
btn: TBitBtn;
begin
dlg := TForm.Create(Application.MainForm);
dp :=
nil;
lbl1 :=
nil;
lbl2 :=
nil;
edt :=
nil;
btn :=
nil;
try
dlg.BorderStyle := bsDialog;
dlg.Caption := '
My Input Query';
dlg.FormStyle := fsStayOnTop;
dlg.Position := poOwnerFormCenter;
dlg.BorderIcons := [biSystemMenu];
lbl1 := TLabel.Create(dlg);
lbl1.Parent := dlg;
lbl1.Align := alTop;
lbl1.Alignment := taCenter;
lbl1.AlignWithMargins := True;
lbl1.Caption := '
Enter Name';
edt := TEdit.Create(dlg);
edt.Parent := dlg;
edt.Align := alTop;
edt.AlignWithMargins :=true;
lbl2 := TLabel.Create(dlg);
lbl2.Parent := dlg;
lbl2.Align := alTop;
lbl2.Alignment := taCenter;
lbl2.AlignWithMargins := True;
lbl2.Caption := '
Choose Date';
dp := TDatePicker.Create(dlg);
dp.Parent := dlg;
dp.Align := alTop;
dp.AlignWithMargins := True;
btn := TBitBtn.Create(dlg);
btn.Parent := dlg;
btn.Align := alTop;
btn.ModalResult := MrOk;
btn.Kind := bkOK;
btn.Caption := '
Use that.';
btn.AlignWithMargins := True;
lbl1.Top := 0;
edt.Top := 1;
lbl2.Top := 2;
dp.Top := 3;
btn.Top := 4;
dlg.AutoSize := True;
Result := (btn.ModalResult = dlg.ShowModal);
if Result
then
begin
ADate :=
dp.date;
AName := edt.Text;
end;
finally
btn.Free;
dp.Free;
lbl1.Free;
edt.Free;
lbl2.Free;
dlg.Free;
end;
end;
procedure TForm9.Button1Click(Sender: TObject);
var
date: TDate;
s:
string;
begin
if MyInpQry(date, s)
then
MessageBox(0, PChar(s + '
has selected: ' + DateToStr(date)), PChar('
Result'), MB_OK)
else
MessageBox(0, PChar('
Dialog canceled.'), PChar('
Result'), MB_OK);
end;
end.