Click here to Skip to main content
12,820,114 members (25,354 online)
Click here to Skip to main content
Add your own
alternative version


10 bookmarked
Posted 20 Jun 2006

Simple Arrow Animation

, 20 Jun 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
This article and code explains how we can implement simple animations with out much technical skills.

Sample Image


This simple program explains how simple animations are implemented, using for loops etc.


Actually, this program was made for my Instant Messaging Client - Gaim. I needed to know when my boss come online and when he went offline. Gaim has a feature called "Buddy Pounce" which allows users to trigger events. As per my logic, when a user logs in, my application will give me a signal by flying an arrow from right-bottom to left-top. And when he goes offline, the arrow moves from left-top to right-bottom.

Using the code

The images are stored as resources, and I call them depending on the value of Status:

this.BackgroundImage = Resource1.arrow2;

I have used this code to check whether the user is logged in or logged off. This accepts command line arguments. When Status is true, it means "LogIn", otherwise it means "LogOff".

if (args.Length > 0)
    if (args[0].ToString() == "logoff") 
        Status = false;

The animation logic is placed inside a Timer_Tick method. Inside the method, the screen width and height are validated, so this program will work under all screen resolutions. An Application.DoEvents(); call is placed in between, to avoid system concentrating on this app only.

private void timer1_Tick(object sender, EventArgs e)
    if (Program.Status)
        if (this.Top <= 0 || this.Left <= 0)
            timer1.Enabled = false;

        this.Left -= 25;
        this.Top -= 15;
        if (this.Top > Screen.GetBounds(this).Height || 
            this.Left > Screen.GetBounds(this).Width)
            timer1.Enabled = false;

        this.Left += 25;
        this.Top += 15;


This is my second version of this program but, this is my first version of this article.


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


About the Author

Praveen Nair (NinethSense)
India India
Praveen.V.Nair - aka NinethSense - PMP, Microsoft MVP - is working as a Head of Technology and Architecture at Orion India Systems, Kochi, India. He has been playing with electronics from the age of 10 and with computers from the age of 14. He usually blogs at

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
manoj kumar choubey26-Feb-12 22:18
membermanoj kumar choubey26-Feb-12 22:18 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 20 Jun 2006
Article Copyright 2006 by Praveen Nair (NinethSense)
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid