DateGadget()
Syntax
Result = DateGadget(#Gadget, x, y, Width, Height [, Mask$ [, Date [, Flags]]])Description
Creates a String gadget in the current GadgetList, in which a date and/or time can be entered. This gadget uses the same date format for its functions as used by the Date library. So you can use for example FormatDate() to display the results you get from GetGadgetState() in a proper format. If #PB_Any is used as '#Gadget' parameter, the new gadget number will be returned as 'Result'. #Gadget will be the numeric number returned by the EventGadget() command.
With the optional Mask$ parameter you can specify the format in which the date can be entered. See FormatDate() for the format of this mask. Important note: The gadget does not support the display of seconds, so if you specify "%ss" in the Mask$ parameter, it will simply be ignored! If you don't specify the mask or specify an empty string, a default mask will be choosen. The mask can be modified with the SetGadgetText() command. With the optional Date parameter you can set the displayed date to any date of your choise. Not specifying it or specifying a 0 value will display the current date. By default, the gadget has a button to display a calendar in which the user can choose a date (see image below). You can change this by specifying #PB_Date_UpDown in the Flags parameter. This will make the gadget display an up/down button that lets the user change the current selected part of the gadget.
If you specify #PB_Date_Checkbox in the Flags parameter, the Gadget will have a checkbox with which the user can set the Gadget to 'no date' (if the checkbox is unchecked). While the checkbox is unchecked, GetGadgetState() will return 0. To change the state of the checkbox, use SetGadgetState() with either 0 (=checkbox unchecked) or any valid date (=checkbox checked).
You can add a 'mini help' to this gadget by using GadgetToolTip().
The following commands can be used for this gadget:
- SetGadgetState(): Set the currently displayed date.
- SetGadgetText(): Change the input mask of the gadget.
- GetGadgetState(): Get the currently displayed date.
- GetGadgetText(): Get the current displayed date as a string, as it is displayed in the gadget.
- GetGadgetAttribute(): With the following attributes:#PB_Date_Minimum: Get the minimum date that can be entered #PB_Date_Maximum: Get the maximum date that can be entered- SetGadgetAttribute(): With the following attributes:#PB_Date_Minimum: Set the minimum date that can be entered #PB_Date_Maximum: Set the maximum date that can be entered
This gadget supports the SetGadgetColor() and GetGadgetColor() commands with the following values as 'ColorType' to color the dropdown calendar (the edit area cannot be colored):#PB_Gadget_BackColor : backgroundcolor #PB_Gadget_FrontColor : textcolor for displayed days #PB_Gadget_TitleBackColor : backgroundcolor of the month title #PB_Gadget_TitleFrontColor: textcolor of the month title #PB_Gadget_GrayTextColor : textcolor for days not of the current monthExample:If OpenWindow(0, 0, 0, 200, 250, "DateGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) If CreateGadgetList(WindowID(0)) DateGadget(0, 10, 10, 180, 25, "Date: %mm/%dd/%yyyy Time: %hh:%ii") Repeat: Until WaitWindowEvent() = #PB_Event_CloseWindow EndIf EndIf
Supported OS
All