Since it’s winter, I decided to write about how to create an application that makes snowflakes fall on your desktop. It’s just like snowing on your desktop, but the application is pretty basic so there’s space for improvements - I tried to write a short code so it’s easier to understand.

## 1.How to?

It’s quite simple:

1. create a transparent form the same size as your desktop (you can still use other programs while this form is running)
2. on this form you add about 40-50 PictureBoxes - each one will contain a snowflake image
3. finally you’ll have to use a timer to constantly change their position in the form, so the snowflakes will look like they’re slowly falling

The program presented in this tutorial has 2 parts:

• a class called snowflake
• the main program

## 2.Creating a Snowflake (class/image)

First, try drawing a white snowflake on a black background. Why? We’ll set the black background as transparent so only the true snowflake will be shown.

For my application I used the following image:

Next is the coding part: I created a separate class called snowflake (inherits from PictureBox class).

It contains 3 methods:

create() - sets the PictureBox’s image and also its position in the form

move() - creates a Timer that changes the snowflake’s position

t_tick() - changes the snowflake’s position each 40ms

Note that using a class makes everything much easier.

The code for the class:

## 3. Creating the main program

We want the main program (the form) to be transparent so we’ll make it black and setting it’s size equal to Screen.PrimaryScreen.Bounds.Size. After we must set the TransparencyKey to black.

Finally, we’ll create an array of snowflake(class), that will contain all the snowflakes we want. When an element from that array is instantiated, a new snowflake will spawn and will start falling.

Note: we must use a timer and not a repetitive structure when we create snowflakes - that’s because our instructions run on the UI Thread.

The sourcecode of the main program:

## The Complete Code

Here’s the complete code: