diff -r 480652d72031 -r 9ffcd8ed8537 GUI/MainForm.cs --- a/GUI/MainForm.cs Sun Feb 03 19:06:01 2013 +0100 +++ b/GUI/MainForm.cs Mon Feb 04 00:47:01 2013 +0100 @@ -25,6 +25,7 @@ using OpenHardwareMonitor.WMI; using OpenHardwareMonitor.Utilities; + namespace OpenHardwareMonitor.GUI { public partial class MainForm : Form { @@ -133,17 +134,6 @@ systemTray.ExitCommand += exitClick; soundGraphDisplay = new SoundGraphDisplay(computer, settings, unitManager); - if (soundGraphDisplay.IsDllLoaded) - { - //Try init - //NativeWindow window; - - - //= Window.GetWindow(this); - //var wih = new WindowInteropHelper(window); - //IntPtr hWnd = wih.Handle; - } - int p = (int)Environment.OSVersion.Platform; @@ -328,6 +318,20 @@ InitializePlotForm(); + // + if (soundGraphDisplay.IsDllLoaded) + { + //Try init + //NativeWindow window; + soundGraphDisplay.Init(Handle); + + //= Window.GetWindow(this); + //var wih = new WindowInteropHelper(window); + //IntPtr hWnd = wih.Handle; + } + + + startupMenuItem.Visible = startupManager.IsAvailable; if (startMinMenuItem.Checked) { @@ -773,25 +777,64 @@ 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) + if (m.Msg == SoundGraph.WM_DSP_PLUGIN_NOTIFY) + { + //Handling messages from our iMON Display + switch ((SoundGraph.DSPNotifyCode)m.WParam.ToInt32()) + { + case SoundGraph.DSPNotifyCode.DSPNM_PLUGIN_SUCCEED: + case SoundGraph.DSPNotifyCode.DSPNM_IMON_RESTARTED: + case SoundGraph.DSPNotifyCode.DSPNM_HW_CONNECTED: + { + //Connection with our display is now open + //Check if we have LCD or VFD + //if ((lParam & DSPN_DSP_VFD) == DSPN_DSP_VFD) m_bVfdConnected = TRUE; + //if ((lParam & DSPN_DSP_LCD) == DSPN_DSP_LCD) m_bLcdConnected = TRUE; + soundGraphDisplay.DisplayPluginMessage(m.WParam.ToInt32(),false); + } + break; + + case SoundGraph.DSPNotifyCode.DSPNM_PLUGIN_FAILED: + case SoundGraph.DSPNotifyCode.DSPNM_HW_DISCONNECTED: + case SoundGraph.DSPNotifyCode.DSPNM_IMON_CLOSED: + { + //Connection with our display is closed + soundGraphDisplay.DisplayPluginMessage(m.LParam.ToInt32(), true); + } + break; + + case SoundGraph.DSPNotifyCode.DSPNM_LCD_TEXT_SCROLL_DONE: + { + //Scroll finnished + } + break; + } + + } + else if (minimizeToTray.Value && + m.Msg == WM_SYSCOMMAND && m.WParam.ToInt64() == SC_MINIMIZE) + { SysTrayHideShow(); - else - WindowState = FormWindowState.Minimized; - } else { - base.WndProc(ref m); + } + 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); } }