I have a form with a button control. When button is clicked; it run a process
which take a bit of time to complete the process.
When this button is clicked; I want to animate an image on the screen while
this process is in progerss. It is the same as displaying a progress bar butI
want to display animated image.
How do I do it in vs2005? My code is similiar to the following:
public partial class Form1 : Form
{
private Bitmap img;
private string sFilename = "C:\\MyGif.gif" ;
PictureBox imgPhoto = new PictureBox();
public Form1()
{
InitializeCompo nent();
img = new Bitmap(sFilenam e);
}
private void button1_Click(o bject sender, EventArgs e)
{
ProgressAnimati on();
MyLongRunningPr ocess()
}
private void MyLongRunningPr ocess()
{
Retrieve20Milli onRecordsFromDa tabase();
}
private void Retrieve20Milli onRecordsFromDa tabase()
{
DoThis();
DoThat();
---- etc.
---- etc.
}
private void ProgressAnimati on()
{
imgPhoto.Border Style = System.Windows. Forms.BorderSty le.Fixed3D;
imgPhoto.Height = 30;
imgPhoto.Width = 100;
imgPhoto.Left = 10;
imgPhoto.Top = 20;
imgPhoto.BackCo lor = Color.Red;
Controls.Add(im gPhoto);
imgPhoto.Image = img;
}
}
which take a bit of time to complete the process.
When this button is clicked; I want to animate an image on the screen while
this process is in progerss. It is the same as displaying a progress bar butI
want to display animated image.
How do I do it in vs2005? My code is similiar to the following:
public partial class Form1 : Form
{
private Bitmap img;
private string sFilename = "C:\\MyGif.gif" ;
PictureBox imgPhoto = new PictureBox();
public Form1()
{
InitializeCompo nent();
img = new Bitmap(sFilenam e);
}
private void button1_Click(o bject sender, EventArgs e)
{
ProgressAnimati on();
MyLongRunningPr ocess()
}
private void MyLongRunningPr ocess()
{
Retrieve20Milli onRecordsFromDa tabase();
}
private void Retrieve20Milli onRecordsFromDa tabase()
{
DoThis();
DoThat();
---- etc.
---- etc.
}
private void ProgressAnimati on()
{
imgPhoto.Border Style = System.Windows. Forms.BorderSty le.Fixed3D;
imgPhoto.Height = 30;
imgPhoto.Width = 100;
imgPhoto.Left = 10;
imgPhoto.Top = 20;
imgPhoto.BackCo lor = Color.Red;
Controls.Add(im gPhoto);
imgPhoto.Image = img;
}
}
Comment