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!

Displaying Real Time 2

Status
Not open for further replies.

uhohhelp

Programmer
Sep 12, 2002
20
0
0
CA
Hello, I have a form and want to be able to display the system time in real time. I was wondering if there was an activex control out there that could do this easily or if someone has already done this. I was playing around a bit with timers and the TIME() function but I'm sure there has got to be an easier way.

Thanks in advance to anyone who can help.

-mike
 
Use - Set clock on.
Set clock status - to place it on the status bar
(Set status bar on, if the status bar is off)
(This also assumes VFP's main window is visible)

There probably is an ActiveX control, but I'm not
familiar with one.

If you create a real time timer in code and your app
performs some intensive operations, you'll have to
issue "doevents" periodically during the tight loop.
Otherwise, the timer will not fire properly.

Hope helps,

Darrell
'We all must do the hard bits so when we get bit we know where to bite' :)
 
uhohhelp

The following might help you: (copy the code into a program and run it and see if it's what you need)

Code:
PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
	Top = 0
	Left = 0
	Height = 148
	Width = 619
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"
	complete = .F.
	ADD OBJECT text1 AS textbox WITH ;
		FontBold = .T., ;
		FontSize = 20, ;
		BackStyle = 1, ;
		Height = 48, ;
		Left = 24, ;
		SpecialEffect = 1, ;
		Top = 17, ;
		Width = 500, ;
		Style = 0, ;
		BackColor = RGB(192,192,192), ;
		BorderColor = RGB(192,192,192), ;
		Name = "Text1"
	ADD OBJECT timer1 AS timer WITH ;
		Top = 12, ;
		Left = 264, ;
		Height = 23, ;
		Width = 23, ;
		Interval = 1000, ;
		Name = "Timer1"
      ADD OBJECT command1 AS commandbutton WITH ;
		Top = 96, ;
		Left = 36, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "Complete", ;
		Name = "Command1"
	PROCEDURE Init
		store time() to thisform.text1.value
	ENDPROC
        PROCEDURE Load
		set talk off
		set cursor off
	ENDPROC
	PROCEDURE timer1.Timer
		IF THISFORM.COMPLETE
		 STORE cdow(date())+" "++cmonth(date())+" "+transform(day(date()))+" "+transform(year(date()))+" "+time() TO THISFORM.TEXT1.VALUE
		ELSE 
		 store time() to thisform.text1.value
		ENDIF
	ENDPROC
	PROCEDURE command1.Click
		IF this.caption="Complete"
			this.caption = "Time only"
			thisform.complete =.T.
		ELSE
			this.caption="Complete"
			thisform.complete =.F.
		ENDIF
	ENDPROC


ENDDEFINE
Mike Gagnon
 
That is exactly what I wanted to do. It seems like no one here takes a break from these forums during the weekend :) I appreciate everyone's quick response to my question.

Thanks again mgagnon!

-mike
 
uhohhelp

It seems like no one here takes a break from these forums during the weekend

Yes, my 3 minute break comes up in only 4 hours [elephant2]
Mike Gagnon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top