mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-29 13:28:04 +00:00
Added an option to minimize on close.
This commit is contained in:
parent
1bd6b91c6f
commit
acf99ee2d7
18
GUI/MainForm.Designer.cs
generated
18
GUI/MainForm.Designer.cs
generated
@ -92,6 +92,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.optionsMenuItem = new System.Windows.Forms.MenuItem();
|
||||
this.startMinMenuItem = new System.Windows.Forms.MenuItem();
|
||||
this.minTrayMenuItem = new System.Windows.Forms.MenuItem();
|
||||
this.minCloseMenuItem = new System.Windows.Forms.MenuItem();
|
||||
this.startupMenuItem = new System.Windows.Forms.MenuItem();
|
||||
this.separatorMenuItem = new System.Windows.Forms.MenuItem();
|
||||
this.temperatureUnitsMenuItem = new System.Windows.Forms.MenuItem();
|
||||
@ -302,6 +303,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.optionsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.startMinMenuItem,
|
||||
this.minTrayMenuItem,
|
||||
this.minCloseMenuItem,
|
||||
this.startupMenuItem,
|
||||
this.separatorMenuItem,
|
||||
this.temperatureUnitsMenuItem,
|
||||
@ -319,19 +321,24 @@ namespace OpenHardwareMonitor.GUI {
|
||||
this.minTrayMenuItem.Index = 1;
|
||||
this.minTrayMenuItem.Text = "Minimize To Tray";
|
||||
//
|
||||
// minCloseMenuItem
|
||||
//
|
||||
this.minCloseMenuItem.Index = 2;
|
||||
this.minCloseMenuItem.Text = "Minimize On Close";
|
||||
//
|
||||
// startupMenuItem
|
||||
//
|
||||
this.startupMenuItem.Index = 2;
|
||||
this.startupMenuItem.Index = 3;
|
||||
this.startupMenuItem.Text = "Run On Windows Startup";
|
||||
//
|
||||
// separatorMenuItem
|
||||
//
|
||||
this.separatorMenuItem.Index = 3;
|
||||
this.separatorMenuItem.Index = 4;
|
||||
this.separatorMenuItem.Text = "-";
|
||||
//
|
||||
// temperatureUnitsMenuItem
|
||||
//
|
||||
this.temperatureUnitsMenuItem.Index = 4;
|
||||
this.temperatureUnitsMenuItem.Index = 5;
|
||||
this.temperatureUnitsMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.celciusMenuItem,
|
||||
this.fahrenheitMenuItem});
|
||||
@ -351,12 +358,12 @@ namespace OpenHardwareMonitor.GUI {
|
||||
//
|
||||
// MenuItem4
|
||||
//
|
||||
this.MenuItem4.Index = 5;
|
||||
this.MenuItem4.Index = 6;
|
||||
this.MenuItem4.Text = "-";
|
||||
//
|
||||
// hddMenuItem
|
||||
//
|
||||
this.hddMenuItem.Index = 6;
|
||||
this.hddMenuItem.Index = 7;
|
||||
this.hddMenuItem.Text = "Read HDD sensors";
|
||||
//
|
||||
// helpMenuItem
|
||||
@ -513,6 +520,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private System.Windows.Forms.MenuItem resetMinMaxMenuItem;
|
||||
private System.Windows.Forms.MenuItem MenuItem3;
|
||||
private System.Windows.Forms.MenuItem gadgetMenuItem;
|
||||
private System.Windows.Forms.MenuItem minCloseMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
private UserOption showMax;
|
||||
private UserOption startMinimized;
|
||||
private UserOption minimizeToTray;
|
||||
private UserOption minimizeOnClose;
|
||||
private UserOption autoStart;
|
||||
private UserOption readHddSensors;
|
||||
private UserOption showGadget;
|
||||
@ -80,14 +81,14 @@ namespace OpenHardwareMonitor.GUI {
|
||||
|
||||
this.settings = new PersistentSettings();
|
||||
this.settings.Load(Path.ChangeExtension(
|
||||
System.Windows.Forms.Application.ExecutablePath, ".config"));
|
||||
Application.ExecutablePath, ".config"));
|
||||
|
||||
this.unitManager = new UnitManager(settings);
|
||||
|
||||
// set the DockStyle here, to avoid conflicts with the MainMenu
|
||||
this.splitContainer.Dock = DockStyle.Fill;
|
||||
|
||||
int p = (int)System.Environment.OSVersion.Platform;
|
||||
int p = (int)Environment.OSVersion.Platform;
|
||||
if ((p == 4) || (p == 128)) {
|
||||
splitContainer.BorderStyle = BorderStyle.None;
|
||||
splitContainer.Border3DStyle = Border3DStyle.Adjust;
|
||||
@ -196,6 +197,8 @@ namespace OpenHardwareMonitor.GUI {
|
||||
systemTray.IsMainIconEnabled = minimizeToTray.Value;
|
||||
};
|
||||
|
||||
minimizeOnClose = new UserOption("minCloseMenuItem", false, minCloseMenuItem, settings);
|
||||
|
||||
autoStart = new UserOption(null, startupManager.Startup, startupMenuItem, settings);
|
||||
autoStart.Changed += delegate(object sender, EventArgs e) {
|
||||
try {
|
||||
@ -447,9 +450,25 @@ namespace OpenHardwareMonitor.GUI {
|
||||
protected override void WndProc(ref Message m) {
|
||||
const int WM_SYSCOMMAND = 0x112;
|
||||
const int SC_MINIMIZE = 0xF020;
|
||||
const int SC_CLOSE = 0xF060;
|
||||
|
||||
if (minimizeToTray.Value &&
|
||||
m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MINIMIZE) {
|
||||
SysTrayHideShow();
|
||||
} else if(minimizeOnClose.Value &&
|
||||
m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_CLOSE) {
|
||||
/*
|
||||
* Apparently the user wants to minimize rather than close
|
||||
* Now we still need to check if we're going to the tray or not
|
||||
*
|
||||
* Note: the correct way to do this would be to send out SC_MINIMIZE,
|
||||
* but since the code here is so simple,
|
||||
* that would just be a waste of time.
|
||||
*/
|
||||
if (minimizeToTray.Value)
|
||||
SysTrayHideShow();
|
||||
else
|
||||
WindowState = FormWindowState.Minimized;
|
||||
} else {
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user