2009-08-23 59 views
0

我在GTK#中有一個對話,通過鼠標點擊打開,單擊其中的一個按鈕後,對話框應該再次關閉。我必須在窗口上調用Hide()和Destroy()兩個方法嗎?在GTK中銷燬Windows#

這裏是我的代碼,以啓動對話:

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

這裏是配置窗口的相關部分:

public partial class MyConfigWindow : Gtk.Dialog 
{ 

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

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

當我只能撥打this.Destroy()主窗口獲取敏感試(因此myConfWindow.Run()已結束),但對話仍可見。

回答

4

你缺少ConfigureDialog過程中的破壞電話...

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

希望有所幫助。