# HG changeset patch # User StephaneLenclud # Date 1359935221 -3600 # Node ID 9ffcd8ed85375bba8b9879b23f24664381c9e8cd # Parent 480652d72031666fbfd166b5ce34459f5a4c643f Now calling display init. Not getting the expected error code though. 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); } } diff -r 480652d72031 -r 9ffcd8ed8537 GUI/SoundGraphDisplay.cs --- a/GUI/SoundGraphDisplay.cs Sun Feb 03 19:06:01 2013 +0100 +++ b/GUI/SoundGraphDisplay.cs Mon Feb 04 00:47:01 2013 +0100 @@ -13,6 +13,7 @@ using System.Drawing; using System.Text; using System.Windows.Forms; +using System.Windows; using OpenHardwareMonitor.Hardware; using OpenHardwareMonitor.Utilities; using System.Runtime.InteropServices; @@ -51,11 +52,14 @@ */ static class SoundGraph { + + const int WM_APP = 0x8000; + public const int WM_DSP_PLUGIN_NOTIFY = WM_APP + 1121; /**DSPResult @brief These enumeration values represent the returned result for iMON Display API function calls.\n All iMON Display API function calls return one of this result values.\n For meaning of each result, refer the comment of each line below*/ - public enum DSPResult : uint + public enum DSPResult : int { DSP_SUCCEEDED = 0, //// Function Call Succeeded Without Error DSP_E_FAIL, //// Unspecified Failure @@ -75,7 +79,7 @@ @brief These enumeration values represent the result status for requesting Display Plug-in Mode to iMON.\n iMON Display API notifies one of this result values to the caller application after requesting Display Plug-in Mode to iMON.\n For more information, refer the comment of each line below*/ - public enum DSPNInitResult : uint + public enum DSPNInitResult : int { DSPN_SUCCEEDED = 0, //// Display Plug-in Mode is Initialized Successfully DSPN_ERR_IN_USED = 0x0100, //// Display Plug-in is Already Used by Other Application @@ -90,7 +94,7 @@ /**DSPType @brief These enumeration values represent display type.\n Currently iMON Display API supports VFD and LCD products.*/ - public enum DSPType : uint + public enum DSPType : int { DSPN_DSP_NONE = 0, DSPN_DSP_VFD = 0x01, //// VFD products @@ -104,7 +108,7 @@ The caller application should assign the message and the winodw handle to receivce message with IMON_Display_Init fucntion.\n These enumeration values are used with WPARAM parameter of the message.\n For more information, see the explanation of each notification code below*/ - public enum DSPNotifyCode : uint + public enum DSPNotifyCode : int { /**DSPNM_PLUGIN_SUCCEED @brief When API succeeds to get the control for the display, API will post caller-specified message with DSPNM_PLUGIN_SUCCEED as WPARAM parameter.\n @@ -345,17 +349,17 @@ */ } - private void Init(IntPtr aHWND) + public void Init(IntPtr aHWND) { - //iIMON_Display_Init + iIMON_Display_Init(aHWND, SoundGraph.WM_DSP_PLUGIN_NOTIFY); } - private void Uninit() + public void Uninit() { iIMON_Display_Uninit(); } - private void SetText(string aUpperLine, string aLowerLine) + public void SetText(string aUpperLine, string aLowerLine) { } @@ -379,5 +383,42 @@ { get { return iSoundGraphDll!=IntPtr.Zero; } } + + public void DisplayPluginMessage(int uErrCode, bool bError) + { + if(bError) + { + switch ((SoundGraph.DSPNInitResult)uErrCode) + { + case SoundGraph.DSPNInitResult.DSPN_ERR_IN_USED: + Console.Write("Display Plug-in is Already Used by Other Application.\n"); break; + case SoundGraph.DSPNInitResult.DSPN_ERR_HW_DISCONNECTED: + Console.Write("iMON HW is Not Connected."); break; + case SoundGraph.DSPNInitResult.DSPN_ERR_NOT_SUPPORTED_HW: + Console.Write("The Connected iMON HW doesn't Support Display Plug-in.\n"); break; + case SoundGraph.DSPNInitResult.DSPN_ERR_PLUGIN_DISABLED: + Console.Write("Display Plug-in Mode Option is Disabled.\n"); break; + case SoundGraph.DSPNInitResult.DSPN_ERR_IMON_NO_REPLY: + Console.Write("The Latest iMON is Not Installed or iMON Not Running.\n"); break; + case SoundGraph.DSPNInitResult.DSPN_ERR_UNKNOWN: + Console.Write("Unknown Failure.\n"); break; + } + } + else + { + switch ((SoundGraph.DSPNotifyCode)uErrCode) + { + case SoundGraph.DSPNotifyCode.DSPNM_PLUGIN_SUCCEED: + Console.Write("Plug-in Mode Inited Successfully.\n"); break; + case SoundGraph.DSPNotifyCode.DSPNM_IMON_RESTARTED: + Console.Write("iMON Started and Plug-in Mode Inited.\n"); break; + case SoundGraph.DSPNotifyCode.DSPNM_HW_CONNECTED: + Console.Write("iMON HW Connected and Plug-in Mode Inited.\n"); break; + } + } + + //GetDlgItem(IDC_STATIC_INFO)->SetWindowText((LPCTSTR)strErrMsg); + } + } }