Post by (X) on May 30, 2023 20:15:53 GMT 1
Are you looking for a millisecond timer for GFA?
Look up TimerQ in GFA's Help file.
It's all there.
From: GFA Help file:
TimerQ function
Requires: GfaWinx.lg32
Purpose
Creates a high-resolution multi-media-timer wrapped in a COM object.
Syntax
Set tmrQ = TimerQ([Form | hWnd], [TimerID], [Interval], [Resolution], [TimerProc])
tmrQ : Object variable
Form : Form object
TimerID, Interval
Resolution, ProcAddr : integer expression
Description
TimerQ creates a high-resolution multi-media timer with a minimal interval of 1 msec. (The Ocx Timer's shortest interval is approximately 55 msec.) The Form or hWnd parameter specifies the form or window that receives the WM_TIMER message after the time period (Interval) has expired. The TimerID must specify a value to identify the timer, it is passed in the wParam of the WM_TIMER message. The Interval parameter can specify the period of timer in milliseconds with a minimum of 1 msec. TimerQ posts a WM_TIMER to the message queue of the specified Form/window and it could be handled in the Form_Message() event sub. The Resolution parameter determines the accuracy of the timer. A value of 0 will provide the highest accuracy, but might also have a negative influence of the performance of the system. By specifying -5 (default) for Resolution the accuracy is set to 5% of the Interval. By specifying the ProcAddr() of a TimerProc the timer's events can be directed to a user supplied procedure instead of being processed using the WM_TIMER message. The signature of the procedure must be:
Proc TmrQProc(uID%, uMsg%, dwUser%, dw1%, dw2%)
The timer is wrapped in an IDispatch COM object and the TimerQ's return value must be stored in an Object variable.
The timer is immediately started if the Interval parameter specifies a valid time and either the Form/hWnd is provided or a procedure address is provided.
Rather than specifying all parameters in the TimerQ() function, the timer's values can be set after creating the object using properties. The object has the following properties:
Enabled R/W Bool Returns or sets the running state of the timer. Set to False to stop a running timer or set to True to start a stopped timer.
Interval R/W Integer Returns or sets the time interval of the timer. The minimum value is 1 ms. Setting the Interval does not change the Resolution.
Resolution R/W Integer Returns or sets the accuracy time of the timer. The minimum value is 0 ms. By setting the Resolution to a negative value the accuracy is specified in a percentage of the Interval setting. E.g. setting Resolution to -5 will set the timer's accuracy to +/- 5% of the Interval. If Interval ia 100 ms, the tick's event will arrive between 95 ms and 105 ms.
TimerProc R/W Integer Returns or sets the current TimerProc for the timer. Either set it to an application defined callback procedure or to 0, which resets the TimerProc to the internal procedure that posts WM_TIMER messages to the target Form/window set with hWndTarget.
hWndTarget R/W Integer Returns the target window's handle or sets the target window from a Form or window-handle. The target window receives the WM_TIMER messages if ProcAddr == 0, otherwise the TimerProc is executed.
TimerID R/W Integer Returns or sets the timer's identifier, the value that is passed in the wParam of the WM_TIMER message.
Purpose
Creates a high-resolution multi-media-timer wrapped in a COM object.
Syntax
Set tmrQ = TimerQ([Form | hWnd], [TimerID], [Interval], [Resolution], [TimerProc])
tmrQ : Object variable
Form : Form object
TimerID, Interval
Resolution, ProcAddr : integer expression
Description
TimerQ creates a high-resolution multi-media timer with a minimal interval of 1 msec. (The Ocx Timer's shortest interval is approximately 55 msec.) The Form or hWnd parameter specifies the form or window that receives the WM_TIMER message after the time period (Interval) has expired. The TimerID must specify a value to identify the timer, it is passed in the wParam of the WM_TIMER message. The Interval parameter can specify the period of timer in milliseconds with a minimum of 1 msec. TimerQ posts a WM_TIMER to the message queue of the specified Form/window and it could be handled in the Form_Message() event sub. The Resolution parameter determines the accuracy of the timer. A value of 0 will provide the highest accuracy, but might also have a negative influence of the performance of the system. By specifying -5 (default) for Resolution the accuracy is set to 5% of the Interval. By specifying the ProcAddr() of a TimerProc the timer's events can be directed to a user supplied procedure instead of being processed using the WM_TIMER message. The signature of the procedure must be:
Proc TmrQProc(uID%, uMsg%, dwUser%, dw1%, dw2%)
The timer is wrapped in an IDispatch COM object and the TimerQ's return value must be stored in an Object variable.
The timer is immediately started if the Interval parameter specifies a valid time and either the Form/hWnd is provided or a procedure address is provided.
Rather than specifying all parameters in the TimerQ() function, the timer's values can be set after creating the object using properties. The object has the following properties:
Enabled R/W Bool Returns or sets the running state of the timer. Set to False to stop a running timer or set to True to start a stopped timer.
Interval R/W Integer Returns or sets the time interval of the timer. The minimum value is 1 ms. Setting the Interval does not change the Resolution.
Resolution R/W Integer Returns or sets the accuracy time of the timer. The minimum value is 0 ms. By setting the Resolution to a negative value the accuracy is specified in a percentage of the Interval setting. E.g. setting Resolution to -5 will set the timer's accuracy to +/- 5% of the Interval. If Interval ia 100 ms, the tick's event will arrive between 95 ms and 105 ms.
TimerProc R/W Integer Returns or sets the current TimerProc for the timer. Either set it to an application defined callback procedure or to 0, which resets the TimerProc to the internal procedure that posts WM_TIMER messages to the target Form/window set with hWndTarget.
hWndTarget R/W Integer Returns the target window's handle or sets the target window from a Form or window-handle. The target window receives the WM_TIMER messages if ProcAddr == 0, otherwise the TimerProc is executed.
TimerID R/W Integer Returns or sets the timer's identifier, the value that is passed in the wParam of the WM_TIMER message.
$Library "gfawinx"
OpenW 1, 0, 0, 600, 500, ~15
PrintScroll = 1 : PrintWrap = 1
Global Object tmrQ1, tmrQ2
Set tmrQ1 = TimerQ(Me, 1, 10) ' create & start timer
Set tmrQ2 = TimerQ() ' create timer
tmrQ2.InterVal = 1000 ' 1 sec
tmrQ2.Resolution = -1 ' +/- 1% of Interval = +/-10 ms
tmrQ2.TimerProc = ProcAddr(TmrQProc)
tmrQ2.Enabled = True ' start timer
Global Int tps
Do
Sleep
Until Me Is Nothing
Sub Win_1_Message(hWnd%, Mess%, wParam%, lParam%)
If Mess% == WM_TIMER
If wParam% == 1 // 10 msec timer
tps++ // increment ticks every 10 msec
Print "."; // do something
EndIf
EndIf
EndSub
Proc TmrQProc(uID%, uMsg%, dwUser%, dw1%, dw2%)
TitleW 1, "Ticks per second:" + Dec(tps)
tps = 0
EndProc