G
Ger
I have a form with a panel (Panel1) in which I dynamically create picturebox
controls. Works like a dream with static pictures, but not when the
picturebox.image is an animated gif. GDI+ throws the following error in this
case:
"An unhandled exception of type
'System.Runtime.InteropServices.ExternalException' occurred in
system.windows.forms.dll
Additional information: A generic error occurred in GDI+."
My code looks as follows:
Private Sub addImage(ByVal Im As Image)
'This sub will instantiate a new picturebox and create eventhandler
for it
'The image for the picturebox is passed as parameter to this sub
Dim p As New System.Windows.Forms.PictureBox
Try
p.Height = 44
p.Width = 80
p.Image = Im
p.BorderStyle = BorderStyle.None
p.SizeMode = PictureBoxSizeMode.AutoSize
Panel1.Controls.Add(p)
p.Invalidate()
AddHandler p.MouseDown, AddressOf Me.newToolboxIcon_MouseDown
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
What can cause the error? I tend to think of a bug in GDI+, because in some
other applications with one picturebox straight on the form (so not in a
panel, and not dynamically created) it works OK, also with animated gifs.
Please help!
/Ger
controls. Works like a dream with static pictures, but not when the
picturebox.image is an animated gif. GDI+ throws the following error in this
case:
"An unhandled exception of type
'System.Runtime.InteropServices.ExternalException' occurred in
system.windows.forms.dll
Additional information: A generic error occurred in GDI+."
My code looks as follows:
Private Sub addImage(ByVal Im As Image)
'This sub will instantiate a new picturebox and create eventhandler
for it
'The image for the picturebox is passed as parameter to this sub
Dim p As New System.Windows.Forms.PictureBox
Try
p.Height = 44
p.Width = 80
p.Image = Im
p.BorderStyle = BorderStyle.None
p.SizeMode = PictureBoxSizeMode.AutoSize
Panel1.Controls.Add(p)
p.Invalidate()
AddHandler p.MouseDown, AddressOf Me.newToolboxIcon_MouseDown
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
What can cause the error? I tend to think of a bug in GDI+, because in some
other applications with one picturebox straight on the form (so not in a
panel, and not dynamically created) it works OK, also with animated gifs.
Please help!
/Ger