[Mono-winforms-list] set_Value seems to be having a problem

Jackson Harper jackson at ximian.com
Tue Apr 18 18:11:49 EDT 2006


This bug is fixed in SVN. Thanks for the report.

Jackson


On Tue, 2006-04-18 at 12:16 +0100, PFJ wrote:
> Hi,
> 
> I have a small image viewer which has been working for quite a while
> now. However, I've just come to run it and it throws up an error after
> loading a jpeg
> 
> Unhandled Exception: System.ArgumentException: '-214783648' not a valid
> value for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'
> <in 0x00163> System.Windows.Forms.ScrollBar:set_Value(Int32 value)
> 
> The jpeg is a valid jpeg (displays in eye of gnome)
> 
> Any ideas what is happening? Source code and throwback is attached.
> 
> As always, I'm happy to BZ this and admit now that the problem could
> either be in my head, on my machine, or not be anything at all because
> I'm a twit at times.
> 
> mono compiled from source (svn) at about 10.30 British Summer Time
> 
> TTFN
> 
> Paul
> 
> 8-->
> /*
>  * ImageViewer.cs - Simple MDI-based image viewer.
>  *
>  * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
>  *
>  * This program is free software, you can redistribute it and/or modify
>  * it under the terms of the GNU General Public License as published by
>  * the Free Software Foundation, either version 2 of the License, or
>  * (at your option) any later version.
>  *
>  * This program is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY, without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>  * GNU General Public License for more details.
>  *
>  * You should have received a copy of the GNU General Public License
>  * along with this program, if not, write to the Free Software
>  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
> USA
>  */
> 
> using System;
> using System.IO;
> using System.Drawing;
> using System.Drawing.Drawing2D;
> using System.Windows.Forms;
> 
> public class ImageViewer : Form
> {
> 	private ImageViewer()
> 	{
> 		MenuItem openMenuItem = new MenuItem("Open");
> 		MenuItem quitMenuItem = new MenuItem("Quit");
> 		MenuItem fileMenuItem =
> 			new MenuItem("File", new MenuItem[]
> 				{openMenuItem, quitMenuItem});
> 		MainMenu mainMenu = new MainMenu(new MenuItem[] { fileMenuItem });
> 		Menu = mainMenu;
> 
> 		Size = new Size(600, 500);
> 		Text = "DotGNU Image Viewer";
> 		IsMdiContainer = true;
> 
> 		openMenuItem.Click += new EventHandler(OpenClicked);
> 		quitMenuItem.Click += new EventHandler(QuitClicked);
> 	}
> 
> 	private void OpenClicked(Object sender, EventArgs e)
> 	{
> 		OpenFileDialog dialog = new OpenFileDialog();
> 		dialog.Filter =
> 			"All image files (*.bmp, *.jpg, *.png, *.gif, *.ico, *.cur)" +
> 			"|*.bmp;*.jpg;*.png;*.gif;*.ico;*.cur" +
> 			"|BMP files (*.bmp)|*.bmp" +
> 			"|JPEG files (*.jpg)|*.jpg" +
> 			"|PNG files (*.png)|*.png" +
> 			"|GIF files (*.gif)|*.gif" +
> 			"|Icon files (*.ico)|*.ico" +
> 			"|Cursor files (*.cur)|*.cur" +
> 			"|All files (*.*)|*.*";
> 		if(dialog.ShowDialog(this) == DialogResult.OK)
> 		{
> 			Bitmap image;
> 			try
> 			{
> 				image = new Bitmap(dialog.FileName);
> 			}
> 			catch(Exception)
> 			{
> 				MessageBox.Show
> 					(String.Format("Unknown image format for \"{0}\"",
> 								   dialog.FileName),
> 					 "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
> 				image = null;
> 			}
> 			if(image != null)
> 			{
> 				ImageWindow window = new ImageWindow
> 					(dialog.FileName, image);
> 				window.MdiParent = this;
> 				window.Visible = true;
> 			}
> 		}
> 	}
> 
> 	private void QuitClicked(Object sender, EventArgs e)
> 	{
> 		Close();
> 	}
> 
> 	protected override bool ProcessDialogKey(Keys keyData)
> 	{
> 		if(keyData == (Keys.Control | Keys.O))
> 		{
> 			OpenClicked(this, EventArgs.Empty);
> 			return true;
> 		}
> 		return base.ProcessDialogKey(keyData);
> 	}
> 
> 	public static void Main(String[] args)
> 	{
> 		ImageViewer form = new ImageViewer();
> 		Application.Run(form);
> 	}
> 
> }
> 
> internal class ImageWindow : Form
> {
> 	private Image image;
> 
> 	public ImageWindow(String filename, Image image)
> 	{
> 		this.image = image;
> 		ClientSize = image.Size;
> 		Text = Path.GetFileName(filename);
> 	}
> 
> 	protected override void OnPaint(PaintEventArgs args)
> 	{
> 		args.Graphics.DrawImage(image, 0, 0);
> 	}
> 
> }
> 
> 
> Unhandled Exception: System.ArgumentException: '-2147483648' is not a
> valid value for 'Value'. 'Value' should be between 'Minimum' and
> 'Maximum'
> in <0x00163> System.Windows.Forms.ScrollBar:set_Value (Int32 value)
> in (wrapper remoting-invoke-with-check)
> System.Windows.Forms.ScrollBar:set_Value (int)
> in <0x00131> System.Windows.Forms.MdiClient:CalcHBar (Int32 left, Int32
> right, Int32 right_edge, Boolean vert_vis)
> in <0x007d7> System.Windows.Forms.MdiClient:SizeScrollBars ()
> in <0x0000a> System.Windows.Forms.MdiClient:FormLocationChanged
> (System.Object sender, System.EventArgs e)
> in (wrapper delegate-invoke)
> System.MulticastDelegate:invoke_void_object_EventArgs
> (object,System.EventArgs)
> in <0x0002e> System.Windows.Forms.Control:OnLocationChanged
> (System.EventArgs e)
> in <0x0016a> System.Windows.Forms.Control:UpdateBounds (Int32 x, Int32
> y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight)
> in <0x00149> System.Windows.Forms.Control:UpdateBounds ()
> in <0x00375> System.Windows.Forms.Control:WndProc
> (System.Windows.Forms.Message m)
> in <0x0000d> System.Windows.Forms.ScrollableControl:WndProc
> (System.Windows.Forms.Message m)
> in <0x0000d> System.Windows.Forms.ContainerControl:WndProc
> (System.Windows.Forms.Message m)
> in <0x00370> System.Windows.Forms.Form:WndProc
> (System.Windows.Forms.Message m)
> in <0x00014> System.Windows.Forms.Control+ControlNativeWindow:WndProc
> (System.Windows.Forms.Message m)
> in <0x0011e> System.Windows.Forms.NativeWindow:WndProc (IntPtr hWnd, Msg
> msg, IntPtr wParam, IntPtr lParam)
> in <0x00013> System.Windows.Forms.XplatUIX11:SendMessage (IntPtr hwnd,
> Msg message, IntPtr wParam, IntPtr lParam)
> in <0x0024e> System.Windows.Forms.XplatUIX11:SetVisible (IntPtr handle,
> Boolean visible)
> in <0x0001a> System.Windows.Forms.XplatUI:SetVisible (IntPtr handle,
> Boolean visible)
> in <0x0007d> System.Windows.Forms.Control:SetVisibleCore (Boolean value)
> in <0x0000f> System.Windows.Forms.Form:SetVisibleCore (Boolean value)
> in <0x00013> System.Windows.Forms.Control:set_Visible (Boolean value)
> in (wrapper remoting-invoke-with-check)
> System.Windows.Forms.Control:set_Visible (bool)
> in <0x00144> ImageViewer:OpenClicked (System.Object sender,
> System.EventArgs e)
> in (wrapper delegate-invoke)
> System.MulticastDelegate:invoke_void_object_EventArgs
> (object,System.EventArgs)
> in <0x0001d> System.Windows.Forms.MenuItem:OnClick (System.EventArgs e)
> in <0x00010> System.Windows.Forms.MenuItem:PerformClick ()
> in (wrapper remoting-invoke-with-check)
> System.Windows.Forms.MenuItem:PerformClick ()
> in <0x00377> System.Windows.Forms.MenuTracker:OnClick
> (System.Windows.Forms.MouseEventArgs args)
> in <0x00e61> System.Windows.Forms.Form:WndProc
> (System.Windows.Forms.Message m)
> in <0x00014> System.Windows.Forms.Control+ControlNativeWindow:WndProc
> (System.Windows.Forms.Message m)
> in <0x0011e> System.Windows.Forms.NativeWindow:WndProc (IntPtr hWnd, Msg
> msg, IntPtr wParam, IntPtr lParam)
> in <0x00016> System.Windows.Forms.XplatUIX11:DispatchMessage
> (System.Windows.Forms.MSG msg)
> in <0x00015> System.Windows.Forms.XplatUI:DispatchMessage
> (System.Windows.Forms.MSG msg)
> in <0x005fe> System.Windows.Forms.Application:RunLoop (Boolean Modal,
> System.Windows.Forms.ApplicationContext context)
> in <0x00024> System.Windows.Forms.Application:Run
> (System.Windows.Forms.Form mainForm)
> in <0x00024> ImageViewer:Main (System.String[] args)
> <--8
> 



More information about the Mono-winforms-list mailing list