Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Timers
Message
De
18/08/2011 19:22:26
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Timers
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01521261
Message ID:
01521298
Vues:
71
I have found problems with the VFP native timer -- I am using a timer class based on the WinAPI:
**************************************************
*-- Class:           apitimer (e:\my work\foxpro\projects\gkktools\editors\classes\gkkapitimer.vcx)
*-- ParentClass:     label
*-- BaseClass:       label
*-- Time Stamp:      05/04/11 12:09:09 PM
*
*-*	API Timer limits
#DEFINE USER_TIMER_MINIMUM      10
#DEFINE USER_TIMER_MAXIMUM      0x7FFFFFFF
*
DEFINE CLASS apitimer AS label


	AutoSize = .T.
	BackStyle = 0
	Caption = "apiTimer"
	Height = 17
	Visible = .F.
	Width = 51
	*-- Numeric Timer ID
	timerid = 0
	*-- Handle to Timer
	hwnd = 0
	*-- Interval of timer; value assigned in seconds and displayed in milliseconds; default is 30min
	interval = 900000
	Name = "apitimer"


	*-- Occurs when the Timer interval completes
	PROCEDURE ontimerinterval
		LPARAMETERS thWnd, tnMsg, twParam, tlParam


		RETURN 0
	ENDPROC


	*-- Initializes the timer
	PROCEDURE initializetimer
		BINDEVENT(this.hWnd, WM_TIMER, This, 'OnTimerInterval')
		apiSetTimer(this.hWnd, this.TimerID, this.Interval, 0)
	ENDPROC


	*-- Clears the timer function
	PROCEDURE cleartimer
		apiKillTimer(this.hWnd, this.TimerID)
		UNBINDEVENTS(this.hWnd)
	ENDPROC


	PROCEDURE interval_assign
		LPARAMETERS tnInterval
		tnInterval = tnInterval * 1000     && Convert seconds to milli-seconds
		DO CASE
			CASE tnInterval < USER_TIMER_MINIMUM
				this.Interval = USER_TIMER_MINIMUM

			CASE tnInterval > USER_TIMER_MAXIMUM
				this.Interval = USER_TIMER_MAXIMUM

			OTHERWISE
				this.Interval = tnInterval
		ENDCASE
	ENDPROC


	PROCEDURE Destroy
		this.ClearTimer()
	ENDPROC


	PROCEDURE Init
		this.hWnd = thisform.hWnd
	ENDPROC


ENDDEFINE
*
*-- EndDefine: apitimer
**************************************************
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform