| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|---|
| 2 | <html>
|
|---|
| 3 | <head>
|
|---|
| 4 | <title>SimpleTimer, ver. 2.0.1</title>
|
|---|
| 5 |
|
|---|
| 6 | <style type='text/css'>
|
|---|
| 7 | /* body { font-family: MS Sans Serif; font-size: 12pt; } */
|
|---|
| 8 | h1 { font: bold 14pt Arial; margin-bottom: 10px; }
|
|---|
| 9 | h2 { font: bold 12pt Arial; margin-bottom: 10px; margin-top: 40px; }
|
|---|
| 10 | td.name { background-color: #00FFCC; width: 120px; font-weight: bold; }
|
|---|
| 11 | td.desc { background-color: #F0F0F0; }
|
|---|
| 12 | td.default { background-color: #F0F0F0; }
|
|---|
| 13 | ul { margin-left: 15px; margin-top: 5px; }
|
|---|
| 14 | li { margin-bottom: 10px; }
|
|---|
| 15 | .declaration { font-weight: bold; }
|
|---|
| 16 | </style>
|
|---|
| 17 |
|
|---|
| 18 | </head>
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | <body topmargin='15' bottommargin='15' leftmargin='10' rightmargin='10'>
|
|---|
| 22 |
|
|---|
| 23 | <a name='Top'><h1>SimpleTimer, ver. 2.0.1</h1>
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 | <a href='#Properties'>[Properties]</a> <a href='#Methods'>[Methods]</a> <a href='#Events'>[Events]</a> <a href='#StandAloneMethods'>[Stand-alone Methods]</a>
|
|---|
| 27 | <br>
|
|---|
| 28 | <a href='#Howto'>[How To Use]</a> <a href='#Bugs'>[Known Bugs]</a> <a href='#Comments'>[Comments]</a>
|
|---|
| 29 | <br>
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 | <p>
|
|---|
| 33 | SimpleTimer is a timer class. It has the same timer resolution as TTimer, but it is more
|
|---|
| 34 | lightweight because it's derived from TObject in stead of TComponent. Furthermore, the same
|
|---|
| 35 | handle is shared between multiple instances of SimpleTimer. This makes it ideal for developers
|
|---|
| 36 | who need a timer in their own components or applications, but want to keep the resource
|
|---|
| 37 | usage minimal.
|
|---|
| 38 | </p>
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 | <a name='Properties'></a><h2>Properties</h2>
|
|---|
| 42 |
|
|---|
| 43 | <table cellpadding='2' cellspacing='2' border='0' width='100%'>
|
|---|
| 44 | <tr>
|
|---|
| 45 | <td class='name' valign='top'>Enabled</td>
|
|---|
| 46 | <td class='desc' valign='top'><span class='declaration'>property Enabled: Boolean;</span><br>
|
|---|
| 47 | Enables (starts) or disables (stops) the timer.</td>
|
|---|
| 48 | <td class='default' valign='top' nowrap>Default False</td>
|
|---|
| 49 | </tr>
|
|---|
| 50 | <tr>
|
|---|
| 51 | <td class='name' valign='top'>Interval</td>
|
|---|
| 52 | <td class='desc' valign='top'><span class='declaration'>property Interval: Cardinal;</span><br>
|
|---|
| 53 | The interval of the timer in millisecs.<br>
|
|---|
| 54 | <b>NOTE:</b> Specifying a value of 0 will cause the timer to stop, but will not set the
|
|---|
| 55 | Enabled property to false.</td>
|
|---|
| 56 | <td class='default' valign='top' nowrap>Default 1000</td>
|
|---|
| 57 | </tr>
|
|---|
| 58 | <tr>
|
|---|
| 59 | <td class='name' valign='top'>AutoDisable</td>
|
|---|
| 60 | <td class='desc' valign='top'><span class='declaration'>property AutoDisable: Boolean;</span><br>
|
|---|
| 61 | If true, the timer will disable itself (Enabled is set to False) immediately after the next
|
|---|
| 62 | time it fires. Useful when you want a one-shot timer.</td>
|
|---|
| 63 | <td class='default' valign='top' nowrap>Default False</td>
|
|---|
| 64 | </tr>
|
|---|
| 65 | </table>
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | <a name='Methods'></a><h2>Methods</h2>
|
|---|
| 70 |
|
|---|
| 71 | <table cellpadding='2' cellspacing='2' border='0' width='100%'>
|
|---|
| 72 | <tr>
|
|---|
| 73 | <td class='name' valign='top'>Create</td>
|
|---|
| 74 | <td class='desc' valign='top'><span class='declaration'>constructor Create;</span><br>
|
|---|
| 75 | Creates a new TSimpleTimer object.</td>
|
|---|
| 76 | </tr>
|
|---|
| 77 | <tr>
|
|---|
| 78 | <td class='name' valign='top'>CreateEx</td>
|
|---|
| 79 | <td class='desc' valign='top'><span class='declaration'>constructor CreateEx(AInterval: Cardinal; AOnTimer: TNotifyEvent);</span><br>
|
|---|
| 80 | Creates a new TSimpleTimer object with the specified Interval property and OnTimer event.</td>
|
|---|
| 81 | </tr>
|
|---|
| 82 | <tr>
|
|---|
| 83 | <td class='name' valign='top'>Destroy</td>
|
|---|
| 84 | <td class='desc' valign='top'><span class='declaration'>destructor Destroy; override;</span><br>
|
|---|
| 85 | Destroys the TSimpleTimer object.</td>
|
|---|
| 86 | </tr>
|
|---|
| 87 | </table>
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 | <a name='Events'></a><h2>Events</h2>
|
|---|
| 92 |
|
|---|
| 93 | <table cellpadding='2' cellspacing='2' border='0' width='100%'>
|
|---|
| 94 | <tr>
|
|---|
| 95 | <td class='name' valign='top'>OnTimer</td>
|
|---|
| 96 | <td class='desc' valign='top'><span class='declaration'>property OnTimer: TNotifyEvent;</span><br>
|
|---|
| 97 | Called when the timer fires.</td>
|
|---|
| 98 | </tr>
|
|---|
| 99 | </table>
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 | <a name='StandAloneMethods'></a><h2>Stand-alone Methods</h2>
|
|---|
| 104 |
|
|---|
| 105 | <table cellpadding='2' cellspacing='2' border='0' width='100%'>
|
|---|
| 106 | <tr>
|
|---|
| 107 | <td class='name' valign='top'>GetSimpleTimerCount</td>
|
|---|
| 108 | <td class='desc' valign='top'><span class='declaration'>function GetSimpleTimerCount: Cardinal;</span><br>
|
|---|
| 109 | Returns the number of TSimpleTimer objects currently allocated.</td>
|
|---|
| 110 | </tr>
|
|---|
| 111 | <tr>
|
|---|
| 112 | <td class='name' valign='top'>GetSimpleTimerActiveCount</td>
|
|---|
| 113 | <td class='desc' valign='top'><span class='declaration'>function GetSimpleTimerActiveCount: Cardinal;</span><br>
|
|---|
| 114 | Returns the number of TSimpleTimer objects that are currently active (enabled).</td>
|
|---|
| 115 | </tr>
|
|---|
| 116 | </table>
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 | <a name='Howto'></a><h2>How To Use</h2>
|
|---|
| 121 |
|
|---|
| 122 | This example creates a SimpleTimer object, initializing Interval to 500 milliseconds and
|
|---|
| 123 | the OnTimer event to TForm1.TimerProc1, then starts the timer:
|
|---|
| 124 | <pre>procedure TForm1.FormCreate(Sender: TObject);
|
|---|
| 125 | begin
|
|---|
| 126 | SimpleTimer1 := TSimpleTimer.Create(500, TimerProc1);
|
|---|
| 127 | SimpleTimer1.Enabled := True;
|
|---|
| 128 | end;</pre>
|
|---|
| 129 |
|
|---|
| 130 | This is what TimerProc1 might look like:
|
|---|
| 131 | <pre>procedure TForm1.TimerProc1(Sender: TObject);
|
|---|
| 132 | begin
|
|---|
| 133 | ListBox1.Items.Add('SimpleTimer1 fired');
|
|---|
| 134 | end;</pre>
|
|---|
| 135 | </li>
|
|---|
| 136 |
|
|---|
| 137 | Remember to destroy the SimpleTimer object when your app. terminates.
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 | <a name='Bugs'></a><h2>Known Bugs</h2>
|
|---|
| 142 |
|
|---|
| 143 | <ul>
|
|---|
| 144 | <li>You may experience occasionally that you lose a timer event when you work with
|
|---|
| 145 | small intervals (approx. below 100 ms.). This is normal, and the same thing happens
|
|---|
| 146 | with a TTimer object. If you want precision you need a multimedia timer, not
|
|---|
| 147 | TTimer or TSimpleTimer which use the low-priority WM_TIMER message. WinXP has better
|
|---|
| 148 | handling of timers and will generally lose fewer timer events than other Windows versions.
|
|---|
| 149 | </li>
|
|---|
| 150 | </ul>
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 | <a name='Comments'></a><h2>Comments</h2>
|
|---|
| 155 |
|
|---|
| 156 | SimpleTimer is <i>freeware</i>. Feel free to use and improve it,
|
|---|
| 157 | but <i>please include all original files if you redistribute the zip-file</i>.
|
|---|
| 158 | If you have any comments or corrections I would very much like to hear them.
|
|---|
| 159 | </p>
|
|---|
| 160 |
|
|---|
| 161 | <p>
|
|---|
| 162 | Get the latest version from <a href='http://www3.brinkster.com/troels/delphi.asp' target='_blank'>
|
|---|
| 163 | http://www3.brinkster.com/troels/delphi.asp</a>.
|
|---|
| 164 | </p>
|
|---|
| 165 |
|
|---|
| 166 | <p>
|
|---|
| 167 | Troels Jakobsen<br>
|
|---|
| 168 | <a href='mailto:delphiuser@get2net.dk'>delphiuser@get2net.dk</a>
|
|---|
| 169 | </p>
|
|---|
| 170 |
|
|---|
| 171 | </body>
|
|---|
| 172 | </html>
|
|---|
| 173 |
|
|---|