[Gtk-sharp-list] [Help] Code Sample

Alessandro Lendaro alendaro1@virgilio.it
Fri, 20 Feb 2004 12:23:40 +0100


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();
        }
    }