1. Technology
Send to a Friend via Email

Your suggestion is on its way!

An email with a link to:

http://delphi.about.com/library/weekly/aa122005a.htm

was emailed to:

Thanks for sharing About.com with others!

Drawing Snowflakes All Over your Desktop Screen
It's time for a little winter joy! Amaze your co-workers: *Snowflakes* application randomly draws and moves snowflake images over your Desktop screen. While having some fun, learn how to create transparent, top-most and caption-less forms that randomly move over your screen.
 More of this Feature
• DOWNLOAD SOURCE CODE
 Join the Discussion
"Post your views, comments, questions and doubts to this article."
Discuss!
 Related Resources
• Form related articles and tricks
• Weird shaped and transparent forms

Stop! Working hard? Deadline approaching? Look outside your window, is it snowing? Look at your Desktop: it is snowing ;)

It's winter time!
If it is not, let's pretend that it is!

I present you the one-and-only, have-fun-while-working-overtime, snowflakes-all-over-your-Desktop screen, full source code Delphi application.

Here's the recipe to amaze yourself and your coworkers (time required: 15 minutes):

  • Let there be a main form (name: "MainSnowFlake") in a Delphi application.
  • Hide the main form from the user by setting "Application.ShowMainForm := False;"
  • Remove the button from the TaskBar.
  • Turn this "program" into a System Tray Application.
  • Add one more form (name: "SnowFlakeForm") to the project, remove it from the "Auto-create forms" list.
  • Add a label to the SnowFlakeForm. Use a font with snowflake images.
  • Play with CreateParams to make this form transparent, top-most, with no title bar. So that only the snowflake "image" remains visible.
  • Add a timer (TTimer) to the SnowFlakeForm and let it randomly move the form over the Desktop screen in the OnTime event.
  • Add a popup menu for the MainSnowFlake form. Popup will feature an "Add snowflake" and an "Exit" item.
  • When the application starts, randomly draw 10 (you pick the number) snawflakes all over the Desktop.
  • Have fun while exploring the full source code.

Delphi draws snowflakes...

Note: this is not a perfect application. It would be better to use an image of the snowflake to create a true transparent form. Yes, this would require some more coding ... and the deadline for your money-making-application is around the corner.

©2014 About.com. All rights reserved.