Click here to Skip to main content
15,566,065 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hello, i want to create a countdown timer using WinApi, I don't know how to do this, i just stuck on it for like a month and i tried everything.
When i search Google i only find console countdown timer and not WinApi, i tried to transfer it to a WinApi project but it is not working.

I have tried everything, but everything and nothing works.
Can someone send me a tutorial or something else ?
I really need it for my final project in School.

What I have tried:

I have tried everything, but without success.
Posted
Updated 9-Nov-19 2:51am
Comments
Rick York 9-Nov-19 12:12pm    
All of your questions are very vague and result in us guessing what it is you are really asking. You need to be much more thorough and descriptive when you ask your questions.

For this one, what is it you want the timer to do? Signal an event after X milliseconds? Decrement a counter down to zero? Exactly WHAT? There are many, many possibilities and its a waste of everyone's time to guess what it is you are after.

Note that the phrase, "countdown timer" really does not mean very much. Also, if all you want to know is when X time has elapsed, it makes no difference whether a counter increments or decrements. The effect is the same - a value differs by X from when you started so why do you care? You are going to subtract one number from another to find the elapsed time so the direction it counts is irrelevant.

What this means is stop worrying about trivial details and use the facilities available to get the job done. It would have been completed hours ago if you had not gotten hung up on details.
[no name] 9-Nov-19 12:14pm    
I want to do countdown timer from 24 : 0 : 0 (24 hours) to 0
Rick York 9-Nov-19 12:21pm    
You still don't get it. WTF does "do countdown timer from 24 to 0 mean?"

Do you want be able to ask an object how much time has elapsed?
Do you want a message sent to a window after 24 hours?

EXACTLY WHAT?????
[no name] 9-Nov-19 12:23pm    
No, i just want to create static window with countdown 24 hours timer, thats all.
Rick York 9-Nov-19 16:02pm    
Try this : https://www.codeproject.com/Articles/307/Static-LED-control-CDigiStatic-1-3

Look at CreateEvent and WaitForSingleObject. This is what I use to provide an interruptable timer when something wants to sleep. SetEvent wakes it up before the timeout expires.
 
Share this answer
 
Comments
[no name] 9-Nov-19 7:42am    
Does not helping at all, you just gave me a function without sense. this function can do many things, not only countdown timer.
CPallini 9-Nov-19 7:58am    
"this function can do many things, not only countdown timer"
That is a nonsense. If the function can do (among the other things) what you need then it IS useful.
[no name] 9-Nov-19 7:59am    
Yes but he don't explain me how to do a timer using this function, he just gave the function. so it is useless.
Greg Utas 9-Nov-19 8:11am    
This isn't a forum for spoon feeding you.
BillWoodruff 9-Nov-19 8:47am    
Since you are a University: do research.
You obviously have not tried everything, since you have not tried Using Timers - Win32 apps | Microsoft Docs[^].
 
Share this answer
 
Comments
CPallini 9-Nov-19 7:57am    
5.
Richard MacCutchan 9-Nov-19 8:25am    
Thank you again.
[no name] 9-Nov-19 7:59am    
I have tried this, not working.
Richard MacCutchan 9-Nov-19 8:23am    
And, as usual, you tell us nothing. The phrase "not working" is actually worse than not answering at all. We have no idea what code you have tried or what results you get. But I can tell you that your code was wrong. Using timers is a sure way of timing just about anything in a Windows application, and is used all over the world every day.
Richard MacCutchan 9-Nov-19 8:26am    
Yes, I wondered how long it would take.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900