Gif in a child window

D

Dominic

Hi there,

I've a form application which calls a couple of child forms.

The 1st child checks the registry for some data, if it doesn't find it it
calls the 2nd child so some user input can be collected, when the input is
collected a 3rd form is called and is supposed to display a nice animated
gif so taht there is at least something for the user to see while some
data is collected whilst the input is worked on. The thing is that I can't
get the 3rd form to display the animated gif... there's just a white
square of the correct dimensions... any ideas?

Code:


private void getAndProcessContacts() {
alterRegKey("user", secondForm.textBox1.Text);
alterRegKey("pass", secondForm.textBox2.Text);
thirdForm.ControlBox = false;
String appPath = Path.GetDirectoryName(Application.ExecutablePath)
Image img = Image.FromFile(appPath + @"\animatedGif.gif");
thirdForm.pictureBox1.Image = img;
thirdForm.Show();
comboBox1.DataSource = getStuff();
thirdForm.Hide();
}

Help appreciated.

Cheers,

Dom
 
J

Jeff Johnson

Image img = Image.FromFile(appPath + @"\animatedGif.gif");
thirdForm.pictureBox1.Image = img;

I seriously doubt that a PictureBox is capable of displaying an animated GIF
by itself. Look up the System.Drawing.ImageAnimator class and check the
Animate() method for a code sample.
 
J

Jeff Johnson

Actually, PictureBox handles animated GIFs just fine. I learned this a
few years ago, and was just as surprised as you probably are to hear it.
:)

Ah. I checked the help for PictureBox and didn't see animated GIFs mentioned
explicitly (which I figured was important enough to deserve a nod). I guess
it's one of those things you have to find out some other way....
 
R

Registered User

Hi there,

I've a form application which calls a couple of child forms.

The 1st child checks the registry for some data, if it doesn't find it it
calls the 2nd child so some user input can be collected, when the input is
collected a 3rd form is called and is supposed to display a nice animated
gif so taht there is at least something for the user to see while some
data is collected whilst the input is worked on. The thing is that I can't
get the 3rd form to display the animated gif... there's just a white
square of the correct dimensions... any ideas?


It soundslike the data collected by the second form is being processed
in the same thread used to display the third form. While processing
the data the thread is unable to maintain the GUI. Look at the
BackgroundWorker thread type. Once the data has been entered into the
second form use a background worker to process the data and let the UI
thread deal with displaying the third form. When the background worker
completes its task an event will be fired. This event can be used to
close the third form and then the app can do what it has to do.

Probably not the clearest explanation but it's a start...

regards
A.G.
 
D

Dominic

It soundslike the data collected by the second form is being processed
in the same thread used to display the third form. While processing
the data the thread is unable to maintain the GUI. Look at the
BackgroundWorker thread type. Once the data has been entered into the
second form use a background worker to process the data and let the UI
thread deal with displaying the third form. When the background worker
completes its task an event will be fired. This event can be used to
close the third form and then the app can do what it has to do.

Probably not the clearest explanation but it's a start...

regards
A.G.

Cheers Jeff, A.G. and Peter,

that worked a treat. More things to think about now though... ;-)

Thanks again,

Dom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top