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.

Usage with a GeDialog

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

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 设置。 SetBool ( DATETIME_NOW_BUTTON , true );

// 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();

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));

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 );

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 了解更多细节。

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 .

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.

Data Type handled

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

延伸阅读

BFH_LEFT
@ BFH_LEFT
Aligned to the left. 1<<3.
定义: gui.h:306
DateTimeControl::SetDateTime
void SetDateTime(const DateTime &d, Bool bSetDate=true, Bool bSetTime=true)
DATETIME_DATE_CONTROL
#define DATETIME_DATE_CONTROL
Bool true, if it is a calendar.
定义: customgui_datetime.h:29
SizePix
Int32 SizePix(Int32 pixels)
定义: c4d_gui.h:3034
BaseContainer::SetBool
void SetBool(Int32 id, Bool b)
定义: c4d_basecontainer.h:498
DiagnosticOutput
#define DiagnosticOutput(formatString,...)
定义: debugdiagnostics.h:166
FormatTime
String FormatTime(const char *pszFormat, const DateTime &t)
DATETIME_GUI
#define DATETIME_GUI
DateTime custom GUI ID.
定义: customgui_datetime.h:20
String
定义: c4d_string.h:38
DATETIME_TIME_CONTROL
#define DATETIME_TIME_CONTROL
Bool true, if it is a clock.
定义: customgui_datetime.h:28
DateTime
Represents a date and time.
定义: customgui_datetime.h:38
DateTimeControl
定义: customgui_datetime.h:130
DATETIME_SHOW_LABELS
#define DATETIME_SHOW_LABELS
Bool true, to show the "Date" and "Time" labels if the GUI is collapsed.
定义: customgui_datetime.h:32
DateTimeControl::GetDateTime
DateTime GetDateTime() const
FormatString
#define FormatString(...)
定义: string.h:2031
DATETIME_NOW_BUTTON
#define DATETIME_NOW_BUTTON
Bool true, to add "Now" button.
定义: customgui_datetime.h:30
BaseContainer
定义: c4d_basecontainer.h:46
BFV_TOP
@ BFV_TOP
Aligned to the top. 1<<0.
定义: gui.h:298

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1