GetDisplayRange PowerScript function
Description
Retrieves the first and last date of the currently displayed
date range and returns the number of months than span the display.
Controls
MonthCalendar control
Syntax
|
1 |
<span>controlname</span>.<span>GetDisplayRange</span> ( <span>start</span>, <span>end</span> {, <span>d </span>} ) |
|
Argument |
Description |
|---|---|
|
controlname |
The name of the MonthCalendar control |
|
start |
A date specifying the first date in the |
|
end |
A date specifying the last date in the |
|
d (optional) |
A value of the MonthCalDisplayState enumerated
|
Return Values
Integer. Returns the number of months
in the display range if it succeeds and –1 if it fails.
Usage
The GetDisplayRange function retrieves
the beginning and end dates of the range of dates currently displayed
in the calendar.
If you do not supply the optional d argument
(or specify PartlyDisplayed!), GetDisplayRange returns
the number of months for which any of the days in the month display.
If the calendar displays one month, the return value is 3, because
the last few days of the previous month and the first few days of
the next month are included.
If you supply EntirelyDisplayed! as the d argument, GetDisplayRange returns the
number of months for which all of the days in the month display.
It ignores the leading and trailing days.
For example, if the calendar display shows the 12 months from
November 2004 to October 2005 and you do not supply the d argument, GetDisplayRange returns
14 and the start and end arguments
are set to October 25, 2004 and November 6, 2005.
If you supply EntirelyDisplayed! as the d argument, GetDisplayRange returns 12
and the start and end arguments
are set to November 1, 2004 and October 31, 2005.
Examples
This example displays a message box that shows the
number of months in the display range and its start and end dates.
Because the third argument is set to PartlyDisplayed!, the range
returned will be greater than the number of full months displayed.
If only one month displays and it neither begins on the first day
of the week nor ends on the last day of the week, li_return will
be 3:
|
1 |
integer li_return<br>Date startdate, enddate<br>string str1, string str2<br> <br>li_return = mc_1.GetDisplayRange(startdate, enddate, &<br>   PartlyDisplayed!)<br>str1 = "Range is " + string(li_return) + " months"<br>str2 = "Start date is " + string(startdate) + "~r~n"<br>str2 += "End date is " + string(enddate)<br> <br>MessageBox(str1, str2) |
This example finds out how many complete months are
shown in the current display and sets the scroll rate to that number:
|
1 |
integer li_return<br>Date startdate, enddate<br> <br>li_return = mc_1.GetDisplayRange(startdate, enddate, &<br>   EntirelyDisplayed!)<br>mc_1.ScrollRate = li_return |