• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Timer

OldDeadOne

[H]ard|Gawd
Joined
Apr 10, 2001
Messages
1,139
I need to have a message box to pop up at certain hours(really just 4 different message boxes to remind me on taking my medication)in C++ but I am lacking on what I am needing to use to in order to do this. Do I need a timer function or a win32 function to achieve this? I've been scouring the web looking for an example to get me started on the code,but I haven't seen much on this. I hate having brain farts on stuff like this.
 
Most people set such reminders with a program like Outlook or Google Calendar.

One approach is to write a program (or script) that pops up the warning, then use the Windows Task Scheduler to schedule the run of that program. This way, your schedule is easy to edit and persistently stored on your computer.

If you want to do it all in C for Win32 yourself, the simplest way is probably to write a loop that calls the Sleep() API. That tells Windows that you don't need to run anymore for a certain period. When you start running again, you can call GetSystemTime() to get the current time and see if it's an interval at which you should pop up your message box. (You can show a message box by calling the MessageBox() API.)

You'll also want to write some data persistently someplace so that the application knows when it most recently alerted. That way, when it restarts, it can be on the same schedule. In other words, you have to concern yourself with re-implementing the persistent features of Windows Task Scheduler.

Note that calling Sleep() isn't necessarily the best way to solve this problem. There are mechanisms for waiting that won't cause you to spin -- to sleep then check then sleep again. Writing code that sleeps and wakes is called "polling", and it can prevent your machine from shutting down or hibernating. Arguably, you want the machine to not hibernate or shut down, since it wouldn't display your reminder if it did stop. Using a waitable timer would allow you to create an object which you can have one thread wait on, then signal when it becomes due. That approach is better, but more complicated.
 
Fine, waste your time hacking together a shitty solution. I'm not the stubborn fool. ;)

f5ZPpf4.jpg
 
Obviously, I agree with using Google Calendar, Outlook, or a smartphone, etc. to do this since it is already done and better than what you will do yourself.

But, if you want to write it yourself.... You could use almost any language... C++, C#, Java, or a scripting language, there may be something easier for a beginner?
 
I'm with mikeblas:

Run a timer at small-ish intervals [if it only has to pop-up on the hour, try 1 minute intervals?], have it query the system time, and compare system time against an array of defined "alert times", and if system time == alert time, throw the alert.


As for persistant storage, etc...I might look at making this in JS or something that has access to cookies [or if you like Flash/AIR, you have shared objects], as that takes out the overhead of file management or having to parse/write TXT/XML
 
Using an existing app is the quickest to solution for critical alerts on medicines. However, rolling your own locally-running application (C, C++, C#, etc.) does give more possibilities for integration, as well as listening for and handling external factors that could (or sometimes should) affect notifications.
 
Last edited:
Using an existing app is the quickest to solution for critical alerts on medicines. However, rolling your own locally-running application (C, C++, C#, etc.) does give more possibilities for integration, as well as listening for and handling external factors that could (or sometimes should) affect notifications.
In addition to the fact that it gives you a simple scenario which you're interested in solving, and that can promote learning and experimentation.
 
Back
Top