4.3.7 Date time

Date time

Handling date-related and time-related data is crucial to most business applications. Visual FoxPro handles this data quite well. However, there are no interface components with which to enter this kind of data other than regular textboxes. The foundation classes found in this category correct this shortcoming.

ActiveX Calendar

Class

_olecalendar

Base class

OLEControl

Class library

_datetime.vcx

Parent class

_olecontrol

Sample

...\Samples\Vfp98\Solution\Ffc\datacal.scx

Dependencies

_base.vcx, Microsoft Calendar ActiveX Control

The ActiveX Calendar class uses the Microsoft Calendar ActiveX control to provide a nice calendar interface (see Figure 21). A good reason to use this class instead of the ActiveX control directly is because this class allows data binding.

You can drop the ActiveX Calendar on any form or container. The class has a property called Date_Column, which specifies the field that will be bound to the calendar. You can think of this property as the "ControlSource" property of this class.

Data binding with ActiveX controls is not trivial. The ActiveX Calendar class does a pretty good job binding the ActiveX control to Visual FoxPro data. However, when the control source is changed from the outside (programmatically or through another user interface component), the control might not recognize the change. In this case, you can call the RefreshDisplay() method to update the control.

Figure 21. A slightly modified version of the ActiveX Calendar control.

Clock

Class

_clock

Base class

Container

Class library

_datetime.vcx

Parent class

_container

Sample

...\Samples\Vfp98\Solution\Controls\Timer\clock.scx

Dependencies

_base.vcx

The Clock class is a simple textbox that displays the actual time. A timer updates the display once a second. The class has a property called TimeFormat, which (in theory) allows you to change the time format from 12 to 24 hours. However, this did not work in the version I have (Visual FoxPro 6.0 release version). In fact, there isn't even any code that would react to settings in that property.

Stop Watch

Class

_stopwatch

Base class

Container

Class library

_datetime.vcx

Parent class

_container

Sample

...\Samples\Vfp98\Solution\Controls\Timer\swatch.scx

Dependencies

_base.vcx

The Stop Watch class provides a simple stopwatch control that can be placed on any form or container (see Figure 22). The Stop Watch class has three important methods: Start(), Stop() and Reset(). Their purpose is self-explanatory. The class also has a property called ElapsedSeconds, which you can query programmatically to check for the number of elapsed seconds.

Figure 22. The Stop Watch class.

 

 



Advanced Object Oriented Programming with Visual FoxPro 6. 0
Advanced Object Oriented Programming with Visual FoxPro 6.0
ISBN: 0965509389
EAN: 2147483647
Year: 1998
Pages: 113
Authors: Markus Egger

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net