C# – Adding simple Transitions on Form Load in Winform App

Simple transitions on load can add some extra touch to the user experience. You can add these transitions using different techniques. You can either use a third party framework or you can use custom class library to add these transitions. But in this very quick tutorial, we’ll learn how add those simple transitions without using any third party framework. So, lets get Started.

Tools Required:

  1. Visual Studio 2010 or later version.

Steps to Follow:

  1. Open up Visual Studio Create a new Windows forms Applications project.
  2. Go to the Solution Explorer, Right Click on Project => Add => Class.
  3. Name this class as ‘WinAPI.cs
  4. Add the following lines of Code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AnimateDemo
{
    class WinAPI
    {
        public const int HOR_Positive = 0X1;

        public const int HOR_NEGATIVE = 0X2;

        public const int VER_POSITIVE = 0X4;

        public const int VER_NEGATIVE = 0X8;

        public const int CENTER = 0X10;

        public const int BLEND = 0X80000;

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int AnimateWindow(IntPtr hwand,int dwTime,int dwFlag);
    }
}

Now go to the load event of your Form and call the AnimateWindow like this,

WinAPI.AnimateWindow(this.Handle,2000,WinAPI.CENTER);

In the above line, the second parameter is the duration of the animation or animation delay, and the last parameter is the Transition type. you can change it to,

  1. HOR_Positive
  2. HOR_NEGATIVE
  3. VER_POSITIVE
  4. VER_NEGATIVE
  5. CENTER
  6. BLEND

Video Tutorial:

Watch full video tutorial to learn how to add those transition in WinForm App C#.

simple transitions on load

Source Code:

I hope you enjoyed this article, Please don’t forget to Subscribe our official YouTube Channel C# Ui Academy

One Reply to “C# – Adding simple Transitions on Form Load in Winform App”

Comments are closed.