Click here to Skip to main content
15,860,972 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.3K   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

 
GeneralBUG: the screen saver name Pin
shineway16-Jul-05 3:14
shineway16-Jul-05 3:14 
AnswerRe: BUG: the screen saver name Pin
Jinoh7-Apr-12 4:04
Jinoh7-Apr-12 4:04 
GeneralClock Screen Saver Pin
monarch1118-Jul-04 23:02
monarch1118-Jul-04 23:02 
GeneralHere's an idea. Pin
WREY4-Jul-04 3:51
WREY4-Jul-04 3:51 
GeneralInternational date Pin
Member 1811732-Jul-04 7:12
Member 1811732-Jul-04 7:12 
GeneralRe: International date Pin
Don Kackman2-Jul-04 15:55
Don Kackman2-Jul-04 15:55 
GeneralRe: International date Pin
Member 1811733-Jul-04 6:42
Member 1811733-Jul-04 6:42 
GeneralRe: International date Pin
Don Kackman3-Jul-04 13:34
Don Kackman3-Jul-04 13:34 
GeneralDoes not work for me Pin
Krotovs18-Jun-04 8:31
Krotovs18-Jun-04 8:31 
GeneralRe: Does not work for me Pin
Don Kackman19-Jun-04 5:47
Don Kackman19-Jun-04 5:47 
GeneralFixed Pin
Don Kackman28-Jun-04 19:14
Don Kackman28-Jun-04 19:14 
GeneralRe: Fixed - Still doesn't work for me on NT Pin
Krotovs30-Jun-04 7:03
Krotovs30-Jun-04 7:03 
GeneralRe: Fixed - Still doesn't work for me on NT Pin
Don Kackman8-Jul-04 14:43
Don Kackman8-Jul-04 14:43 
GeneralWin XP Pro + NUMBERIC mode problem Pin
Mixa116-Jun-04 14:20
Mixa116-Jun-04 14:20 
GeneralRe: Win XP Pro + NUMBERIC mode problem Pin
Don Kackman22-Jun-04 7:54
Don Kackman22-Jun-04 7:54 
GeneralFixed Pin
Don Kackman28-Jun-04 19:16
Don Kackman28-Jun-04 19:16 
Generala small problem Pin
Yingwei Yang16-Jun-04 7:33
Yingwei Yang16-Jun-04 7:33 
GeneralCute, I like it ( nt ) Pin
Maximilien16-Jun-04 3:28
Maximilien16-Jun-04 3:28 
GeneralDoesn't work for me Pin
Darren Schroeder16-Jun-04 2:58
Darren Schroeder16-Jun-04 2:58 
GeneralRe: Doesn't work for me Pin
Don Kackman16-Jun-04 11:08
Don Kackman16-Jun-04 11:08 
GeneralRe: Doesn't work for me Pin
Darren Schroeder16-Jun-04 13:07
Darren Schroeder16-Jun-04 13:07 
GeneralRe: Doesn't work for me Pin
Don Kackman28-Jun-04 19:19
Don Kackman28-Jun-04 19:19 
GeneralCould you ... Pin
Rage15-Jun-04 21:25
professionalRage15-Jun-04 21:25 
GeneralRe: Could you ... Pin
Don Kackman16-Jun-04 2:27
Don Kackman16-Jun-04 2:27 
GeneralBad Work !!! Pin
Aris Adrianto S11-Jun-04 10:30
Aris Adrianto S11-Jun-04 10:30 

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.