[Mono-winforms-list] MessageBox

Dasnois Benjamin Dasnois Benjamin <benjamin.dasnois@gmail.com>
Sun, 24 Oct 2004 11:19:17 +0200


------=_Part_4125_5216548.1098609557766
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,
I just did a quick test and it appeared that this is not a MessageBox
problem. The problem certainly is in Form because any Form you try to
ShowDialog will just throw the same exception... A test is attached.


On Sun, 24 Oct 2004 01:12:00 +0100, Paul <paul@all-the-johnsons.co.uk> wrote:
> Hi,
> 
> I'm trying to get the following code to work. It will compile, but when
> I run it, I get the following error
> 
> Unhandled Exception: System.InvalidOperationException: Already visible
> forms cannot be displayed as a modal dialog. Set the Visible property to
> 'false' prior to calling Form.ShowDialog.
> in <0x0008d> System.Windows.Forms.Form:ShowDialog
> (System.Windows.Forms.IWin32Window)
> in <0x00058> (wrapper remoting-invoke-with-check)
> System.Windows.Forms.Form:ShowDialog (System.Windows.Forms.IWin32Window)
> in <0x00012> System.Windows.Forms.Form:ShowDialog ()
> in <0x0004b> (wrapper remoting-invoke-with-check)
> System.Windows.Forms.Form:ShowDialog ()
> in <0x00038> MessageBoxForm:RunDialog ()
> in <0x0004b> (wrapper remoting-invoke-with-check)
> MessageBoxForm:RunDialog ()
> in <0x00040> System.Windows.Forms.MessageBox:Show (string,string)
> in <0x00142> PointTest.PointTest:Main (string[])
> 
> The code is this
> 
> using System;
> using System.Windows.Forms
> 
> namespace PointTest
> {
>   public class Point
>   {
>      private int x, y;
>      public Point()
>      {
>      }
>      public Point( int xValue, int yValue )
>      {
>         X = xValue;
>         Y = yValue;
>      }
>      public int X
>      {
>         get
>         {
>            return x;
>         }
>         set
>         {
>            x = value; // no need for validation
>         }
>      }
>      public int Y
>      {
>         get
>         {
>            return y;
>         }
>         set
>         {
>            y = value; // no need for validation
>         }
>      }
>      public override string ToString()
>      {
>         return "[" + x + ", " + y + "]";
>      }
>   }
> 
>   class PointTest
>   {
>      static void Main( string[] args )
>      {
>         Point point = new Point( 72, 115 );
>         string output = "X coordinate is " + point.X +
>            "\n" + "Y coordinate is " + point.Y;
>         point.X = 10; // set x-coordinate via X property
>         point.Y = 10; // set y-coordinate via Y property
>         output += "\n\nThe new location of point is " + point;
>         MessageBox.Show( output, "Demonstrating Class Point" );
>      }
>   }
> }
> 
> mcs PointTest.cs -r:System.Windows.Forms
> 
> Is this a problem with MessageBox or something else?
> 
> TTFN
> 
> Paul
> --
> "Trust me, I know what I'm doing" - Det. Sledgehammer
> 
> 
> 


-- 
DASNOIS Benjamin

------=_Part_4125_5216548.1098609557766
Content-Type: application/pgp-signature; name=signature.asc
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQBBevNPusSVe5EZv3wRAoeeAJ0Sdx3e5xiSs9jTRwEGNPHpzn8W6wCgg2qe
KOJBCXrK58JiglRvG4IGihY=
=h8vY
-----END PGP SIGNATURE-----


------=_Part_4125_5216548.1098609557766
Content-Type: text/plain; name="Program.cs"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="Program.cs"

=EF=BB=BF#region Using directives

using System;
//using System.Collections.Generic;
using System.Text;

#endregion

namespace tstforms
{
        class Program
        {
                static void Main(string[] args)
                {
                        System.Windows.Forms.Form t =3D new System.Windows.=
Forms.Form();
                        t.ShowDialog();
                }
        }
}

------=_Part_4125_5216548.1098609557766--