MonthView Ocx

Purpose

Creates an Ocx MonthView control 'in' the current active form, window, or dialog.

Syntax

Ocx MonthView name [= text$] [, id%], [ x, y, w, h] [, style%]

text$:control text
id%:control identifier
x, y, b, h:iexp
style%:the control styles

Description

The MonthView control enables you to create applications that let users view and set date information via a calendar-like interface.

The Value property of the MonthView control returns the currently selected date.

You can allow end users to select a contiguous range of dates by setting the MultiSelect property to True, and specifying the number of selectable days with the MaxSelProperty. The SelStart and SelEnd properties return the start and end dates of a selection.

You can customize a MonthView control's appearance in many ways. Various color attributes such as MonthBackColor, TitleBackColor, TitleForeColor, and TrailingForeColor enable you to create a unique color scheme for the control.

You can display more than one month at a time (up to 12) in a MonthView control by setting the MonthRows and MonthColumns properties. The total of the MonthRows and MonthColumns properties must be less than or equal to 12.

The MonthView Ocx control has the following properties, methods, and events.

Properties

Appearance | BackColor | BorderStyle | Day | DayBold | DayOfWeek | DayVisible | Enabled | Font | FontBold | FontItalic | FontStrikethru | FontUnderline | FontName | FontSize | ForeColor | Height | HelpContextID | HideSelection | hWnd | Index | Left | MaxDate | MaxSelCount | MinDate | Month | MonthBackColor | MonthColumns | MonthRows | MouseCursor | MouseIcon | MousePointer | MultiSelect | Name | Parent | ScrollRate | SelEnd | SelStart | ShowToday | ShowWeekNumbers | StartOfWeek | TabStop | Tag | TitleBackColor | TitleForeColor | Today | ToolTiptext | Top | TrailingForeColor | Value | Visible | VisibleDays | Week | WhatsThisHelpID | Width | Year

Methods

AboutBox | ComputeControlSize | HitTest | Move | Refresh | SetFocus | SetFont | ZOrder

Events

Click | DateClick | DateDblClick | DayClick | DblClick | GetDayBold | GotFocus | KeyDown, KeyUp | KeyPress | LostFocus | MouseDown | MouseUp | MouseMove | SelChange

Example

Mode StrSpace 0

OpenW 1, , , 570, 450

Ocx MonthView mvw = "", 10, 90, 0, 0 /* Width and Height are ignored

With mvw

.MonthColumns = 2 : .MonthRows = 2

.Value = Date

.ForeColor = RGB(0, 0, 255)

.MonthBackColor = colBtnFace

.StartOfWeek = 1      ' Sunday

.ShowToday = 1

.ShowWeekNumbers = True

EndWith

Ocx Command cmd1 = "Restrict", 200, 10, 150, 25

Ocx Command cmd2 = "Multi Select", 200, 40, 150, 25

Ocx Label lbl = mvw.Value , 200, 70, 80, 25

Ocx Label lblWeek = mvw.Week, 280, 70, 20, 25

Ocx Label lblWeekDay = mvw.DayOfWeek , 310, 70, 20, 25

Debug.Show

mvw.SetFocus

Trace mvw.DayVisible(mvw.Value)

Trace mvw.ScrollRate

Do

Sleep

Until Me Is Nothing

 

Sub cmd1_Click

mvw.MinDate = #01.07.1998#

mvw.MaxDate = #01.07.1999#

mvw.Value = #17.04.1999#

 

Sub cmd2_Click

mvw.MultiSelect = True

mvw.MaxSelCount = 10

mvw.Value = #01.01.1999#

 

Sub mvw_Click

Debug.Print "Event _Click"

 

Sub mvw_DateClick(DateClicked As Date)

Trace DateClicked

 

Sub mvw_DateDblClick(DateDblClicked As Date)

Trace DateDblClicked

 

Sub mvw_DayClick(DayOfWeek%)

Trace DayOfWeek

 

Sub mvw_DblClick

Debug.Print "Event _DblClick"

 

Sub mvw_GetDayBold(StartDate As Date, Count%, State?())

Debug.Print "Event _ GetDayBold"

 

Sub mvw_GotFocus

Debug.Print "Event _GotFocus"

 

Sub mvw_KeyDown(Code&, Shift&)

Debug.Print "Event _KeyDown (Param: ",Code&,":",Shift&,")"

 

Sub mvw_LostFocus

Debug.Print "Event _LostFocus"

 

Sub mvw_SelChange(StartDate As Date, EndDate As Date)

Trace StartDate

Trace EndDate

lbl = mvw.Value

lblWeekDay = mvw.DayOfWeek

lblWeek = mvw.Week

Known Issues

As at the time of writing (Win8/10), DateDblClick does not work; all that happens is that the DateClick event is called twice. See the DateClick page for a workaround.

See Also

Ocx, OcxOcx

Animation, CheckBox, ComboBox, Command, CommDlg, Form, Frame, Image, ImageList, Label, ListBox, ListView, Option, ProgressBar, RichEdit, Scroll, Slider, StatusBar, TabStrip, TextBox, Timer, TrayIcon, TreeView, UpDown

{Created by Sjouke Hamstra; Last updated: 07/10/2017 by James Gaite}