[Gtk-sharp-list] re:Code Sample

Craig Williams craig@ip80.com
Fri, 20 Feb 2004 07:25:26 -0500


I think you need the following lines;

Application.Init();    // first line

Application.Run();    // last line of Main

Application.Quit();    // in your closing event handler

Craig


> ----- Original Message ----- 
> From: "Alessandro Lendaro" <alendaro1@virgilio.it>
> To: <gtk-sharp-list@lists.ximian.com>
> Sent: Friday, February 20, 2004 6:23 AM
> Subject: [Gtk-sharp-list] [Help] Code Sample
>
>
> > Is somebody willing to post a code sample to make a simple "Hello World"
> > program?
> >
> > I tried to, but the window I open doesn't respond and doesn't show
> > anything in,
> > here the code:
> >
> > (I'm using VS.NET 2002 with the FrameWork v1.0.3705 on a W2000 Server
> > machine, GTK# v. 0.16, no Mono)
> >
> >     class Class1
> >     {
> >         /// <summary>
> >         /// Il punto di ingresso principale dell'applicazione.
> >         /// </summary>
> >         [STAThread]
> >         static void Main(string[] args)
> >         {
> >             try
> >             {
> >
> > //AppDomain.CurrentDomain.AppendPrivatePath(@"C:\Programmi\Common
> > Files\GTK\GtKSharp\lib");
> >                 int rc;
> >                 Gtk.Button but;
> >                 Gtk.Label lab;
> >
> >                 Gtk.Init.Check(out rc,"");
> >
> >
> >                 Window win = new Window(WindowType.Toplevel);
> >                 win.Title = "HelloWin";
> >                 win.DefaultHeight = 100;
> >                 win.DefaultWidth = 100;
> >                 win.WindowPosition = WindowPosition.Center;
> >
> >                 win.DeleteEvent += new
> > GtkSharp.DeleteEventHandler(Class1.DeleteEvent);
> >                 but = new Button();
> >
> >                 lab = new Label("Hello World!");
> >
> >                 ((Container)but).Add(lab);
> >                 ((Container)win).Add(but);
> >
> >                 //win.Activate();
> >                 lab.Show();
> >                 but.Show();
> >                 win.Show();
> >
> >                 Console.WriteLine(rc);
> >
> >             }
> >             catch (Exception exc)
> >             {
> >                 Console.WriteLine(exc.Message);
> >             }
> >             finally
> >             {
> >                 Console.ReadLine();
> >             }
> >         }
> >
> >         private static void DeleteEvent(object sender,
> > GtkSharp.DeleteEventArgs e)
> >         {
> >             Gtk.Main.Quit();
> >         }
> >     }
> > _______________________________________________
> > Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
> >