Calendar Widget and OCX Replacement¶
Calendar¶
Calendar widget replaces MS Date and Time Picker ActiveX control. It supports these date and time formats: long date, short date, standard time and custom date and time format.
These format styles are given or set via 'FormatStyle' and 'CustomFormat' widget's properties.
- Long date
IfFormatStyle = 0
, then the calendar displays the date in long format. The default format string for this style is defined by the current locale settings of the client,
which produces output like "Saturday, February 1, 2020". - Short date
IfFormatStyle = 1
, then the calendar displays the date in short format. The default format string for this style is defined by the current locale settings of the client,
which produces output like "02/01/20". - Standard Time
IfFormatStyle = 2
, then the calendar displays the standard time. The default format string for this time style is defined by the current locale settings of the client,
which produces output like "10:29:00 AM". - Custom date and time.
IfFormatStyle = 3
, then the calendar displays date and time using the format string specified in the 'CustomFormat' property.
The current implementation supports only the java date and time format specifiers. https://docs.oracle.com/javase/tutorial/i18n/format/simpleDateFormat.html
This is an example of standard format styles with check box and up/down buttons
with unselected checkbox
Attributes¶
Attribute Name | OCX Name | Handle Type | Return Type | Read Only | Default | Description |
---|---|---|---|---|---|---|
DateTimeValue | Value | CALENDAR | CHARACTER | N | NOW | Returns/sets the current date using the current format. |
CustomFormat | CustomFormat | CALENDAR | CHARACTER | N | The current format style | Returns/sets the custom format string used to format the date and/or time displayed in the control. |
FormatStyle | Format | CALENDAR | INTEGER | N | 0 | Determines whether dates and times are displayed using standard or custom formatting: DTS_LONGDATEFORMAT = 0, DTS_SHORTDATEFORMAT = 1, DTS_TIMEFORMAT = 2, DTS_CUSTOMFORMAT = 3 |
CalendarBackColor | CalendarBackColor | CALENDAR | INTEGER | N | The current theme default value | Returns/sets the background color used to display the month portion of the dropdown calendar using the BGR encoding. |
CalendarForeColor | CalendarForeColor | CALENDAR | INTEGER | N | The current theme default value | Returns/sets the foreground color used to display text in the month portion of the dropdown calendar using the BGR encoding. |
CalendarTitleBackColor | CalendarTitleBackColor | CALENDAR | INTEGER | N | The current theme default value | Returns/sets the background color used to display the title portion of the dropdown calendar using the BGR encoding. |
CalendarTitleForeColor | CalendarTitleForeColor | CALENDAR | INTEGER | N | The current theme default value | Returns/sets the foreground color used to display the title portion of the dropdown calendar using the BGR encoding. |
CalendarTrailingForeColor | CalendarTrailingForeColor | CALENDAR | INTEGER | N | The current theme default value | Returns/sets the foreground color used to display the days at the beginning and end of the dropdown calendar that are from previous and following months using the BGR encoding. |
CheckBox | CheckBox | CALENDAR | LOGICAL | N | NO | Returns/sets whether the control displays a checkbox to the left of the date. When unchecked, no date is selected. |
UpDown | UpDown | CALENDAR | LOGICAL | N | NO | Returns/sets a value that determines whether an updown (spin) button is used to modify dates instead of a dropdown calendar. |
Example¶
define variable dtWidget as handle no-undo. define variable dtWidget1 as handle no-undo. define variable dtWidget2 as handle no-undo. define variable dtWidget3 as handle no-undo. define variable dtWidget4 as handle no-undo. define button btnGetDateTime label "DateTimeValue" size 19 by 1.14. define button btnExit auto-end-key label "Exit" size 19 by 1.14. define button btnChangeBgColor label "BgColor" size 19 by 1.14. define button btnChangeFgColor label "FgColor" size 19 by 1.14. define button btnGetScreenValue label "SCREEN-VALUE" size 19 by 1.14. def frame f btnGetDateTime at row 1.95 col 5 btnGetScreenValue at row 1.95 col 25 btnChangeBgColor at row 1.95 col 45 btnChangeFgColor at row 1.95 col 65 btnExit at row 1.95 col 85 with size-pixels 640 by 480 overlay view-as dialog-box title "Calendar widget". create calendar dtWidget assign frame = frame f:handle row = 3.62 column = 5 height = 1.2 width = 30 visible = true. /* calendar methods and attributes */ dtWidget:FormatStyle = 1. dtWidget:DateTimeValue = NOW. create calendar dtWidget1 assign frame = frame f:handle row = 5.62 column = 5 height = 1.2 width = 40 formatStyle = 0 visible = true. dtWidget1:DateTimeValue = "2020-02-25T23:23:23". create calendar dtWidget2 assign frame = frame f:handle row = 7.62 column = 5 height = 1.2 width = 40 formatStyle = 2 visible = true. dtWidget2:DateTimeValue = DATETIME(02,25, 2020, 23, 23, 23). create calendar dtWidget3 assign frame = frame f:handle row = 9.62 column = 5 height = 1.2 width = 40 formatStyle = 2 checked = true visible = true. create calendar dtWidget4 assign frame = frame f:handle row = 11.62 column = 5 height = 1.2 width = 40 formatStyle = 3 checked = true visible = true. dtWidget4:CustomFormat="yyyy-MM-dd HH:mm". on choose of btnGetDateTime do: MESSAGE dtWidget3:DateTimeValue VIEW-AS ALERT-BOX. end. define variable bgColorValue as integer no-undo. bgColorValue = dtWidget:CalendarBackColor. define variable fgColorValue as integer no-undo. fgColorValue = dtWidget:CalendarForeColor. on choose of btnChangeBgColor do: define variable bgColorValue2 as integer no-undo. bgColorValue2 = dtWidget:CalendarBackColor. if (bgColorValue2 = bgColorValue) then do: RUN fillColor(INPUT-OUTPUT bgColorValue2, 255, 127, 255). dtWidget:CalendarBackColor=bgColorValue2. end. else do: dtWidget:CalendarBackColor=bgColorValue. end. end. on choose of btnChangeFgColor do: define variable fgColorValue2 as integer no-undo. fgColorValue2 = dtWidget:CalendarForeColor. if (fgColorValue2 = fgColorValue) then do: RUN fillColor(INPUT-OUTPUT fgColorValue2, 0, 127, 0). dtWidget:CalendarForeColor=fgColorValue2. end. else do: dtWidget:CalendarForeColor=fgColorValue. end. END. on choose of btnGetScreenValue do: MESSAGE dtWidget3:SCREEN-VALUE VIEW-AS ALERT-BOX. END. enable all with frame f. wait-for window-close of current-window. procedure fillColor: DEF INPUT-OUTPUT PARAMETER clrValue AS INTEGER. DEF INPUT PARAMETER redVal AS INTEGER. DEF INPUT PARAMETER greenVal AS INTEGER. DEF INPUT PARAMETER blueVal AS INTEGER. /* r-g-b */ PUT-BITS(clrValue, 1, 8) = redVal. PUT-BITS(clrValue, 9, 8) = greenVal. PUT-BITS(clrValue, 17, 8) = blueVal. end procedure.
This code creates 5 calendar widgets using different styles:
----
© 2004-2020 Golden Code Development Corporation. ALL RIGHTS RESERVED.