-
January 8th, 2003, 04:44 AM
#1
Add timer to my class (my class does not derived form MFC)
Hi GURU!
How to add timer to my class (my class does not derived form MFC).
class MyClass{
}
Thank You.
Sorry for bad English.
-
January 8th, 2003, 06:32 AM
#2
You can use SetTimer and KillTimer, but this functions need your class has a window and a message loop to handle a WM_TIMER message.
-
January 8th, 2003, 08:53 AM
#3
Phogang,
I would look at ::SetTimer(...). Reading the MSDN documentaion, I'm guessing the only requirement is that your application has a message pump. If your class has a single instance, you should be able to kludge something using ::SetTimer.
Good luck,
John Flegert
-
January 8th, 2003, 09:31 AM
#4
There is no need for a message loop to use a timer
You just havew to use one that is not based on messages!
A WaitableTimer is directly supported via Windows API calls.
Check MSDN for a starting point into the documentation.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
January 8th, 2003, 10:02 AM
#5
Use this function
CreateTimerQueue();
CreateTimerQueueTimer(
PHANDLE phNewTimer,
HANDLE hTimerQueue,
WAITORTIMERCALLBACK pfnCallback,
PVOID pvContext,
DWORD dwDueTime,
DWORD dwPeriod,
ULONG dwFlags);
with callback WAITORTIMERCALLBACK pfnCallback,
-
January 8th, 2003, 10:49 AM
#6
A TimerQueue may or may not be prefferable over a WaitableTimer. Only the user knows for sure...
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
January 8th, 2003, 11:23 AM
#7
Re: Add timer to my class (my class does not derived form MFC)
Originally posted by Phogang
Hi GURU!
How to add timer to my class (my class does not derived form MFC).
To be able to answer the question you would need to provide some more information. Does your application has a message loop? Which resolution of the timer do you need? What is the purpose of the timer?
Based on these information one can provide a fully satisfying answer. Without these it is more-likely just guessing in the dark...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|