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;
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
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:
We’ll probably add this to the next release of the Smart Device Framework.