April 29, 2024, 10:49:28 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


CTimer Class

Started by Mike Stefanik, February 12, 2006, 04:21:18 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Mike Stefanik

I was doing some work on an example that needed a timer and so I took some time to create a CTimer class. Unlike the StartTimer method that's part of the base Window class, the CTimer class doesn't use a window and doesn't require that you implement your own callback function used by the SetTimer API call.

CTimer is designed to work in a much more object oriented fashion, in that to create a timer you define your own class derived from CTimer and implement the OnTimer method. The code is fairly well documentated and I included a simple example which demonstrates how to use it.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

Ionic Wind Support Team

Nice.

Just a note...the StartTimer method of the window class doesn't require a callback funciton.  It is optional.  If you don't supply one then Windows will send WM_TIMER messages to your window which can be handled by the OnTimer override.

Paul.
Ionic Wind Support Team

Mike Stefanik

February 12, 2006, 01:20:56 PM #2 Last Edit: February 12, 2006, 01:27:05 PM by Mike Stefanik
Thanks. And true, that really should have been an "and/or" there. You either provide a callback function, or you have to process messages if you use a window handle with SetTimer. CTimer just makes things a little easier because you don't have to worry about the underlying mechanism, you just create an instance of the class and off you go. :)
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

Mike Stefanik

I've updated the class and example for the latest version of the compiler (the 2/16/2006 build).
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation