If you have any tips to contribute, email us at email@example.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.
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 firstname.lastname@example.org
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 email@example.com
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
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.
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