Changed minimizing to system tray on Windows systems.

This commit is contained in:
Michael Möller
2010-02-05 22:45:15 +00:00
parent 0543259a0b
commit 15162a2a12
6 changed files with 357 additions and 257 deletions

View File

@@ -325,6 +325,38 @@ namespace OpenHardwareMonitor.GUI {
node.SetVisible(SensorType.Temperature, tempMenuItem.Checked);
node.SetVisible(SensorType.Fan, fansMenuItem.Checked);
}
}
}
private void ToggleSysTray() {
if (Visible) {
notifyIcon.Visible = true;
Visible = false;
} else {
Visible = true;
notifyIcon.Visible = false;
}
}
protected override void WndProc(ref Message m) {
const int WM_SYSCOMMAND = 0x112;
const int SC_MINIMIZE = 0xF020;
if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE) {
ToggleSysTray();
} else {
base.WndProc(ref m);
}
}
private void notifyIcon_Click(object sender, EventArgs e) {
MouseEventArgs m = e as MouseEventArgs;
if (m == null || m.Button != MouseButtons.Left)
return;
ToggleSysTray();
}
private void restoreToolStripMenuItem_Click(object sender, EventArgs e) {
ToggleSysTray();
}
}
}