How to Create a Clock Class to Show Time in AM/PM FormatID: Q141736 3.00 3.00b WINDOWS
The information in this article applies to:
SUMMARYThe TIME() function in Visual FoxPro returns the time as a character string in the format of hh:mm:ss. With this format, 1:35:30 PM displays as 13:35:30 and 9:45:30 AM displays as 09:45:30. In certain situations, you may prefer the standard time display with the AM/PM format. This article shows you how to do it.
MORE INFORMATIONThe following steps create a Visual FoxPro Class that displays the current time in the standard AM/PM format when you place it on a form.
Steps to Create Clock Class1. Type the following command in the Command window:
2. In the dialog box, enter oClock in the Class Name field, Container in
3. Add a Timer control to the container, and give the Timer control the
4. Add a text box to the container, and give the text box the following
5. Add the following code to the Init event of Oclock:
6. Save the container class. Then type the following in the Command window:
7. On the Form Controls toolbar, click the Visual Class tool.
8. On the Visual Class menu, click Add. Locate the .vcx file where you 9. Save and run the form. The system time will display on the form in the
To add functionality to the clock to allows toggling between both the
standard AM/PM and military (24 hour) formats, make the following
modifications to the Class:
Steps to Add Format-Toggling Functionality1. While the oClock container is open in design mode, click New Property 2. In the Init event of oClock, add the following line of code:
3. In the Refresh method of tdisplay, the followings lines of code replace
4. In the oClock DblClick event, enter the following two lines of code:
5. Save the container class.
6. Run the previously saved seeclock form. When the form initially loads, Additional reference words: 3.00 3.00b VFoxWin normal switch
KBCategory: kbhowto
KBSubcategory: FxtoolClassdes
|
Last Reviewed: May 22, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |