简体   繁体   English

在GTK中销毁Windows#

[英]Destroying Windows in GTK#

I have a dialogue in GTK# that gets opened by a mouse click, and after clicking a button in it, the dialogue should be closed again. 我在GTK#中有一个对话框,通过单击鼠标即可打开该对话框,单击其中的一个按钮后,该对话框应再次关闭。 Do I have to call both methods Hide() and Destroy() on the window? 我必须在窗口上同时调用方法Hide()和Destroy()吗?

Here is my code to launch the dialogue: 这是我启动对话的代码:

protected virtual void ConfigureDialogue (object sender, System.EventArgs e)
{
    MyConfigWindow myConfWindow = new MyConfigWindow ();
    this.Sensitive = false;
    myConfWindow.Run ();
    this.Sensitive = true;
}

And here is the relevant part of the config window: 这是配置窗口的相关部分:

public partial class MyConfigWindow  : Gtk.Dialog
{

    public MyConfigWindow ()
    {
        this.Build();
    }

    protected virtual void onSave (object sender, System.EventArgs e)
    {
        this.Hide();
        this.Destroy ();
    }
}

When I only call this.Destroy () the main window gets sensitive again (therefore myConfWindow.Run () has ended), but the dialogue is still visible. 当我仅调用this.Destroy () ,主窗口再次变得敏感(因此myConfWindow.Run ()已结束),但是对话框仍然可见。

Your missing the destroy call in the ConfigureDialog procedure ... 您错过了ConfigureDialog过程中的destroy调用...

  this.Sensitive = false; 
  result = myConfWindow.run();
  if (result == gtk.RESPONSE_CLOSE:)
    myConfWindow.destroy();
  this.Sensitive = true;

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM