This article was brought to you by the guys from VDF-GUIdance.
For more DataFlex targeted articles see http://www.vdf-guidance.com


Date control in forms and dbforms

by Allan Greis Eriksen

Summary

This mixin class adds functionality to your date controls. It makes it possible for the user to insert a day and month and have the current year added automatically. 2-digits years will be converted to a 4 digit year. If no date is entered, the current date will automatically be inserted. This can be avoided by setting AllowBlankDate to True.
<PGUP> or <PGDOWN> increase/decrease the date by 1.
<CTRL>+<D> correct the date to current date.
<CTRL>+<F4> to popup a calender. The calender here used are from Sture Andersens VDFQuery.
<SHIFT>+<PGUP> Increase the date by a week
<SHIFT>+<PGDOWN> Decrease the date by a week
<CTRL>+<PGUP> Increase the date by a month
<CTRL>+<PGDOWN> Decrease the date by a month
Size: 4 KB Download
Date Created: 10/02/2004
Date Updated: 10/02/2004
Author: Allan Greis Eriksen
Company: NordTeam Gruppen ApS


This mixin class is used to assist the user when editing date fields from within your VDF application.
It's features are:
  • The code makes it possible for the user to insert a day and month and when navigating out of the control, the current year will be automatically added to the field.
  • A 2-digits year will be converted to 4 digit year.
  • If no date has been entered then the current date will be inserted. This feature is optionally as it can disabled by by setting the property AllowBlankDate to True.

The code has defined the following shortcutkeys to be added to your date controls:

Keys Functionality
<PGUP> or <PGDOWN> Increase/decrease the date by 1 day
<CTRL>+<D> Change the date in the control to the current date
<CTRL>+<F4> Popup a date selection dialog. The calender used here is from Sture Andersens VDFQuery.
<SHIFT>+<PGUP> Increase the date by a week
<SHIFT>+<PGDOWN> Decrease the date by a week
<CTRL>+<PGUP> Increase the date by a month
<CTRL>+<PGDOWN> Decrease the date by a month

Installation


The notes below are only meant to help you when installing the code to the workspace of your application.
There are more ways to do this:-)
Included in the download are 2 subclasses (cWsForm.pkg and cWsdbForm.pkg) that use our mixinclass only to show you how you can add the mixin package to your own subclass layer.
The associated cWsForm.dfc and cWsdbForm.dfc files show how to make the property pbAllowBlankDate visible in the properties dialog inside the IDE.

Some quick steps to get you going.
  1. Copy the .bmp, .dfc, .dfo files in the zipfile to the IdeSrc folder of your workspace
  2. Copy all the .pkg files to your AppSrc folder
  3. Go to 'maintain classlists' in your VDF IDE/Studio
  4. Select the workspace tabpage and add the new controls cWsForm and cWsdbForm
  5. Open a view in your application that you want to use the control with and switch the view into full source mode
  6. Change the standard dbForm control in your application that is used to enter dates from "Object oFoo is a dbForm" into "Object oFoo is a cWsdbForm"
  7. Switch the view back into normal mode and make a minimal change (for ex. add a space character) to have the IDE/Studio write the extra line into the source that includes the new subclass and save your change.
  8. Compile, test and enjoy!