From a61f1a75839ef3adf510cb2f250d5b359f60c5df Mon Sep 17 00:00:00 2001 From: Pavel Petroshenko Date: Fri, 23 May 2008 10:35:45 +0000 Subject: [PATCH] - handle form minimize event and hide window to tray; git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@90 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/webimtray/WebIMTray/Main.Designer.cs | 18 +++++++++--------- src/webimtray/WebIMTray/Main.cs | 10 ++++++++-- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/webimtray/WebIMTray/Main.Designer.cs b/src/webimtray/WebIMTray/Main.Designer.cs index 37c0ab43..b6a69e97 100644 --- a/src/webimtray/WebIMTray/Main.Designer.cs +++ b/src/webimtray/WebIMTray/Main.Designer.cs @@ -30,7 +30,7 @@ namespace webImTray { this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.refreshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.hideWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.hideWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.notifyMenu.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -90,7 +90,7 @@ namespace webImTray { this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.refreshToolStripMenuItem, this.optionsMenuItem, - this.hideWindowMenuItem}); + this.hideWindowToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(864, 24); @@ -111,12 +111,12 @@ namespace webImTray { this.optionsMenuItem.Text = "Options"; this.optionsMenuItem.Click += new System.EventHandler(this.optionsToolStripMenuItem1_Click); // - // hideWindowMenuItem + // hideWindowToolStripMenuItem // - this.hideWindowMenuItem.Name = "hideWindowMenuItem"; - this.hideWindowMenuItem.Size = new System.Drawing.Size(79, 20); - this.hideWindowMenuItem.Text = "Hide window"; - this.hideWindowMenuItem.Click += new System.EventHandler(this.hideWindowToolStripMenuItem_Click); + this.hideWindowToolStripMenuItem.Name = "hideWindowToolStripMenuItem"; + this.hideWindowToolStripMenuItem.Size = new System.Drawing.Size(79, 20); + this.hideWindowToolStripMenuItem.Text = "Hide window"; + this.hideWindowToolStripMenuItem.Click += new System.EventHandler(this.hideWindowToolStripMenuItem_Click); // // MainWindow // @@ -126,12 +126,12 @@ namespace webImTray { this.Controls.Add(this.menuStrip1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.menuStrip1; - this.MinimizeBox = false; this.Name = "MainWindow"; this.ShowInTaskbar = false; this.Shown += new System.EventHandler(this.MainWindow_Shown); this.GotFocus += new System.EventHandler(this.gotFocus); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Client_FormClosing); + this.Resize += new System.EventHandler(this.FormResize); this.notifyMenu.ResumeLayout(false); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); @@ -150,7 +150,7 @@ namespace webImTray { private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem refreshToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem optionsMenuItem; - private System.Windows.Forms.ToolStripMenuItem hideWindowMenuItem; + private System.Windows.Forms.ToolStripMenuItem hideWindowToolStripMenuItem; } } diff --git a/src/webimtray/WebIMTray/Main.cs b/src/webimtray/WebIMTray/Main.cs index 183bd521..3788fc80 100644 --- a/src/webimtray/WebIMTray/Main.cs +++ b/src/webimtray/WebIMTray/Main.cs @@ -49,8 +49,8 @@ namespace webImTray { private void updateLocalizedControls() { // Update localized controls - hideWindowMenuItem.Text = Options.resourceManager.GetString("hideWindow"); - optionsMenuItem.Text = Options.resourceManager.GetString("optionsMenuItem"); + hideWindowToolStripMenuItem.Text = Options.resourceManager.GetString("hideWindow"); + optionsToolStripMenuItem.Text = Options.resourceManager.GetString("optionsMenuItem"); refreshToolStripMenuItem.Text = Options.resourceManager.GetString("refreshMenuItem"); optionsToolStripMenuItem.Text = Options.resourceManager.GetString("trayOptions"); exitToolStripMenuItem.Text = Options.resourceManager.GetString("trayExit"); @@ -218,5 +218,11 @@ namespace webImTray { private void hideWindowToolStripMenuItem_Click(object sender, EventArgs e) { hideWindow(); } + + private void FormResize(object sender, System.EventArgs e) { + if (FormWindowState.Minimized == WindowState) { + hideWindow(); + } + } } }