Timer Ocx

Purpose

Creates an Ocx Timer control 'in' the current active form, window, or dialog.

Syntax

Ocx Timer name [= text$] [, id%], [ x, y, w, h] [, style%]

text$:control text
id%:control identifier
x, y, w, h:iexp
style%:the control styles

Description

A Timer control can execute code at regular intervals by causing a Timer event to occur. The Timer control, invisible to the user, is useful for background processing.

The Interval property returns or sets the number of milliseconds between calls to a Timer control's Timer event. You can set a Timer control's Interval property at design time or run time.

The Timer control's Enabled property determines whether the control responds to the passage of time. Set Enabled to False to turn a Timer control off, and to True to turn it on. When a Timer control is enabled, its countdown always starts from the value of its Interval property setting.

Create a Timer event procedure to handle the situation that the time of Interval has passed.

Properties

Enabled | hWnd | Index | Interval | Name | Parent | Tag

Events

Timer

Syntax Events

Sub Timer_Timer

Occurs when a preset interval for a Timer control has elapsed. The interval's frequency is stored in the control's Interval property, which specifies the length of time in milliseconds.

Example

OpenW 1

PrintScroll = 1

Ocx Timer tmr

tmr.Interval = 1000

tmr.Enabled = True

Do

Sleep

Until Me Is Nothing

 

Sub tmr_Timer

Static counter% = 0

counter++

Text 0, 0, "Timer Event " & counter

EndSub

Remarks

The minimum interval for the Ocx Timer is around 15ms; if a shorter time interval is required, use the TimerQ command instead.

See Also

TimerQ.

Ocx, OcxOcx

Animation, CheckBox, ComboBox, Command, CommDlg, Form, Frame, Image, ImageList, Label, ListBox, ListView, MonthView, Option, ProgressBar, RichEdit, Scroll, Slider, StatusBar, TabStrip, TextBox, TrayIcon, TreeView, UpDown

{Created by Sjouke Hamstra; Last updated: 05/06/2023 by James Gaite}