uses FMX.Platform, FMX.Pickers, FMX.DateTimeCtrls;
procedure TForm1.Button2Click(Sender: TObject);
var
PickerService: IFMXPickerService;
FDateTimePicker: TCustomDateTimePicker;
begin
TPlatformServices.Current.SupportsPlatformService(IFMXPickerService, PickerService);
FDateTimePicker := PickerService.CreateDateTimePicker;
FDateTimePicker.Parent := Button2;
FDateTimePicker.ShowMode := TDatePickerShowMode.psmDate;
FDateTimePicker.Date := Date;
FDateTimePicker.TodayDefault := True;
FDateTimePicker.PreferedDisplayIndex := Screen.DisplayFromPoint(Screen.MousePos).Index;
FDateTimePicker.OnDateChanged := WhenDateChanged;
FDateTimePicker.Show;
end;
procedure TForm1.WhenDateChanged(Sender: TObject; const ADate: TDateTime);
begin
ShowMessage(DateTimeToStr(ADate));
end;
沒有留言:
張貼留言