Date Gadget

Home
Introduction
Tips and Techniques
Projects
Libraries
Links

Library

Tested with Functional Developer 2.0.

You can download version 1.0 of the date-gadgets projects here: date-gadgets.zip (approx. 9KB).

Overview

This is a simple DUIM gadget for entering dates. It is implemented using the Win32 Date Time Picker common control. I wrote it as an experiment to learn how to create new DUIM gadgets so it's pretty basic. I've provided the source code for anyone who wants to build on it or use it as an example of how to create DUIM gadgets based on Win32 controls.

There are three projects in the .zip file. They are:

win32-common-controls-ex
Provides the basic Win32 constants, functions and structures needed to access the new date/time common control stuff. It also intialises the windows common control library to use the date/time routines. This should be expanded upon to include all the latest common controls one day. Note that the date and time routines need at least version 4.70 of the windows common control dynamic link library. Currently this module does no error checking for this but it probably should if it was to be used in 'real life'.
date-gadgets
Provides the <date-gadget> and <date-selection-field> gadgets. It also contains the Win32 implementation of the date gadgets.
date-time-play
An example DUIM program that displays a couple of <date-selection-field> gadgets and allows you to enter values. Pressing the top-most button on the windows causes the values of the gadgets to be set using 'gadget-value' and demonstrates that this works and that the 'value-changed-callback' functionality works.

Quick Notes

<date-selection-field> is the gadget to create for entering dates. It is a subclass of <value-gadget> so the gadget-value and value-changed-callback functionality applies to it. It has one optional keyword on creation called 'no-date-valid?'. This is a boolean value where '#t' indicates that the user may choose to enter no date and '#f' indicates that a valid date must be entered. It defaults to '#t'.

The 'gadget-value' may be an instance of the standard <date> class or the value $no-date-entered which is exported from 'date-gadgets'. This value indicates that no date has been entered.

Example Usage

make(<date-selection-field>, 
   value-changed-callback: on-date-changed,
   value: make(<date>, year: 1990, month: 12, day: 9));

make(<date-selection-field>,
   no-date-valid?: #f);

Important

This is code that was pretty much thrown together just to try out creating new DUIM gadgets. I'm providing the source code as an example of how I created a DUIM gadget. Feel free to use it as you wish but I don't take any responsiblity for it working or not working as you intend it to.

I had a problem of access violations occuring when clicking on the year in the date control and trying to edit it. I tracked the cause of this to a problem with a version of the common control DLL that was installed with some beta software. Downloading the latest common control DLL from microsoft fixed the problem. The common controls DLL can be obtained from the Microsoft web site.


Copyright © 2000, Chris ^M Double. All Rights Reserved.
^M All products and brand names are the registered trademarks or trademarks ^M of their respective owners.

^M