Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I have a panel on a form.
If I set the background image of the panel when I run my app on windows XP I get the following error.

************** Exception Text **************
System.ArgumentException: Parameter is not valid.
   at System.Drawing.Image.get_Flags()
   at System.Windows.Forms.ControlPaint.IsImageTransparent(Image backgroundImage)
   at System.Windows.Forms.Control.set_BackgroundImageLayout(ImageLayout value)
   at TestCrashApp.frmMessage.InitializeComponent() in C:\Projects\Test Projects\TestCrashApp\TestCrashApp\frmMessage.Designer.vb:line 34
   at TestCrashApp.frmMessage..ctor()
   at TestCrashApp.Form1.Button1_Click(Object sender, EventArgs e) in C:\Projects\Test Projects\TestCrashApp\TestCrashApp\Form1.vb:line 5
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



If I remove the background image it runs fine.

The app runs fine on windows 7 also.

Any ideas what I can do to resolve this.

Cheers Guys
Posted
Updated 26-Jul-10 22:36pm
v2
Comments
Dalek Dave 27-Jul-10 4:36am    
Edited for Readability, Spelling and Grammar.
tiggerc 27-Jul-10 4:42am    
Cheers Dave!, I'm not very good at spelling.
DaveAuld 27-Jul-10 4:43am    
Have you tried loading the image at runtime and seeing if the crash still occurs?

Since you do not have a System.Windows.Forms.PaintEventArgs
error, I'm just wondering if you have set the background in a
Panel1.paint subroutine?

Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

If yes, then please show some code and where the error occurs!
 
Share this answer
 
Comments
tiggerc 27-Jul-10 5:40am    
I hadn't set the image in an on paint event I had set the image at design time, after some messign about, I resolved this see answer below.
I had an issue with the actual image, it was a Jpeg, but i don't think XP like the Jpeg, I converted the image to Bitmap, and it works fine now, thanks for the input guys.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900