Visual Basic Code of the Week (COTW)
http://www.codeoftheweek.com
Issue #127
Online Version at http://www.codeoftheweek.com/membersonly/bi/0127.html (paid subscribers only)
All content and source code is Copyright (c) 2000 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.

Issue topic: Calendar control Version 2

Extra CASH!

If you have any tips to contribute, email us at tips@codeoftheweek.com. Be sure to include instructions and source code. For each tip received which gets published we will pay you $10 to $25 US Dollars.

Requirements

In this Issue

In this issue we discuss how enhance the calendar control we created last week.

If you have any questions about using this module, let us know at questions@codeoftheweek.com

ucCalendar

See issue number 126 for the basic description of this control.

This week we have enhanced this control to have built-in methods for moving forward and backward within the calendar. It now supports move forward and backward one month and one year. It also supports a quick month change feature. If you click on the month of the calendar you will get a drop down list of all available months. This allows a very fast way to switch months.

The mechanism used to implement these features is very extensible. The source code is commented heavily in order to explain some of the processes as you view the source code.

The place to start is to look at the CalendarCommand enumerator. This is where all the commands are added in order to implement new features. Let's say you want to add a feature to highlight a column when you click on the day of the week. You can add a command called ccHighlightColumn to the CalendarCommand enum. In the RedrawCalendar routine you would need to add a call to AddRangeCheck with the dimensions of the day of the week cell and the command ccHighlightColumn. This would add the range to the range array (maClickRanges) which is used in CheckMouseClick. In CheckMouseClick you would add your command to the select case statement with the logic that highlights the column. Take a look at the source code. It really is fairly simple. The hardest part is figuring out the dimensions of the range you want to define for a command.

There are many additional ways this control can be enhanced. If an enhanced version of this control would be useful to you, please email us at calendar@codeoftheweek.com

Properties

All of these properties were discussed last week. We have left them out in order to save space since the source code in this issue is pretty long. The issue can be read at http://www.codeoftheweek.com/issues/0126.html

Sample Usage

This sample shows how to use the calendar control. There really is nothing more to do than to drop the calendar control on a form and set the properties appropriately. This example assumes the calendar control is called oCal.

    oCal.Month = 9
    oCal.Year = 2000
    ' will force the calendar to display the calendar for September 2000.

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0127.html


This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945
Email: info@codeoftheweek.com
Web: http://www.codeoftheweek.com