Class: cMonthCalendarPrompt
Properties | Events | Methods | Index of Classes
Calendar Prompt class
Hierarchy
cObject > cUIObject > DfBaseObject > DfBaseWindow > DfBaseUIWindow > DfBaseControl > cWinControl > cWinControlEx > cMonthCalendar > cMonthCalendarPrompt
Show full hierarchy and direct subclasses
- cObject
- cUIObject
- DfBaseObject
- DfBaseWindow
- DfBaseUIWindow
- DfBaseControl
- cWinControl
- cWinControlEx
- cMonthCalendar
- cMonthCalendarPrompt
Library: Windows Application Class Library
Package: cMonthCalendarPrompt.pkg
Description
A Calendar Prompt class to be used as a component inside of a modal dialog. Usually, the oMonthCalendarPrompt dialog defined in MonthCalendarPrompt.dg can be used for this.
The package MonthCalendarPrompt.dg provides a date picker prompt dialog that can be used anytime you need a date prompt list. This is based on the Microsoft month calendar control so it has the standard look and feel of the Windows date picker. This can be used to select a date or to select a date range.
The dialog is added to you program by adding a 'Use MonthCalendarPrompt.dg' statement to your code and invoking it by sending Popup to oMonthCalendarPrompt. With many entry objects (dbForm, Form, etc.) you can use it as its standard prompt object by setting the Prompt_Object property as follows:
Use MonthCalendarPrompt.dg
:
Object oDateFormTest is a Form
Set Location to 16 89
Set Size to 13 66
Set Label to "Date Select Test:"
Set Prompt_Object to oMonthCalendarPrompt
Set Prompt_Button_Mode to PB_PromptOn
End_Object
This will act like a typical prompt object. You can make a selection and that selection will be returned to your invoking object. Its usage and interface are very similar to the cCJGridPromptList and cDbCJGridPromptList classes.
By default:
- The Calendar prompt dialog appears as small as possible. It can be resized. When resized, additional months are shown.
- The dialog is single select and will seed and update from the invoking object.
- A selection is made by clicking on a day in the month calendar. It will update the invoking object and set its Changed_State to True.
In addition:
- Various callback methods (Prompt_Callback, phmPromptUpdateCallback, etc.) allow you to customize the prompt list's update mode (peUpdateMode), appearance and other behaviors.
- The dialog can be used to make single select and for date-range selections (pbMultiSelect).
Much like the DataDictionary-based selection list dialogs, this single calendar prompt dialog can be used throughout your application. The calendar control inside of this dialog is based on the cMonthCalendarPrompt class and uses the interface described here. In particular, the Prompt_Callback event is used to customize any particular invocation of this calendar prompt dialog.
If you enable multi selection (via pbMultiSelect), a date range can be selected by clicking on the start date with the mouse and then dragging the mosue toward the end date; dragging the mouse onto the last day of the month while doing so will switch the the next month to allow the user to select and end date.
This sample shows how to use this as a date range selector
Object oFromDate is a Form
Set Label to "From Date:"
Set Location to 29 66
Set Size to 13 66
Set Prompt_Button_Mode to PB_PromptOn
Set Prompt_Object to oMonthCalendarPrompt
Procedure DoDateUpdate Integer hoSel Date dDate1 Date dDate2
Set Value to dDate1
Set Value of oToDate to dDate2
End_Procedure
Procedure Prompt_Callback Integer hoPrompt
Date dDate1 dDate2
Set pbMultiSelect of hoPrompt to True
Set peMouseSelectOk of hoPrompt to msoNone
Set phmPromptUpdateCallback of hoPrompt to (RefProc(DoDateUpdate))
Set pbWeekNumbers of hoPrompt to True
Set pbNoToday of hoPrompt to True
Set pbNoTodayCircle of hoPrompt to True
Get Value to dDate1
Get Value of oToDate to dDate2
Set pdSeedValue of hoPrompt to dDate1
Set pdSeedValue2 of hoPrompt to dDate2
End_Procedure
End_Object
Object oToDate is a Form
Set Label to "To:"
Set Location to 50 66
Set Size to 13 66
Set Enabled_State to False
End_Object
This sample shows how to invoke this from a button
Object oButton1 is a Button
Set Location to 121 100
Set Label to 'Change'
Procedure Prompt_Callback Integer hoPrompt
Date dDate
Get Value of oDateTextBox to dDate
Set peUpdateMode of hoPrompt to umPromptCustom
Set pdSeedValue of hoPrompt to dDate
Set phmPromptUpdateCallback of hoPrompt to (RefProc(DoDateUpdate))
End_Procedure
Procedure DoDateUpdate Integer hoSel Date dDate1 Date dDate2
Set Value of oDateTextBox to dDate1
End_Procedure
Procedure OnClick
Send Popup of oMonthCalendarPrompt
End_Procedure
End_Object
You can also use the cMonthCalendarPrompt class and create your own custom date prompt dialogs. To do that, we would advise that you review the code in the MonthCalendarPrompt.dg and use that as your starting template.
This class is based on the cMonthCalendar class, which is a more generic wrapping of the Microsoft calendar control. The cMonthCalendar class could be used inside of other views and dialogs, although its usage will be less automatic.