DateTimeControl Manual
DateTimeControl
is the CustomGui element that represents a
DateTimeData
.
DateTimeData
handles date and time, see page_manual_customdata_datetimedata.
In a
GeDialog
it is represented by two fields, one for the date, the other for the time. Both fields can be displayed or only one.
A "now" button can also be added to defines the stored
DateTimeData
to the actual date/time.
The gadget can be maximized and show a calendar and a clock.
DateTimeControl can be added and used in a GeDialog , more information in GeDialog 手册 .
This example shows how to add a DateTimeControl in GeDialog::CreateLayout() using GeDialog::AddCustomGui() .
// This example shows how to add a DateTimeControl in a GeDialog// Activates the clock 设置。 SetBool ( DATETIME_TIME_CONTROL , true );
// Activates the calendar 设置。 SetBool ( DATETIME_DATE_CONTROL , true );
// Shows the "Date" and "Time" labels if the GUI is collapsed 设置。 SetBool ( DATETIME_SHOW_LABELS , true );
// settings.SetBool(DESC_GUIOPEN, true);
// Adds the gadget and store the result in a pointer that we can use later to retrieve the value. dateTimeGUI = static_cast< DateTimeControl * > (AddCustomGui(dateTimeID, DATETIME_GUI , "" _s, BFH_LEFT | BFV_TOP , SizePix (300), SizePix (50), settings)); // dateTimeGUI->SetLayoutMode(LAYOUTMODE_MAXIMIZED); // dateTimeGUI->Redraw();
Accessing the value of a
DateTimeControl
CustomGui gadget is done by using a pointer to this gadget, or by using
GeDialog::FindCustomGui()
if it has been added with
GeDialog::AddCustomGui()
.
DateTime
can be retrieved by using the function
DateTimeControl::GetDateTime()
.
// Gets the DateTime from the Gadget. const DateTime myDateTime = dateTimeGadget-> GetDateTime ();
// Formats the string to a specific pattern String myTimeAsString = FormatTime ( "%A %d %B %G" , myDateTime);
// Outputs results DiagnosticOutput ( "the time is set to @" , FormatString (myTimeAsString));
Setting the value of the gadget is done through a pointer to the gadget and the function DateTimeControl::SetDateTime() .
// This example shows how to set Time and Date to a DateTimeControl// Creates the DateTime for Bill Gate birthday const DateTime timeToSet(1955, 10, 28, 15, 00, 00);
// Retrieves the DateTimeControl gadget DateTimeControl * dateTimeGadget = static_cast< DateTimeControl * > (FindCustomGui(dateTimeID, DATETIME_GUI )); if (dateTimeGadget == nullptr ) return false ;
// Update the date of the gadget but only the date, not the time dateTimeGadget-> SetDateTime (timeToSet, true , false );
DateTimeControl can also be used as a description of a parameter. For a description, a parameter has to be added and the custom GUI defined. See DateTimeData Manual 了解更多细节。
For a description and a dialog resource file, the symbol to add is:
DATETIME
For common flags see page_description_resource::section_descriptionresource_elementflags.
For DateTimeControl flags, see DATETIME .
见
Description Resource
for more information about description resource.
见
Dialog Resource
for more information about dialog resource.
Settings can be defined for extra functionality. Some only make sense in a description.
See page_customgui_resource for a description of the common settings.
见
Description Settings Manual
for more information about settings.
DateTimeControl can handle DateTimeData . For more information, see DateTimeData Manual .