About

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.

Usage with a GeDialog

DateTimeControl can be added and used in a GeDialog, more information in GeDialog Manual.

Add a DateTimeControl.

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
BaseContainer settings;
// Activates the now button
settings.SetBool(DATETIME_NOW_BUTTON, true);
// Activates the clock
settings.SetBool(DATETIME_TIME_CONTROL, true);
// Activates the calendar
settings.SetBool(DATETIME_DATE_CONTROL, true);
// Shows the "Date" and "Time" labels if the GUI is collapsed
settings.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();
Int32 SizePix(Int32 pixels)
Definition: c4d_gui.h:3214
Definition: c4d_basecontainer.h:48
void SetBool(Int32 id, Bool b)
Definition: c4d_basecontainer.h:572
Definition: customgui_datetime.h:131
#define DATETIME_GUI
DateTime custom GUI ID.
Definition: customgui_datetime.h:20
#define DATETIME_DATE_CONTROL
Bool true, if it is a calendar.
Definition: customgui_datetime.h:29
#define DATETIME_TIME_CONTROL
Bool true, if it is a clock.
Definition: customgui_datetime.h:28
#define DATETIME_SHOW_LABELS
Bool true, to show the "Date" and "Time" labels if the GUI is collapsed.
Definition: customgui_datetime.h:32
#define DATETIME_NOW_BUTTON
Bool true, to add "Now" button.
Definition: customgui_datetime.h:30
@ BFV_TOP
Aligned to the top. 1<<0.
Definition: gui.h:304
@ BFH_LEFT
Aligned to the left. 1<<3.
Definition: gui.h:312

Access

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().

// Retrieves the gadget added with FindCustomGui. The GUI object must have been previously added with AddCustomGui()
// Creates a pointer to the gadget
DateTimeControl* dateTimeGadget = static_cast<DateTimeControl*>(FindCustomGui(dateTimeID, DATETIME_GUI));
if (dateTimeGadget == nullptr)
return false;
// 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));
Definition: c4d_string.h:39
DateTime GetDateTime() const
String FormatTime(const char *pszFormat, const DateTime &t)
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
#define FormatString(...)
Definition: string.h:2112
Represents a date and time.
Definition: customgui_datetime.h:39

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);
void SetDateTime(const DateTime &d, Bool bSetDate=true, Bool bSetTime=true)

Usage with a parameter description

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 more details.

Resource

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.

See Description Resource for more information about description resource.
See Dialog Resource for more information about dialog resource.

Settings

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.
See Description Settings Manual for more information about settings.

Data Type handled

DateTimeControl can handle DateTimeData. For more information, see DateTimeData Manual.

Further Reading