Shutting off CE Form Animation

Today we were working on some final testing of a new app and I was irritated by the About Form’s behavior of generice CE devices.  When we went to display the form, we’d get the ugly “expanding rectangle” animation of the Form opening, and even worse, when we closed it it would animate the close, then animate the re-opeing of the main form.

Unfortunately the Compact Framework give us absolutely nothing for controlling this behavior (hello?  Windows Mobile isn’t the only platform the CF is used on….).  So we have to work around it.

Add the following to your form (or a utility class is what we actually used, as we called this from multiple places):

private const int WS_EX_NOANIMATION = 0x04000000;
private const int GWL_EX_STYLE = -20;

[DllImport(“Coredll.dll”, SetLastError=true)]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

[DllImport(“coredll.dll”, SetLastError=true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);

internal static void StopAnimation(Form form)
    int style = GetWindowLong(form.Handle, GWL_EX_STYLE);
    style |= WS_EX_NOANIMATION;
    SetWindowLong(form.Handle, GWL_EX_STYLE, style);

Then simply call StopAnimation in your Form’s constructor immediately after InitializeComponent is called:

public Form1()

We’ll probably add this to the next release of the Smart Device Framework.

One thought on “Shutting off CE Form Animation”

  1. Even simpler, edit the device registry:-


    (create a DWORD entry if not there) 0 – Disable / 1 – Enable


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s