mail-archives/gtk-sharp-list/2004-February/003434.html

145 строки
5.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Gtk-sharp-list] re:Code Sample
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:craig%40ip80.com">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="003433.html">
<LINK REL="Next" HREF="003435.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Gtk-sharp-list] re:Code Sample
</H1>
<B>Craig Williams
</B>
<A HREF="mailto:craig%40ip80.com"
TITLE="[Gtk-sharp-list] re:Code Sample">craig@ip80.com
</A><BR>
<I>Fri, 20 Feb 2004 07:25:26 -0500</I>
<P><UL>
<LI> Previous message: <A HREF="003433.html">[Gtk-sharp-list] [Help] Code Sample
</A></li>
<LI> Next message: <A HREF="003435.html">[Gtk-sharp-list] Cancelling events
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#3434">[ date ]</a>
<a href="thread.html#3434">[ thread ]</a>
<a href="subject.html#3434">[ subject ]</a>
<a href="author.html#3434">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>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
&gt;<i> ----- Original Message -----
</I>&gt;<i> From: &quot;Alessandro Lendaro&quot; &lt;<A HREF="mailto:alendaro1@virgilio.it">alendaro1@virgilio.it</A>&gt;
</I>&gt;<i> To: &lt;<A HREF="mailto:gtk-sharp-list@lists.ximian.com">gtk-sharp-list@lists.ximian.com</A>&gt;
</I>&gt;<i> Sent: Friday, February 20, 2004 6:23 AM
</I>&gt;<i> Subject: [Gtk-sharp-list] [Help] Code Sample
</I>&gt;<i>
</I>&gt;<i>
</I>&gt;<i> &gt; Is somebody willing to post a code sample to make a simple &quot;Hello World&quot;
</I>&gt;<i> &gt; program?
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; I tried to, but the window I open doesn't respond and doesn't show
</I>&gt;<i> &gt; anything in,
</I>&gt;<i> &gt; here the code:
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; (I'm using VS.NET 2002 with the FrameWork v1.0.3705 on a W2000 Server
</I>&gt;<i> &gt; machine, GTK# v. 0.16, no Mono)
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; class Class1
</I>&gt;<i> &gt; {
</I>&gt;<i> &gt; /// &lt;summary&gt;
</I>&gt;<i> &gt; /// Il punto di ingresso principale dell'applicazione.
</I>&gt;<i> &gt; /// &lt;/summary&gt;
</I>&gt;<i> &gt; [STAThread]
</I>&gt;<i> &gt; static void Main(string[] args)
</I>&gt;<i> &gt; {
</I>&gt;<i> &gt; try
</I>&gt;<i> &gt; {
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; //AppDomain.CurrentDomain.AppendPrivatePath(@&quot;C:\Programmi\Common
</I>&gt;<i> &gt; Files\GTK\GtKSharp\lib&quot;);
</I>&gt;<i> &gt; int rc;
</I>&gt;<i> &gt; Gtk.Button but;
</I>&gt;<i> &gt; Gtk.Label lab;
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; Gtk.Init.Check(out rc,&quot;&quot;);
</I>&gt;<i> &gt;
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; Window win = new Window(WindowType.Toplevel);
</I>&gt;<i> &gt; win.Title = &quot;HelloWin&quot;;
</I>&gt;<i> &gt; win.DefaultHeight = 100;
</I>&gt;<i> &gt; win.DefaultWidth = 100;
</I>&gt;<i> &gt; win.WindowPosition = WindowPosition.Center;
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; win.DeleteEvent += new
</I>&gt;<i> &gt; GtkSharp.DeleteEventHandler(Class1.DeleteEvent);
</I>&gt;<i> &gt; but = new Button();
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; lab = new Label(&quot;Hello World!&quot;);
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; ((Container)but).Add(lab);
</I>&gt;<i> &gt; ((Container)win).Add(but);
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; //win.Activate();
</I>&gt;<i> &gt; lab.Show();
</I>&gt;<i> &gt; but.Show();
</I>&gt;<i> &gt; win.Show();
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; Console.WriteLine(rc);
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; }
</I>&gt;<i> &gt; catch (Exception exc)
</I>&gt;<i> &gt; {
</I>&gt;<i> &gt; Console.WriteLine(exc.Message);
</I>&gt;<i> &gt; }
</I>&gt;<i> &gt; finally
</I>&gt;<i> &gt; {
</I>&gt;<i> &gt; Console.ReadLine();
</I>&gt;<i> &gt; }
</I>&gt;<i> &gt; }
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; private static void DeleteEvent(object sender,
</I>&gt;<i> &gt; GtkSharp.DeleteEventArgs e)
</I>&gt;<i> &gt; {
</I>&gt;<i> &gt; Gtk.Main.Quit();
</I>&gt;<i> &gt; }
</I>&gt;<i> &gt; }
</I>&gt;<i> &gt; _______________________________________________
</I>&gt;<i> &gt; Gtk-sharp-list maillist - <A HREF="mailto:Gtk-sharp-list@lists.ximian.com">Gtk-sharp-list@lists.ximian.com</A>
</I>&gt;<i> &gt; <A HREF="http://lists.ximian.com/mailman/listinfo/gtk-sharp-list">http://lists.ximian.com/mailman/listinfo/gtk-sharp-list</A>
</I>&gt;<i> &gt;
</I>
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="003433.html">[Gtk-sharp-list] [Help] Code Sample
</A></li>
<LI> Next message: <A HREF="003435.html">[Gtk-sharp-list] Cancelling events
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#3434">[ date ]</a>
<a href="thread.html#3434">[ thread ]</a>
<a href="subject.html#3434">[ subject ]</a>
<a href="author.html#3434">[ author ]</a>
</LI>
</UL>
</body></html>