VCL.Windows 10 Calendar Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample shows how to use Windows api.

Location

You can find the Windows 10 Calendar sample project at:

Description

The purpose of this sample is to show how to use the Windows API. As en example, this project uses the WinAPI to access different calendars types.

The sample displays the current system date in the provided language, and displays information of four the different calendar systems: Gregorian, Japanese, Hebrew, and Hijri. The sample uses locales to show the calendar data in different formats.

How to Use the Sample

  1. Navigate to the location given above and open: ProjectCalendar.dproj.
  2. Select 32-bit Windows or 64-bit Windows as target platform.
    Note: This sample is only compatible with Windows 10.
  3. Press F9 or choose Run > Run.
  4. Click the Show Data button to display the information.
  5. You can use the Clear Memo button to wipe the information.
  6. Use the EditLanguage TEdit to change the language by typing for example es-ES or tk-TM.

The EditLanguage TEdit expects the Windows locale name, this is either the language code (ISO_639-1), such as en, es, ar, and so on; or the language code in combination with the country code (ISO 3166-1) such as en-US, es-ES, and ar-SA.

Win10CalendarSample.PNG

Files

File Contains

ProjectCalendar.dproj

The project itself.

FCalendar.dfm

The main VCL form where the components are located.

FCalendar.pas

Used to define and implement the sample.

UCommonTypes.pas

Another unit used to implement the TIteratorArrayOfHstring and TArrayOfHString classes.

Classes

The UCommonTypes.pas unit implements the following classes:

  • The iterator class TIteratorArrayOfHstring.
  • The vector and iterable class TArrayOfHString.

The above two classes implement the interfaces IIterator_1__HSTRING; and IVector_1__HSTRING and IIterable_1__HSTRING respectively.

Implementation

The sample displays the information of the calendars in a TMemo.

TCalendarIdentifiers is used to set the different calendar systems: Gregorian, Japanese, Hebrew, and Hijri.

The sample uses the ICalendar interface to show the current date of the system in the different calendar systems, as well as specific information from the four calendar systems.

Uses

The main units used in this sample are:

  • Winapi.Globalization.pas
  • Winapi.WinRT.pas
  • Winapi.Foundation.Collections.pas

See Also