-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dlgDOBPicker.pas
59 lines (49 loc) · 1.29 KB
/
dlgDOBPicker.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
unit dlgDOBPicker;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.WinXCalendars, System.DateUtils,
Vcl.StdCtrls;
type
TDOBPicker = class(TForm)
CalendarView1: TCalendarView;
btnOk: TButton;
procedure btnOkClick(Sender: TObject);
procedure CalendarView1DblClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
DOBPicker: TDOBPicker;
implementation
{$R *.dfm}
procedure TDOBPicker.btnOkClick(Sender: TObject);
begin
ModalResult := mrOk;
end;
procedure TDOBPicker.CalendarView1DblClick(Sender: TObject);
var
d1, d2: TDateTime;
begin
// Sometimes a double click can produce a null result?
// To produce a reliable result - assignment needed
// TControl may be threaded and CalendarView1.Date isn't read correctly
// when used inline.
d1 := Date();
d2 := CalendarView1.Date;
if (WithinPastYears(d1, d2, 99)) then
ModalResult := mrOk;
end;
procedure TDOBPicker.FormKeyDown(Sender: TObject; var Key: Word; Shift:
TShiftState);
begin
if key = VK_ESCAPE then
begin
ModalResult := mrCancel;
Key := 0;
end;
end;
end.