Click here to Skip to main content
15,883,778 members
Articles / Programming Languages / C++

Clock Screen Saver

Rate me:
Please Sign up or sign in to vote.
4.73/5 (42 votes)
27 Jun 2004CPOL4 min read 154.6K   4.5K   48   41
A mouse trailing clock screen saver written in MFC
This project is a screen saver application that I originally started as a way to pick up C++/MFC. In the years since, I’ve added some features to it like Outlook Calendar and MAPI support for signaling when new mail arrives while the screen saver is active.

Image 1

Introduction

This project is a screen saver application that I originally started as a way to pick up C++/MFC. That was a few years back, and in that time I’ve gone back to it a number of times to add new features and try new things. It’s made the rounds of my family’s and friend’s computers and, since they all seem to like it, I thought I’d put it out here on CodeProject in the hopes that you all may enjoy it as well.

Background

Back in 2001, after the Internet bubble burst, the two man consulting company I was part of found itself suddenly without clients or cash. So it was back to working for the man for the both of us. My former business partner found a job before I did and was kind enough to brow-beat his new boss into giving me an interview as well.

At the time, I had done mostly VB6 programming, and during the interview it became quickly apparent that they were looking for an MFC developer. I had done some C++ programming and did as well as I could under the circumstances but came home certain that I wouldn’t get the job.

Well, as they say, necessity is the mother of invention. That, plus a quickly dwindling bank account and plenty of free time makes for a great motivator, so I thought I’d better do something quick to prove that I was the person for the job.

At this same time, my dad sent me a cool web page that used some pretty impressive JavaScript in order to create an animated clock that tracked the user’s mouse as it moved around the page. He wanted to know if there was any way to turn it into a screen saver.

I decided to implement the same thing in MFC, and send it off to the guys who had interviewed me in the hopes of changing their minds.

After a week of nearly round the clock (pun intended) study and development, I had it working to the point that I figured it was ready to go. Literally, as I was writing the email to the head of the department where I had been interviewed, explaining the application and my motivation for writing it, he called me on the phone. A change of direction on the project, and some additional prodding from my associate lead them to hire me!

So I never did send him this application, but my dad enjoyed it and I learned a lot in that short time.

In the years since, I’ve added some features to it like Outlook Calendar and MAPI support for signaling when new mail has arrived while the screen saver is active. So now, it’s actually a nice little program, and kind of a fun screen saver to boot.

Using the Code

Because the Outlook integration requires some MS Office type libraries, and I’m sure it’s not legal to redistribute those, I have conditional compilation statements around those parts. If you do want to compile the Outlook integration code, you’ll need a copy of MSOUTL.OLB and MSO9.DLL. Define MS_OFFICE_INTEGRATION in stdafx.h, make sure the two Office typelibs are in the right place, and it should compile.

The version installed by the downloadable MSI (above) includes the Outlook integration functionality.

The MAPI mail notification should work with any MAPI compliant email client, but I’ve only tested it with Outlook Express, so your mileage may vary.

Once you install ClockSaver.scr, it will show up in your list of available screen savers as ClockSaver.

Some Acknowledgements

I don’t know to whom to attribute the original JavaScript clock as the HTML page that I got from my dad did not have any information about the author.

The screen saver base class came from an article by chensu, posted on CodeGuru.com. (Give me a break, I hadn’t heard about CodeProject yet).

Points of Interest

One of the most interesting things about working on this project over such a long period, is that a lot of the code comes from CodeProject, which I think is a testament to how valuable a resource this site is!

This project uses:

The code to support multiple monitors I eventually turned into some reusable classes, so it also uses MFC Classes for Multiple Monitors.

History

  • 30th May, 2004: Initial release 1.1.3
  • 14th June, 2004: 1.1.4
    • Added separate color settings for second hand and date
    • Spruced up the config dialog
    • Added shutdown computer option
    • Bugs fixes, refactoring and extensive code clean-up
  • 24th June, 2004: 1.1.5
    • Fixed bug with AnimateWindow
    • Improved MAPI support
    • Added "force left to right" option
    • Added custom text option
    • Added NT4 support

License

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


Written By
Team Leader Starkey Laboratories
United States United States
The first computer program I ever wrote was in BASIC on a TRS-80 Model I and it looked something like:
10 PRINT "Don is cool"
20 GOTO 10

It only went downhill from there.

Hey look, I've got a blog

Comments and Discussions

 
GeneralBad Work !!! Pin
Aris Adrianto S11-Jun-04 10:30
Aris Adrianto S11-Jun-04 10:30 
GeneralGreat work Pin
Shail_Srivastav7-Jun-04 10:48
Shail_Srivastav7-Jun-04 10:48 
GeneralReally nice! Pin
bneacetp6-Jun-04 11:54
bneacetp6-Jun-04 11:54 
GeneralRe: Really nice! Pin
Larrgh28-Dec-04 6:51
Larrgh28-Dec-04 6:51 
GeneralRe: Really nice! Pin
Don Kackman28-Dec-04 7:05
Don Kackman28-Dec-04 7:05 
GeneralAwsome Pin
Shekar Narayanan4-Jun-04 3:06
Shekar Narayanan4-Jun-04 3:06 
Generalvery nice ! Pin
TeeBee3033-Jun-04 22:53
TeeBee3033-Jun-04 22:53 
GeneralFunctional and entertaining !! Pin
WREY3-Jun-04 19:43
WREY3-Jun-04 19:43 
Very nice! An encouraging '5' from me!

"Encouraging," because to rate it less would be a discouragement to something you've kept working on for quite a while (and never gave up). That's endurance, and such quality alone is worthy of a '5', moreso when you finally bring the product to fruition.

Nonetheless, the work could do with a bit of a sprucing up. For example, give the "second" hand a different color, and intermittently make the clock move to different parts of the screen in the same swirling manner when you move the mouse. Do this automatically rather than have it just sitting in one place all the time.

And talking about "time", consider this a big bonus if you could have it shut the person's machine down after a certain time has expired (as set by the user). Now that would be adding some kind of functionality to an already useful tool.

Great job (with greater possibilities)!!

Wink | ;)

William

Fortes in fide et opere!
GeneralRe: Functional and entertaining !! Pin
AllenR3-Jun-04 20:47
professionalAllenR3-Jun-04 20:47 
GeneralRe: Functional and entertaining !! Pin
TeaShirt4-Jun-04 3:00
TeaShirt4-Jun-04 3:00 
GeneralRe: Functional and entertaining !! Pin
Don Kackman4-Jun-04 4:31
Don Kackman4-Jun-04 4:31 
GeneralRe: Functional and entertaining !! Pin
WREY4-Jun-04 19:23
WREY4-Jun-04 19:23 
GeneralRe: Functional and entertaining !! Pin
Don Kackman5-Jun-04 18:11
Don Kackman5-Jun-04 18:11 
GeneralRe: Functional and entertaining !! Pin
WREY6-Jun-04 7:16
WREY6-Jun-04 7:16 
GeneralRe: Functional and entertaining !! Pin
Don Kackman16-Jun-04 2:44
Don Kackman16-Jun-04 2:44 
GeneralThis is sooooo cooooool !! Pin
WREY16-Jun-04 4:58
WREY16-Jun-04 4:58 
GeneralSweet!!! Pin
Luis Alonso Ramos3-Jun-04 18:54
Luis Alonso Ramos3-Jun-04 18:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.