Creating an Alarm Clock in the System Tray

Sign in to queue

The Discussion

  • User profile image
    Clint

    @Hung:  The VB link is on the top of the article for downloading.

  • User profile image
    Hung

    Can I create this in Microsoft Visual Basic? (excel)

  • User profile image
    Upheaval

    wav files won't play

    we are using Visual Basic 2005

    pls help

  • User profile image
    Clint

    @Upheaval is it throwing exceptions?  Did you attempt to do a small scale test?

  • User profile image
    Sabine

    I need a modification to use the application for our Toastmasters meetings as a countdown timer. Our speeches can last between x and y minutes. After x minutes are reached, the green light of the traffic light switches to yellow. When the maximum time y is reached, the red light is activated. Anyone?

  • User profile image
    Clint

    I'd have two threads.  One turns on your yellow light, the other the red light.  Thread sleep them for the desired milliseconds.

    Another way to do this is to start the program, Thread.Sleep(neededMilliseconds).  then turn on the yellow light.  Then subtract the Redlight time minus the yellow light time to figure out the needed milliseconds and sleep and turn on the red light.

  • User profile image
    Janie

    Okay so I'm kinda new to C# and I've been doing a few projects to get into the swing of it.

    This is an app I will seriously use, but I'm getting an error on SoundBrowserDialog & EnabledToolStripMenuItem saying they don't exist in the current content.

    I'm sure its something right in front of me, but just to make sure I downloaded the source code and double, triple, quadruple checked my code and event handles.

    Your version ran perfectly on my computer, but I keep getting these errors when I try to Debug my own. Any suggestions?

  • User profile image
    Javed

    This is the Best solution that i can show my appliaction icon in system tray and can show ballon message.

    Wish u best of luck and thnx

  • User profile image
    Clint

    @smith yeah, moving foward all Coding4Fun projects will have a "Run It", "Build It" set up as more and more of the stuff we do actually has useful applications Smiley

    This is a pretty old article actually, we'll rebuild it in the future I'm betting.

  • User profile image
    smith

    Wanted such an app today... too lazy to code my own but preferred code to a compiled freeware app.  Downloaded, ran through the VS 2008 upgrade wiz, ran the exe and I for once I left the office on time for my son's school thing.  Thanks Arian Smiley.  Oh, on a typical programmer's Vista 32-Biz without the Windows Media Plyer  SDK installed it of course faulted out on an MP3 but was fine with a real wav.

  • User profile image
    Clint

    @howBoutTheObvious well, doing that is possible but requires some extra work.  You'll need a font that is crisp but very small like SilkScreen (http://www.kottke.org/plus/type/silkscreen/) and you'll have to create the graphic on the fly.  I did the quick math and that font should work.  3 pixels for space, 1 for the colon, that gives you 12 pixels left and each SilkScreen number is 4 pixels in width.

    This may not be a bad program to update and do something like that in the future.

  • User profile image
    howBoutThe​Obvious

    Very cute.  But come on, the darn clock's TIME (TEXT) should appear in the tray.  How to do that?

  • User profile image
    Clint

    @Dummy1912 social.msdn.microsoft.com/.../05dc2d35-1d45-4837-8e16-562ee919da85 looks like that should be able to do it.  You still have the issue of if the physical speakers have their volume turned down.

  • User profile image
    Dummy1912

    How to get if your pc sound is on?

    so you can hear the message.

  • User profile image
    Clint

    @Tom doing a quick glance at the article, I'd do two things, create a new class called "alarm" with a DateTime(alarmTime) and bool(alarmEnabled) then in the app I'd have a list of alarms  I'd follow the pattern Arian laid out since we now it works but anytime you see alarmTime or alarmEnabled, you'd have to alter the code to work with the new class.

    One other item you'd have to do is made a new user interface as well.

  • User profile image
    Tom

    I am new to vb and have written an alarm close to this but with some bells and whistles. Now I want to add the ability to store and run several alarms concurrently. I do not expect a full explanation but some useful pointers or if you have something close for me to look at it would help greatly. Does anyone know how to accomplish this?

  • User profile image
    tom

    I have remade the whole project, but I have no idea about creating the dll. Does anyone have an example of using the class as suggested? I cannot find related information that helps.

  • User profile image
    Tom

    does anyone have a sample of using a class in this way? I tried looking up some examples but I did not understand it.

  • User profile image
    Clint

    @Tom so once you have the project fully done, hit "f5" on your keyboard, Debug->Start Debugging from the menus, or there is a play icon in the toolbars

    The physical files for the project will be where you saved the

    app folder\bin\debug\

    The debug may be release depending on what you set your compile to, i'm going to bet it is debug however.  

    Another quick way to get to the physical files is right click on your project or a folder in that project and go to "Open Folder in Explorer"

  • User profile image
    Clint

    @ajp, This is a .NET example.  You can write the app in c/c++ but would have to be done differently.  You could write in in Managed C++ and the code would be, for the most part, the same.

  • User profile image
    ajp

    Can we write this code in C?

  • User profile image
    Clint

    @Stephen thanks for providing useful feedback!

  • User profile image
    Stephen

    Just in case you didnt know, you can also initiate a new DateTime object using DateTime.Add or DateTime.Subtract, each taking a TimeSpan argument, and you give the TimeSpan object a value of a day and it makes your code "read" better as to your intent Big Smile

  • User profile image
    shashikant

    I am using visual 2008 and how Can I show Time as mention in Your appliction alarmtime,It only show the day ,month,year ,and current time ,how can I srt the alrmtime

  • User profile image
    Clint

    @shashikant if you look in the tick event, you'll see how the alarm actually starts.  The article above outlines this part too.

    if( DateTime.Now.CompareTo(alarmTime) >= 0 ) is how the application actually checks if it is time to fire off the alarm.

Add Your 2 Cents