R
Rick
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()
{
InitializeComponent();
img = new Bitmap(sFilename);
}
private void button1_Click(object sender, EventArgs e)
{
ProgressAnimation();
MyLongRunningProcess()
}
private void MyLongRunningProcess()
{
Retrieve20MillionRecordsFromDatabase();
}
private void Retrieve20MillionRecordsFromDatabase()
{
DoThis();
DoThat();
---- etc.
---- etc.
}
private void ProgressAnimation()
{
imgPhoto.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
imgPhoto.Height = 30;
imgPhoto.Width = 100;
imgPhoto.Left = 10;
imgPhoto.Top = 20;
imgPhoto.BackColor = Color.Red;
Controls.Add(imgPhoto);
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()
{
InitializeComponent();
img = new Bitmap(sFilename);
}
private void button1_Click(object sender, EventArgs e)
{
ProgressAnimation();
MyLongRunningProcess()
}
private void MyLongRunningProcess()
{
Retrieve20MillionRecordsFromDatabase();
}
private void Retrieve20MillionRecordsFromDatabase()
{
DoThis();
DoThat();
---- etc.
---- etc.
}
private void ProgressAnimation()
{
imgPhoto.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
imgPhoto.Height = 30;
imgPhoto.Width = 100;
imgPhoto.Left = 10;
imgPhoto.Top = 20;
imgPhoto.BackColor = Color.Red;
Controls.Add(imgPhoto);
imgPhoto.Image = img;
}
}