Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / September 2006

Tip: Looking for answers? Try searching our database.

VS.NET 2005: Picturebox with animated GIF causes error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LongBow - 27 Sep 2006 08:26 GMT
Hello,

 I have a problem that I am not sure what is causing the error.
Basically, I have a Picturebox on a form which the image is set to an
animated gif at design time. When the application runs all is well and
the gif is iterating through each of the frames.

 Then if I attempt to change the image and set it to another animated
gif I get the following errors:

"A generic error occurred in GDI+"
"No symbols are loaded for any call stack frame. The source code
cannot be displayed"

The following code is how I am linking the image to the picture box at
runtime...

private void SetImage( )
{
 System.IO.Stream             resourceStream = null;
 Bitmap                       image = null;            
 System.Reflection..Assembly  assemblyRef;
 string                       resName;

 resName = "PCTestStation.images.throbber_TB_still.gif";
 assemblyRef = SR.Assembly.GetExecutingAssembly();
 resourceStream = assemblyRef.GetManifestResourceStream( resName );

 if( resourceStream != null )
 {                    
   // create a new bitmap from this stream
   image = Bitmap.FromStream( resourceStream ) as Bitmap;
   if( image != null )
   {
     Throbber.Image = image;
   }
   resourceStream.Close();
   resourceStream = null;
 }
}

Any help is greatly appreciated. Thanks

Mark
FUnky - 27 Sep 2006 08:57 GMT
Why are you using images like this? Use the in-built rich support of .Net
2.0.

Copy and paste your image (throbber_TB_still.gif) in the
Properties\Resources.resx file.
And then simply access it via :
Throbber.Image =
global::<ProjectName>.Properties.Resources.throbber_TB_still;

You can even create a Bitmap and then use it.

Hope this helps.
FUnky

> Hello,
>
[quoted text clipped - 40 lines]
>
> Mark
LordHog@hotmail.com - 28 Sep 2006 16:39 GMT
Funky,

 Thanks for the information and this did indeed work. I initially
tried pasting the images into the resource file of the form that uses
the images, but that didn't work. I eventually figured out that the
images needed to be place into the project resources in order for it
see the global resources.

 Why does this method work, but the initial path I took didn't? Is it
because the stream was closed after the method finished executing?

Mark

> Why are you using images like this? Use the in-built rich support of .Net
> 2.0.
[quoted text clipped - 54 lines]
> >
> > Mark

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.