I wrote this little ditty one afternoon after, for the 101st time, I became frustrated that I needed to add a form to my project just to support a timer. After passing it along to my friends at the Common Controls Replacement Project, they convinced me to release it as part of their (totally free) toolset.
The ccrpTimers library is an axDLL that currently exposes Timer, Countdown, and Stopwatch objects. You can sink fired events, using either the classic WithEvents method or via (non-blocking) implemented interfaces, into any form or class module. All objects use the multimedia timer, thus enabling true 1 millisecond resolution and intervals. Swing on over to the CCRP site for all the latest details.
I've now fully converted over to HtmlHelp. If you'd like to try this online documentation, or download it, I'd be most interested in your feedback! Note that the downloaded version (124K) requires IE4 to be installed. The online version works best with IE4, but will work with IE3 if you allow a small OCX from Microsoft to be installed. The VB6 build of this library uses CHM exclusively for help, since all VB6 developers have IE4 installed.
CCRP High Performance Timer Objects, created by CCRP member Karl E. Peterson, provide much more robust options than Visual Basic's intrinsic Timer control ever has. For years, the only option available to VB developers was to add a form to their project if they wanted to use a timer. This had the effect of totally destroying any hope of encapsulation if, for example, a class module needed periodic timer events.
No more superfluous forms!
This library provides ccrpTimer, ccrpStopWatch, and ccrpCountdown objects that may be instantiated anywhere, at any time. All three objects use the multimedia timer, thus providing true 1ms resolution (if supported by the hardware). Taking advantage of the WithEvents method of declaring an object instance, Timer and Tick events may be sunk in either forms or class modules. Alternatively, use Implements for more efficient notification and non-blocking event notification.
November 24, 1998
Version 2.00 (build 171)
Important Note: An initial VB6 build of the CCRP High Performance Timer Objects (version 2.0 Build 167) was mistakenly made available prematurely. Issues affecting the ability to install (and even use from the same project) both VB5 and VB6 builds of the library hadn't been thoroughly worked out at the time this archive was placed on the web site.
If you have already downloaded Build 167 -- Please unregister this build immediately, and replace it with build 171 which was made available late yesterday. I urge you to download the new library from the CCRP download page at your earliest convenience. Build 167 is incompatible with the current, and all future, VB6 versions of this library.
November 23, 1998
Version 2.00 (build 171)
- Upgraded the library to VB6. This build uses Service Pack 1 to avoid a terribly nasty issue with the initial drop (Q192653 ,"FIX: Eight or More ActiveX DLLs in Compiled Project Cause Error"). See Service Pack Issues for more details.
- Binary compatibility was broken, thus allowing either or both VB5 and VB6 libraries to be present on a single machine. To update existing projects just open the References dialog, uncheck the old VB5 reference, and check the new VB6 reference.
- New ProgIDs were employed to allow both VB5 and VB6 libraries to be present on a single machine. This means that if you do have References to both libraries within a single project, you must fully qualify all object references with the library name. Use "ccrpTimers6" to specify a VB6 library object.
- The default value for the .Stats.Frequency property was changed to accomodate slower hardware that choked on the performance enhancements made in build 163. The default for this property is now 20 milliseconds. Please update any projects which rely on the former defaults. ***
- The old-style HLP file was abandoned for good! Since all VB6 developers have IE4 (or better) installed, there was no need to hang onto the old ways when this new-fangled HtmlHelp offers the developer (me, in this case <g>) so much more.
- The underlying behavior of the library was altered so that no multimedia system timer is started until the first ccrpTimer or ccrpCountdown object is enabled. Previously, the system callbacks were initiated during the Initialization event of the first instantiated object. ***
*** These fixes were also applied to Version 1.23 for VB5.
Past Release History
October 26, 1998
- Patched an extremely nasty bug that caused a GPF when the timers were used from an ActiveX EXE with specific Threading Model settings (either Thread Per Object or a Thread Pool set to a value greater than 1). In the process of hunting down this bug, it was determined that the very design of Visual Basic itself was responsible. If you build a DLL that makes use of system callbacks, and the client is an ActiveX EXE, expect big trouble (speaking nicely).
- Patched another bug that presented when the code within a Timer event lasted for a measureable period. In those cases, the next Timer event would be delayed by that length of time that the previous Timer event consumed. This has been fixed and will no longer be an issue.
August 19, 1998
- Added a build of the Timer Objects library specifically for the Alpha platform, in addition to the original i386 Intel version.
August 6, 1998
- Fixed a bug that caused a "Runtime Error 6 -- Overflow" in very unique situations. Not likely to have wide ranging impact, but update is encouraged.
April 30, 1998
- Added the ccrpTimer.NotifyEx and ccrpCountdown.NotifyEx properties. These properties have been declared As Object, in anticipation of accommodating both two new secondary interfaces as well as any new interfaces added in the future. Currently supported are two new additions -- ICcrpTimerNotifyEx and ICcrpCountdownNotifyEx. These interfaces vary from the original in that they also pass references to the object firing their methods. With this identification available, it is easy to simulate control arrays with class objects.
- A new demo, ObjArray.vbp, was added to illustrate simulated control array syntax via the new NotifyEx property and secondary interface event notification.
- Fixed a limitation on the maximum value accepted for Interval properties. Previously, the Interval was restricted to the maximum supported by the operating system (typically 1,000,000ms in NT and 65,535ms in Win95/98). This restriction is no longer enforced, and you may set an Interval to any positive value within the range of a Long (1 to 2,147,483,647ms).
April 11, 1998
- Version 1.11.130 adds Tag properties to all three timer objects, and updates the help file to include documentation on this and the previous release. Previous downloaders of the Timer Objects should update to this file.
March 29, 1998
- Version 1.10.113 added a Notify property to the ccrpTimer and ccrpCountdown objects. This addition provides significant new functionality by exposing two new interfaces, ICcrpTimerNotify and ICcrpCountdownNotify. Client programs may choose to use Implements to add this secondary interface to their forms, usercontrols, or classes. The advantage of using the secondary interface over the classic event model is two-fold. Foremost, interface notification is significantly faster than raised events. Also, raised events may be blocked within the Visual Basic IDE by message boxes or modal dialogs, while interface notifications continue to come through, thus making debugging significantly easier. A new demo, Notify.vbp, was also added to demonstrate the new interface usage.
The CCRP High Resolution Timer Objects download zip (for VB5 only) now contains an additional folder with a version of the Timer Objects library that was built on and for the DEC Alpha platform.
DO NOT USE THIS FILE ON INTEL MACHINES.
Please see the help for support policies regarding the Alpha platform. From all reports received to date, it appears this DLL functions just fine, however the author doesn't have direct access to such a machine so is unable to independently confirm these reports.
USE AT YOUR OWN RISK.This build shares the same version information, and is binary-compatible, with the i386 build. The only way to determine which is which is by size (the Alpha build is larger) and the "Product Name" version resource.
All demos reportedly work fine when run from the VB IDE, however the EXEs must be rebuilt (recompiled from the supplied source) as they originated on i386 machines.
While support for this build is virtually non-existent, your reports of success or failure using it would be appreciated. This cumulative knowledge can then be summarized for succeeding updates to the documentation, and to foster Alpha releases of other CCRP controls.
Service Pack Issues for the ccrpTimer Objects
The VB6 Timer DLL was compiled under VB6 Service Pack 1, but has been reported successfully run on 'original' VB6 systems.
The VB5 Timer DLL requires that either VB5 Service Pack 2 or 3 be installed. A non-service pack version of the Timer Objects is not currently available. This amends previous information for this library which stated that separate zip files were available for SP0 and SP2/3 machines.
About Multimedia Timers
Multimedia timer raise a number of interesting issues. Some of them are dealt with in more detail in the About Multimedia Timers section of this help file.
Installing and Registering the Library
Understanding that the great bulk of CCRP's users will be sophisticated developers themselves, it has been decided that you're quite capable of manual installation of these components. See the Installation topic for complete details.
The CCRP High Performance Timer Objects library will function without regard to what version of the common controls you have installed, since it uses system multimedia timer services and does not use any features of comctl32.dll.
Three demos are included with the ccrpTimers library. Their files may be placed anywhere you find convenient.
- TimerTest demonstrates most of the standard features of all the CCRP Timer objects. This project consists of four files (TimerTest.vbp, FTimerTest.frm, FTimerTest.frx, and TimerTest.exe).
- Notify demonstrates proper implementation of the ICcrpTimerNotify and ICcrpCountdownNotify interfaces, and how they can be used to avoid event blocking while running within the Visual Basic IDE. This project consists of four files (Notify.vbp, FNotify.frm, FNotify.frx, and Notify.exe).
- ObjArray demonstrates both the use of Implemented interfaces as opposed to more traditional Events, and how to work with an array of event sinking objects. This project consists of four files (ObjArray.vbp, FTmrArray.frm, FTmrArray.frx, and ObjArray.exe).
Videosoft kindly provided CCRP with a copy of their VSDOCX software for documenting ActiveX controls. The bundled help file was created using VSDOCX. CCRP would like to extend their sincere thanks to Videosoft for their generosity.