TCalendarDialog: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | **TCalendarDialog**  is a dialog that aids in selecting a date from a calendar. It can be found on the [[Dialogs tab]] of the [[Component Palette]]. | |
| 2 | 2 | ||
| 3 | - | ||
| 4 | - | ||
| 5 | - | ||
| 6 | - | ||
| 3 | + |  | |
| 7 | 4 | ||
| 8 | 5 | The Execute [[Method|method]] displays the calendar dialog. It returns [[True|true]] when user has selected date, [[False|false]] when user has aborted. | |
| 9 | 6 | ||
| 10 | 7 | ## Example | |
| 11 | 8 | ||
| 12 | 9 | 1. From the menu choose Project/New Project… | |
| 13 | 10 | 2. Place a TCalendarDialog widget  on your [[TForm|form]].\ | |
| 14 | 11 | It can be placed anywhere as it is not visible during program [[runtime|run time]] but only during design time. \<br \\\>  \<br \\\> It is located on the [[Dialogs tab]] of the [[Component Palette|component palette]]\ | |
| 15 | 12 | 3. Add a [[TButton|button]]  in the form. | |
| 16 | 13 | 4. The [[IDE Window: Object Inspector|Object Inspector]] will display the properties of the object Button1. Click on the Events tab on the Object Inspector. Select the box to the right of OnClick: a smaller box with three dots (... ellipsis) appears. Click on this, you are taken automatically into the Source Editor and your cursor will be placed in a piece of code starting. | |
| 17 | 14 | 5. Completion code: | |
| 18 | 15 | ||
| 19 | 16 | ``` pascal | |
| 20 | 17 | uses | |
| 21 | 18 | ExtDlgs, // for the CalendarDialog | |
| 22 | 19 | Calendar; // for the DisplaySettings and FirstDayOfWeek enumerations | |
| 23 | 20 | ||
| 24 | 21 | procedure TForm1.Button1Click(Sender: TObject); | |
| 25 | 22 | var | |
| 26 | 23 | dt: TDate; | |
| 27 | 24 | begin | |
| 28 | 25 | CalendarDialog1.Date := Now; | |
| 29 | 26 | CalendarDialog1.Title := 'Select a date'; | |
| 30 | 27 | CalendarDialog1.DisplaySettings := [dsShowWeekNumbers]; | |
| 31 | 28 | CalendarDialog1.FirstDayOfWeek := dowMonday; // in Laz 3.99+ | |
| 32 | 29 | if CalendarDialog1.Execute then | |
| 33 | 30 | begin | |
| 34 | 31 | dt := CalendarDialog1.Date; | |
| 35 | 32 | ShowMessage('The selected date is ' + FormatDateTime('yyyy-mm-dd', dt)); | |
| 36 | 33 | end | |
| 37 | 34 | else | |
| 38 | 35 | ShowMessage('Today is ' + FormatDateTime('yyyy-mm-dd', dt)); | |
| 39 | 36 | end; | |
| 40 | 37 | ``` | |
| 41 | 38 | ||
| 42 | 39 | ## See also | |
| 43 | 40 | ||
| 44 | 41 | - [[doc:lcl/dialogs/tcalendardialog.html|TCalendarDialog doc]] | |
| 45 | 42 | - [[TDBDateTimePicker]] | |
| 46 | 43 | - [[TDateTimePicker]] | |
| 47 | 44 | - [[TDateEdit]] | |
| 48 | 45 | - [[TTimeEdit]] | |
| 49 | 46 | - [[TDateTime]] | |
| 50 | 47 | ||
| 51 | 48 | --- | |
| 52 | 49 | *From the Free Pascal wiki, page "TCalendarDialog", as it stood on 2023-09-09 after a change by Wp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
