Click here to Skip to main content
14,385,812 members
Rate this:
Please Sign up or sign in to vote.
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.
Updated 9-Nov-19 2:51am
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.
CodingUniversity 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?

CodingUniversity 9-Nov-19 12:23pm
No, i just want to create static window with countdown 24 hours timer, thats all.
Richard MacCutchan 9-Nov-19 12:38pm
This guy has already been cited for abuse per messages below.
Rick York 9-Nov-19 16:02pm
Try this :
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
CodingUniversity 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.
CodingUniversity 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.
BillWoodruff 9-Nov-19 8:48am
phil.o 9-Nov-19 9:01am
You are being inredibly rude with someone who genuinely wants to help you.
Please stop being a help vampire and start learning how to do your own basic research when provided with a pertinent link.
CodingUniversity 9-Nov-19 9:03am
He's making fun of me over and over, this site is useless
Rate this:
Please Sign up or sign in to vote.

Solution 2

You obviously have not tried everything, since you have not tried Using Timers - Win32 apps | Microsoft Docs[^].
CPallini 9-Nov-19 7:57am
CodingUniversity 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:25am
Thank you again.
Richard MacCutchan 9-Nov-19 8:26am
Yes, I wondered how long it would take.
CodingUniversity 9-Nov-19 8:26am
I'm joking doctor.
CPallini 9-Nov-19 8:28am
You've been reported as abusive.
BillWoodruff 9-Nov-19 8:48am
Richard MacCutchan 9-Nov-19 9:05am
Thank you, William.

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100