Click here to Skip to main content
13,297,048 members (57,481 online)
Click here to Skip to main content
Add your own
alternative version


29 bookmarked
Posted 15 Apr 2005

Simulate the "Nudge" Effect

, 15 Apr 2005
Rate this:
Please Sign up or sign in to vote.
A very basic idea for the MSN-style nudging effect,, available on the latest MSN Messenger v7.0, on a Windows Form.


A small class which layouts my basic idea in order to establish the nudge effect that is available under the latest version of MSN Messenger is presented here.


I am not a fanatic user of MSN Messenger, since whenever I sign in, I have to spend endless amounts of time talking with each one of my online buddies, and at the end I don't get any work done. But anyways, this is not the point of the article...

As soon as I downloaded the latest version of MSN Messenger (v7.0), I couldn't help noticing some new buttons they added that provide users with some "cool" functionalities (e.g. for sending a wink). The one that I really liked though was the nudge effect that actually shakes the form around, supposedly waking up whoever it is you are chatting with. I came up with a very small method which tries to simulate this effect and wrapped it in an even smaller class just for the sake of the article. Now, there are many ways to implement this effect and even more things to include in this class (e.g. add sound functionality for being able to nudge your form with different WAV sounds, adding nudge time-intervals by implementing timers for shaking the form, and so on...).

I just wanted to present the basic idea of shaking the form around a bit, and since I wasn't really sure where to post this code snippet for people to take a look at, I decided to wrap it up in a class and post it in an article.

Using the code

Since class "Nudge" is a really small class, I don't think I need to explain any details. The small portion of code that is included here is quite self-explanatory I think. The only thing I want to mention here is that currently, nudging is based on a loop which is not the best tactic. A more consistent way for implementing it is to let the user decide the length of the nudge by implementing a timer.

Anyways, now that we got this out of the way, the basic idea here is the generation of random numbers that are assigned to the form's location inside a loop. After the loop has finished, the form's original location is restored.

// The only method of the class :)
public void NudgeMe()
    // Store the original location of the form.
    int xCoord = this.tmpFrm.Left;
    int yCoord = this.tmpFrm.Top;
    // An integer for storing the random number each time
    int rnd = 0;

    // Instantiate the random generation mechanism
    Random RandomClass = new Random();

    for (int i = 0;  i <= 500; i++)
        rnd = RandomClass.Next(xCoord + 1, xCoord + 15);
        this.tmpFrm.Left = rnd;
        rnd = RandomClass.Next(yCoord + 1, yCoord + 15);
        this.tmpFrm.Top = rnd;

    // Restore the original location of the form
    this.tmpFrm.Left = xCoord;
    this.tmpFrm.Top = yCoord;

The usage of the Nudge class is quite straight-forward. From within the form that you wish to nudge, just enter something like this:

Nudge nudged = new Nudge(this);

Ideas for Additions (for making "Nudge" class a real class!)

  • Sound functionality during nudging.
  • Nudging based on time-intervals set by the user (by implementing timers) instead of a loop.
  • Implement nudging types (e.g. small, medium, massive) based on the value of the random numbers that are created, and on their nudge length.

That's all.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Polis Pilavas
Web Developer
Cyprus Cyprus
Simpsons' fanatic.

You may also be interested in...

Comments and Discussions

GeneralA bit off-topic... Pin
reinux22-Apr-05 12:50
memberreinux22-Apr-05 12:50 
GeneralRe: A bit off-topic... Pin
Polis Pilavas22-Apr-05 12:57
memberPolis Pilavas22-Apr-05 12:57 
GeneralThis is cool! Pin
ajrulez22-Apr-05 12:47
memberajrulez22-Apr-05 12:47 
GeneralRe: This is cool! Pin
Polis Pilavas22-Apr-05 12:58
memberPolis Pilavas22-Apr-05 12:58 
GeneralRe: This is cool! Pin
zenimpulse28-Apr-05 6:59
memberzenimpulse28-Apr-05 6:59 
GeneralRe: This is cool! Pin
Polis Pilavas29-Apr-05 1:49
memberPolis Pilavas29-Apr-05 1:49 
GeneralRe: This is cool! Pin
sabrown10020-Oct-07 12:57
membersabrown10020-Oct-07 12:57 
GeneralMake NudgeMe static Pin
bmiller15-Apr-05 20:54
memberbmiller15-Apr-05 20:54 
GeneralRe: Make NudgeMe static Pin
Polis Pilavas16-Apr-05 2:05
memberPolis Pilavas16-Apr-05 2:05 

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
Web04 | 2.8.171207.1 | Last Updated 15 Apr 2005
Article Copyright 2005 by Polis Pilavas
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid