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.ToInt64() == SC_MINIMIZE) {
SysTrayHideShow();
} else if (minimizeOnClose.Value &&
m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == 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);
}
}