Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display running time and date using editbox? 1

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
578
0
16
PH
Hello guys, part of the app i am doing which is almost done, i want to include running realtime.... i issued TIME() command, it only displays the time that it ran the app. What i want is to display the time while its running... any help? thanks so much....
 
Hi Mandy_crw,

If you have _screen = ON then VFP can display the time in _screens statusbar or somewhere on the _screen.
You can play around with this in developing mode by using these commands in the command window:

Code:
SET CLOCK ON
SET CLOCK TO 50,50
SET CLOCK STATUS

If _screen is not visible, surprise, surprise :) you're in need of a timer object that's fired every 60 seconds and writes the current time into the object you want to use for displaying the time. And 60 seconds is more than enough. Don't activate it every second. Reduce the time display to hh:mm and cut of the seconds.

But !!!!!! the best way of displaying the time without using App and Systemresources is to train your users to use the windows taskbar as it always shows date and time in the lower right corner or wherever the taskbar is positioned. Showing it in your app is redundant.

JM2C

-Tom
 
Mandy,

Tom has made a good point. There is already a clock in the notification area of the Windows taskbar. No need to display it in your app as well.

However, if you really want to do it yourself, follow these steps:

1. Create a form.

2. Drop a label and a timer on the form.

3. Set the timer's Interval to, say, 1 second.

4. In the timer's Timer event, set the caption of the label to the value returned by TIME().

5. Customise the appearance of the label (font, colour, size, etc). Also, customise the form, for example, by removing the title bar and making the label fill the form.

6. In your program, run the form.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top