mail-archives/gtk-sharp-list/2004-July/004466.html

99 строки
3.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Gtk-sharp-list] Newbie cuestion: delete_event of a window
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:jymdman%40home.se">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="004465.html">
<LINK REL="Next" HREF="004467.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Gtk-sharp-list] Newbie cuestion: delete_event of a window
</H1>
<B>Fredrik Nilsson
</B>
<A HREF="mailto:jymdman%40home.se"
TITLE="[Gtk-sharp-list] Newbie cuestion: delete_event of a window">jymdman@home.se
</A><BR>
<I>Fri, 16 Jul 2004 19:49:04 +0200</I>
<P><UL>
<LI> Previous message: <A HREF="004465.html">[Gtk-sharp-list] Newbie cuestion: delete_event of a window
</A></li>
<LI> Next message: <A HREF="004467.html">[Gtk-sharp-list] Newbie cuestion: delete_event of a window
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#4466">[ date ]</a>
<a href="thread.html#4466">[ thread ]</a>
<a href="subject.html#4466">[ subject ]</a>
<a href="author.html#4466">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>On fre, 2004-07-16 at 19:35 +0200, Raúl Moratalla wrote:
&gt;<i> Hi everybody:
</I>&gt;<i>
</I>&gt;<i> I'm using the documentation of mono and there is the following example
</I>&gt;<i> of a messagedialog:
</I>&gt;<i>
</I>&gt;<i> MessageDialog md = new MessageDialog (parent_window,
</I>&gt;<i> DialogFlags.DestroyWithParent,
</I>&gt;<i> MessageType.Question,
</I>&gt;<i> ButtonsType.YesNo, &quot;Are you sure you want to quit?&quot;);
</I>&gt;<i>
</I>&gt;<i> ResponseType result = (ResponseType)md.Run ();
</I>&gt;<i>
</I>&gt;<i> if (result == ResponseType.Yes)
</I>&gt;<i> Application.Quit();
</I>&gt;<i> else
</I>&gt;<i> md.Destroy();
</I>&gt;<i>
</I>&gt;<i> This code is launched in the signal delete_event of a window but, after
</I>&gt;<i> this the window of the application is deleted. What should I do for
</I>&gt;<i> avoid it?
</I>&gt;<i>
</I>&gt;<i> Best regards,
</I>&gt;<i>
</I>&gt;<i> Raúl
</I>
Hi Raúl,
You need to set the RetVal property of the eventargs, like this:
void on_window_delete_event (object o, DeleteEventArgs args) {
// Show your dialog here
if (result == ResponseType.Yes) {
Application.Quit();
args.RetVal = false; // &lt;-- Destroy window
} else {
md.Destroy();
args.RetVal = true; // &lt;-- Don't destroy window
}
}
/Fredrik
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="004465.html">[Gtk-sharp-list] Newbie cuestion: delete_event of a window
</A></li>
<LI> Next message: <A HREF="004467.html">[Gtk-sharp-list] Newbie cuestion: delete_event of a window
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#4466">[ date ]</a>
<a href="thread.html#4466">[ thread ]</a>
<a href="subject.html#4466">[ subject ]</a>
<a href="author.html#4466">[ author ]</a>
</LI>
</UL>
</body></html>