Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Timers in vfp mtdlls
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
ActiveVFP
Title:
Timers in vfp mtdlls
Miscellaneous
Thread ID:
00910146
Message ID:
00910146
Views:
82
From turiya36 on microsoft.public.fox.programmer.exchange:
"After doing some digging, and researching various options, I came across this control library on activex.com (download.com). It's a series of timer controls, and they work great. Also, they are Freeware (not shareware). The .DLL is very compact as well ( only 80K)
1) go get this .ZIP file from here:
http://download.com.com/3000-2401-889219.html?tag=lst-0-1
2) unzip the .EXE and regsvr32 the associated .DLL
regsvr32.exe ccrpTmr.dll
3) Build the following code as a MTDLL:
DEFINE CLASS TimerTest AS CUSTOM OLEPUBLIC
oTimerControl = .NULL.
oTimerEventHandler = .NULL.

PROCEDURE INIT
** Create the timer object
THIS.oTimerControl = CREATEOBJECT( "ccrpTimers.ccrpTimer" )

** Create the event handler
THIS.oTimerEventHandler = CREATEOBJECT( "TimerEventHandler" )

** Attach the eventhandler to the timer control
EVENTHANDLER( THIS.oTimerControl, THIS.oTimerEventHandler )

** Set the timer properties
** As soon as your set enabled to .T., the timer will begin functioning
** Event type, 0 - one shot timer event, 1 - Periodic timer events
THIS.oTimerControl.EventType = 1
THIS.oTimerControl.INTERVAL = 1000
THIS.oTimerControl.ENABLED = .T.
ENDPROC
ENDDEFINE

** Replace the path in the IMPLEMENTS line with the path where you installed ccrptmr.dll
DEFINE CLASS TimerEventHandler AS SESSION
IMPLEMENTS __ccrpTimer IN "c:\ccrp\ccrptmr.dll"

PROCEDURE __ccrpTimer_Timer( Milliseconds AS NUMBER ) AS VOID ;
HELPSTRING "Event that fires whenever [Interval] milliseconds elapses."

** Your timer event code goes here

IF !DIRECTORY( "c:\temp\" )
MD c:\temp ENDIF
=STRTOFILE( "", "c:\temp\" + ALLTRIM( STR( SECONDS(), 12, 2 )) + ".txt" )
ENDPROC
ENDDEFINE

4) Instantiate the class:

oCom = CREATEOBJECT( "TimerTest.TimerTest" )

That's it! Your timer events will now function correctly in a VFP MTDLL.

One final thing to remember. Before you release the object (in the case of above, oCom) you must set the enabled property of the timer control to .F. like this:

oCom.oTimerControl.Enabled = .F.

Otherwise VFP will crash with a C00005 error."
Next
Reply
Map
View

Click here to load this message in the networking platform