Hi SridharV,
To show an animated gif in the background of a form, we can set the BackgroundImage of the Form to a gif image and then use ImageAnimator to handle the animation. This is a code snippet:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//Enable double buffering to reduce flicker.
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
//Enable paint via message to reduce flicker.
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
//Whether the animation starts.
bool currentlyAnimating = false;
//Indicate if update the animation.
bool isAnimating = true;
protected override void OnPaintBackground(PaintEventArgs e)
{
if (isAnimating)
{
//Begin the animation.
AnimateImage();
//Update the frames. The cell would paint the next frame of the image late on.
ImageAnimator.UpdateFrames();
}
base.OnPaintBackground(e);
}
//This method begins the animation.
public void AnimateImage()
{
if (!currentlyAnimating)
{
ImageAnimator.Animate(this.BackgroundImage, new EventHandler(this.OnFrameChanged));
currentlyAnimating = true;
}
}
private void OnFrameChanged(object o, EventArgs e)
{
//Force to redraw the form.
this.Invalidate();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("alala");
}
}
This is a similar thread: http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/0d9e790e-6816-40e7-96fe-bbf333a4abc0/.
To disable a form, we can set the Enable property of the Form to false.
Let me know if this helps or not.
Aland Li
Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.