diff --git a/fancontrol/Backup/fancontrol.sln b/fancontrol/Backup/fancontrol.sln new file mode 100644 index 0000000..6512690 --- /dev/null +++ b/fancontrol/Backup/fancontrol.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fancontrol", "fancontrol.vcproj", "{45F7E4D3-AF42-4594-80E1-099D3FCE3F37}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {45F7E4D3-AF42-4594-80E1-099D3FCE3F37}.Debug|Win32.ActiveCfg = Debug|Win32 + {45F7E4D3-AF42-4594-80E1-099D3FCE3F37}.Debug|Win32.Build.0 = Debug|Win32 + {45F7E4D3-AF42-4594-80E1-099D3FCE3F37}.Release|Win32.ActiveCfg = Release|Win32 + {45F7E4D3-AF42-4594-80E1-099D3FCE3F37}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/fancontrol/SystemTraySDK.cpp b/fancontrol/SystemTraySDK.cpp index f6ef2b7..6a913e3 100644 --- a/fancontrol/SystemTraySDK.cpp +++ b/fancontrol/SystemTraySDK.cpp @@ -1,4 +1,4 @@ -// TrayIcon.cpp: implementation of the CSystemTray class. +// TrayIcon.cpp: implementation of the CSystemTray class. // // NON-MFC VERSION // @@ -27,14 +27,12 @@ #ifdef _DEBUG #undef THIS_FILE -static char THIS_FILE[] = __FILE__; +static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif #ifndef ASSERT - #include - #define ASSERT assert #endif @@ -53,8 +51,8 @@ static char THIS_FILE[] = __FILE__; // TrayIcon per application CSystemTray* CSystemTray::m_pThis = NULL; -const UINT CSystemTray::m_nTimerID = 4567; // Animation -UINT CSystemTray::m_nMaxTooltipLength = 64; // This may change... +const UINT CSystemTray::m_nTimerID = 4567; // Animation +UINT CSystemTray::m_nMaxTooltipLength = 64; // This may change... const UINT CSystemTray::m_nTaskbarCreatedMsg = ::RegisterWindowMessage(_T("TaskbarCreated")); HWND CSystemTray::m_hWndInvisible; @@ -62,330 +60,346 @@ HWND CSystemTray::m_hWndInvisible; // Construction/Destruction ////////////////////////////////////////////////////////////////////// -CSystemTray::CSystemTray() { - Initialise(); -} +CSystemTray::CSystemTray() + { + Initialise(); + } CSystemTray::CSystemTray -( - HINSTANCE hInst, // Handle to application instance - HWND hParent, // The window that will recieve tray notifications - UINT uCallbackMessage, // the callback message to send to parent - LPCTSTR szToolTip, // tray icon tooltip - HICON icon, // Handle to icon - UINT uID, // Identifier of tray icon - BOOL bHidden, // Hidden on creation? - LPCTSTR szBalloonTip, // Ballon tip (w2k only) - LPCTSTR szBalloonTitle, // Balloon tip title (w2k) - DWORD dwBalloonIcon, // Ballon tip icon (w2k) - UINT uBalloonTimeout // Balloon timeout (w2k) -) { - Initialise(); - Create - ( - hInst, - hParent, - uCallbackMessage, - szToolTip, - icon, - uID, - bHidden, - szBalloonTip, - szBalloonTitle, - dwBalloonIcon, - uBalloonTimeout - ); -} - -void CSystemTray::Initialise() { - // If maintaining a list of all TrayIcon windows (instead of - // only allowing a single TrayIcon per application) then add - // this TrayIcon to the list + ( + HINSTANCE hInst, // Handle to application instance + HWND hParent, // The window that will recieve tray notifications + UINT uCallbackMessage, // the callback message to send to parent + LPCTSTR szToolTip, // tray icon tooltip + HICON icon, // Handle to icon + UINT uID, // Identifier of tray icon + BOOL bHidden, // Hidden on creation? + LPCTSTR szBalloonTip, // Ballon tip (w2k only) + LPCTSTR szBalloonTitle, // Balloon tip title (w2k) + DWORD dwBalloonIcon, // Ballon tip icon (w2k) + UINT uBalloonTimeout // Balloon timeout (w2k) + ) + { + Initialise(); + Create + ( + hInst, + hParent, + uCallbackMessage, + szToolTip, + icon, + uID, + bHidden, + szBalloonTip, + szBalloonTitle, + dwBalloonIcon, + uBalloonTimeout + ); + } + +void CSystemTray::Initialise() +{ + // If maintaining a list of all TrayIcon windows (instead of + // only allowing a single TrayIcon per application) then add + // this TrayIcon to the list - m_pThis = this; + m_pThis = this; - memset(&m_tnd, 0, sizeof(m_tnd)); - m_bEnabled = FALSE; - m_bHidden = TRUE; - m_bRemoved = TRUE; + memset(&m_tnd, 0, sizeof(m_tnd)); + m_bEnabled = FALSE; + m_bHidden = TRUE; + m_bRemoved = TRUE; - m_DefaultMenuItemID = 0; - m_DefaultMenuItemByPos = TRUE; + m_DefaultMenuItemID = 0; + m_DefaultMenuItemByPos = TRUE; - m_bShowIconPending = FALSE; + m_bShowIconPending = FALSE; - m_uIDTimer = 0; - m_hSavedIcon = NULL; + m_uIDTimer = 0; + m_hSavedIcon = NULL; m_hTargetWnd = NULL; m_uCreationFlags = 0; #ifdef SYSTEMTRAY_USEW2K - OSVERSIONINFOEX os = { sizeof(os) }; - VerifyVersionInfoA(&os, VER_MAJORVERSION, 1); - m_bWin2K = (VER_PLATFORM_WIN32_NT == os.dwPlatformId && os.dwMajorVersion >= 5); + OSVERSIONINFO os = { sizeof(os) }; + GetVersionEx(&os); + m_bWin2K = ( VER_PLATFORM_WIN32_NT == os.dwPlatformId && os.dwMajorVersion >= 5 ); #else - m_bWin2K = FALSE; + m_bWin2K = FALSE; #endif } -ATOM CSystemTray::RegisterClass(HINSTANCE hInstance) { +ATOM CSystemTray::RegisterClass(HINSTANCE hInstance) +{ WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - - wcex.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; - wcex.lpfnWndProc = (WNDPROC)WindowProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInstance; - wcex.hIcon = 0; - wcex.hCursor = 0; - wcex.hbrBackground = 0; - wcex.lpszMenuName = 0; - wcex.lpszClassName = TRAYICON_CLASS; - wcex.hIconSm = 0; - - return RegisterClassEx(&wcex); + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; + wcex.lpfnWndProc = (WNDPROC)WindowProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = 0; + wcex.hCursor = 0; + wcex.hbrBackground = 0; + wcex.lpszMenuName = 0; + wcex.lpszClassName = TRAYICON_CLASS; + wcex.hIconSm = 0; + + return RegisterClassEx(&wcex); } BOOL CSystemTray::Create( - HINSTANCE hInst, - HWND hParent, - UINT uCallbackMessage, - LPCTSTR szToolTip, - HICON icon, - UINT uID, - BOOL bHidden /*=FALSE*/, - LPCTSTR szBalloonTip /*=NULL*/, - LPCTSTR szBalloonTitle /*=NULL*/, - DWORD dwBalloonIcon /*=NIIF_NONE*/, - UINT uBalloonTimeout /*=10*/ -) { + HINSTANCE hInst, + HWND hParent, + UINT uCallbackMessage, + LPCTSTR szToolTip, + HICON icon, + UINT uID, + BOOL bHidden /*=FALSE*/, + LPCTSTR szBalloonTip /*=NULL*/, + LPCTSTR szBalloonTitle /*=NULL*/, + DWORD dwBalloonIcon /*=NIIF_NONE*/, + UINT uBalloonTimeout /*=10*/ + ) + + +{ #ifdef _WIN32_WCE - m_bEnabled = TRUE; + m_bEnabled = TRUE; #else - // this is only for Windows 95 (or higher) - m_bEnabled = (GetVersion() & 0xff) >= 4; - if (!m_bEnabled) { - ASSERT(FALSE); - return FALSE; - } + // this is only for Windows 95 (or higher) + m_bEnabled = (GetVersion() & 0xff) >= 4; + if (!m_bEnabled) + { + ASSERT(FALSE); + return FALSE; + } #endif + + m_nMaxTooltipLength = _countof(m_tnd.szTip); + + // Make sure we avoid conflict with other messages + ASSERT(uCallbackMessage >= WM_USER); - m_nMaxTooltipLength = _countof(m_tnd.szTip); - - // Make sure we avoid conflict with other messages - ASSERT(uCallbackMessage >= WM_USER); - - // Tray only supports tooltip text up to m_nMaxTooltipLength) characters - ASSERT(_tcslen(szToolTip) <= m_nMaxTooltipLength); + // Tray only supports tooltip text up to m_nMaxTooltipLength) characters + ASSERT(_tcslen(szToolTip) <= m_nMaxTooltipLength); - m_hInstance = hInst; + m_hInstance = hInst; - RegisterClass(hInst); + RegisterClass(hInst); - // Create an invisible window - m_hWnd = ::CreateWindow(TRAYICON_CLASS, _T(""), WS_POPUP, - CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, - NULL, 0, - hInst, 0); + // Create an invisible window + m_hWnd = ::CreateWindow(TRAYICON_CLASS, _T(""), WS_POPUP, + CW_USEDEFAULT,CW_USEDEFAULT, + CW_USEDEFAULT,CW_USEDEFAULT, + NULL, 0, + hInst, 0); - // load up the NOTIFYICONDATA structure - m_tnd.cbSize = sizeof(NOTIFYICONDATA); - m_tnd.hWnd = (hParent) ? hParent : m_hWnd; - m_tnd.uID = uID; - m_tnd.hIcon = icon; - m_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; - m_tnd.uCallbackMessage = uCallbackMessage; + // load up the NOTIFYICONDATA structure + m_tnd.cbSize = sizeof(NOTIFYICONDATA); + m_tnd.hWnd = (hParent)? hParent : m_hWnd; + m_tnd.uID = uID; + m_tnd.hIcon = icon; + m_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; + m_tnd.uCallbackMessage = uCallbackMessage; - strncpy_s(m_tnd.szTip, sizeof(m_tnd.szTip), szToolTip, m_nMaxTooltipLength); + strncpy_s(m_tnd.szTip,sizeof(m_tnd.szTip), szToolTip, m_nMaxTooltipLength); #ifdef SYSTEMTRAY_USEW2K - if (m_bWin2K && szBalloonTip) - { - // The balloon tooltip text can be up to 255 chars long. - //ASSERT(AfxIsValidString(szBalloonTip)); - ASSERT(lstrlen(szBalloonTip) < 256); - - // The balloon title text can be up to 63 chars long. - if (szBalloonTitle) - { - //ASSERT(AfxIsValidString(szBalloonTitle)); - ASSERT(lstrlen(szBalloonTitle) < 64); - } - - // dwBalloonIcon must be valid. - ASSERT(NIIF_NONE == dwBalloonIcon || NIIF_INFO == dwBalloonIcon || - NIIF_WARNING == dwBalloonIcon || NIIF_ERROR == dwBalloonIcon); - - // The timeout must be between 10 and 30 seconds. - ASSERT(uBalloonTimeout >= 10 && uBalloonTimeout <= 30); - - m_tnd.uFlags |= NIF_INFO; - - _tcsncpy_s(m_tnd.szInfo, sizeof(m_tnd.szInfo), szBalloonTip, 255); - if (szBalloonTitle) - _tcsncpy_s(m_tnd.szInfoTitle, sizeof(m_tnd.szInfoTitle), szBalloonTitle, 63); - else - m_tnd.szInfoTitle[0] = _T('\0'); - m_tnd.uTimeout = uBalloonTimeout * 1000; // convert time to ms - m_tnd.dwInfoFlags = dwBalloonIcon; - } + if (m_bWin2K && szBalloonTip) + { + // The balloon tooltip text can be up to 255 chars long. + //ASSERT(AfxIsValidString(szBalloonTip)); + ASSERT(lstrlen(szBalloonTip) < 256); + + // The balloon title text can be up to 63 chars long. + if (szBalloonTitle) + { + //ASSERT(AfxIsValidString(szBalloonTitle)); + ASSERT(lstrlen(szBalloonTitle) < 64); + } + + // dwBalloonIcon must be valid. + ASSERT(NIIF_NONE == dwBalloonIcon || NIIF_INFO == dwBalloonIcon || + NIIF_WARNING == dwBalloonIcon || NIIF_ERROR == dwBalloonIcon); + + // The timeout must be between 10 and 30 seconds. + ASSERT(uBalloonTimeout >= 10 && uBalloonTimeout <= 30); + + m_tnd.uFlags |= NIF_INFO; + + _tcsncpy_s(m_tnd.szInfo, sizeof(m_tnd.szInfo), szBalloonTip, 255); + if (szBalloonTitle) + _tcsncpy_s(m_tnd.szInfoTitle, sizeof(m_tnd.szInfoTitle), szBalloonTitle, 63); + else + m_tnd.szInfoTitle[0] = _T('\0'); + m_tnd.uTimeout = uBalloonTimeout * 1000; // convert time to ms + m_tnd.dwInfoFlags = dwBalloonIcon; + } #endif - m_bHidden = bHidden; + m_bHidden = bHidden; m_hTargetWnd = m_tnd.hWnd; -#ifdef SYSTEMTRAY_USEW2K - if (m_bWin2K && m_bHidden) - { - m_tnd.uFlags = NIF_STATE; - m_tnd.dwState = NIS_HIDDEN; - m_tnd.dwStateMask = NIS_HIDDEN; - } +#ifdef SYSTEMTRAY_USEW2K + if (m_bWin2K && m_bHidden) + { + m_tnd.uFlags = NIF_STATE; + m_tnd.dwState = NIS_HIDDEN; + m_tnd.dwStateMask = NIS_HIDDEN; + } #endif - m_uCreationFlags = m_tnd.uFlags; // Store in case we need to recreate in OnTaskBarCreate + m_uCreationFlags = m_tnd.uFlags; // Store in case we need to recreate in OnTaskBarCreate - BOOL bResult = FALSE; + BOOL bResult = FALSE; - if (!m_bHidden || m_bWin2K) { + if (!m_bHidden || m_bWin2K){ - for (int i = 0; i < 5; i++) { + for (int i = 0; i < 5; i++){ bResult = Shell_NotifyIcon(NIM_ADD, &m_tnd); if (bResult) break; Sleep(100); } m_bShowIconPending = m_bHidden = m_bRemoved = !bResult; } - -#ifdef SYSTEMTRAY_USEW2K - if (m_bWin2K && szBalloonTip) - { - // Zero out the balloon text string so that later operations won't redisplay - // the balloon. - m_tnd.szInfo[0] = _T('\0'); - } + +#ifdef SYSTEMTRAY_USEW2K + if (m_bWin2K && szBalloonTip) + { + // Zero out the balloon text string so that later operations won't redisplay + // the balloon. + m_tnd.szInfo[0] = _T('\0'); + } #endif - return bResult; + return bResult; } -CSystemTray::~CSystemTray() { - RemoveIcon(); - m_IconList.clear(); - if (m_hWnd) - ::DestroyWindow(m_hWnd); +CSystemTray::~CSystemTray() +{ + RemoveIcon(); + m_IconList.clear(); + if (m_hWnd) + ::DestroyWindow(m_hWnd); } ///////////////////////////////////////////////////////////////////////////// // CSystemTray icon manipulation -void CSystemTray::SetFocus() { +void CSystemTray::SetFocus() +{ #ifdef SYSTEMTRAY_USEW2K - Shell_NotifyIcon(NIM_SETFOCUS, &m_tnd); + Shell_NotifyIcon ( NIM_SETFOCUS, &m_tnd ); #endif } -BOOL CSystemTray::MoveToRight() { - RemoveIcon(); - return AddIcon(); +BOOL CSystemTray::MoveToRight() +{ + RemoveIcon(); + return AddIcon(); } -BOOL CSystemTray::AddIcon() { - if (!m_bRemoved) - RemoveIcon(); - - if (m_bEnabled) { - m_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; - if (!Shell_NotifyIcon(NIM_ADD, &m_tnd)) - m_bShowIconPending = TRUE; - else - m_bRemoved = m_bHidden = FALSE; - } - return (m_bRemoved == FALSE); +BOOL CSystemTray::AddIcon() +{ + if (!m_bRemoved) + RemoveIcon(); + + if (m_bEnabled) + { + m_tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; + if (!Shell_NotifyIcon(NIM_ADD, &m_tnd)) + m_bShowIconPending = TRUE; + else + m_bRemoved = m_bHidden = FALSE; + } + return (m_bRemoved == FALSE); } -BOOL CSystemTray::RemoveIcon() { - m_bShowIconPending = FALSE; +BOOL CSystemTray::RemoveIcon() +{ + m_bShowIconPending = FALSE; - if (!m_bEnabled || m_bRemoved) - return TRUE; + if (!m_bEnabled || m_bRemoved) + return TRUE; - m_tnd.uFlags = 0; - if (Shell_NotifyIcon(NIM_DELETE, &m_tnd)) - m_bRemoved = m_bHidden = TRUE; + m_tnd.uFlags = 0; + if (Shell_NotifyIcon(NIM_DELETE, &m_tnd)) + m_bRemoved = m_bHidden = TRUE; - return (m_bRemoved == TRUE); + return (m_bRemoved == TRUE); } -BOOL CSystemTray::HideIcon() { - if (!m_bEnabled || m_bRemoved || m_bHidden) - return TRUE; +BOOL CSystemTray::HideIcon() +{ + if (!m_bEnabled || m_bRemoved || m_bHidden) + return TRUE; #ifdef SYSTEMTRAY_USEW2K - if (m_bWin2K) - { - m_tnd.uFlags = NIF_STATE; - m_tnd.dwState = NIS_HIDDEN; - m_tnd.dwStateMask = NIS_HIDDEN; - - m_bHidden = Shell_NotifyIcon(NIM_MODIFY, &m_tnd); - } - else + if (m_bWin2K) + { + m_tnd.uFlags = NIF_STATE; + m_tnd.dwState = NIS_HIDDEN; + m_tnd.dwStateMask = NIS_HIDDEN; + + m_bHidden = Shell_NotifyIcon( NIM_MODIFY, &m_tnd); + } + else #endif - RemoveIcon(); + RemoveIcon(); - return (m_bHidden == TRUE); + return (m_bHidden == TRUE); } -BOOL CSystemTray::ShowIcon() { - if (m_bRemoved) - return AddIcon(); +BOOL CSystemTray::ShowIcon() +{ + if (m_bRemoved) + return AddIcon(); - if (!m_bHidden) - return TRUE; + if (!m_bHidden) + return TRUE; #ifdef SYSTEMTRAY_USEW2K - if (m_bWin2K) - { - m_tnd.uFlags = NIF_STATE; - m_tnd.dwState = 0; - m_tnd.dwStateMask = NIS_HIDDEN; - Shell_NotifyIcon(NIM_MODIFY, &m_tnd); - } - else + if (m_bWin2K) + { + m_tnd.uFlags = NIF_STATE; + m_tnd.dwState = 0; + m_tnd.dwStateMask = NIS_HIDDEN; + Shell_NotifyIcon ( NIM_MODIFY, &m_tnd ); + } + else #endif - AddIcon(); + AddIcon(); - return (m_bHidden == FALSE); + return (m_bHidden == FALSE); } -BOOL CSystemTray::SetIcon(HICON hIcon) { - if (!m_bEnabled) - return FALSE; +BOOL CSystemTray::SetIcon(HICON hIcon) +{ + if (!m_bEnabled) + return FALSE; - m_tnd.uFlags = NIF_ICON; - m_tnd.hIcon = hIcon; + m_tnd.uFlags = NIF_ICON; + m_tnd.hIcon = hIcon; - if (m_bHidden) - return TRUE; - else - return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); + if (m_bHidden) + return TRUE; + else + return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); } -BOOL CSystemTray::SetIcon(LPCTSTR lpszIconName) { - HICON - hIcon = (HICON) - ::LoadImage( - m_hInstance, - lpszIconName, - IMAGE_ICON, - 0, 0, - LR_LOADFROMFILE); +BOOL CSystemTray::SetIcon(LPCTSTR lpszIconName) +{ + HICON hIcon = (HICON) ::LoadImage( + m_hInstance, + lpszIconName, + IMAGE_ICON, + 0, 0, + LR_LOADFROMFILE); if (!hIcon) return FALSE; @@ -394,154 +408,167 @@ BOOL CSystemTray::SetIcon(LPCTSTR lpszIconName) { return returnCode; } -BOOL CSystemTray::SetIcon(UINT nIDResource) { - HICON - hIcon = (HICON) - ::LoadImage(m_hInstance, - MAKEINTRESOURCE(nIDResource), - IMAGE_ICON, - 0, 0, - LR_DEFAULTCOLOR); +BOOL CSystemTray::SetIcon(UINT nIDResource) +{ + HICON hIcon = (HICON) ::LoadImage(m_hInstance, + MAKEINTRESOURCE(nIDResource), + IMAGE_ICON, + 0, 0, + LR_DEFAULTCOLOR); BOOL returnCode = SetIcon(hIcon); ::DestroyIcon(hIcon); return returnCode; } -BOOL CSystemTray::SetStandardIcon(LPCTSTR lpIconName) { - HICON hIcon = ::LoadIcon(NULL, lpIconName); +BOOL CSystemTray::SetStandardIcon(LPCTSTR lpIconName) +{ + HICON hIcon = ::LoadIcon(NULL, lpIconName); - return SetIcon(hIcon); + return SetIcon(hIcon); } -BOOL CSystemTray::SetStandardIcon(UINT nIDResource) { - HICON hIcon = ::LoadIcon(NULL, MAKEINTRESOURCE(nIDResource)); +BOOL CSystemTray::SetStandardIcon(UINT nIDResource) +{ + HICON hIcon = ::LoadIcon(NULL, MAKEINTRESOURCE(nIDResource)); - return SetIcon(hIcon); + return SetIcon(hIcon); } - -HICON CSystemTray::GetIcon() const { - return (m_bEnabled) ? m_tnd.hIcon : NULL; + +HICON CSystemTray::GetIcon() const +{ + return (m_bEnabled)? m_tnd.hIcon : NULL; } -BOOL CSystemTray::SetIconList(UINT uFirstIconID, UINT uLastIconID) { +BOOL CSystemTray::SetIconList(UINT uFirstIconID, UINT uLastIconID) +{ if (uFirstIconID > uLastIconID) - return FALSE; + return FALSE; UINT uIconArraySize = uLastIconID - uFirstIconID + 1; - m_IconList.clear(); - try { - for (UINT i = uFirstIconID; i <= uLastIconID; i++) - m_IconList.push_back(::LoadIcon(m_hInstance, MAKEINTRESOURCE(i))); - } - catch (...) { - m_IconList.clear(); - return FALSE; - } - - return TRUE; + m_IconList.clear(); + try + { + for (UINT i = uFirstIconID; i <= uLastIconID; i++) + m_IconList.push_back(::LoadIcon(m_hInstance, MAKEINTRESOURCE(i))); + } + catch (...) + { + m_IconList.clear(); + return FALSE; + } + + return TRUE; } -BOOL CSystemTray::SetIconList(HICON* pHIconList, UINT nNumIcons) { - m_IconList.clear(); - - try { - for (UINT i = 0; i <= nNumIcons; i++) - m_IconList.push_back(pHIconList[i]); - } - catch (...) { - m_IconList.clear(); - return FALSE; - } - - return TRUE; +BOOL CSystemTray::SetIconList(HICON* pHIconList, UINT nNumIcons) +{ + m_IconList.clear(); + + try { + for (UINT i = 0; i <= nNumIcons; i++) + m_IconList.push_back(pHIconList[i]); + } + catch (...) + { + m_IconList.clear(); + return FALSE; + } + + return TRUE; } -BOOL CSystemTray::Animate(UINT nDelayMilliSeconds, int nNumSeconds /*=-1*/) { +BOOL CSystemTray::Animate(UINT nDelayMilliSeconds, int nNumSeconds /*=-1*/) +{ if (m_IconList.empty()) return FALSE; - StopAnimation(); + StopAnimation(); - m_nCurrentIcon = 0; - time(&m_StartTime); - m_nAnimationPeriod = nNumSeconds; - m_hSavedIcon = GetIcon(); + m_nCurrentIcon = 0; + time(&m_StartTime); + m_nAnimationPeriod = nNumSeconds; + m_hSavedIcon = GetIcon(); // Setup a timer for the animation m_uIDTimer = ::SetTimer(m_hWnd, m_nTimerID, nDelayMilliSeconds, NULL); - return (m_uIDTimer != 0); + return (m_uIDTimer != 0); } -BOOL CSystemTray::StepAnimation() { - if (!m_IconList.size()) - return FALSE; +BOOL CSystemTray::StepAnimation() +{ + if (!m_IconList.size()) + return FALSE; - m_nCurrentIcon++; - if (m_nCurrentIcon >= m_IconList.size()) - m_nCurrentIcon = 0; + m_nCurrentIcon++; + if (m_nCurrentIcon >= m_IconList.size()) + m_nCurrentIcon = 0; - return SetIcon(m_IconList[m_nCurrentIcon]); + return SetIcon(m_IconList[m_nCurrentIcon]); } -BOOL CSystemTray::StopAnimation() { - BOOL bResult = FALSE; +BOOL CSystemTray::StopAnimation() +{ + BOOL bResult = FALSE; - if (m_uIDTimer) - bResult = ::KillTimer(m_hWnd, m_uIDTimer); - m_uIDTimer = 0; + if (m_uIDTimer) + bResult = ::KillTimer(m_hWnd, m_uIDTimer); + m_uIDTimer = 0; - if (m_hSavedIcon) - SetIcon(m_hSavedIcon); - m_hSavedIcon = NULL; + if (m_hSavedIcon) + SetIcon(m_hSavedIcon); + m_hSavedIcon = NULL; - return bResult; + return bResult; } ///////////////////////////////////////////////////////////////////////////// // CSystemTray tooltip text manipulation -BOOL CSystemTray::SetTooltipText(LPCTSTR pszTip) { - ASSERT(_tcslen(pszTip) < m_nMaxTooltipLength); +BOOL CSystemTray::SetTooltipText(LPCTSTR pszTip) +{ + ASSERT(_tcslen(pszTip) < m_nMaxTooltipLength); if (!m_bEnabled) - return FALSE; - - m_tnd.uFlags = NIF_TIP; - _tcsncpy_s(m_tnd.szTip, sizeof(m_tnd.szTip), pszTip, m_nMaxTooltipLength - 1); - - if (m_bHidden) - return TRUE; - else - return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); + return FALSE; + + m_tnd.uFlags = NIF_TIP; + _tcsncpy_s(m_tnd.szTip, sizeof(m_tnd.szTip), pszTip, m_nMaxTooltipLength-1); + + if (m_bHidden) + return TRUE; + else + return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); } -BOOL CSystemTray::SetTooltipText(UINT nID) { - TCHAR strBuffer[1024]; - ASSERT(1024 >= m_nMaxTooltipLength); +BOOL CSystemTray::SetTooltipText(UINT nID) +{ + TCHAR strBuffer[1024]; + ASSERT(1024 >= m_nMaxTooltipLength); - if (!LoadString(m_hInstance, nID, strBuffer, m_nMaxTooltipLength - 1)) - return FALSE; + if (!LoadString(m_hInstance, nID, strBuffer, m_nMaxTooltipLength-1)) + return FALSE; - return SetTooltipText(strBuffer); + return SetTooltipText(strBuffer); } -LPTSTR CSystemTray::GetTooltipText() const { - if (!m_bEnabled) - return FALSE; +LPTSTR CSystemTray::GetTooltipText() const +{ + if (!m_bEnabled) + return FALSE; - static TCHAR strBuffer[1024]; - ASSERT(1024 >= m_nMaxTooltipLength); + static TCHAR strBuffer[1024]; + ASSERT(1024 >= m_nMaxTooltipLength); #ifdef _UNICODE - strBuffer[0] = _T('\0'); - MultiByteToWideChar(CP_ACP, 0, m_tnd.szTip, -1, strBuffer, m_nMaxTooltipLength, NULL, NULL); + strBuffer[0] = _T('\0'); + MultiByteToWideChar(CP_ACP, 0, m_tnd.szTip, -1, strBuffer, m_nMaxTooltipLength, NULL, NULL); #else - strncpy_s(strBuffer, sizeof(strBuffer), m_tnd.szTip, m_nMaxTooltipLength - 1); + strncpy_s(strBuffer, sizeof(strBuffer), m_tnd.szTip, m_nMaxTooltipLength-1); #endif - return strBuffer; + return strBuffer; } ////////////////////////////////////////////////////////////////////////// @@ -571,139 +598,149 @@ LPTSTR CSystemTray::GetTooltipText() const { ////////////////////////////////////////////////////////////////////////// BOOL CSystemTray::ShowBalloon(LPCTSTR szText, - LPCTSTR szTitle /*=NULL*/, - DWORD dwIcon /*=NIIF_NONE*/, - UINT uTimeout /*=10*/) { + LPCTSTR szTitle /*=NULL*/, + DWORD dwIcon /*=NIIF_NONE*/, + UINT uTimeout /*=10*/ ) +{ #ifndef SYSTEMTRAY_USEW2K - return FALSE; + return FALSE; #else - // Bail out if we're not on Win 2K. - if (!m_bWin2K) - return FALSE; + // Bail out if we're not on Win 2K. + if (!m_bWin2K) + return FALSE; - // Verify input parameters. + // Verify input parameters. - // The balloon tooltip text can be up to 255 chars long. - //ASSERT(AfxIsValidString(szText)); - ASSERT(lstrlen(szText) < 256); + // The balloon tooltip text can be up to 255 chars long. + //ASSERT(AfxIsValidString(szText)); + ASSERT(lstrlen(szText) < 256); - // The balloon title text can be up to 63 chars long. - if (szTitle) - { - //ASSERT(AfxIsValidString( szTitle)); - ASSERT(lstrlen(szTitle) < 64); - } + // The balloon title text can be up to 63 chars long. + if (szTitle) + { + //ASSERT(AfxIsValidString( szTitle)); + ASSERT(lstrlen(szTitle) < 64); + } - // dwBalloonIcon must be valid. - ASSERT(NIIF_NONE == dwIcon || NIIF_INFO == dwIcon || - NIIF_WARNING == dwIcon || NIIF_ERROR == dwIcon); + // dwBalloonIcon must be valid. + ASSERT(NIIF_NONE == dwIcon || NIIF_INFO == dwIcon || + NIIF_WARNING == dwIcon || NIIF_ERROR == dwIcon); - // The timeout must be between 10 and 30 seconds. - ASSERT(uTimeout >= 10 && uTimeout <= 30); + // The timeout must be between 10 and 30 seconds. + ASSERT(uTimeout >= 10 && uTimeout <= 30); - m_tnd.uFlags = NIF_INFO; - _tcsncpy_s(m_tnd.szInfo, sizeof(m_tnd.szInfo), szText, 256); - if (szTitle) - _tcsncpy_s(m_tnd.szInfoTitle, sizeof(m_tnd.szInfoTitle), szTitle, 64); - else - m_tnd.szInfoTitle[0] = _T('\0'); - m_tnd.dwInfoFlags = dwIcon; - m_tnd.uTimeout = uTimeout * 1000; // convert time to ms + m_tnd.uFlags = NIF_INFO; + _tcsncpy_s(m_tnd.szInfo, sizeof(m_tnd.szInfo), szText, 256); + if (szTitle) + _tcsncpy_s(m_tnd.szInfoTitle, sizeof(m_tnd.szInfoTitle), szTitle, 64); + else + m_tnd.szInfoTitle[0] = _T('\0'); + m_tnd.dwInfoFlags = dwIcon; + m_tnd.uTimeout = uTimeout* 1000; // convert time to ms - BOOL bSuccess = Shell_NotifyIcon(NIM_MODIFY, &m_tnd); + BOOL bSuccess = Shell_NotifyIcon (NIM_MODIFY, &m_tnd); - // Zero out the balloon text string so that later operations won't redisplay - // the balloon. - m_tnd.szInfo[0] = _T('\0'); + // Zero out the balloon text string so that later operations won't redisplay + // the balloon. + m_tnd.szInfo[0] = _T('\0'); - return bSuccess; + return bSuccess; #endif } ///////////////////////////////////////////////////////////////////////////// // CSystemTray notification window stuff -BOOL CSystemTray::SetNotificationWnd(HWND hNotifyWnd) { - if (!m_bEnabled) - return FALSE; - - // Make sure Notification window is valid - if (!hNotifyWnd || !::IsWindow(hNotifyWnd)) { - ASSERT(FALSE); - return FALSE; - } - - m_tnd.hWnd = hNotifyWnd; - m_tnd.uFlags = 0; - - if (m_bHidden) - return TRUE; - else - return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); +BOOL CSystemTray::SetNotificationWnd(HWND hNotifyWnd) +{ + if (!m_bEnabled) + return FALSE; + + // Make sure Notification window is valid + if (!hNotifyWnd || !::IsWindow(hNotifyWnd)) + { + ASSERT(FALSE); + return FALSE; + } + + m_tnd.hWnd = hNotifyWnd; + m_tnd.uFlags = 0; + + if (m_bHidden) + return TRUE; + else + return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); } -HWND CSystemTray::GetNotificationWnd() const { - return m_tnd.hWnd; +HWND CSystemTray::GetNotificationWnd() const +{ + return m_tnd.hWnd; } // Hatr added // Change or retrive the window to send menu commands to -BOOL CSystemTray::SetTargetWnd(HWND hTargetWnd) { - m_hTargetWnd = hTargetWnd; - return TRUE; +BOOL CSystemTray::SetTargetWnd(HWND hTargetWnd) +{ + m_hTargetWnd = hTargetWnd; + return TRUE; } // CSystemTray::SetTargetWnd() -HWND CSystemTray::GetTargetWnd() const { - if (m_hTargetWnd) - return m_hTargetWnd; - else - return m_tnd.hWnd; +HWND CSystemTray::GetTargetWnd() const +{ + if (m_hTargetWnd) + return m_hTargetWnd; + else + return m_tnd.hWnd; } // CSystemTray::GetTargetWnd() ///////////////////////////////////////////////////////////////////////////// // CSystemTray notification message stuff -BOOL CSystemTray::SetCallbackMessage(UINT uCallbackMessage) { - if (!m_bEnabled) - return FALSE; +BOOL CSystemTray::SetCallbackMessage(UINT uCallbackMessage) +{ + if (!m_bEnabled) + return FALSE; - // Make sure we avoid conflict with other messages - ASSERT(uCallbackMessage >= WM_APP); + // Make sure we avoid conflict with other messages + ASSERT(uCallbackMessage >= WM_APP); - m_tnd.uCallbackMessage = uCallbackMessage; - m_tnd.uFlags = NIF_MESSAGE; + m_tnd.uCallbackMessage = uCallbackMessage; + m_tnd.uFlags = NIF_MESSAGE; - if (m_bHidden) - return TRUE; - else - return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); + if (m_bHidden) + return TRUE; + else + return Shell_NotifyIcon(NIM_MODIFY, &m_tnd); } -UINT CSystemTray::GetCallbackMessage() const { - return m_tnd.uCallbackMessage; +UINT CSystemTray::GetCallbackMessage() const +{ + return m_tnd.uCallbackMessage; } ///////////////////////////////////////////////////////////////////////////// // CSystemTray menu manipulation -BOOL CSystemTray::SetMenuDefaultItem(UINT uItem, BOOL bByPos) { +BOOL CSystemTray::SetMenuDefaultItem(UINT uItem, BOOL bByPos) +{ #ifdef _WIN32_WCE return FALSE; #else - if ((m_DefaultMenuItemID == uItem) && (m_DefaultMenuItemByPos == bByPos)) + if ((m_DefaultMenuItemID == uItem) && (m_DefaultMenuItemByPos == bByPos)) return TRUE; m_DefaultMenuItemID = uItem; - m_DefaultMenuItemByPos = bByPos; + m_DefaultMenuItemByPos = bByPos; HMENU hMenu = ::LoadMenu(m_hInstance, MAKEINTRESOURCE(m_tnd.uID)); if (!hMenu) return FALSE; HMENU hSubMenu = ::GetSubMenu(hMenu, 0); - if (!hSubMenu) { + if (!hSubMenu) + { ::DestroyMenu(hMenu); return FALSE; } @@ -717,9 +754,10 @@ BOOL CSystemTray::SetMenuDefaultItem(UINT uItem, BOOL bByPos) { #endif } -void CSystemTray::GetMenuDefaultItem(UINT& uItem, BOOL& bByPos) { - uItem = m_DefaultMenuItemID; - bByPos = m_DefaultMenuItemByPos; +void CSystemTray::GetMenuDefaultItem(UINT& uItem, BOOL& bByPos) +{ + uItem = m_DefaultMenuItemID; + bByPos = m_DefaultMenuItemByPos; } ///////////////////////////////////////////////////////////////////////////// @@ -733,447 +771,378 @@ BEGIN_MESSAGE_MAP(CSystemTray, CWnd) #ifndef _WIN32_WCE ON_WM_SETTINGCHANGE() #endif - ON_REGISTERED_MESSAGE(WM_TASKBARCREATED, OnTaskbarCreated) + ON_REGISTERED_MESSAGE(WM_TASKBARCREATED, OnTaskbarCreated) END_MESSAGE_MAP() */ -LRESULT CSystemTray::OnTimer(UINT nIDEvent) { - if (nIDEvent != m_uIDTimer) { - ASSERT(FALSE); - return 0L; - } - - time_t CurrentTime; - time(&CurrentTime); - - time_t period = CurrentTime - m_StartTime; - if (m_nAnimationPeriod > 0 && m_nAnimationPeriod < period) { - StopAnimation(); - return 0L; - } - - StepAnimation(); - - return 0L; +LRESULT CSystemTray::OnTimer(UINT nIDEvent) +{ + if (nIDEvent != m_uIDTimer) + { + ASSERT(FALSE); + return 0L; + } + + time_t CurrentTime; + time(&CurrentTime); + + time_t period = CurrentTime - m_StartTime; + if (m_nAnimationPeriod > 0 && m_nAnimationPeriod < period) + { + StopAnimation(); + return 0L; + } + + StepAnimation(); + + return 0L; } // This is called whenever the taskbar is created (eg after explorer crashes // and restarts. Please note that the WM_TASKBARCREATED message is only passed // to TOP LEVEL windows (like WM_QUERYNEWPALETTE) -LRESULT CSystemTray::OnTaskbarCreated(WPARAM wParam, LPARAM lParam) { - InstallIconPending(); - return 0L; +LRESULT CSystemTray::OnTaskbarCreated(WPARAM wParam, LPARAM lParam) +{ + InstallIconPending(); + return 0L; } #ifndef _WIN32_WCE - -LRESULT CSystemTray::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) { - if (uFlags == SPI_SETWORKAREA) - InstallIconPending(); +LRESULT CSystemTray::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) +{ + if (uFlags == SPI_SETWORKAREA) + InstallIconPending(); return 0L; } - #endif -LRESULT CSystemTray::OnTrayNotification(UINT wParam, LONG lParam) { - //Return quickly if its not for this tray icon - if (wParam != m_tnd.uID) - return 0L; +LRESULT CSystemTray::OnTrayNotification(UINT wParam, LONG lParam) +{ + //Return quickly if its not for this tray icon + if (wParam != m_tnd.uID) + return 0L; - HWND hTargetWnd = GetTargetWnd(); - if (!hTargetWnd) - return 0L; + HWND hTargetWnd = GetTargetWnd(); + if (!hTargetWnd) + return 0L; - // Clicking with right button brings up a context menu + // Clicking with right button brings up a context menu #if defined(_WIN32_WCE) //&& _WIN32_WCE < 211 - BOOL bAltPressed = ((GetKeyState(VK_MENU) & (1 << (sizeof(SHORT) * 8 - 1))) != 0); - if (LOWORD(lParam) == WM_LBUTTONUP && bAltPressed) + BOOL bAltPressed = ((GetKeyState(VK_MENU) & (1 << (sizeof(SHORT)*8-1))) != 0); + if (LOWORD(lParam) == WM_LBUTTONUP && bAltPressed) #else - if (LOWORD(lParam) == WM_RBUTTONUP) + if (LOWORD(lParam) == WM_RBUTTONUP) #endif - { - HMENU hMenu = ::LoadMenu(m_hInstance, MAKEINTRESOURCE(m_tnd.uID)); - if (!hMenu) - return 0; + { + HMENU hMenu = ::LoadMenu(m_hInstance, MAKEINTRESOURCE(m_tnd.uID)); + if (!hMenu) + return 0; - HMENU hSubMenu = ::GetSubMenu(hMenu, 0); - if (!hSubMenu) { - ::DestroyMenu(hMenu); //Be sure to Destroy Menu Before Returning + HMENU hSubMenu = ::GetSubMenu(hMenu, 0); + if (!hSubMenu) + { + ::DestroyMenu(hMenu); //Be sure to Destroy Menu Before Returning return 0; } #ifndef _WIN32_WCE - // Make chosen menu item the default (bold font) - ::SetMenuDefaultItem(hSubMenu, m_DefaultMenuItemID, m_DefaultMenuItemByPos); + // Make chosen menu item the default (bold font) + ::SetMenuDefaultItem(hSubMenu, m_DefaultMenuItemID, m_DefaultMenuItemByPos); #endif - CustomizeMenu(hSubMenu); + CustomizeMenu(hSubMenu); - // Display and track the popup menu - POINT pos; + // Display and track the popup menu + POINT pos; #ifdef _WIN32_WCE DWORD messagepos = ::GetMessagePos(); pos.x = GET_X_LPARAM(messagepos); pos.y = GET_Y_LPARAM(messagepos); #else - GetCursorPos(&pos); + GetCursorPos(&pos); #endif - ::SetForegroundWindow(m_tnd.hWnd); - ::TrackPopupMenu(hSubMenu, 0, pos.x, pos.y, 0, hTargetWnd, NULL); + ::SetForegroundWindow(m_tnd.hWnd); + ::TrackPopupMenu(hSubMenu, 0, pos.x, pos.y, 0, hTargetWnd, NULL); - // BUGFIX: See "PRB: Menus for Notification Icons Don't Work Correctly" - ::PostMessage(m_tnd.hWnd, WM_NULL, 0, 0); + // BUGFIX: See "PRB: Menus for Notification Icons Don't Work Correctly" + ::PostMessage(m_tnd.hWnd, WM_NULL, 0, 0); - DestroyMenu(hMenu); - } + DestroyMenu(hMenu); + } #if defined(_WIN32_WCE) //&& _WIN32_WCE < 211 - if (LOWORD(lParam) == WM_LBUTTONDBLCLK && bAltPressed) + if (LOWORD(lParam) == WM_LBUTTONDBLCLK && bAltPressed) #else - else if (LOWORD(lParam) == WM_LBUTTONDBLCLK) + else if (LOWORD(lParam) == WM_LBUTTONDBLCLK) #endif - { - // double click received, the default action is to execute default menu item - ::SetForegroundWindow(m_tnd.hWnd); - - UINT uItem; - if (m_DefaultMenuItemByPos) { - HMENU hMenu = ::LoadMenu(m_hInstance, MAKEINTRESOURCE(m_tnd.uID)); - if (!hMenu) - return 0; - - HMENU hSubMenu = ::GetSubMenu(hMenu, 0); - if (!hSubMenu) - return 0; - uItem = ::GetMenuItemID(hSubMenu, m_DefaultMenuItemID); - - DestroyMenu(hMenu); - } - else - uItem = m_DefaultMenuItemID; - - ::PostMessage(hTargetWnd, WM_COMMAND, uItem, 0); - } - - return 1; + { + // double click received, the default action is to execute default menu item + ::SetForegroundWindow(m_tnd.hWnd); + + UINT uItem; + if (m_DefaultMenuItemByPos) + { + HMENU hMenu = ::LoadMenu(m_hInstance, MAKEINTRESOURCE(m_tnd.uID)); + if (!hMenu) + return 0; + + HMENU hSubMenu = ::GetSubMenu(hMenu, 0); + if (!hSubMenu) + return 0; + uItem = ::GetMenuItemID(hSubMenu, m_DefaultMenuItemID); + + DestroyMenu(hMenu); + } + else + uItem = m_DefaultMenuItemID; + + ::PostMessage(hTargetWnd, WM_COMMAND, uItem, 0); + } + + return 1; } // This is the global (static) callback function for all TrayIcon windows -LRESULT PASCAL -CSystemTray::WindowProc(HWND - hWnd, - UINT message, WPARAM - wParam, - LPARAM lParam -) +LRESULT PASCAL CSystemTray::WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - // The option here is to maintain a list of all TrayIcon windows, - // and iterate through them. If you do this, remove these 3 lines. - CSystemTray* pTrayIcon = m_pThis; - if (pTrayIcon-> - - GetSafeHwnd() - - != hWnd) - return - ::DefWindowProc(hWnd, message, wParam, lParam - ); - - // If maintaining a list of TrayIcon windows, then the following... - // pTrayIcon = GetFirstTrayIcon() - // while (pTrayIcon != NULL) - // { - // if (pTrayIcon->GetSafeHwnd() != hWnd) continue; - - // Taskbar has been recreated - all TrayIcons must process this. - if (message == CSystemTray::m_nTaskbarCreatedMsg) - return pTrayIcon-> - OnTaskbarCreated(wParam, lParam - ); - - // Animation timer - if (message == - WM_TIMER && wParam - == pTrayIcon-> - - GetTimerID() - - ) - return pTrayIcon-> - OnTimer(wParam); - - // Settings changed - if (message == - WM_SETTINGCHANGE && wParam - == pTrayIcon-> - - GetTimerID() - - ) - return pTrayIcon-> - OnSettingChange(wParam, (LPCTSTR) - lParam); - - // Is the message from the icon for this TrayIcon? - if (message == pTrayIcon-> - - GetCallbackMessage() - - ) - return pTrayIcon-> - OnTrayNotification(wParam, lParam - ); - - // pTrayIcon = GetNextTrayIcon(); - // } - - // Message has not been processed, so default. - return - ::DefWindowProc(hWnd, message, wParam, lParam - ); + // The option here is to maintain a list of all TrayIcon windows, + // and iterate through them. If you do this, remove these 3 lines. + CSystemTray* pTrayIcon = m_pThis; + if (pTrayIcon->GetSafeHwnd() != hWnd) + return ::DefWindowProc(hWnd, message, wParam, lParam); + + // If maintaining a list of TrayIcon windows, then the following... + // pTrayIcon = GetFirstTrayIcon() + // while (pTrayIcon != NULL) + // { + // if (pTrayIcon->GetSafeHwnd() != hWnd) continue; + + // Taskbar has been recreated - all TrayIcons must process this. + if (message == CSystemTray::m_nTaskbarCreatedMsg) + return pTrayIcon->OnTaskbarCreated(wParam, lParam); + + // Animation timer + if (message == WM_TIMER && wParam == pTrayIcon->GetTimerID()) + return pTrayIcon->OnTimer(wParam); + + // Settings changed + if (message == WM_SETTINGCHANGE && wParam == pTrayIcon->GetTimerID()) + return pTrayIcon->OnSettingChange(wParam, (LPCTSTR) lParam); + + // Is the message from the icon for this TrayIcon? + if (message == pTrayIcon->GetCallbackMessage()) + return pTrayIcon->OnTrayNotification(wParam, lParam); + + // pTrayIcon = GetNextTrayIcon(); + // } + + // Message has not been processed, so default. + return ::DefWindowProc(hWnd, message, wParam, lParam); } -void CSystemTray::InstallIconPending() { - // Is the icon display pending, and it's not been set as "hidden"? - if (!m_bShowIconPending || m_bHidden) - return; +void CSystemTray::InstallIconPending() +{ + // Is the icon display pending, and it's not been set as "hidden"? + if (!m_bShowIconPending || m_bHidden) + return; // Reset the flags to what was used at creation m_tnd.uFlags = m_uCreationFlags; - // Try and recreate the icon - m_bHidden = !Shell_NotifyIcon(NIM_ADD, &m_tnd); + // Try and recreate the icon + m_bHidden = !Shell_NotifyIcon(NIM_ADD, &m_tnd); - // If it's STILL hidden, then have another go next time... - m_bShowIconPending = !m_bHidden; + // If it's STILL hidden, then have another go next time... + m_bShowIconPending = !m_bHidden; - ASSERT(m_bHidden == FALSE); + ASSERT(m_bHidden == FALSE); } ///////////////////////////////////////////////////////////////////////////// // For minimising/maximising from system tray -BOOL CALLBACK -FindTrayWnd(HWND - hwnd, - LPARAM lParam -) +BOOL CALLBACK FindTrayWnd(HWND hwnd, LPARAM lParam) { - TCHAR szClassName[256]; - GetClassName(hwnd, szClassName, - 255); - - // Did we find the Main System Tray? If so, then get its size and keep going - if ( - _tcscmp(szClassName, _T("TrayNotifyWnd") - ) == 0) - { - LPRECT lpRect = (LPRECT)lParam; - ::GetWindowRect(hwnd, lpRect - ); - return - TRUE; - } - - // Did we find the System Clock? If so, then adjust the size of the rectangle - // we have and quit (clock will be found after the system tray) - if ( - _tcscmp(szClassName, _T("TrayClockWClass") - ) == 0) - { - LPRECT lpRect = (LPRECT)lParam; - RECT rectClock; - ::GetWindowRect(hwnd, &rectClock - ); - // if clock is above system tray adjust accordingly - if (rectClock.bottom < lpRect->bottom - 5) // 10 = random fudge factor. - lpRect-> - top = rectClock.bottom; - else - lpRect-> - right = rectClock.left; - return - FALSE; - } - - return - TRUE; + TCHAR szClassName[256]; + GetClassName(hwnd, szClassName, 255); + + // Did we find the Main System Tray? If so, then get its size and keep going + if (_tcscmp(szClassName, _T("TrayNotifyWnd")) == 0) + { + LPRECT lpRect = (LPRECT) lParam; + ::GetWindowRect(hwnd, lpRect); + return TRUE; + } + + // Did we find the System Clock? If so, then adjust the size of the rectangle + // we have and quit (clock will be found after the system tray) + if (_tcscmp(szClassName, _T("TrayClockWClass")) == 0) + { + LPRECT lpRect = (LPRECT) lParam; + RECT rectClock; + ::GetWindowRect(hwnd, &rectClock); + // if clock is above system tray adjust accordingly + if (rectClock.bottom < lpRect->bottom-5) // 10 = random fudge factor. + lpRect->top = rectClock.bottom; + else + lpRect->right = rectClock.left; + return FALSE; + } + + return TRUE; } - + #ifndef _WIN32_WCE - -void CSystemTray::GetTrayWndRect(LPRECT lprect) { +void CSystemTray::GetTrayWndRect(LPRECT lprect) +{ #define DEFAULT_RECT_WIDTH 150 #define DEFAULT_RECT_HEIGHT 30 - HWND hShellTrayWnd = FindWindow(_T("Shell_TrayWnd"), NULL); - if (hShellTrayWnd) { - GetWindowRect(hShellTrayWnd, lprect); - EnumChildWindows(hShellTrayWnd, FindTrayWnd, (LPARAM)lprect); - return; - } - // OK, we failed to get the rect from the quick hack. Either explorer isn't - // running or it's a new version of the shell with the window class names - // changed (how dare Microsoft change these undocumented class names!) So, we - // try to find out what side of the screen the taskbar is connected to. We - // know that the system tray is either on the right or the bottom of the - // taskbar, so we can make a good guess at where to minimize to - APPBARDATA appBarData; - appBarData.cbSize = sizeof(appBarData); - if (SHAppBarMessage(ABM_GETTASKBARPOS, &appBarData)) { - // We know the edge the taskbar is connected to, so guess the rect of the - // system tray. Use various fudge factor to make it look good - switch (appBarData.uEdge) { - case ABE_LEFT: - case ABE_RIGHT: - // We want to minimize to the bottom of the taskbar - lprect->top = appBarData.rc.bottom - 100; - lprect->bottom = appBarData.rc.bottom - 16; - lprect->left = appBarData.rc.left; - lprect->right = appBarData.rc.right; - break; - - case ABE_TOP: - case ABE_BOTTOM: - // We want to minimize to the right of the taskbar - lprect->top = appBarData.rc.top; - lprect->bottom = appBarData.rc.bottom; - lprect->left = appBarData.rc.right - 100; - lprect->right = appBarData.rc.right - 16; - break; - } - return; - } - - // Blimey, we really aren't in luck. It's possible that a third party shell - // is running instead of explorer. This shell might provide support for the - // system tray, by providing a Shell_TrayWnd window (which receives the - // messages for the icons) So, look for a Shell_TrayWnd window and work out - // the rect from that. Remember that explorer's taskbar is the Shell_TrayWnd, - // and stretches either the width or the height of the screen. We can't rely - // on the 3rd party shell's Shell_TrayWnd doing the same, in fact, we can't - // rely on it being any size. The best we can do is just blindly use the - // window rect, perhaps limiting the width and height to, say 150 square. - // Note that if the 3rd party shell supports the same configuraion as - // explorer (the icons hosted in NotifyTrayWnd, which is a child window of - // Shell_TrayWnd), we would already have caught it above - if (hShellTrayWnd) { - ::GetWindowRect(hShellTrayWnd, lprect); - if (lprect->right - lprect->left > DEFAULT_RECT_WIDTH) - lprect->left = lprect->right - DEFAULT_RECT_WIDTH; - if (lprect->bottom - lprect->top > DEFAULT_RECT_HEIGHT) - lprect->top = lprect->bottom - DEFAULT_RECT_HEIGHT; - - return; - } - - // OK. Haven't found a thing. Provide a default rect based on the current work - // area - SystemParametersInfo(SPI_GETWORKAREA, 0, lprect, 0); - lprect->left = lprect->right - DEFAULT_RECT_WIDTH; - lprect->top = lprect->bottom - DEFAULT_RECT_HEIGHT; + HWND hShellTrayWnd = FindWindow(_T("Shell_TrayWnd"), NULL); + if (hShellTrayWnd) + { + GetWindowRect(hShellTrayWnd, lprect); + EnumChildWindows(hShellTrayWnd, FindTrayWnd, (LPARAM)lprect); + return; + } + // OK, we failed to get the rect from the quick hack. Either explorer isn't + // running or it's a new version of the shell with the window class names + // changed (how dare Microsoft change these undocumented class names!) So, we + // try to find out what side of the screen the taskbar is connected to. We + // know that the system tray is either on the right or the bottom of the + // taskbar, so we can make a good guess at where to minimize to + APPBARDATA appBarData; + appBarData.cbSize=sizeof(appBarData); + if (SHAppBarMessage(ABM_GETTASKBARPOS,&appBarData)) + { + // We know the edge the taskbar is connected to, so guess the rect of the + // system tray. Use various fudge factor to make it look good + switch(appBarData.uEdge) + { + case ABE_LEFT: + case ABE_RIGHT: + // We want to minimize to the bottom of the taskbar + lprect->top = appBarData.rc.bottom-100; + lprect->bottom = appBarData.rc.bottom-16; + lprect->left = appBarData.rc.left; + lprect->right = appBarData.rc.right; + break; + + case ABE_TOP: + case ABE_BOTTOM: + // We want to minimize to the right of the taskbar + lprect->top = appBarData.rc.top; + lprect->bottom = appBarData.rc.bottom; + lprect->left = appBarData.rc.right-100; + lprect->right = appBarData.rc.right-16; + break; + } + return; + } + + // Blimey, we really aren't in luck. It's possible that a third party shell + // is running instead of explorer. This shell might provide support for the + // system tray, by providing a Shell_TrayWnd window (which receives the + // messages for the icons) So, look for a Shell_TrayWnd window and work out + // the rect from that. Remember that explorer's taskbar is the Shell_TrayWnd, + // and stretches either the width or the height of the screen. We can't rely + // on the 3rd party shell's Shell_TrayWnd doing the same, in fact, we can't + // rely on it being any size. The best we can do is just blindly use the + // window rect, perhaps limiting the width and height to, say 150 square. + // Note that if the 3rd party shell supports the same configuraion as + // explorer (the icons hosted in NotifyTrayWnd, which is a child window of + // Shell_TrayWnd), we would already have caught it above + if (hShellTrayWnd) + { + ::GetWindowRect(hShellTrayWnd, lprect); + if (lprect->right - lprect->left > DEFAULT_RECT_WIDTH) + lprect->left = lprect->right - DEFAULT_RECT_WIDTH; + if (lprect->bottom - lprect->top > DEFAULT_RECT_HEIGHT) + lprect->top = lprect->bottom - DEFAULT_RECT_HEIGHT; + + return; + } + + // OK. Haven't found a thing. Provide a default rect based on the current work + // area + SystemParametersInfo(SPI_GETWORKAREA,0,lprect, 0); + lprect->left = lprect->right - DEFAULT_RECT_WIDTH; + lprect->top = lprect->bottom - DEFAULT_RECT_HEIGHT; } // Check to see if the animation has been disabled (Matthew Ellis ) -BOOL CSystemTray::GetDoWndAnimation() { - ANIMATIONINFO ai; +BOOL CSystemTray::GetDoWndAnimation() +{ + ANIMATIONINFO ai; - ai.cbSize = sizeof(ai); - SystemParametersInfo(SPI_GETANIMATION, sizeof(ai), &ai, 0); + ai.cbSize=sizeof(ai); + SystemParametersInfo(SPI_GETANIMATION,sizeof(ai),&ai,0); - return ai.iMinAnimate ? TRUE : FALSE; + return ai.iMinAnimate?TRUE:FALSE; } - #endif -BOOL CSystemTray::RemoveTaskbarIcon(HWND - hWnd) +BOOL CSystemTray::RemoveTaskbarIcon(HWND hWnd) { - // Create static invisible window - if (! - ::IsWindow(m_hWndInvisible) - ) - { + // Create static invisible window + if (!::IsWindow(m_hWndInvisible)) + { m_hWndInvisible = CreateWindowEx(0, "Static", _T(""), WS_POPUP, - CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, 0, NULL, 0); + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + NULL, 0, NULL, 0); if (!m_hWndInvisible) - return - FALSE; - } + return FALSE; + } - SetParent(hWnd, m_hWndInvisible - ); + SetParent(hWnd, m_hWndInvisible); - return - TRUE; + return TRUE; } -void CSystemTray::MinimiseToTray(HWND - hWnd) +void CSystemTray::MinimiseToTray(HWND hWnd) { #ifndef _WIN32_WCE - if ( + if (GetDoWndAnimation()) + { + RECT rectFrom, rectTo; - GetDoWndAnimation() + GetWindowRect(hWnd, &rectFrom); + GetTrayWndRect(&rectTo); - ) - { - RECT rectFrom, rectTo; - - GetWindowRect(hWnd, &rectFrom - ); - GetTrayWndRect(&rectTo); + DrawAnimatedRects(hWnd, IDANI_CAPTION, &rectFrom, &rectTo); + } - DrawAnimatedRects(hWnd, IDANI_CAPTION, &rectFrom, &rectTo - ); - } - - RemoveTaskbarIcon(hWnd); - SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) - & ~WS_VISIBLE); + RemoveTaskbarIcon(hWnd); + SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) &~ WS_VISIBLE); #endif } -void CSystemTray::MaximiseFromTray(HWND - hWnd) +void CSystemTray::MaximiseFromTray(HWND hWnd) { #ifndef _WIN32_WCE - if ( - - GetDoWndAnimation() - - ) - { - RECT rectTo; - ::GetWindowRect(hWnd, &rectTo - ); - - RECT rectFrom; - GetTrayWndRect(&rectFrom); - - ::SetParent(hWnd, NULL - ); - DrawAnimatedRects(hWnd, IDANI_CAPTION, &rectFrom, &rectTo - ); - } - else - ::SetParent(hWnd, NULL - ); - - SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) - | WS_VISIBLE); - RedrawWindow(hWnd, NULL, NULL, RDW_UPDATENOW - | RDW_ALLCHILDREN | RDW_FRAME | - RDW_INVALIDATE | RDW_ERASE); - - // Move focus away and back again to ensure taskbar icon is recreated - if ( - ::IsWindow(m_hWndInvisible) - ) - SetActiveWindow(m_hWndInvisible); - SetActiveWindow(hWnd); - SetForegroundWindow(hWnd); + if (GetDoWndAnimation()) + { + RECT rectTo; + ::GetWindowRect(hWnd, &rectTo); + + RECT rectFrom; + GetTrayWndRect(&rectFrom); + + ::SetParent(hWnd, NULL); + DrawAnimatedRects(hWnd, IDANI_CAPTION, &rectFrom, &rectTo); + } + else + ::SetParent(hWnd, NULL); + + SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) | WS_VISIBLE); + RedrawWindow(hWnd, NULL, NULL, RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_FRAME | + RDW_INVALIDATE | RDW_ERASE); + + // Move focus away and back again to ensure taskbar icon is recreated + if (::IsWindow(m_hWndInvisible)) + SetActiveWindow(m_hWndInvisible); + SetActiveWindow(hWnd); + SetForegroundWindow(hWnd); #endif } diff --git a/fancontrol/TPFanControl.ini b/fancontrol/TPFanControl.ini index 500454c..2f4d081 100644 --- a/fancontrol/TPFanControl.ini +++ b/fancontrol/TPFanControl.ini @@ -1,179 +1,175 @@ -// new: // -Hotkeys=1 -// HOTKEY Integration: -// Crtl+Shift+B -> BIOS-Mode -// Crtl+Shift+S -> Smart-Mode -// Crtl+Shift+M -> Manual Mode -// Crtl+Shift+1 -> Smart-Mode 1 -// Crtl+Shift+2 -> Smart-Mode 2 +// >>>> Celsius / Fahrenheit: temperatures in °C (active) / °F <<<< // -// -// -// >>>> Celsius / Fahrenheit: temperatures in °C (active) / °F <<<< -// !!! Temp of lowest Level > 79 -> switch to Fahrenheit !!! see below -// ATTENTION: example temp values are for my T61, especially -// BluetoothEDR=1, SensorName5=no5, IgnoreSensors=no5 too -// temp levels 10 degrees centgrade higher than in T4x, R5x, -// change for your purposes. -// Achtung: die eingetragenen Temperaturwerte benutze ich beim T61, -// speziell hier: BluetoothEDR=1, SensorName5=no5, IgnoreSensors=no5 -// Für T4x, R5x können die Temps 10 Grad niedriger eingetragen werden. -// Bitte alles für die eigenen Zwecke anpassen. +// ATTENTION: program versionvery special for Edge E520 onlx + // advice for programmers: TPFanControl must acquire mutex named -// "Access_Thinkpad_EC" to get access to embedded controller -// Hinweis für Programmierer: TPFanControl muss den Mutex -// "Access_Thinkpad_EC" aquirieren können um Zugang zum embbeded -// controller zu bekommen. -// with Active=3 & ManFanSpeed=0 & ManModeExit=78 you can have a nice -// quiet time until temps reaches 78 deg. centigrade :-)) -// mit Active=3 & ManFanSpeed=0 & ManModeExit=78 kann man nach dem -// "Kaltstart eine schöne ruhige Zeit haben, bis die Temps 78 °C -// erreichen und das Programm auf smart mode schaltet. +// "Access_Thinkpad_EC" to get access to embedded controller // ----------------------------------------------------------------- -// ----------------------------------------------------------------- -// "Active=0" program just reads config. +// ENGL: +// "Active=0" program just reads config. // "Active=1" allow program to modify fan. // "Active=2" program will come up in smart mode. // "Active=3" program will come up in manual mode. -// bei "Active=0" wird nur die Konfiguration ausgelesen. -// bei "Active=1" die Veränderung des Lüfterverhaltens ist aktiviert. -// bei "Active=2" startet das Programm im "Smart"-Modus. -// bei "Active=3" startet das Programm im "Manual"-Modus. -Active=2 -// ----------------------------------------------------------------- -// manual fan speed at program start -// Lüfterstufe beim Programmstart -ManFanSpeed=0 -// ----------------------------------------------------------------- -// Program exits manual mode and switches to smart mode with last chosen -// profile, if this temp (degrees Centigrade or Fahrenheit) is achieved. -// default= 80 degrees Centigrade / 176 degrees Fahrenheit. -// Das Program verlässt den manual mode und schaltet auf smart mode mit -// letztem gewähltem Profil, wenn diese Temperatur erreicht ist. -// default= 80 Grad Celsius / 176 Grad Fahrenheit. -ManModeExit=78 //ManModeExit=172 // with Fahrenheit -// ----------------------------------------------------------------- -// Window stays on Top if StayOnTop=1, normal behavior =0 -// Programmfenster bleibt im Vordergrund bei StayOnTop=1, ansonsten =0 -StayOnTop=1 -// ----------------------------------------------------------------- -// Set to 1 for slim widget -// Schmales Programmfenster bei SlimDialog=1, ansonsten =0 -SlimDialog=0 -// ----------------------------------------------------------------- -// set to 1 for bluetooth with enhanced data rate (i.e. T61, -// X61 for T4x, R5x set BluetoothEDR=0 ) -// BluetoothEDR=1 für bluetooth mit enhanced data rate (EDR, z.B. T61, -// X61 für T4x, R5x BluetoothEDR=0 setzen) -BluetoothEDR=0 +// +// DE: +// bei "Active=0" wird nur die Konfiguration ausgelesen. +// bei "Active=1" die Veränderung des Lüfterverhaltens ist aktiviert. +// bei "Active=2" startet das Programm im "Smart"-Modus. +// bei "Active=3" startet das Programm im "Manual"-Modus. + +Active=1 + +ManFanSpeed=255 // Manual Fan Speed + +SlimDialog=0 // Set to 1 for slim widget + +StayOnTop=1 //Windows stays on Top if 1, normal behavior =0 + + // ----------------------------------------------------------------- -// Windows Priority of Process (0-5, normal=2), increase if fancontrol has +// Windows Priority of Process (0-5, normal=2), increase if fancontrol has // big delays in response while other processes consume performance. -// Windows-Priorität des Processes (0-5, normal=2), ggf. erhöhen, falls -// Reaktion des Programms zu träge wegen Resourcenverbrauch durch andere +// Windows-Priorität des Processes (0-5, normal=2), ggf. erhöhen, falls +// Reaktion des Programms zu träge wegen Resourcenverbrauch durch andere // Anwendungen + ProcessPriority=2 + // ----------------------------------------------------------------- -// Show no icon ballons: NoBallons=1, show icon ballons: NoBallons=0 -// Icon Sprechblasen anzeigen mit NoBallons=0, keine bei NoBallons=1 +// Show no icon ballons: NoBallons=1 +// Show icon ballons: NoBallons=0 + NoBallons=1 + // ----------------------------------------------------------------- -// check temperatures every x seconds (default 5) -// Ãœberprüft die Temperaturen alle x Sekunden (Standard ist 5). -Cycle=5 +// ENGL: check temperatures every x seconds (default 5) +// DE: Überprüft die Temperaturen alle x Sekunden (Standard ist 5). + +Cycle=10 + + // ----------------------------------------------------------------- -// For Thinkpads A2x,T2x,X2x set NoExtSensor=1 to exclude reading -// of extended sensors to prevent program errors. Attention 570(E) -// is NOT compatible. Fan speed is not available on all models. -// Bei Thinkpads A2x,T2x,X2x NoExtSensor=1 setzen: die Sensoren 9-12 -// werden nicht ausgelesen und dadurch Fehlermeldungen vermieden. -// Funktioniert NICHT bei 570(E), Fanspeed nicht immer verfügbar. -NoExtSensor=0 -// ----------------------------------------------------------------- -// Minimize to systray immediately when starting -// Minimiert das Programm schon beim Start in die Taskleiste. +// ENGL: Minimize to systray immediately when starting +// DE: Minimiert das Programm schon beim Start in die Taskleiste. + StartMinimized=1 + + // ----------------------------------------------------------------- -// check icon of tpfcicon.exe (optional) every x seconds (default 1) -// Ãœberprüft das Icon von tpfcicon.exe alle x Sekunden (Standard =1). -IconCycle=1 +// ENGL: check vista icon every x seconds (default 1) +// DE: Überprüft das Vista Icon alle x Sekunden (Standard ist 1). + +IconCycle=10 + + // ----------------------------------------------------------------- -// Show new icon with max. temperature / sensor name -// Zeige neues Icon mit Max. Temperatur / Sensorbezeichnung +// ENGL: Show new icon with max. temperature / sensor name +// DE: Zeige neues Icon mit Max. Temperatur / Sensorbezeichnung + ShowTempIcon=1 + + // ----------------------------------------------------------------- -// Save the icon by a start delay of the program/service of +// ENGL: Save the icon by a start delay of the service of // "SecStartDelay" (sec.) within "SecWinUptime" (sec.) after (re)boot -// Delete slashes '//' at next 3 parameters. -// Das Problem der nicht erscheinenden Icons wird durch eine -// Startverzögerung um SecStartDelay (Sekunden) innerhalb einer Zeit von -// SecWinUptime (Sekunden) verhindert. Kommentarstriche "//" entfernen. -// -//SecWinUptime=120 //"SecWinUptime" (sec.) after (re)boot -//SecStartDelay=60 //start delay of the program (sec.) -//NoWaitMessage=0 //set to 1 to avoid sleep message -//ReIcCycle=600 //rebuild TempIcon every xxx secs. +// DE: Das Problem der nicht erscheinenden Icons wird durch eine +// Startverzögerung um SecStartDelay (Sekunden) innerhalb einer Zeit von +// SecWinUptime (Sekunden) verhindert. + +// SecWinUptime=120 +// SecStartDelay=60 +// ReIcCycle=10 //rebuild TempIcon every xxx secs. +// NoWaitMessage=0 //set to 1 to avoid sleep message + // ----------------------------------------------------------------- -// Temperature thresholds for turning the taskbar icon +// ENGL: Temperature thresholds for turning the taskbar icon // yellow orange red (Smart and Manual mode only and // only together with MinimizeToTray=1) -// Temperaturgrenzwerte, die das Symbol in der Taskbar gelb, -// orange bzw. rot färben. (Nur im "Smart"- und "Manual"-Modus -// in Kombination mit "MinimizeToTray=1" verfügbar.) -IconLevels=65 75 80 // Fahrenheit: IconLevels=122 140 158 + +// DE: Temperaturgrenzwerte, die das Symbol in der Taskbar gelb, +// orange bzw. rot färben. (Nur im "Smart"- und "Manual"-Modus +// in Kombination mit "MinimizeToTray=1" verfügbar.) + +IconLevels=60 70 80 + + // ----------------------------------------------------------------- -// Beep frequency and duration (in ms) for successful -// fan state changes. (Set either or both to zero to +// ENGL: Beep frequency and duration (in ms) for successful +// fan state changes. (Set either or both to zero to // disable) -// Frequenz und Dauer des Piep-Signals (in ms), das eine erfolgreiche -// Änderung des Lüfterzustands ankündigt. (Um den Piepton abzuschalten, + +// DE: Frequenz und Dauer des Piep-Signals (in ms), das eine erfolgreiche +// Änderung des Lüfterzustands ankündigt. (Um den Piepton abzuschalten, // setzen Sie entweder einen oder beide Werte auf 0.) + FanBeep=0 0 + + // -------------------------------------------------------- -// If this max number of consecutive EC read errors occur +// ENGL: If this max number of consecutive EC read errors occur // program will switch fan back to bios mode and exit -// Sobald die maximale Anzahl aufeinanderfolgender EC-Lesefehler -// erreicht ist, schaltet das Programm auf den BIOS-Modus um + +// DE: Sobald die maximale Anzahl aufeinanderfolgender EC-Lesefehler +// erreicht ist, schaltet das Programm auf den BIOS-Modus um // und wird beendet. + MaxReadErrors= 10 + + // -------------------------------------------------------- -// Log2File=1 enables, Log2File=0 disables writing to TPFanControl.log -// Start program with admin rights. -// Log2File=1 aktiviert, Log2File=0 deaktiviert -// Schreiben nach TPFanControl.log, Programm benötigt Admin-Rechte. -Log2File=0 +// ENGL: Log2File=1 enables, Log2File=0 disables +// writing to TPFanControl.log . To log to file TPFanControl +// has to run with admin rights in Win7 + +// DE: Log2File=1 aktiviert, Log2File=0 deaktiviert +// TPFanControl muss mit Admin-Rechten laufen in Win7 +// um nach TPFanControl.log zu loggen + +Log2File=1 + + // -------------------------------------------------------- -// Log2csv=1 enables, Log2csv=0 disables -// writing to TPFanControl_csv.txt renamed to +// ENGL: Log2csv=1 enables, Log2csv=0 disables +// writing to TPFanControl_csv.txt renamed to // TPFanControl_last_csv.txt after restart of TPFanControl -// rename to *.csv for use with excel -// Start program with admin rights. -// Log2csv=1 aktiviert Schreiben nach TPFanControl_csv.txt -// Programm benötigt Admin-Rechte. Datei wird umbenannt in +// rename to *.csv for use with excel. To log to file TPFanControl +// has to run with admin rights in Win7 + +// DE: Log2csv=1 aktiviert, Log2csv=0 deaktiviert +// Schreiben nach TPFanControl_csv.txt umbenannt in // TPFanControl_last_csv.txt nach erneutem Start von TPFanControl -// In *.csv umbenennen für anschliessende Bearbeitung mit excel +// nach *.csv umbenennen für Bearbeitung mit excel +// TPFanControl muss mit Admin-Rechten laufen in Win7 +// um nach TPFanControl_csv.txt zu loggen + Log2csv=0 + + // -------------------------------------------------------- -// List (separated by comma) of sensors to ignore when -// determining the max. temperature. (Use lower case, +// ENGL: list (separated by comma) of sensors to ignore when +// determining the max. temperature. (Use lower case, // e.g "IgnoreSensors=pci,aps") -// Liste der Sensoren, getrennt durch Kommata, die bei der + +// DE: Liste der Sensoren, getrennt durch Kommata, die bei der // Ermittlung der Maximaltemperatur ignoriert werden. (Verwenden // Sie kleine Buchstaben, z.B. "IgnoreSensors=pci,aps".) -IgnoreSensors=no5 + +IgnoreSensors=x7f + // --------------------------------------------------------- -// List of new 3 letter sensor names, delete leading -// slashes to aktivat. Don't use capital letters for readability +// ENGL: List of new 3 letter sensor names, delete leading +// slashes to aktivat. Don't use capital letters for readability // of temp icon. -// Liste von neuen Sensorname (jeweils 3 Buchstaben), zum -// Aktivieren die Schrägstriche löschen. Kleine Buschstaben +// DE: Liste von neuen Sensorname (jeweils 3 Buchstaben), zum +// Aktivieren die Schrägstriche löschen. Kleine Buschstaben // wg. der Lesbarkeit im TempIcon gebrauchen. + //SensorName1=cpu //SensorName2=aps //SensorName3=pcm //SensorName4=gpu -SensorName5=no5 +//SensorName5=no5 //SensorName6=x7d //SensorName7=bat //SensorName8=x7f @@ -181,20 +177,23 @@ SensorName5=no5 //SensorName10=pci //SensorName11=pwr //SensorName12=xc3 + // --------------------------------------------------------- -// calculating Highest Temp with: +// ENGL: calculating Highest Temp with: // temperature of sensor no. = real temp minus SensorOffsetno. // Default SensorOffset1-12=0 , Capital O in SensorOffset, -// to activate delete slashes '//', +// to activate delete slashes, // Negative SensorOffsetno. values increase temperature values. -// Berechnung von Highest Temp mit: + +// DE: Berechnung von Highest Temp mit: // Temperatur des Sensor Nr. = reale Temp minus SensorOffsetnr. // Default: SensorOffset1-12=0 , Grosses O in SensorOffsetnr. -// zum Aktivieren Schrägstriche '//' löschen, -// Negative SensorOffsetnr-Werte erhöhen den Temperaturwert. +// zum Aktivieren Schrägstriche löschen, +// Negative SensorOffsetnr-Werte erhöhen den Temperaturwert. + + //SensorOffset1=20 -//SensorOffset2=20 -//SensorOffset3=0 +//SensorOffset2=6 //SensorOffset4=2 //SensorOffset5=1 //SensorOffset6=5 @@ -204,87 +203,85 @@ SensorName5=no5 //SensorOffset10=2 //SensorOffset11=1 //SensorOffset12=5 -// ----------------------------------------------------------------- -// set to 1 to show calculated temps for sensors -// =1 gesetzt zeigt die Temperaturen mit Offsetkorrektur an -ShowBiasedTemps=1 + +ShowBiasedTemps=1 // set to 1 to show calculated temps for sensors + // ----------------------------------------------------------------- // Show all/active sensors at start up. all=1 only active=0 -// Zeige alle/aktive Sensoren an: alle=1, nur aktive =0 -ShowAll=0 + +ShowAll=0 + // -------------------------------------------------------- -// temperature levels 'Level=' with associated fan levels +// ENGL: temperature levels with associated fan levels // (for the fan to come back, temperature must fall -// down to previous level). There may be more or -// less levels in this list. The first one should +// down to previous level). There may be more or +// less levels in this list. The first one should // have a fan speed of zero and is the "turn off" // temperature. +// // Fan speed of 64 is extreme and may be an *unsupported* -// and *damaging* mode. A fan speed of 128 setting is +// and *damaging* mode. A fan speed of 128 setting is // not really a fan speed in itself but will instead switch -// fan control to BIOS mode (0x80). The idea of this +// fan control to BIOS mode (0x80). The idea of this // is to let the program get out of the way and let the // BIOS handle extremes.(and then switch back to smart if // the temperature is okay again) + +// DE: Im Folgenden sind die Temperaturpegel samt den jeweils +// zugeordeten Lüfterstufen aufgelistet. (Sobald die Temperatur in +// den Bereich eines niedrigeren bzw. höheren Pegels wechselt, wird +// die Lüfterstufe automatisch angepasst und folglich verringert bzw. +// erhöht sich die Geschwindigkeit des Lüfters.) Diese Liste kann +// weniger oder auch mehr Stufen beinhalten. Sinngemäß sollte die +// erste Stufe die gewünschte Temperatur definieren, bei der sich +// der Lüfter ausschaltet (Lüftergeschwindigkeit 0) // -// Im Folgenden sind die Temperaturpegel samt den jeweils -// zugeordeten Lüfterstufen aufgelistet. (Sobald die Temperatur in -// den Bereich eines niedrigeren bzw. höheren Pegels wechselt, wird -// die Lüfterstufe automatisch angepasst und folglich verringert bzw. -// erhöht sich die Geschwindigkeit des Lüfters.) Diese Liste kann -// weniger oder auch mehr Stufen beinhalten. Sinngemäß sollte die -// erste Stufe die gewünschte Temperatur definieren, bei der sich -// der Lüfter ausschaltet (Lüftergeschwindigkeit 0) -// Die Lüftergeschwindigkeit 64 ist ein Extremwert und könnte somit -// eine von IBM nicht unterstützte und sogar schädigende Betriebsart -// darstellen. Die Lüftergeschwindigkeit 128 ist an sich keine eigene +// Die Lüftergeschwindigkeit 64 ist ein Extremwert und könnte somit +// eine von IBM nicht unterstützte und sogar schädigende Betriebsart +// darstellen. Die Lüftergeschwindigkeit 128 ist an sich keine eigene // Geschwindigkeitsstufe, sondern gibt stattdessen die Kontrolle -// des Lüfters an das BIOS (BIOS mode, 0x80) zurück. Der Hintergrund -// dieser Einstellung ist die Möglichkeit, das Programm auszuschließen, -// um Extemfälle wieder vom BIOS steuern zu lassen. (Sobald sich die +// des Lüfters an das BIOS (BIOS mode, 0x80) zurück. Der Hintergrund +// dieser Einstellung ist die Möglichkeit, das Programm auszuschließen, +// um Extemfälle wieder vom BIOS steuern zu lassen. (Sobald sich die // Temperatur wieder im Normbereich befindet, wird erneut der Smart // Modus aktiviert.) -// -// Temp of lowest Level (commonly set to fan speed zero) of profile -// "Smart Mode 1" will switch from Celsius to Fahrenheit if set higher -// than 79 degrees. Temps of higher levels have no influence on F/C. -// -// profile "Smart Mode 1" -// change values and number of items for your needs -// Celsius: // Fahrenheit: -MenuLabelSM1=Smart Mode 1/ Label for Icon Menu, must be terminated by '/' -// Level=60 0 // Level=140 0 -// Level=65 1 // Level=150 1 -// Level=75 3 // Level=165 3 -// Level=80 7 // Level=175 7 -// Level=90 64 // Level=195 64 -Level=50 0 // Level2=70 0 -Level=60 1 // Level2=90 1 -Level=70 2 // Level2=100 2 -Level=80 4 // Level2=110 3 -Level=90 7 // Level2=130 7 -// optional 2nd profile "Smart Mode 2", switched by icon menue -// change values and number of items for your needs -// to deactivate, insert leading '//' into following lines -// MenuLabelSM2=Smart Mode 2/ Label for Icon Menu, must be terminated by '/' -// Level2=22 0 // Level2=70 0 -// Level2=33 1 // Level2=90 1 -// Level2=38 2 // Level2=100 2 -// Level2=44 3 // Level2=110 3 -// Level2=55 7 // Level2=130 7 -// Level2=66 64 // Level2=150 64 -// Level2=77 128 // Level2=170 128 -// ----------------------------------------------------------------- -// IconColorFan=1 digital Icon will turn green while fan is running. -// IconColorFan=1 Digitales Icon wird grün während der Lüfter läuft. + +// Celsius: // Fahrenheit: (Level FAN 0>80 -> Fahrenheit) + +MenuLabelSM1=Smart Mode Cool/ Label for Icon Menu, must be terminated by '/' + +Level=50 255 +Level=60 128 +Level=67 169 +Level=80 140 +Level=85 126 +Level=90 0 + + +// optional 2nd profile +// if you don't need, deactivate following lines with '//' + +MenuLabelSM2=Smart Mode Hot/ Label for Icon Menu, must be terminated by '/' +/Level2=60 255 +/Level2=70 196 +/Level2=80 169 +/Level2=85 140 +/Level2=90 126 +/Level2=95 0 + + +// IconColorFan=1 digital Icon will turn green while fan is running. +// IconColorFan=1 Digitales Icon wird grün während der Lüfter läuft. + IconColorFan=1 -// ----------------------------------------------------------------- -// Lev64Norm=1 : Fan level 64 acts as normal level with hysteresis, -// fan will run till next lower temp step is reached (no pulsing fan). -// If set to zero fan level 64 acts as emergency level without hysteresis, -// fan will run till level64 temp is reached again (pulsing fan can happen). -// Lev64Norm=1 : Fan level 64 arbeitet mit Hysterese, Lüfter läuft, -// bis nächst tieferer level erreicht wird. Lüfter pulsiert nicht. -// Falls Lev64Norm=0 gesetzt, arbeitet level 64 als Notfallkühlung oberhalb -// der Temperatur von level 64. Ein Pulsieren des Lüfters ist möglich. -Lev64Norm=1 + + +// Program exits manual mode and switches to smart mode with last chosen +// profile, if this temp (degrees Centigrade or Fahrenheit) is achieved. +// default= 80 degrees Centigrade / 176 degrees Fahrenheit. + +// Das Program verlässt den manual mode und schaltet auf smart mode mit +// letztem gewähltem Profil, wenn diese Temperatur erreicht ist. +// default= 80 Grad Celsius / 176 Grad Fahrenheit. + +ManModeExit=80 diff --git a/fancontrol/TVicPort.h b/fancontrol/TVicPort.h index c36f774..e9fd10a 100644 --- a/fancontrol/TVicPort.h +++ b/fancontrol/TVicPort.h @@ -19,121 +19,87 @@ extern "C" { #pragma pack(1) - typedef struct _HDDInfo { - ULONG BufferSize; - ULONG DoubleTransfer; - ULONG ControllerType; - ULONG ECCMode; - ULONG SectorsPerInterrupt; - ULONG Cylinders; - ULONG Heads; - ULONG SectorsPerTrack; - char Model[41]; - char SerialNumber[21]; - char Revision[9]; - } HDDInfo, * pHDDInfo; - - - void VICFN CloseTVicPort(); - - BOOL VICFN OpenTVicPort(); - - BOOL VICFN IsDriverOpened(); - - BOOL VICFN TestHardAccess(); - - void VICFN SetHardAccess(BOOL bNewValue); - - UCHAR VICFN ReadPort(USHORT PortAddr); - - void VICFN WritePort(USHORT PortAddr, UCHAR nNewValue); - - USHORT VICFN ReadPortW(USHORT PortAddr); - - void VICFN WritePortW(USHORT PortAddr, USHORT nNewValue); - - ULONG VICFN ReadPortL(USHORT PortAddr); - - void VICFN WritePortL(USHORT PortAddr, ULONG nNewValue); - - void VICFN ReadPortFIFO(USHORT PortAddr, ULONG NumPorts, UCHAR* Buffer); - - void VICFN WritePortFIFO(USHORT PortAddr, ULONG NumPorts, UCHAR* Buffer); - - void VICFN ReadPortWFIFO(USHORT PortAddr, ULONG NumPorts, USHORT* Buffer); - - void VICFN WritePortWFIFO(USHORT PortAddr, ULONG NumPorts, USHORT* Buffer); - - void VICFN ReadPortLFIFO(USHORT PortAddr, ULONG NumPorts, ULONG* Buffer); - - void VICFN WritePortLFIFO(USHORT PortAddr, ULONG NumPorts, ULONG* Buffer); - - USHORT VICFN GetLPTNumber(); - - void VICFN SetLPTNumber(USHORT nNewValue); - - USHORT VICFN GetLPTNumPorts(); - - USHORT VICFN GetLPTBasePort(); - - UCHAR VICFN AddNewLPT(USHORT PortBaseAddress); - - BOOL VICFN GetPin(USHORT nPin); - - void VICFN SetPin(USHORT nPin, BOOL bNewValue); - - BOOL VICFN GetLPTAckwl(); - - BOOL VICFN GetLPTBusy(); - - BOOL VICFN GetLPTPaperEnd(); - - BOOL VICFN GetLPTSlct(); - - BOOL VICFN GetLPTError(); - - void VICFN LPTInit(); - - void VICFN LPTSlctIn(); - - void VICFN LPTStrobe(); - - void VICFN LPTAutofd(BOOL Flag); - - void VICFN GetHDDInfo(UCHAR IdeNumber, UCHAR Master, pHDDInfo Info); - - ULONG VICFN MapPhysToLinear(ULONG PhAddr, ULONG PhSize); - - void VICFN UnmapMemory(ULONG PhAddr, ULONG PhSize); - - UCHAR VICFN GetMem(ULONG MappedAddr, ULONG Offset); - - void VICFN SetMem(ULONG MappedAddr, ULONG Offset, UCHAR nNewValue); - - USHORT VICFN GetMemW(ULONG MappedAddr, ULONG Offset); - - void VICFN SetMemW(ULONG MappedAddr, ULONG Offset, USHORT nNewValue); - - ULONG VICFN GetMemL(ULONG MappedAddr, ULONG Offset); - - void VICFN SetMemL(ULONG MappedAddr, ULONG Offset, ULONG nNewValue); - - void VICFN SetLPTReadMode(); - - void VICFN SetLPTWriteMode(); - - void VICFN LaunchWeb(); - - void VICFN LaunchMail(); - - int VICFN EvaluationDaysLeft(); +typedef struct _HDDInfo { + ULONG BufferSize; + ULONG DoubleTransfer; + ULONG ControllerType; + ULONG ECCMode; + ULONG SectorsPerInterrupt; + ULONG Cylinders; + ULONG Heads; + ULONG SectorsPerTrack; + char Model[41]; + char SerialNumber[21]; + char Revision[9]; +} HDDInfo, *pHDDInfo; + + + +void VICFN CloseTVicPort(); +BOOL VICFN OpenTVicPort(); +BOOL VICFN IsDriverOpened(); + +BOOL VICFN TestHardAccess(); +void VICFN SetHardAccess(BOOL bNewValue); + +UCHAR VICFN ReadPort (USHORT PortAddr); +void VICFN WritePort (USHORT PortAddr, UCHAR nNewValue); +USHORT VICFN ReadPortW (USHORT PortAddr); +void VICFN WritePortW(USHORT PortAddr, USHORT nNewValue); +ULONG VICFN ReadPortL (USHORT PortAddr); +void VICFN WritePortL(USHORT PortAddr, ULONG nNewValue); + +void VICFN ReadPortFIFO (USHORT PortAddr, ULONG NumPorts, UCHAR * Buffer); +void VICFN WritePortFIFO (USHORT PortAddr, ULONG NumPorts, UCHAR * Buffer); +void VICFN ReadPortWFIFO (USHORT PortAddr, ULONG NumPorts, USHORT * Buffer); +void VICFN WritePortWFIFO(USHORT PortAddr, ULONG NumPorts, USHORT * Buffer); +void VICFN ReadPortLFIFO (USHORT PortAddr, ULONG NumPorts, ULONG * Buffer); +void VICFN WritePortLFIFO(USHORT PortAddr, ULONG NumPorts, ULONG * Buffer); + +USHORT VICFN GetLPTNumber(); +void VICFN SetLPTNumber(USHORT nNewValue); +USHORT VICFN GetLPTNumPorts(); +USHORT VICFN GetLPTBasePort(); +UCHAR VICFN AddNewLPT(USHORT PortBaseAddress); + +BOOL VICFN GetPin(USHORT nPin); +void VICFN SetPin(USHORT nPin, BOOL bNewValue); + +BOOL VICFN GetLPTAckwl(); +BOOL VICFN GetLPTBusy(); +BOOL VICFN GetLPTPaperEnd(); +BOOL VICFN GetLPTSlct(); +BOOL VICFN GetLPTError(); + +void VICFN LPTInit(); +void VICFN LPTSlctIn(); +void VICFN LPTStrobe(); +void VICFN LPTAutofd(BOOL Flag); + +void VICFN GetHDDInfo (UCHAR IdeNumber, UCHAR Master, pHDDInfo Info); + +ULONG VICFN MapPhysToLinear(ULONG PhAddr, ULONG PhSize); +void VICFN UnmapMemory (ULONG PhAddr, ULONG PhSize); + +UCHAR VICFN GetMem (ULONG MappedAddr, ULONG Offset); +void VICFN SetMem (ULONG MappedAddr, ULONG Offset, UCHAR nNewValue); +USHORT VICFN GetMemW(ULONG MappedAddr, ULONG Offset); +void VICFN SetMemW(ULONG MappedAddr, ULONG Offset, USHORT nNewValue); +ULONG VICFN GetMemL(ULONG MappedAddr, ULONG Offset); +void VICFN SetMemL(ULONG MappedAddr, ULONG Offset, ULONG nNewValue); + +void VICFN SetLPTReadMode(); +void VICFN SetLPTWriteMode(); + +void VICFN LaunchWeb(); +void VICFN LaunchMail(); + +int VICFN EvaluationDaysLeft(); #pragma pack() #ifdef __cplusplus - } // extern "C" - #endif #endif diff --git a/fancontrol/UpgradeLog.htm b/fancontrol/UpgradeLog.htm new file mode 100644 index 0000000..3fcac82 Binary files /dev/null and b/fancontrol/UpgradeLog.htm differ diff --git a/fancontrol/_prec.cpp b/fancontrol/_prec.cpp index b256fc5..109af0d 100644 --- a/fancontrol/_prec.cpp +++ b/fancontrol/_prec.cpp @@ -1,2 +1,2 @@ -//this file generates the pch-file +//this file generates the pch-file #include "_prec.h" \ No newline at end of file diff --git a/fancontrol/afxres.h b/fancontrol/afxres.h deleted file mode 100644 index 96b8bfd..0000000 --- a/fancontrol/afxres.h +++ /dev/null @@ -1,798 +0,0 @@ -// This is a part of the Microsoft Foundation Classes C++ library. -// Copyright (C) 1992-1998 Microsoft Corporation -// All rights reserved. -// -// This source code is only intended as a supplement to the -// Microsoft Foundation Classes Reference and related -// electronic documentation provided with the library. -// See these sources for detailed information regarding the -// Microsoft Foundation Classes product. - -#ifndef __AFXRES_H__ -#define __AFXRES_H__ - -#ifdef RC_INVOKED -#ifndef _INC_WINDOWS -#define _INC_WINDOWS -#include "winres.h" // extract from windows header -#endif -#endif - -#ifdef _AFX_MINREBUILD -#pragma component(minrebuild, off) -#endif - -#ifdef APSTUDIO_INVOKED -#define APSTUDIO_HIDDEN_SYMBOLS -#endif - -#ifndef _MFC_VER -#define _MFC_VER 0x0600 -#endif - -///////////////////////////////////////////////////////////////////////////// -// MFC resource types (see Technical note TN024 for implementation details) - -#ifndef RC_INVOKED -#define RT_DLGINIT MAKEINTRESOURCE(240) -#define RT_TOOLBAR MAKEINTRESOURCE(241) -#endif - -///////////////////////////////////////////////////////////////////////////// - -#ifdef APSTUDIO_INVOKED -#undef APSTUDIO_HIDDEN_SYMBOLS -#endif - -///////////////////////////////////////////////////////////////////////////// -// General style bits etc - -// Tab Control styles -#ifndef TCS_MULTILINE // new in later versions of Win32 -#define TCS_MULTILINE 0x0200 -#endif - -// ControlBar styles -#define CBRS_ALIGN_LEFT 0x1000L -#define CBRS_ALIGN_TOP 0x2000L -#define CBRS_ALIGN_RIGHT 0x4000L -#define CBRS_ALIGN_BOTTOM 0x8000L -#define CBRS_ALIGN_ANY 0xF000L - -#define CBRS_BORDER_LEFT 0x0100L -#define CBRS_BORDER_TOP 0x0200L -#define CBRS_BORDER_RIGHT 0x0400L -#define CBRS_BORDER_BOTTOM 0x0800L -#define CBRS_BORDER_ANY 0x0F00L - -#define CBRS_TOOLTIPS 0x0010L -#define CBRS_FLYBY 0x0020L -#define CBRS_FLOAT_MULTI 0x0040L -#define CBRS_BORDER_3D 0x0080L -#define CBRS_HIDE_INPLACE 0x0008L -#define CBRS_SIZE_DYNAMIC 0x0004L -#define CBRS_SIZE_FIXED 0x0002L -#define CBRS_FLOATING 0x0001L - -#if _MFC_VER >= 0x0600 -#define CBRS_GRIPPER 0x00400000L -#endif - -#define CBRS_ORIENT_HORZ (CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM) -#define CBRS_ORIENT_VERT (CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT) -#define CBRS_ORIENT_ANY (CBRS_ORIENT_HORZ|CBRS_ORIENT_VERT) - -#if _MFC_VER >= 0x0600 -#define CBRS_ALL 0x0040FFFFL -#else -#define CBRS_ALL 0xFFFFL -#endif - -// the CBRS_ style is made up of an alignment style and a draw border style -// the alignment styles are mutually exclusive -// the draw border styles may be combined -#define CBRS_NOALIGN 0x00000000L -#define CBRS_LEFT (CBRS_ALIGN_LEFT|CBRS_BORDER_RIGHT) -#define CBRS_TOP (CBRS_ALIGN_TOP|CBRS_BORDER_BOTTOM) -#define CBRS_RIGHT (CBRS_ALIGN_RIGHT|CBRS_BORDER_LEFT) -#define CBRS_BOTTOM (CBRS_ALIGN_BOTTOM|CBRS_BORDER_TOP) - -///////////////////////////////////////////////////////////////////////////// -// Standard window components - -// Mode indicators in status bar - these are routed like commands -#define ID_INDICATOR_EXT 0xE700 // extended selection indicator -#define ID_INDICATOR_CAPS 0xE701 // cap lock indicator -#define ID_INDICATOR_NUM 0xE702 // num lock indicator -#define ID_INDICATOR_SCRL 0xE703 // scroll lock indicator -#define ID_INDICATOR_OVR 0xE704 // overtype mode indicator -#define ID_INDICATOR_REC 0xE705 // record mode indicator -#define ID_INDICATOR_KANA 0xE706 // kana lock indicator - -#define ID_SEPARATOR 0 // special separator value - -#ifndef RC_INVOKED // code only -// Standard control bars (IDW = window ID) -#define AFX_IDW_CONTROLBAR_FIRST 0xE800 -#define AFX_IDW_CONTROLBAR_LAST 0xE8FF - -#define AFX_IDW_TOOLBAR 0xE800 // main Toolbar for window -#define AFX_IDW_STATUS_BAR 0xE801 // Status bar window -#define AFX_IDW_PREVIEW_BAR 0xE802 // PrintPreview Dialog Bar -#define AFX_IDW_RESIZE_BAR 0xE803 // OLE in-place resize bar -#if _MFC_VER >= 0x0600 -#define AFX_IDW_REBAR 0xE804 // COMCTL32 "rebar" Bar -#define AFX_IDW_DIALOGBAR 0xE805 // CDialogBar -#endif - -// Note: If your application supports docking toolbars, you should -// not use the following IDs for your own toolbars. The IDs chosen -// are at the top of the first 32 such that the bars will be hidden -// while in print preview mode, and are not likely to conflict with -// IDs your application may have used succesfully in the past. - -#define AFX_IDW_DOCKBAR_TOP 0xE81B -#define AFX_IDW_DOCKBAR_LEFT 0xE81C -#define AFX_IDW_DOCKBAR_RIGHT 0xE81D -#define AFX_IDW_DOCKBAR_BOTTOM 0xE81E -#define AFX_IDW_DOCKBAR_FLOAT 0xE81F - -// Macro for mapping standard control bars to bitmask (limit of 32) -#define AFX_CONTROLBAR_MASK(nIDC) (1L << (nIDC - AFX_IDW_CONTROLBAR_FIRST)) - -// parts of Main Frame -#define AFX_IDW_PANE_FIRST 0xE900 // first pane (256 max) -#define AFX_IDW_PANE_LAST 0xE9ff -#define AFX_IDW_HSCROLL_FIRST 0xEA00 // first Horz scrollbar (16 max) -#define AFX_IDW_VSCROLL_FIRST 0xEA10 // first Vert scrollbar (16 max) - -#define AFX_IDW_SIZE_BOX 0xEA20 // size box for splitters -#define AFX_IDW_PANE_SAVE 0xEA21 // to shift AFX_IDW_PANE_FIRST -#endif //!RC_INVOKED - -#ifndef APSTUDIO_INVOKED - -// common style for form views -#define AFX_WS_DEFAULT_VIEW (WS_CHILD | WS_VISIBLE | WS_BORDER) - -#endif //!APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// Standard app configurable strings - -// for application title (defaults to EXE name or name in constructor) -#define AFX_IDS_APP_TITLE 0xE000 -// idle message bar line -#define AFX_IDS_IDLEMESSAGE 0xE001 -// message bar line when in shift-F1 help mode -#define AFX_IDS_HELPMODEMESSAGE 0xE002 -// document title when editing OLE embedding -#define AFX_IDS_APP_TITLE_EMBEDDING 0xE003 -// company name -#define AFX_IDS_COMPANY_NAME 0xE004 -// object name when server is inplace -#define AFX_IDS_OBJ_TITLE_INPLACE 0xE005 - -///////////////////////////////////////////////////////////////////////////// -// Standard Commands - -// File commands -#define ID_FILE_NEW 0xE100 -#define ID_FILE_OPEN 0xE101 -#define ID_FILE_CLOSE 0xE102 -#define ID_FILE_SAVE 0xE103 -#define ID_FILE_SAVE_AS 0xE104 -#define ID_FILE_PAGE_SETUP 0xE105 -#define ID_FILE_PRINT_SETUP 0xE106 -#define ID_FILE_PRINT 0xE107 -#define ID_FILE_PRINT_DIRECT 0xE108 -#define ID_FILE_PRINT_PREVIEW 0xE109 -#define ID_FILE_UPDATE 0xE10A -#define ID_FILE_SAVE_COPY_AS 0xE10B -#define ID_FILE_SEND_MAIL 0xE10C - -#define ID_FILE_MRU_FIRST 0xE110 -#define ID_FILE_MRU_FILE1 0xE110 // range - 16 max -#define ID_FILE_MRU_FILE2 0xE111 -#define ID_FILE_MRU_FILE3 0xE112 -#define ID_FILE_MRU_FILE4 0xE113 -#define ID_FILE_MRU_FILE5 0xE114 -#define ID_FILE_MRU_FILE6 0xE115 -#define ID_FILE_MRU_FILE7 0xE116 -#define ID_FILE_MRU_FILE8 0xE117 -#define ID_FILE_MRU_FILE9 0xE118 -#define ID_FILE_MRU_FILE10 0xE119 -#define ID_FILE_MRU_FILE11 0xE11A -#define ID_FILE_MRU_FILE12 0xE11B -#define ID_FILE_MRU_FILE13 0xE11C -#define ID_FILE_MRU_FILE14 0xE11D -#define ID_FILE_MRU_FILE15 0xE11E -#define ID_FILE_MRU_FILE16 0xE11F -#define ID_FILE_MRU_LAST 0xE11F - -// Edit commands -#define ID_EDIT_CLEAR 0xE120 -#define ID_EDIT_CLEAR_ALL 0xE121 -#define ID_EDIT_COPY 0xE122 -#define ID_EDIT_CUT 0xE123 -#define ID_EDIT_FIND 0xE124 -#define ID_EDIT_PASTE 0xE125 -#define ID_EDIT_PASTE_LINK 0xE126 -#define ID_EDIT_PASTE_SPECIAL 0xE127 -#define ID_EDIT_REPEAT 0xE128 -#define ID_EDIT_REPLACE 0xE129 -#define ID_EDIT_SELECT_ALL 0xE12A -#define ID_EDIT_UNDO 0xE12B -#define ID_EDIT_REDO 0xE12C - -// Window commands -#define ID_WINDOW_NEW 0xE130 -#define ID_WINDOW_ARRANGE 0xE131 -#define ID_WINDOW_CASCADE 0xE132 -#define ID_WINDOW_TILE_HORZ 0xE133 -#define ID_WINDOW_TILE_VERT 0xE134 -#define ID_WINDOW_SPLIT 0xE135 -#ifndef RC_INVOKED // code only -#define AFX_IDM_WINDOW_FIRST 0xE130 -#define AFX_IDM_WINDOW_LAST 0xE13F -#define AFX_IDM_FIRST_MDICHILD 0xFF00 // window list starts here -#endif //!RC_INVOKED - -// Help and App commands -#define ID_APP_ABOUT 0xE140 -#define ID_APP_EXIT 0xE141 -#define ID_HELP_INDEX 0xE142 -#define ID_HELP_FINDER 0xE143 -#define ID_HELP_USING 0xE144 -#define ID_CONTEXT_HELP 0xE145 // shift-F1 -// special commands for processing help -#define ID_HELP 0xE146 // first attempt for F1 -#define ID_DEFAULT_HELP 0xE147 // last attempt - -// Misc -#define ID_NEXT_PANE 0xE150 -#define ID_PREV_PANE 0xE151 - -// Format -#define ID_FORMAT_FONT 0xE160 - -// OLE commands -#define ID_OLE_INSERT_NEW 0xE200 -#define ID_OLE_EDIT_LINKS 0xE201 -#define ID_OLE_EDIT_CONVERT 0xE202 -#define ID_OLE_EDIT_CHANGE_ICON 0xE203 -#define ID_OLE_EDIT_PROPERTIES 0xE204 -#define ID_OLE_VERB_FIRST 0xE210 // range - 16 max -#ifndef RC_INVOKED // code only -#define ID_OLE_VERB_LAST 0xE21F -#endif //!RC_INVOKED - -// for print preview dialog bar -#define AFX_ID_PREVIEW_CLOSE 0xE300 -#define AFX_ID_PREVIEW_NUMPAGE 0xE301 // One/Two Page button -#define AFX_ID_PREVIEW_NEXT 0xE302 -#define AFX_ID_PREVIEW_PREV 0xE303 -#define AFX_ID_PREVIEW_PRINT 0xE304 -#define AFX_ID_PREVIEW_ZOOMIN 0xE305 -#define AFX_ID_PREVIEW_ZOOMOUT 0xE306 - -// View commands (same number used as IDW used for control bar) -#define ID_VIEW_TOOLBAR 0xE800 -#define ID_VIEW_STATUS_BAR 0xE801 -#if _MFC_VER >= 0x0600 -#define ID_VIEW_REBAR 0xE804 -#define ID_VIEW_AUTOARRANGE 0xE805 - // E810 -> E81F must be kept in order for RANGE macros -#define ID_VIEW_SMALLICON 0xE810 -#define ID_VIEW_LARGEICON 0xE811 -#define ID_VIEW_LIST 0xE812 -#define ID_VIEW_DETAILS 0xE813 -#define ID_VIEW_LINEUP 0xE814 -#define ID_VIEW_BYNAME 0xE815 -#define AFX_ID_VIEW_MINIMUM ID_VIEW_SMALLICON -#define AFX_ID_VIEW_MAXIMUM ID_VIEW_BYNAME -#endif - // E800 -> E8FF reserved for other control bar commands - -// RecordForm commands -#define ID_RECORD_FIRST 0xE900 -#define ID_RECORD_LAST 0xE901 -#define ID_RECORD_NEXT 0xE902 -#define ID_RECORD_PREV 0xE903 - -///////////////////////////////////////////////////////////////////////////// -// Standard control IDs - -#ifdef IDC_STATIC -#undef IDC_STATIC -#endif -#define IDC_STATIC (-1) // all static controls - -///////////////////////////////////////////////////////////////////////////// -// Standard string error/warnings - -#ifndef RC_INVOKED // code only -#define AFX_IDS_SCFIRST 0xEF00 -#endif //!RC_INVOKED - -#define AFX_IDS_SCSIZE 0xEF00 -#define AFX_IDS_SCMOVE 0xEF01 -#define AFX_IDS_SCMINIMIZE 0xEF02 -#define AFX_IDS_SCMAXIMIZE 0xEF03 -#define AFX_IDS_SCNEXTWINDOW 0xEF04 -#define AFX_IDS_SCPREVWINDOW 0xEF05 -#define AFX_IDS_SCCLOSE 0xEF06 -#define AFX_IDS_SCRESTORE 0xEF12 -#define AFX_IDS_SCTASKLIST 0xEF13 - -#define AFX_IDS_MDICHILD 0xEF1F - -#define AFX_IDS_DESKACCESSORY 0xEFDA - -// General strings -#define AFX_IDS_OPENFILE 0xF000 -#define AFX_IDS_SAVEFILE 0xF001 -#define AFX_IDS_ALLFILTER 0xF002 -#define AFX_IDS_UNTITLED 0xF003 -#define AFX_IDS_SAVEFILECOPY 0xF004 -#define AFX_IDS_PREVIEW_CLOSE 0xF005 -#define AFX_IDS_UNNAMED_FILE 0xF006 -#define AFX_IDS_HIDE 0xF011 - -// MFC Standard Exception Error messages -#define AFX_IDP_NO_ERROR_AVAILABLE 0xF020 -#define AFX_IDS_NOT_SUPPORTED_EXCEPTION 0xF021 -#define AFX_IDS_RESOURCE_EXCEPTION 0xF022 -#define AFX_IDS_MEMORY_EXCEPTION 0xF023 -#define AFX_IDS_USER_EXCEPTION 0xF024 -#define AFX_IDS_INVALID_ARG_EXCEPTION 0xF025 - -// Printing and print preview strings -#define AFX_IDS_PRINTONPORT 0xF040 -#define AFX_IDS_ONEPAGE 0xF041 -#define AFX_IDS_TWOPAGE 0xF042 -#define AFX_IDS_PRINTPAGENUM 0xF043 -#define AFX_IDS_PREVIEWPAGEDESC 0xF044 -#define AFX_IDS_PRINTDEFAULTEXT 0xF045 -#define AFX_IDS_PRINTDEFAULT 0xF046 -#define AFX_IDS_PRINTFILTER 0xF047 -#define AFX_IDS_PRINTCAPTION 0xF048 -#define AFX_IDS_PRINTTOFILE 0xF049 - - -// OLE strings -#define AFX_IDS_OBJECT_MENUITEM 0xF080 -#define AFX_IDS_EDIT_VERB 0xF081 -#define AFX_IDS_ACTIVATE_VERB 0xF082 -#define AFX_IDS_CHANGE_LINK 0xF083 -#define AFX_IDS_AUTO 0xF084 -#define AFX_IDS_MANUAL 0xF085 -#define AFX_IDS_FROZEN 0xF086 -#define AFX_IDS_ALL_FILES 0xF087 -// dynamically changing menu items -#define AFX_IDS_SAVE_MENU 0xF088 -#define AFX_IDS_UPDATE_MENU 0xF089 -#define AFX_IDS_SAVE_AS_MENU 0xF08A -#define AFX_IDS_SAVE_COPY_AS_MENU 0xF08B -#define AFX_IDS_EXIT_MENU 0xF08C -#define AFX_IDS_UPDATING_ITEMS 0xF08D -// COlePasteSpecialDialog defines -#define AFX_IDS_METAFILE_FORMAT 0xF08E -#define AFX_IDS_DIB_FORMAT 0xF08F -#define AFX_IDS_BITMAP_FORMAT 0xF090 -#define AFX_IDS_LINKSOURCE_FORMAT 0xF091 -#define AFX_IDS_EMBED_FORMAT 0xF092 -// other OLE utility strings -#define AFX_IDS_PASTELINKEDTYPE 0xF094 -#define AFX_IDS_UNKNOWNTYPE 0xF095 -#define AFX_IDS_RTF_FORMAT 0xF096 -#define AFX_IDS_TEXT_FORMAT 0xF097 -// OLE datatype format error strings -#define AFX_IDS_INVALID_CURRENCY 0xF098 -#define AFX_IDS_INVALID_DATETIME 0xF099 -#define AFX_IDS_INVALID_DATETIMESPAN 0xF09A - -// General error / prompt strings -#define AFX_IDP_INVALID_FILENAME 0xF100 -#define AFX_IDP_FAILED_TO_OPEN_DOC 0xF101 -#define AFX_IDP_FAILED_TO_SAVE_DOC 0xF102 -#define AFX_IDP_ASK_TO_SAVE 0xF103 -#define AFX_IDP_FAILED_TO_CREATE_DOC 0xF104 -#define AFX_IDP_FILE_TOO_LARGE 0xF105 -#define AFX_IDP_FAILED_TO_START_PRINT 0xF106 -#define AFX_IDP_FAILED_TO_LAUNCH_HELP 0xF107 -#define AFX_IDP_INTERNAL_FAILURE 0xF108 // general failure -#define AFX_IDP_COMMAND_FAILURE 0xF109 // command failure -#define AFX_IDP_FAILED_MEMORY_ALLOC 0xF10A -#define AFX_IDP_UNREG_DONE 0xF10B -#define AFX_IDP_UNREG_FAILURE 0xF10C -#define AFX_IDP_DLL_LOAD_FAILED 0xF10D -#define AFX_IDP_DLL_BAD_VERSION 0xF10E - -// DDV parse errors -#define AFX_IDP_PARSE_INT 0xF110 -#define AFX_IDP_PARSE_REAL 0xF111 -#define AFX_IDP_PARSE_INT_RANGE 0xF112 -#define AFX_IDP_PARSE_REAL_RANGE 0xF113 -#define AFX_IDP_PARSE_STRING_SIZE 0xF114 -#define AFX_IDP_PARSE_RADIO_BUTTON 0xF115 -#define AFX_IDP_PARSE_BYTE 0xF116 -#define AFX_IDP_PARSE_UINT 0xF117 -#define AFX_IDP_PARSE_DATETIME 0xF118 -#define AFX_IDP_PARSE_CURRENCY 0xF119 - -// CFile/CArchive error strings for user failure -#define AFX_IDP_FAILED_INVALID_FORMAT 0xF120 -#define AFX_IDP_FAILED_INVALID_PATH 0xF121 -#define AFX_IDP_FAILED_DISK_FULL 0xF122 -#define AFX_IDP_FAILED_ACCESS_READ 0xF123 -#define AFX_IDP_FAILED_ACCESS_WRITE 0xF124 -#define AFX_IDP_FAILED_IO_ERROR_READ 0xF125 -#define AFX_IDP_FAILED_IO_ERROR_WRITE 0xF126 - -// OLE errors / prompt strings -#define AFX_IDP_STATIC_OBJECT 0xF180 -#define AFX_IDP_FAILED_TO_CONNECT 0xF181 -#define AFX_IDP_SERVER_BUSY 0xF182 -#define AFX_IDP_BAD_VERB 0xF183 -#if _MFC_VER >= 0x0600 -#define AFX_IDS_NOT_DOCOBJECT 0xF184 -#endif -#define AFX_IDP_FAILED_TO_NOTIFY 0xF185 -#define AFX_IDP_FAILED_TO_LAUNCH 0xF186 -#define AFX_IDP_ASK_TO_UPDATE 0xF187 -#define AFX_IDP_FAILED_TO_UPDATE 0xF188 -#define AFX_IDP_FAILED_TO_REGISTER 0xF189 -#define AFX_IDP_FAILED_TO_AUTO_REGISTER 0xF18A -#define AFX_IDP_FAILED_TO_CONVERT 0xF18B -#define AFX_IDP_GET_NOT_SUPPORTED 0xF18C -#define AFX_IDP_SET_NOT_SUPPORTED 0xF18D -#define AFX_IDP_ASK_TO_DISCARD 0xF18E -#define AFX_IDP_FAILED_TO_CREATE 0xF18F - -// MAPI errors / prompt strings -#define AFX_IDP_FAILED_MAPI_LOAD 0xF190 -#define AFX_IDP_INVALID_MAPI_DLL 0xF191 -#define AFX_IDP_FAILED_MAPI_SEND 0xF192 - -#define AFX_IDP_FILE_NONE 0xF1A0 -#define AFX_IDP_FILE_GENERIC 0xF1A1 -#define AFX_IDP_FILE_NOT_FOUND 0xF1A2 -#define AFX_IDP_FILE_BAD_PATH 0xF1A3 -#define AFX_IDP_FILE_TOO_MANY_OPEN 0xF1A4 -#define AFX_IDP_FILE_ACCESS_DENIED 0xF1A5 -#define AFX_IDP_FILE_INVALID_FILE 0xF1A6 -#define AFX_IDP_FILE_REMOVE_CURRENT 0xF1A7 -#define AFX_IDP_FILE_DIR_FULL 0xF1A8 -#define AFX_IDP_FILE_BAD_SEEK 0xF1A9 -#define AFX_IDP_FILE_HARD_IO 0xF1AA -#define AFX_IDP_FILE_SHARING 0xF1AB -#define AFX_IDP_FILE_LOCKING 0xF1AC -#define AFX_IDP_FILE_DISKFULL 0xF1AD -#define AFX_IDP_FILE_EOF 0xF1AE - -#define AFX_IDP_ARCH_NONE 0xF1B0 -#define AFX_IDP_ARCH_GENERIC 0xF1B1 -#define AFX_IDP_ARCH_READONLY 0xF1B2 -#define AFX_IDP_ARCH_ENDOFFILE 0xF1B3 -#define AFX_IDP_ARCH_WRITEONLY 0xF1B4 -#define AFX_IDP_ARCH_BADINDEX 0xF1B5 -#define AFX_IDP_ARCH_BADCLASS 0xF1B6 -#define AFX_IDP_ARCH_BADSCHEMA 0xF1B7 - -#define AFX_IDS_OCC_SCALEUNITS_PIXELS 0xF1C0 - -// 0xf200-0xf20f reserved - -// font names and point sizes -#define AFX_IDS_STATUS_FONT 0xF230 -#define AFX_IDS_TOOLTIP_FONT 0xF231 -#define AFX_IDS_UNICODE_FONT 0xF232 -#define AFX_IDS_MINI_FONT 0xF233 - -// ODBC Database errors / prompt strings -#ifndef RC_INVOKED // code only -#define AFX_IDP_SQL_FIRST 0xF280 -#endif //!RC_INVOKED -#define AFX_IDP_SQL_CONNECT_FAIL 0xF281 -#define AFX_IDP_SQL_RECORDSET_FORWARD_ONLY 0xF282 -#define AFX_IDP_SQL_EMPTY_COLUMN_LIST 0xF283 -#define AFX_IDP_SQL_FIELD_SCHEMA_MISMATCH 0xF284 -#define AFX_IDP_SQL_ILLEGAL_MODE 0xF285 -#define AFX_IDP_SQL_MULTIPLE_ROWS_AFFECTED 0xF286 -#define AFX_IDP_SQL_NO_CURRENT_RECORD 0xF287 -#define AFX_IDP_SQL_NO_ROWS_AFFECTED 0xF288 -#define AFX_IDP_SQL_RECORDSET_READONLY 0xF289 -#define AFX_IDP_SQL_SQL_NO_TOTAL 0xF28A -#define AFX_IDP_SQL_ODBC_LOAD_FAILED 0xF28B -#define AFX_IDP_SQL_DYNASET_NOT_SUPPORTED 0xF28C -#define AFX_IDP_SQL_SNAPSHOT_NOT_SUPPORTED 0xF28D -#define AFX_IDP_SQL_API_CONFORMANCE 0xF28E -#define AFX_IDP_SQL_SQL_CONFORMANCE 0xF28F -#define AFX_IDP_SQL_NO_DATA_FOUND 0xF290 -#define AFX_IDP_SQL_ROW_UPDATE_NOT_SUPPORTED 0xF291 -#define AFX_IDP_SQL_ODBC_V2_REQUIRED 0xF292 -#define AFX_IDP_SQL_NO_POSITIONED_UPDATES 0xF293 -#define AFX_IDP_SQL_LOCK_MODE_NOT_SUPPORTED 0xF294 -#define AFX_IDP_SQL_DATA_TRUNCATED 0xF295 -#define AFX_IDP_SQL_ROW_FETCH 0xF296 -#define AFX_IDP_SQL_INCORRECT_ODBC 0xF297 -#define AFX_IDP_SQL_UPDATE_DELETE_FAILED 0xF298 -#define AFX_IDP_SQL_DYNAMIC_CURSOR_NOT_SUPPORTED 0xF299 -#define AFX_IDP_SQL_FIELD_NOT_FOUND 0xF29A -#define AFX_IDP_SQL_BOOKMARKS_NOT_SUPPORTED 0xF29B -#define AFX_IDP_SQL_BOOKMARKS_NOT_ENABLED 0xF29C - -#if _MFC_VER >= 0x0600 -// ODBC Database strings -#define AFX_IDS_DELETED 0xF29D -#endif - -// DAO Database errors / prompt strings -#ifndef RC_INVOKED // code only -#define AFX_IDP_DAO_FIRST 0xF2B0 -#endif //!RC_INVOKED -#define AFX_IDP_DAO_ENGINE_INITIALIZATION 0xF2B0 -#define AFX_IDP_DAO_DFX_BIND 0xF2B1 -#define AFX_IDP_DAO_OBJECT_NOT_OPEN 0xF2B2 - -// ICDAORecordset::GetRows Errors -// These are not placed in DAO Errors collection -// and must be handled directly by MFC. -#define AFX_IDP_DAO_ROWTOOSHORT 0xF2B3 -#define AFX_IDP_DAO_BADBINDINFO 0xF2B4 -#define AFX_IDP_DAO_COLUMNUNAVAILABLE 0xF2B5 - -///////////////////////////////////////////////////////////////////////////// -// Strings for ISAPI support - -#define AFX_IDS_HTTP_TITLE 0xF2D1 -#define AFX_IDS_HTTP_NO_TEXT 0xF2D2 -#define AFX_IDS_HTTP_BAD_REQUEST 0xF2D3 -#define AFX_IDS_HTTP_AUTH_REQUIRED 0xF2D4 -#define AFX_IDS_HTTP_FORBIDDEN 0xF2D5 -#define AFX_IDS_HTTP_NOT_FOUND 0xF2D6 -#define AFX_IDS_HTTP_SERVER_ERROR 0xF2D7 -#define AFX_IDS_HTTP_NOT_IMPLEMENTED 0xF2D8 - -///////////////////////////////////////////////////////////////////////////// -// AFX implementation - control IDs (AFX_IDC) - -// Parts of dialogs -#define AFX_IDC_LISTBOX 100 -#define AFX_IDC_CHANGE 101 - -// for print dialog -#define AFX_IDC_PRINT_DOCNAME 201 -#define AFX_IDC_PRINT_PRINTERNAME 202 -#define AFX_IDC_PRINT_PORTNAME 203 -#define AFX_IDC_PRINT_PAGENUM 204 - -// Property Sheet control id's (determined with Spy++) -#define ID_APPLY_NOW 0x3021 -#define ID_WIZBACK 0x3023 -#define ID_WIZNEXT 0x3024 -#define ID_WIZFINISH 0x3025 -#define AFX_IDC_TAB_CONTROL 0x3020 - -///////////////////////////////////////////////////////////////////////////// -// IDRs for standard components - -#ifndef RC_INVOKED // code only -// These are really COMMDLG dialogs, so there usually isn't a resource -// for them, but these IDs are used as help IDs. -#define AFX_IDD_FILEOPEN 28676 -#define AFX_IDD_FILESAVE 28677 -#define AFX_IDD_FONT 28678 -#define AFX_IDD_COLOR 28679 -#define AFX_IDD_PRINT 28680 -#define AFX_IDD_PRINTSETUP 28681 -#define AFX_IDD_FIND 28682 -#define AFX_IDD_REPLACE 28683 -#endif //!RC_INVOKED - -// Standard dialogs app should leave alone (0x7801->) -#define AFX_IDD_NEWTYPEDLG 30721 -#define AFX_IDD_PRINTDLG 30722 -#define AFX_IDD_PREVIEW_TOOLBAR 30723 - -// Dialogs defined for OLE2UI library -#define AFX_IDD_INSERTOBJECT 30724 -#define AFX_IDD_CHANGEICON 30725 -#define AFX_IDD_CONVERT 30726 -#define AFX_IDD_PASTESPECIAL 30727 -#define AFX_IDD_EDITLINKS 30728 -#define AFX_IDD_FILEBROWSE 30729 -#define AFX_IDD_BUSY 30730 - -#define AFX_IDD_OBJECTPROPERTIES 30732 -#define AFX_IDD_CHANGESOURCE 30733 - -// Standard cursors (0x7901->) - // AFX_IDC = Cursor resources -#define AFX_IDC_CONTEXTHELP 30977 // context sensitive help -#define AFX_IDC_MAGNIFY 30978 // print preview zoom -#define AFX_IDC_SMALLARROWS 30979 // splitter -#define AFX_IDC_HSPLITBAR 30980 // splitter -#define AFX_IDC_VSPLITBAR 30981 // splitter -#define AFX_IDC_NODROPCRSR 30982 // No Drop Cursor -#define AFX_IDC_TRACKNWSE 30983 // tracker -#define AFX_IDC_TRACKNESW 30984 // tracker -#define AFX_IDC_TRACKNS 30985 // tracker -#define AFX_IDC_TRACKWE 30986 // tracker -#define AFX_IDC_TRACK4WAY 30987 // tracker -#define AFX_IDC_MOVE4WAY 30988 // resize bar (server only) - -// Mini frame window bitmap ID -#define AFX_IDB_MINIFRAME_MENU 30994 - -// CheckListBox checks bitmap ID -#define AFX_IDB_CHECKLISTBOX_NT 30995 -#define AFX_IDB_CHECKLISTBOX_95 30996 - -// AFX standard accelerator resources -#define AFX_IDR_PREVIEW_ACCEL 30997 - -// AFX standard ICON IDs (for MFC V1 apps) (0x7A01->) -#define AFX_IDI_STD_MDIFRAME 31233 -#define AFX_IDI_STD_FRAME 31234 - -///////////////////////////////////////////////////////////////////////////// -// AFX OLE control implementation - control IDs (AFX_IDC) - -// Font property page -#define AFX_IDC_FONTPROP 1000 -#define AFX_IDC_FONTNAMES 1001 -#define AFX_IDC_FONTSTYLES 1002 -#define AFX_IDC_FONTSIZES 1003 -#define AFX_IDC_STRIKEOUT 1004 -#define AFX_IDC_UNDERLINE 1005 -#define AFX_IDC_SAMPLEBOX 1006 - -// Color property page -#define AFX_IDC_COLOR_BLACK 1100 -#define AFX_IDC_COLOR_WHITE 1101 -#define AFX_IDC_COLOR_RED 1102 -#define AFX_IDC_COLOR_GREEN 1103 -#define AFX_IDC_COLOR_BLUE 1104 -#define AFX_IDC_COLOR_YELLOW 1105 -#define AFX_IDC_COLOR_MAGENTA 1106 -#define AFX_IDC_COLOR_CYAN 1107 -#define AFX_IDC_COLOR_GRAY 1108 -#define AFX_IDC_COLOR_LIGHTGRAY 1109 -#define AFX_IDC_COLOR_DARKRED 1110 -#define AFX_IDC_COLOR_DARKGREEN 1111 -#define AFX_IDC_COLOR_DARKBLUE 1112 -#define AFX_IDC_COLOR_LIGHTBROWN 1113 -#define AFX_IDC_COLOR_DARKMAGENTA 1114 -#define AFX_IDC_COLOR_DARKCYAN 1115 -#define AFX_IDC_COLORPROP 1116 -#define AFX_IDC_SYSTEMCOLORS 1117 - -// Picture porperty page -#define AFX_IDC_PROPNAME 1201 -#define AFX_IDC_PICTURE 1202 -#define AFX_IDC_BROWSE 1203 -#define AFX_IDC_CLEAR 1204 - -///////////////////////////////////////////////////////////////////////////// -// IDRs for OLE control standard components - -// Standard propery page dialogs app should leave alone (0x7E01->) -#define AFX_IDD_PROPPAGE_COLOR 32257 -#define AFX_IDD_PROPPAGE_FONT 32258 -#define AFX_IDD_PROPPAGE_PICTURE 32259 - -#define AFX_IDB_TRUETYPE 32384 - -///////////////////////////////////////////////////////////////////////////// -// Standard OLE control strings - -// OLE Control page strings -#define AFX_IDS_PROPPAGE_UNKNOWN 0xFE01 -#define AFX_IDS_COLOR_DESKTOP 0xFE04 -#define AFX_IDS_COLOR_APPWORKSPACE 0xFE05 -#define AFX_IDS_COLOR_WNDBACKGND 0xFE06 -#define AFX_IDS_COLOR_WNDTEXT 0xFE07 -#define AFX_IDS_COLOR_MENUBAR 0xFE08 -#define AFX_IDS_COLOR_MENUTEXT 0xFE09 -#define AFX_IDS_COLOR_ACTIVEBAR 0xFE0A -#define AFX_IDS_COLOR_INACTIVEBAR 0xFE0B -#define AFX_IDS_COLOR_ACTIVETEXT 0xFE0C -#define AFX_IDS_COLOR_INACTIVETEXT 0xFE0D -#define AFX_IDS_COLOR_ACTIVEBORDER 0xFE0E -#define AFX_IDS_COLOR_INACTIVEBORDER 0xFE0F -#define AFX_IDS_COLOR_WNDFRAME 0xFE10 -#define AFX_IDS_COLOR_SCROLLBARS 0xFE11 -#define AFX_IDS_COLOR_BTNFACE 0xFE12 -#define AFX_IDS_COLOR_BTNSHADOW 0xFE13 -#define AFX_IDS_COLOR_BTNTEXT 0xFE14 -#define AFX_IDS_COLOR_BTNHIGHLIGHT 0xFE15 -#define AFX_IDS_COLOR_DISABLEDTEXT 0xFE16 -#define AFX_IDS_COLOR_HIGHLIGHT 0xFE17 -#define AFX_IDS_COLOR_HIGHLIGHTTEXT 0xFE18 -#define AFX_IDS_REGULAR 0xFE19 -#define AFX_IDS_BOLD 0xFE1A -#define AFX_IDS_ITALIC 0xFE1B -#define AFX_IDS_BOLDITALIC 0xFE1C -#define AFX_IDS_SAMPLETEXT 0xFE1D -#define AFX_IDS_DISPLAYSTRING_FONT 0xFE1E -#define AFX_IDS_DISPLAYSTRING_COLOR 0xFE1F -#define AFX_IDS_DISPLAYSTRING_PICTURE 0xFE20 -#define AFX_IDS_PICTUREFILTER 0xFE21 -#define AFX_IDS_PICTYPE_UNKNOWN 0xFE22 -#define AFX_IDS_PICTYPE_NONE 0xFE23 -#define AFX_IDS_PICTYPE_BITMAP 0xFE24 -#define AFX_IDS_PICTYPE_METAFILE 0xFE25 -#define AFX_IDS_PICTYPE_ICON 0xFE26 -#define AFX_IDS_COLOR_PPG 0xFE28 -#define AFX_IDS_COLOR_PPG_CAPTION 0xFE29 -#define AFX_IDS_FONT_PPG 0xFE2A -#define AFX_IDS_FONT_PPG_CAPTION 0xFE2B -#define AFX_IDS_PICTURE_PPG 0xFE2C -#define AFX_IDS_PICTURE_PPG_CAPTION 0xFE2D -#define AFX_IDS_PICTUREBROWSETITLE 0xFE30 -#define AFX_IDS_BORDERSTYLE_0 0xFE31 -#define AFX_IDS_BORDERSTYLE_1 0xFE32 - -// OLE Control verb names -#define AFX_IDS_VERB_EDIT 0xFE40 -#define AFX_IDS_VERB_PROPERTIES 0xFE41 - -// OLE Control internal error messages -#define AFX_IDP_PICTURECANTOPEN 0xFE83 -#define AFX_IDP_PICTURECANTLOAD 0xFE84 -#define AFX_IDP_PICTURETOOLARGE 0xFE85 -#define AFX_IDP_PICTUREREADFAILED 0xFE86 - -// Standard OLE Control error strings -#define AFX_IDP_E_ILLEGALFUNCTIONCALL 0xFEA0 -#define AFX_IDP_E_OVERFLOW 0xFEA1 -#define AFX_IDP_E_OUTOFMEMORY 0xFEA2 -#define AFX_IDP_E_DIVISIONBYZERO 0xFEA3 -#define AFX_IDP_E_OUTOFSTRINGSPACE 0xFEA4 -#define AFX_IDP_E_OUTOFSTACKSPACE 0xFEA5 -#define AFX_IDP_E_BADFILENAMEORNUMBER 0xFEA6 -#define AFX_IDP_E_FILENOTFOUND 0xFEA7 -#define AFX_IDP_E_BADFILEMODE 0xFEA8 -#define AFX_IDP_E_FILEALREADYOPEN 0xFEA9 -#define AFX_IDP_E_DEVICEIOERROR 0xFEAA -#define AFX_IDP_E_FILEALREADYEXISTS 0xFEAB -#define AFX_IDP_E_BADRECORDLENGTH 0xFEAC -#define AFX_IDP_E_DISKFULL 0xFEAD -#define AFX_IDP_E_BADRECORDNUMBER 0xFEAE -#define AFX_IDP_E_BADFILENAME 0xFEAF -#define AFX_IDP_E_TOOMANYFILES 0xFEB0 -#define AFX_IDP_E_DEVICEUNAVAILABLE 0xFEB1 -#define AFX_IDP_E_PERMISSIONDENIED 0xFEB2 -#define AFX_IDP_E_DISKNOTREADY 0xFEB3 -#define AFX_IDP_E_PATHFILEACCESSERROR 0xFEB4 -#define AFX_IDP_E_PATHNOTFOUND 0xFEB5 -#define AFX_IDP_E_INVALIDPATTERNSTRING 0xFEB6 -#define AFX_IDP_E_INVALIDUSEOFNULL 0xFEB7 -#define AFX_IDP_E_INVALIDFILEFORMAT 0xFEB8 -#define AFX_IDP_E_INVALIDPROPERTYVALUE 0xFEB9 -#define AFX_IDP_E_INVALIDPROPERTYARRAYINDEX 0xFEBA -#define AFX_IDP_E_SETNOTSUPPORTEDATRUNTIME 0xFEBB -#define AFX_IDP_E_SETNOTSUPPORTED 0xFEBC -#define AFX_IDP_E_NEEDPROPERTYARRAYINDEX 0xFEBD -#define AFX_IDP_E_SETNOTPERMITTED 0xFEBE -#define AFX_IDP_E_GETNOTSUPPORTEDATRUNTIME 0xFEBF -#define AFX_IDP_E_GETNOTSUPPORTED 0xFEC0 -#define AFX_IDP_E_PROPERTYNOTFOUND 0xFEC1 -#define AFX_IDP_E_INVALIDCLIPBOARDFORMAT 0xFEC2 -#define AFX_IDP_E_INVALIDPICTURE 0xFEC3 -#define AFX_IDP_E_PRINTERERROR 0xFEC4 -#define AFX_IDP_E_CANTSAVEFILETOTEMP 0xFEC5 -#define AFX_IDP_E_SEARCHTEXTNOTFOUND 0xFEC6 -#define AFX_IDP_E_REPLACEMENTSTOOLONG 0xFEC7 - -///////////////////////////////////////////////////////////////////////////// - -#ifdef _AFX_MINREBUILD -#pragma component(minrebuild, on) -#endif - -#endif //__AFXRES_H__ - -///////////////////////////////////////////////////////////////////////////// diff --git a/fancontrol/approot.cpp b/fancontrol/approot.cpp index 7044ade..6694b23 100644 --- a/fancontrol/approot.cpp +++ b/fancontrol/approot.cpp @@ -240,7 +240,6 @@ void StopWorkerThread() void WorkerThread(void *dummy) { char curdir[MAX_PATH]= ""; - // #ifdef _DEBUG // Sleep(30000); // #endif @@ -289,8 +288,6 @@ void WorkerThread(void *dummy) FANCONTROL fc(hInstApp); - fc.Test(); - g_dialogWnd = fc.GetDialogWnd(); fc.ProcessDialog(); diff --git a/fancontrol/approot.h b/fancontrol/approot.h index 02f464a..7901f2e 100644 --- a/fancontrol/approot.h +++ b/fancontrol/approot.h @@ -11,34 +11,20 @@ HANDLE hPipe4; HINSTANCE hInstApp, hInstRes; LPSTR g_ServiceName = "TPFanControl"; -SERVICE_STATUS g_SvcStatus = { 0 }; +SERVICE_STATUS g_SvcStatus = {0}; SERVICE_STATUS_HANDLE g_SvcHandle = NULL; HWND g_dialogWnd = NULL; HANDLE g_workerThread = NULL; -void ShowError(DWORD ec, const char* description); - -void ShowMessage(const char* title, const char* description); - +void ShowError(DWORD ec, const char *description); +void ShowMessage(const char *title, const char *description); void ShowHelp(); - DWORD InstallService(bool quiet); - DWORD UninstallService(bool quiet); - -VOID WINAPI -Handler(DWORD - fdwControl); -VOID WINAPI -ServiceMain(DWORD - aArgc, - LPTSTR* aArgv -); - +VOID WINAPI Handler(DWORD fdwControl); +VOID WINAPI ServiceMain(DWORD aArgc, LPTSTR* aArgv); void StartWorkerThread(); - void StopWorkerThread(); +void WorkerThread(void *dummy); -void WorkerThread(void* dummy); - -void debug(const char* msg); \ No newline at end of file +void debug(const char *msg); \ No newline at end of file diff --git a/fancontrol/dynamicicon.cpp b/fancontrol/dynamicicon.cpp index 7efe553..4d6052a 100644 --- a/fancontrol/dynamicicon.cpp +++ b/fancontrol/dynamicicon.cpp @@ -1,89 +1,90 @@ -#include "_prec.h" +#include "_prec.h" #include "DynamicIcon.h" #include -CDynamicIcon::CDynamicIcon(const char *line1, const char *line2, const int iFarbeIconA, const int iFontIconA) { +CDynamicIcon::CDynamicIcon(const char *line1,const char *line2, const int iFarbeIconA, const int iFontIconA) { //3 chars per line - char _line1[4], _line2[4]; - strncpy_s(_line1, sizeof(_line1), line1, 3); - strncpy_s(_line2, sizeof(_line2), line2, 3); - _line1[3] = 0; - _line2[3] = 0; - - - //TODO: implement errorhandling - - HDC hDC = GetDC(0); - - memDC1_ = CreateCompatibleDC(hDC); - memDC2_ = CreateCompatibleDC(hDC); - iconBmp_ = CreateCompatibleBitmap(hDC, iconWidth_, iconHeight_); - - iconMaskBmp_ = CreateCompatibleBitmap(hDC, iconWidth_, iconHeight_); - oldBmp_1 = (HBITMAP) SelectObject(memDC1_, (HBITMAP) iconBmp_); - oldBmp_2 = (HBITMAP) SelectObject(memDC2_, (HBITMAP) iconMaskBmp_); - - // prepare mask - HBRUSH hBrush = CreateSolidBrush(RGB(255, 255, 255)); - hOldBrush = (HBRUSH) SelectObject(memDC2_, hBrush); - PatBlt(memDC2_, 0, 0, iconWidth_, iconHeight_, PATCOPY); - SelectObject(memDC2_, hOldBrush); - DeleteObject(hBrush); - - // draw circle on both bitmaps - rgn = CreateRectRgn(0, 0, iconWidth_, iconHeight_); - - switch (iFarbeIconA) { - case 10: - hBrush = CreateSolidBrush(RGB(245, 245, 245)); //grau - break; - case 11: - hBrush = CreateSolidBrush(RGB(191, 239, 255)); //blau - break; - case 12: - hBrush = CreateSolidBrush(RGB(255, 255, 0)); //gelb - break; - case 13: - hBrush = CreateSolidBrush(RGB(255, 165, 0)); //orange - break; - case 14: - hBrush = CreateSolidBrush(RGB(255, 69, 0)); //rot - break; - case 21: - hBrush = CreateSolidBrush(RGB(175, 255, 175)); //sehr hell grün - break; - case 22: - hBrush = CreateSolidBrush(RGB(123, 255, 123)); //hell grün - break; - case 23: - hBrush = CreateSolidBrush(RGB(0, 255, 0)); //grün - break; - case 24: - hBrush = CreateSolidBrush(RGB(0, 218, 0)); //dunkel grün - break; - case 25: - hBrush = CreateSolidBrush(RGB(0, 164, 0)); //sehr dunkel grün - break; - default: - hBrush = CreateSolidBrush(RGB(255, 255, 255)); // weiss - }; - - - FillRgn(memDC1_, rgn, hBrush); - DeleteObject(hBrush); - - hBrush = CreateSolidBrush(RGB(0, 0, 0)); - FillRgn(memDC2_, rgn, hBrush); - - - HFONT hfnt, hOldFont; - + char _line1[4],_line2[4]; + strncpy_s(_line1,sizeof(_line1),line1,3); + strncpy_s(_line2,sizeof(_line2),line2,3); + _line1[3]=0; + _line2[3]=0; + + + //TODO: implement errorhandling + + HDC hDC = GetDC (0); + + memDC1_ = CreateCompatibleDC (hDC); + memDC2_ = CreateCompatibleDC (hDC); + iconBmp_ = CreateCompatibleBitmap (hDC, iconWidth_, iconHeight_); + + iconMaskBmp_ = CreateCompatibleBitmap (hDC, iconWidth_, iconHeight_); + oldBmp_1 = (HBITMAP) SelectObject (memDC1_, (HBITMAP) iconBmp_); + oldBmp_2 = (HBITMAP) SelectObject (memDC2_, (HBITMAP) iconMaskBmp_); + + // prepare mask + HBRUSH hBrush = CreateSolidBrush (RGB (255, 255, 255)); + hOldBrush = (HBRUSH) SelectObject (memDC2_, hBrush); + PatBlt (memDC2_, 0, 0, iconWidth_, iconHeight_, PATCOPY); + SelectObject (memDC2_, hOldBrush); + DeleteObject (hBrush); + + // draw circle on both bitmaps + rgn = CreateRectRgn (0, 0, iconWidth_, iconHeight_); + + switch (iFarbeIconA) { + case 10: + hBrush = CreateSolidBrush (RGB (245,245,245)); //grau + break; + case 11: + hBrush = CreateSolidBrush (RGB (191,239,255)); //blau + break; + case 12: + hBrush = CreateSolidBrush (RGB (255,255,0)); //gelb + break; + case 13: + hBrush = CreateSolidBrush (RGB (255,165,0)); //orange + break; + case 14: + hBrush = CreateSolidBrush (RGB (255,69,0)); //rot + break; + case 21: + hBrush = CreateSolidBrush (RGB (175,255,175)); //sehr hell grün + break; + case 22: + hBrush = CreateSolidBrush (RGB (123,255,123)); //hell grün + break; + case 23: + hBrush = CreateSolidBrush (RGB (0,255,0)); //grün + break; + case 24: + hBrush = CreateSolidBrush (RGB (0,218,0)); //dunkel grün + break; + case 25: + hBrush = CreateSolidBrush (RGB (0,164,0)); //sehr dunkel grün + break; + default: + hBrush = CreateSolidBrush (RGB (255,255,255)); // weiss + }; + + + FillRgn (memDC1_, rgn, hBrush); + DeleteObject (hBrush); + + hBrush = CreateSolidBrush (RGB (0, 0, 0)); + FillRgn (memDC2_, rgn, hBrush); + + + HFONT hfnt, hOldFont; + hfnt = this->CreateFont(memDC1_); - if (hOldFont = (HFONT) SelectObject(memDC1_, hfnt)) { + if (hOldFont = (HFONT)SelectObject(memDC1_, hfnt)) + { //SetBkColor(memDC1_,RGB(255,0,0)); - SetBkMode(memDC1_, TRANSPARENT); + SetBkMode(memDC1_,TRANSPARENT); //TODO: Textcolors //default textcolor: RGB(32,16,176) @@ -92,50 +93,51 @@ CDynamicIcon::CDynamicIcon(const char *line1, const char *line2, const int iFarb r.left = 0; r.bottom = 9; //org 10 r.right = 15; - DrawTextEx(memDC1_, (LPSTR) _line1, strlen(_line1), &r, DT_CENTER, NULL); + DrawTextEx(memDC1_,(LPSTR)_line1,strlen(_line1),&r,DT_CENTER,NULL); r.top = 5; //org 6 neu ? r.left = 0; r.bottom = 16; // org 15 r.right = 15; - DrawTextEx(memDC1_, (LPSTR) _line2, strlen(_line2), &r, DT_CENTER, NULL); + DrawTextEx(memDC1_,(LPSTR)_line2,strlen(_line2),&r,DT_CENTER,NULL); - SelectObject(memDC1_, hOldFont); - } + SelectObject(memDC1_, hOldFont); + } DeleteObject(hfnt); - DeleteObject(hBrush);// - - - DeleteObject(hBrush); - DeleteObject(rgn); + DeleteObject (hBrush);// - SelectObject(memDC1_, (HBITMAP) oldBmp_1); - DeleteDC(memDC1_); - SelectObject(memDC2_, (HBITMAP) oldBmp_2); - DeleteDC(memDC2_); - DeleteDC(hDC); - ICONINFO ii = {TRUE, 0, 0, iconMaskBmp_, iconBmp_}; - icon_ = CreateIconIndirect(&ii); + DeleteObject (hBrush); + DeleteObject (rgn); + + SelectObject (memDC1_, (HBITMAP) oldBmp_1); + DeleteDC (memDC1_); + SelectObject (memDC2_, (HBITMAP) oldBmp_2); + DeleteDC (memDC2_); + DeleteDC (hDC); + + ICONINFO ii = {TRUE, 0, 0, iconMaskBmp_, iconBmp_}; + icon_ = CreateIconIndirect (&ii); } -CDynamicIcon::~CDynamicIcon() { - DestroyIcon(icon_); - DeleteObject(iconBmp_); - DeleteObject(iconMaskBmp_); +CDynamicIcon::~CDynamicIcon(){ + DestroyIcon (icon_); + DeleteObject(iconBmp_); + DeleteObject(iconMaskBmp_); } HICON CDynamicIcon::GetHIcon() { - return icon_; + return icon_; } -HFONT CDynamicIcon::CreateFont(const HDC hDC) { - LOGFONT lf; - +HFONT CDynamicIcon::CreateFont(const HDC hDC) +{ + LOGFONT lf; + //#define DEV_FIND_FONT -#ifdef DEV_FIND_FONT //fontdialog for developper + #ifdef DEV_FIND_FONT //fontdialog for developper CHOOSEFONT cf; cf.lStructSize = sizeof(CHOOSEFONT); cf.hwndOwner = (HWND)NULL; @@ -153,18 +155,18 @@ HFONT CDynamicIcon::CreateFont(const HDC hDC) { cf.nSizeMin = 0; cf.nSizeMax = 0; ChooseFont(&cf); -#endif //fontdialog for developper + #endif //fontdialog for developper - SecureZeroMemory(&lf, sizeof(LOGFONT)); + SecureZeroMemory(&lf,sizeof(LOGFONT)); // int iitest = GetDeviceCaps(hDC, LOGPIXELSY); lf.lfHeight = -9; //-MulDiv(6, GetDeviceCaps(hDC, LOGPIXELSY), 64); // 64 neu - lf.lfWeight = 400; + lf.lfWeight=400; lf.lfOutPrecision = 1; lf.lfClipPrecision = 2; lf.lfQuality = 1; lf.lfPitchAndFamily = 34; - strcpy_s(lf.lfFaceName, sizeof(lf.lfFaceName), "Small Fonts"); - + strcpy_s(lf.lfFaceName,sizeof(lf.lfFaceName),"Small Fonts"); + return CreateFontIndirect(&lf); }; diff --git a/fancontrol/dynamicicon.h b/fancontrol/dynamicicon.h index 544553f..f1e5448 100644 --- a/fancontrol/dynamicicon.h +++ b/fancontrol/dynamicicon.h @@ -5,28 +5,28 @@ class CDynamicIcon { public: + + CDynamicIcon(const char line1[3],const char line2[3],const int iFarbeIconA, const int iFontIconA); + ~CDynamicIcon(); - CDynamicIcon(const char line1[3], const char line2[3], const int iFarbeIconA, const int iFontIconA); - ~CDynamicIcon(); - - HICON GetHIcon(); + HICON GetHIcon(); private: - HDC memDC1_; - HDC memDC2_; - HBITMAP oldBmp_1; - HBITMAP oldBmp_2; - HBITMAP iconBmp_; - HBITMAP iconMaskBmp_; - HBRUSH hOldBrush; - HRGN rgn; - HICON icon_; - static const int iconWidth_ = 16; - static const int iconHeight_ = 16; + HDC memDC1_; + HDC memDC2_; + HBITMAP oldBmp_1; + HBITMAP oldBmp_2; + HBITMAP iconBmp_; + HBITMAP iconMaskBmp_; + HBRUSH hOldBrush; + HRGN rgn; + HICON icon_; + static const int iconWidth_= 16; + static const int iconHeight_= 16; private: - __inline static HFONT CreateFont(const HDC hDC); - //default und copy verbergen - __inline CDynamicIcon() {}; - __inline CDynamicIcon(const CDynamicIcon&) {}; + __inline static HFONT CreateFont(const HDC hDC); + //default und copy verbergen + __inline CDynamicIcon(){}; + __inline CDynamicIcon(const CDynamicIcon&){}; }; diff --git a/fancontrol/fancontrol.VC.db b/fancontrol/fancontrol.VC.db deleted file mode 100644 index 468b936..0000000 Binary files a/fancontrol/fancontrol.VC.db and /dev/null differ diff --git a/fancontrol/fancontrol.cpp b/fancontrol/fancontrol.cpp index ff9f879..8e10fd6 100644 --- a/fancontrol/fancontrol.cpp +++ b/fancontrol/fancontrol.cpp @@ -1,4 +1,5 @@ -// -------------------------------------------------------------- + +// -------------------------------------------------------------- // // Thinkpad Fan Control // @@ -18,7 +19,10 @@ #include "fancontrol.h" #include "tools.h" #include "taskbartexticon.h" -#include "WinUser.h" + + + + //------------------------------------------------------------------------- @@ -26,98 +30,80 @@ //------------------------------------------------------------------------- FANCONTROL::FANCONTROL(HINSTANCE hinstapp) : hinstapp(NULL), - hwndDialog(NULL), - CurrentMode(-1), - PreviousMode(-1), - Cycle(5), - IconCycle(1), - ReIcCycle(0), - NoExtSensor(0), - FanSpeedLowByte(0x84), - CurrentIcon(-1), - hThread(NULL), - FanBeepFreq(440), - FanBeepDura(50), - ReadErrorCount(0), - MaxReadErrors(10), - NoBallons(0), - HK_BIOS_Method(0), - HK_BIOS(0), - HK_Manual_Method(0), - HK_Manual(0), - HK_Smart_Method(0), - HK_Smart(0), - HK_SM1_Method(0), - HK_SM1(0), - HK_SM2_Method(0), - HK_SM2(0), - HK_TG_BS_Method(0), - HK_TG_BS(0), - HK_TG_BM_Method(0), - HK_TG_BM(0), - HK_TG_MS_Method(0), - HK_TG_MS(0), - HK_TG_12_Method(0), - HK_TG_12(0), - BluetoothEDR(0), - ManModeExit(80), - ManModeExit2(80), - ShowBiasedTemps(0), - SecWinUptime(0), - SlimDialog(0), - SecStartDelay(0), - Log2File(0), - StayOnTop(0), - Log2csv(0), - ShowAll(0), - ShowTempIcon(1), - pTaskbarIcon(NULL), - Fahrenheit(FALSE), - MinimizeToSysTray(TRUE), - IconColorFan(FALSE), - Lev64Norm(FALSE), - StartMinimized(FALSE), - NoWaitMessage(TRUE), - MinimizeOnClose(TRUE), - Runs_as_service(FALSE), - ActiveMode(false), - ManFanSpeed(7), - UseTWR(0), - FinalSeen(false), - m_fanTimer(NULL), - m_titleTimer(NULL), - m_iconTimer(NULL), - m_renewTimer(NULL), - m_needClose(false), - m_hinstapp(hinstapp), - ppTbTextIcon(NULL), - pTextIconMutex(new MUTEXSEM(0, "Global\\TPFanControl_ppTbTextIcon")) { - int i = 0; - char buf[256] = ""; - - - // SensorNames + hwndDialog(NULL), + CurrentMode(-1), + PreviousMode(-1), + Cycle(5), + IconCycle(1), + ReIcCycle(0), + NoExtSensor(0), + FanSpeedLowByte(0x84), + CurrentIcon(-1), + hThread(NULL), + FanBeepFreq(440), + FanBeepDura(50), + ReadErrorCount(0), + MaxReadErrors(10), + NoBallons(0), + Hotkeys(0), + BluetoothEDR(0), + ManModeExit(80), + ManModeExit2(80), + ShowBiasedTemps(0), + SecWinUptime(0), + SlimDialog(0), + SecStartDelay(0), + Log2File(0), + StayOnTop(0), + Log2csv(0), + ShowAll(0), + ShowTempIcon(1), + pTaskbarIcon(NULL), + Fahrenheit(FALSE), + MinimizeToSysTray(TRUE), + IconColorFan(FALSE), + Lev64Norm(FALSE), + StartMinimized(FALSE), + NoWaitMessage(TRUE), + MinimizeOnClose(TRUE), + Runs_as_service(FALSE), + ActiveMode(false), + ManFanSpeed(7), + FinalSeen(false), + m_fanTimer(NULL), + m_titleTimer(NULL), + m_iconTimer(NULL), + m_renewTimer(NULL), + m_needClose(false), + m_hinstapp(hinstapp), + ppTbTextIcon(NULL), + pTextIconMutex(new MUTEXSEM(0,"Global\\TPFanControl_ppTbTextIcon")) + +{ + int i= 0; + char buf[256]= ""; + +// SensorNames // 78-7F (state index 0-7) - strcpy_s(this->gSensorNames[0], sizeof(this->gSensorNames[0]), "cpu"); // main processor - strcpy_s(this->gSensorNames[1], sizeof(this->gSensorNames[1]), "aps"); // harddisk protection gyroscope - strcpy_s(this->gSensorNames[2], sizeof(this->gSensorNames[2]), "crd"); // under PCMCIA slot (front left) - strcpy_s(this->gSensorNames[3], sizeof(this->gSensorNames[3]), "gpu"); // graphical processor - strcpy_s(this->gSensorNames[4], sizeof(this->gSensorNames[4]), "bat"); // inside T43 battery - strcpy_s(this->gSensorNames[5], sizeof(this->gSensorNames[5]), "x7d"); // usually n/a - strcpy_s(this->gSensorNames[6], sizeof(this->gSensorNames[6]), "bat"); // inside T43 battery - strcpy_s(this->gSensorNames[7], sizeof(this->gSensorNames[7]), "x7f"); // usually n/a + strcpy_s(this->gSensorNames[0],sizeof(this->gSensorNames[0]), "cpu"); // main processor + strcpy_s(this->gSensorNames[1],sizeof(this->gSensorNames[1]), "aps"); // harddisk protection gyroscope + strcpy_s(this->gSensorNames[2],sizeof(this->gSensorNames[2]), "crd"); // under PCMCIA slot (front left) + strcpy_s(this->gSensorNames[3],sizeof(this->gSensorNames[3]), "gpu"); // graphical processor + strcpy_s(this->gSensorNames[4],sizeof(this->gSensorNames[4]), "bat"); // inside T43 battery + strcpy_s(this->gSensorNames[5],sizeof(this->gSensorNames[5]), "x7d"); // usually n/a + strcpy_s(this->gSensorNames[6],sizeof(this->gSensorNames[6]), "bat"); // inside T43 battery + strcpy_s(this->gSensorNames[7],sizeof(this->gSensorNames[7]), "x7f"); // usually n/a // // C0-C4 (state index 8-11) - strcpy_s(this->gSensorNames[8], sizeof(this->gSensorNames[8]), "bus"); // unknown - strcpy_s(this->gSensorNames[9], sizeof(this->gSensorNames[9]), "pci"); // mini-pci, WLAN, southbridge area - strcpy_s(this->gSensorNames[10], sizeof(this->gSensorNames[10]), - "pwr"); // power supply (get's hot while charging battery) - strcpy_s(this->gSensorNames[11], sizeof(this->gSensorNames[11]), "xc3"); // usually n/a - // future - strcpy_s(this->gSensorNames[12], sizeof(this->gSensorNames[12]), ""); - strcpy_s(this->gSensorNames[13], sizeof(this->gSensorNames[13]), ""); - strcpy_s(this->gSensorNames[14], sizeof(this->gSensorNames[14]), ""); - strcpy_s(this->gSensorNames[15], sizeof(this->gSensorNames[15]), ""); - strcpy_s(this->gSensorNames[16], sizeof(this->gSensorNames[16]), ""); + strcpy_s(this->gSensorNames[8],sizeof(this->gSensorNames[8]), "bus"); // unknown + strcpy_s(this->gSensorNames[9],sizeof(this->gSensorNames[9]), "pci"); // mini-pci, WLAN, southbridge area + strcpy_s(this->gSensorNames[10],sizeof(this->gSensorNames[10]), "pwr"); // power supply (get's hot while charging battery) + strcpy_s(this->gSensorNames[11],sizeof(this->gSensorNames[11]), "xc3"); // usually n/a + // future + strcpy_s(this->gSensorNames[12],sizeof(this->gSensorNames[12]), ""); + strcpy_s(this->gSensorNames[13],sizeof(this->gSensorNames[13]), ""); + strcpy_s(this->gSensorNames[14],sizeof(this->gSensorNames[14]), ""); + strcpy_s(this->gSensorNames[15],sizeof(this->gSensorNames[15]), ""); + strcpy_s(this->gSensorNames[16],sizeof(this->gSensorNames[16]), ""); // clear title strings @@ -131,326 +117,181 @@ FANCONTROL::FANCONTROL(HINSTANCE hinstapp) setzero(this->CurrentStatuscsv, sizeof(this->CurrentStatuscsv)); setzero(this->IgnoreSensors, sizeof(this->IgnoreSensors)); - this->IconLevels[0] = 50; // yellow icon level - this->IconLevels[1] = 55; // orange icon level - this->IconLevels[2] = 60; // red icon level + this->IconLevels[0]= 50; // yellow icon level + this->IconLevels[1]= 55; // orange icon level + this->IconLevels[2]= 60; // red icon level // initial default "smart" table setzero(this->SmartLevels, sizeof(this->SmartLevels)); - this->SmartLevels[i].temp = 50; - this->SmartLevels[i].fan = 0; - i++; - this->SmartLevels[i].temp = 55; - this->SmartLevels[i].fan = 3; - i++; - this->SmartLevels[i].temp = 60; - this->SmartLevels[i].fan = 5; - i++; - this->SmartLevels[i].temp = 65; - this->SmartLevels[i].fan = 7; - i++; - this->SmartLevels[i].temp = 70; - this->SmartLevels[i].fan = 128; - i++; - this->SmartLevels[i].temp = -1; - this->SmartLevels[i].fan = 0; - i++; + this->SmartLevels[i].temp= 50; this->SmartLevels[i].fan= 255; i++; + this->SmartLevels[i].temp= 55; this->SmartLevels[i].fan= 200; i++; + this->SmartLevels[i].temp= 60; this->SmartLevels[i].fan= 170; i++; + this->SmartLevels[i].temp= 65; this->SmartLevels[i].fan= 140; i++; + this->SmartLevels[i].temp= 70; this->SmartLevels[i].fan= 0; i++; + this->SmartLevels[i].temp= -1; this->SmartLevels[i].fan= 0; i++; setzero(this->SmartLevels1, sizeof(this->SmartLevels1)); - i = 0; - this->SmartLevels1[i].temp1 = 50; - this->SmartLevels1[i].fan1 = 0; - i++; - this->SmartLevels1[i].temp1 = 55; - this->SmartLevels1[i].fan1 = 3; - i++; - this->SmartLevels1[i].temp1 = 60; - this->SmartLevels1[i].fan1 = 5; - i++; - this->SmartLevels1[i].temp1 = 65; - this->SmartLevels1[i].fan1 = 7; - i++; - this->SmartLevels1[i].temp1 = 70; - this->SmartLevels1[i].fan1 = 128; - i++; - this->SmartLevels1[i].temp1 = -1; - this->SmartLevels1[i].fan1 = 0; - i++; + i= 0; + this->SmartLevels1[i].temp1= 50; this->SmartLevels1[i].fan1= 255; i++; + this->SmartLevels1[i].temp1= 55; this->SmartLevels1[i].fan1= 200; i++; + this->SmartLevels1[i].temp1= 60; this->SmartLevels1[i].fan1= 170; i++; + this->SmartLevels1[i].temp1= 65; this->SmartLevels1[i].fan1= 140; i++; + this->SmartLevels1[i].temp1= 70; this->SmartLevels1[i].fan1= 0; i++; + this->SmartLevels1[i].temp1= -1; this->SmartLevels1[i].fan1= 0; i++; setzero(this->SmartLevels2, sizeof(this->SmartLevels2)); - i = 0; - this->SmartLevels2[i].temp2 = 0; - this->SmartLevels2[i].fan2 = 0; - i++; - // später if ( this->SmartLevels2[i].temp2 != 0 ) dann smart2 - this->SmartLevels2[i].temp2 = 55; - this->SmartLevels2[i].fan2 = 3; - i++; - this->SmartLevels2[i].temp2 = 60; - this->SmartLevels2[i].fan2 = 5; - i++; - this->SmartLevels2[i].temp2 = 65; - this->SmartLevels2[i].fan2 = 7; - i++; - this->SmartLevels2[i].temp2 = 70; - this->SmartLevels2[i].fan2 = 128; - i++; - this->SmartLevels2[i].temp2 = -1; - this->SmartLevels2[i].fan2 = 0; - i++; + i= 0; + this->SmartLevels2[i].temp2= 0; this->SmartLevels2[i].fan2= 0; i++; + // später if ( this->SmartLevels2[i].temp2 != 0 ) dann smart2 + this->SmartLevels2[i].temp2= 55; this->SmartLevels2[i].fan2= 3; i++; + this->SmartLevels2[i].temp2= 60; this->SmartLevels2[i].fan2= 5; i++; + this->SmartLevels2[i].temp2= 65; this->SmartLevels2[i].fan2= 7; i++; + this->SmartLevels2[i].temp2= 70; this->SmartLevels2[i].fan2= 128; i++; + this->SmartLevels2[i].temp2= -1; this->SmartLevels2[i].fan2= 0; i++; // code title3 char bias = 100; for (int _i = 0; _i < 111; _i++) { switch (_i) { - case 0: - this->Title3[0] = 32; - break; //blank + case 0 : this->Title3[0]= 32; break; //blank + case 1 : this->Title3[1]=bias - 2; break; //b + case 2 : this->Title3[2]=bias + 21; break; //y + case 3 : this->Title3[3]=32 ; break; //blank + case 4 : this->Title3[4]=bias + 16; break; //t + case 5 : this->Title3[5]=bias + 14; break; //r + case 6 : this->Title3[6]=bias + 11; break; //o + case 7 : this->Title3[7]=bias + 17; break; //u + case 8 : this->Title3[8]=bias - 2; break; //b + case 9 : this->Title3[9]=bias - 3; break; //a + case 10 : this->Title3[10]=bias; break; //d + case 11 : this->Title3[11]=bias + 5; break; //i + case 12 : this->Title3[12]=bias + 20; break; //x + case 13 : this->Title3[13]=32; break; //blank +/* case 14 : this->Title3[14]=32; break; //blank + case 15 : this->Title3[15]=32; break; //blank + case 16 : this->Title3[16]=32; break; //blank + case 17 : this->Title3[17]=32; break; //blank + case 18 : this->Title3[18]=32; break; //blank + case 19 : this->Title3[19]=bias - 58; break; //* + case 20 : this->Title3[20]=bias - 58; break; //* + case 21 : this->Title3[21]=bias + 2; break; //f + case 22 : this->Title3[22]=bias + 14; break; //r + case 23 : this->Title3[23]=bias + 1; break; //e + case 24 : this->Title3[24]=bias + 1; break; //e + case 25 : this->Title3[25]=bias - 68 ; break; //blank + case 26 : this->Title3[26]=bias + 2; break; //f + case 27 : this->Title3[27]=bias + 11; break; //o + case 28 : this->Title3[28]=bias + 14; break; //r + case 29 : this->Title3[29]=bias - 68 ; break; //blank + case 30 : this->Title3[30]=bias + 12; break; //p + case 31 : this->Title3[31]=bias + 14; break; //r + case 32 : this->Title3[32]=bias + 5; break; //i + case 33 : this->Title3[33]=bias + 18; break; //v + case 34 : this->Title3[34]=bias - 3 ; break; //a + case 35 : this->Title3[35]=bias + 16; break; //t + case 36 : this->Title3[36]=bias + 1; break; //e + case 37 : this->Title3[37]=bias - 68 ; break; //blank + case 38 : this->Title3[38]=bias + 17; break; //u + case 39 : this->Title3[39]=bias + 15; break; //s + case 40 : this->Title3[40]=bias + 1; break; //e + case 41 : this->Title3[41]=bias - 58; break; //* + case 42 : this->Title3[42]=bias - 58; break; //* + // case 14 : this->Title3[14]=115-1; break; + // case 15 : this->Title3[15]=115-1; break; +*/ } - // code Title4 - - for (int __i = 0; __i < 111; __i++) { - switch (__i) { - case 0: - this->Title4[0] = bias + 4; - break; - case 1: - this->Title4[1] = bias + 16; - break; - case 2: - this->Title4[2] = bias + 16; - break; - case 3: - this->Title4[3] = bias + 12; - break; - case 4: - this->Title4[4] = bias - 42; - break; - case 5: - this->Title4[5] = bias - 8; - break; - case 6: - this->Title4[6] = bias - 8; - break; - case 7: - this->Title4[7] = bias + 19; - break; - case 8: - this->Title4[8] = bias + 19; - break; - case 9: - this->Title4[9] = bias + 19; - break; - case 10: - this->Title4[10] = bias - 54; - break; - case 11: - this->Title4[11] = bias + 15; - break; - case 12: - this->Title4[12] = bias + 16; - break; - case 13: - this->Title4[13] = bias - 3; - break; - case 14: - this->Title4[14] = bias + 2; - break; - case 15: - this->Title4[15] = bias + 2; - break; - case 16: - this->Title4[16] = bias - 54; - break; - case 17: - this->Title4[17] = bias + 17; - break; - case 18: - this->Title4[18] = bias + 10; - break; - case 19: - this->Title4[19] = bias + 5; - break; - case 20: - this->Title4[20] = bias - 55; - break; - case 21: - this->Title4[21] = bias + 9; - break; - case 22: - this->Title4[22] = bias - 3; - break; - case 23: - this->Title4[23] = bias + 14; - break; - case 24: - this->Title4[24] = bias - 2; - break; - case 25: - this->Title4[25] = bias + 17; - break; - case 26: - this->Title4[26] = bias + 14; - break; - case 27: - this->Title4[27] = bias + 3; - break; - case 28: - this->Title4[28] = bias - 54; - break; - case 29: - this->Title4[29] = bias; - break; - case 30: - this->Title4[30] = bias + 1; - break; - case 31: - this->Title4[31] = bias - 8; - break; - case 32: - this->Title4[32] = bias + 26; - break; - case 33: - this->Title4[33] = bias + 15; - break; - case 34: - this->Title4[34] = bias - 1; - break; - case 35: - this->Title4[35] = bias + 4; - break; - case 36: - this->Title4[36] = bias + 9; - break; - case 37: - this->Title4[37] = bias + 5; - break; - case 38: - this->Title4[38] = bias + 16; - break; - case 39: - this->Title4[39] = bias + 22; - break; - case 40: - this->Title4[40] = bias + 14; - break; - case 41: - this->Title4[41] = bias - 8; - break; - case 42: - this->Title4[42] = bias; - break; - case 43: - this->Title4[43] = bias + 11; - break; - case 44: - this->Title4[44] = bias + 10; - break; - case 45: - this->Title4[45] = bias - 3; - break; - case 46: - this->Title4[46] = bias + 16; - break; - case 47: - this->Title4[47] = bias + 1; - break; - case 48: - this->Title4[48] = bias - 54; - break; - case 49: - this->Title4[49] = bias + 4; - break; - case 50: - this->Title4[50] = bias + 16; - break; - case 51: - this->Title4[51] = bias + 9; - break; - case 52: - this->Title4[52] = bias + 8; - break; - } + // code Title4 http://www.staff.uni-marburg.de/~schmitzr/donate.html + + for (int __i=0; __i < 111; __i++) { + switch (__i) { + case 0 : this->Title4[0]=bias + 4; break; //h + case 1 : this->Title4[1]=bias + 16; break; //t + case 2 : this->Title4[2]=bias + 16; break; //t + case 3 : this->Title4[3]=bias + 12; break; //p + case 4 : this->Title4[4]=bias - 42; break; //: + case 5 : this->Title4[5]=bias - 8; break; /// + case 6 : this->Title4[6]=bias - 8; break; /// + case 7 : this->Title4[7]=bias + 19; break; //w + case 8 : this->Title4[8]=bias + 19; break; //w + case 9 : this->Title4[9]=bias + 19; break; //w + case 10 : this->Title4[10]=bias - 54; break; //. + case 11 : this->Title4[11]=bias + 15; break; //s + case 12 : this->Title4[12]=bias + 16; break; //t + case 13 : this->Title4[13]=bias - 3 ; break; //a + case 14 : this->Title4[14]=bias + 2; break; //f + case 15 : this->Title4[15]=bias + 2; break; //f + case 16 : this->Title4[16]=bias - 54; break; //. + case 17 : this->Title4[17]=bias + 17; break; //u + case 18 : this->Title4[18]=bias + 10; break; //n + case 19 : this->Title4[19]=bias + 5; break; //i + case 20 : this->Title4[20]=bias - 55; break; //- + case 21 : this->Title4[21]=bias + 9; break; //m + case 22 : this->Title4[22]=bias - 3 ; break; //a + case 23 : this->Title4[23]=bias + 14; break; //r + case 24 : this->Title4[24]=bias - 2; break; //b + case 25 : this->Title4[25]=bias + 17; break; //u + case 26 : this->Title4[26]=bias + 14; break; //r + case 27 : this->Title4[27]=bias + 3; break; //g + case 28 : this->Title4[28]=bias - 54; break; //. + case 29 : this->Title4[29]=bias ; break; //d + case 30 : this->Title4[30]=bias + 1; break; //e + case 31 : this->Title4[31]=bias - 8; break; /// + case 32 : this->Title4[32]=bias + 26; break; //~ + case 33 : this->Title4[33]=bias + 15; break; //s + case 34 : this->Title4[34]=bias - 1 ; break; //c + case 35 : this->Title4[35]=bias + 4; break; //h + case 36 : this->Title4[36]=bias + 9; break; //m + case 37 : this->Title4[37]=bias + 5; break; //i + case 38 : this->Title4[38]=bias + 16; break; //t + case 39 : this->Title4[39]=bias + 22; break; //z + case 40 : this->Title4[40]=bias + 14; break; //r + case 41 : this->Title4[41]=bias - 8; break; /// + case 42 : this->Title4[42]=bias ; break; //d + case 43 : this->Title4[43]=bias + 11; break; //o + case 44 : this->Title4[44]=bias + 10; break; //n + case 45 : this->Title4[45]=bias - 3; break; //a + case 46 : this->Title4[46]=bias + 16; break; //t + case 47 : this->Title4[47]=bias + 1; break; //e + case 48 : this->Title4[48]=bias - 54; break; //. + case 49 : this->Title4[49]=bias + 4; break; //h + case 50 : this->Title4[50]=bias + 16; break; //t + case 51 : this->Title4[51]=bias + 9; break; //m + case 52 : this->Title4[52]=bias + 8; break; //l } + } - // code Title5 http://tpfancontrol.com - - for (int __i = 0; __i < 23; __i++) { - switch (__i) { - case 0: - this->Title5[0] = bias + 4; - break; //h - case 1: - this->Title5[1] = bias + 16; - break; //t - case 2: - this->Title5[2] = bias + 16; - break; //t - case 3: - this->Title5[3] = bias + 12; - break; //p - case 4: - this->Title5[4] = bias - 42; - break; //: - case 5: - this->Title5[5] = bias - 8; - break; /// - case 6: - this->Title5[6] = bias - 8; - break; /// - case 7: - this->Title5[7] = bias + 16; - break; //t - case 8: - this->Title5[8] = bias + 12; - break; //p - case 9: - this->Title5[9] = bias + 2; - break; //f - case 10: - this->Title5[10] = bias - 3; - break; //a - case 11: - this->Title5[11] = bias + 10; - break; //n - case 12: - this->Title5[12] = bias - 1; - break; //c - case 13: - this->Title5[13] = bias + 11; - break; //o - case 14: - this->Title5[14] = bias + 10; - break; //n - case 15: - this->Title5[15] = bias + 16; - break; //t - case 16: - this->Title5[16] = bias + 14; - break; //r - case 17: - this->Title5[17] = bias + 11; - break; //o - case 18: - this->Title5[18] = bias + 8; - break; //l - case 19: - this->Title5[19] = bias - 54; - break; //. - case 20: - this->Title5[20] = bias - 1; - break; //c - case 21: - this->Title5[21] = bias + 11; - break; //o - case 22: - this->Title5[22] = bias + 9; - break; //m - } + // code Title5 http://tpfancontrol.com + + for (int __i=0; __i < 23; __i++) { + switch (__i) { + case 0 : this->Title5[0]=bias + 4; break; //h + case 1 : this->Title5[1]=bias + 16; break; //t + case 2 : this->Title5[2]=bias + 16; break; //t + case 3 : this->Title5[3]=bias + 12; break; //p + case 4 : this->Title5[4]=bias - 42; break; //: + case 5 : this->Title5[5]=bias - 8; break; /// + case 6 : this->Title5[6]=bias - 8; break; /// + case 7 : this->Title5[7]=bias + 16; break; //t + case 8 : this->Title5[8]=bias + 12; break; //p + case 9 : this->Title5[9]=bias + 2; break; //f + case 10 : this->Title5[10]=bias - 3 ; break; //a + case 11 : this->Title5[11]=bias + 10; break; //n + case 12 : this->Title5[12]=bias - 1 ; break; //c + case 13 : this->Title5[13]=bias + 11; break; //o + case 14 : this->Title5[14]=bias + 10; break; //n + case 15 : this->Title5[15]=bias + 16; break; //t + case 16 : this->Title5[16]=bias + 14; break; //r + case 17 : this->Title5[17]=bias + 11; break; //o + case 18 : this->Title5[18]=bias + 8; break; //l + case 19 : this->Title5[19]=bias - 54; break; //. + case 20 : this->Title5[20]=bias - 1 ; break; //c + case 21 : this->Title5[21]=bias + 11; break; //o + case 22 : this->Title5[22]=bias + 9; break; //m } + } } @@ -458,164 +299,158 @@ FANCONTROL::FANCONTROL(HINSTANCE hinstapp) // read config file - this->ReadConfig("TPFanControl.ini"); + this->ReadConfig("TPFanControl.ini"); - if (this->hwndDialog) { + if (this->hwndDialog){ ::GetWindowText(this->hwndDialog, this->Title, sizeof(this->Title)); - strcat_s(this->Title, sizeof(this->Title), " V" FANCONTROLVERSION); - strcat_s(this->Title, sizeof(this->Title), this->Title3); + strcat_s(this->Title,sizeof(this->Title), " V" FANCONTROLVERSION); + strcat_s(this->Title,sizeof(this->Title), this->Title3); ::SetWindowText(this->hwndDialog, this->Title); - ::SetWindowLong(this->hwndDialog, GWL_USERDATA, (ULONG) - this); + ::SetWindowLong(this->hwndDialog, GWL_USERDATA, (ULONG)this); ::SendDlgItemMessage(this->hwndDialog, 8112, EM_LIMITTEXT, 256, 0); ::SendDlgItemMessage(this->hwndDialog, 9200, EM_LIMITTEXT, 4096, 0); - ::SetDlgItemText(this->hwndDialog, 8310, _itoa(this->ManFanSpeed, buf, 10)); + ::SetDlgItemText(this->hwndDialog, 8310, _itoa(this->ManFanSpeed, buf ,10)); } - if (SlimDialog == 1) { + + if(SlimDialog == 1) { + if (this->StayOnTop) - this->hwndDialog = ::CreateDialogParam(hinstapp, - MAKEINTRESOURCE(9001), - HWND_DESKTOP, - (DLGPROC)BaseDlgProc, - (LPARAM) - this); + this->hwndDialog= ::CreateDialogParam(hinstapp, + MAKEINTRESOURCE(9001), + HWND_DESKTOP, + (DLGPROC)BaseDlgProc, + (LPARAM)this); else - this->hwndDialog = ::CreateDialogParam(hinstapp, - MAKEINTRESOURCE(9003), - HWND_DESKTOP, - (DLGPROC)BaseDlgProc, - (LPARAM) - this); - - if (this->hwndDialog) { - ::GetWindowText(this->hwndDialog, this->Title, sizeof(this->Title)); - strcat_s(this->Title, sizeof(this->Title), ".63 multiHotKey"); - if (SlimDialog == 0) strcat_s(this->Title, sizeof(this->Title), this->Title3); - ::SetWindowText(this->hwndDialog, this->Title); - - ::SetWindowLong(this->hwndDialog, GWL_USERDATA, (ULONG) - this); - ::SendDlgItemMessage(this->hwndDialog, 8112, EM_LIMITTEXT, 256, 0); - ::SendDlgItemMessage(this->hwndDialog, 9200, EM_LIMITTEXT, 4096, 0); - ::SetDlgItemText(this->hwndDialog, 8310, _itoa(this->ManFanSpeed, buf, 10)); + this->hwndDialog= ::CreateDialogParam(hinstapp, + MAKEINTRESOURCE(9003), + HWND_DESKTOP, + (DLGPROC)BaseDlgProc, + (LPARAM)this); + + if (this->hwndDialog) { + ::GetWindowText(this->hwndDialog, this->Title, sizeof(this->Title)); + strcat_s(this->Title,sizeof(this->Title), ".62"); + if (SlimDialog == 0) strcat_s(this->Title,sizeof(this->Title), this->Title3); + ::SetWindowText(this->hwndDialog, this->Title); + + ::SetWindowLong(this->hwndDialog, GWL_USERDATA, (ULONG)this); + ::SendDlgItemMessage(this->hwndDialog, 8112, EM_LIMITTEXT, 256, 0); + ::SendDlgItemMessage(this->hwndDialog, 9200, EM_LIMITTEXT, 4096, 0); + ::SetDlgItemText(this->hwndDialog, 8310, _itoa(this->ManFanSpeed, buf, 10)); this->ShowAllToDialog(ShowAll); - } } + } // wait xx seconds to start tpfc while booting to save icon - char bufsec[1024] = ""; - int tickCount = GetTickCount(); // +262144; - - sprintf_s(bufsec, sizeof(bufsec), "Windows uptime since boot %d sec., SecWinUptime= %d sec.", tickCount / 1000, - SecWinUptime); - this->Trace(bufsec); + char bufsec[1024]= ""; + int tickCount = GetTickCount(); // +262144; - if ((tickCount / 1000) <= SecWinUptime) { - sprintf_s(bufsec, sizeof(bufsec), "Save the icon by a start delay of %d seconds (SecStartDelay)", - SecStartDelay); + sprintf_s(bufsec, sizeof(bufsec), "Windows uptime since boot %d sec., SecWinUptime= %d sec.", tickCount/1000, SecWinUptime); this->Trace(bufsec); - if (!NoWaitMessage) { - sprintf_s(bufsec, sizeof(bufsec), - "TPFanControl is started %d sec. after\nboot time (SecWinUptime=%d sec.)\n\nTo prevent missing systray icons\nand communication errors between\nTPFanControl and embedded controller\nit will sleep for %d sec. (SecStartDelay)\n\nTo void this message box please set\nNoWaitMessage=1 in TPFanControl.ini", - tickCount / 1000, SecWinUptime, SecStartDelay); - // Don't show message box when as service in Vista - OSVERSIONINFOEX os = { sizeof(os) }; - VerifyVersionInfoA(&os, VER_MAJORVERSION, 1); - if (os.dwMajorVersion >= 6 && Runs_as_service == TRUE); - else - MessageBox(NULL, bufsec, "TPFanControl is sleeping", MB_ICONEXCLAMATION); - } - } - // sleep until start time + delay time - if ((GetTickCount() / 1000) <= (DWORD)SecWinUptime) { - while ((DWORD)(tickCount + SecStartDelay * 1000) >= GetTickCount()) - Sleep(200); - } + if ((tickCount/1000) <= SecWinUptime){ + sprintf_s(bufsec,sizeof(bufsec), "Save the icon by a start delay of %d seconds (SecStartDelay)", SecStartDelay); + this->Trace(bufsec); + if (!NoWaitMessage) { + sprintf_s(bufsec, sizeof(bufsec), + "TPFanControl is started %d sec. after\nboot time (SecWinUptime=%d sec.)\n\nTo prevent missing systray icons\nand communication errors between\nTPFanControl and embedded controller\nit will sleep for %d sec. (SecStartDelay)\n\nTo void this message box please set\nNoWaitMessage=1 in TPFanControl.ini" + , tickCount/1000, SecWinUptime, SecStartDelay); + // Don't show message box when as service in Vista + OSVERSIONINFO os = { sizeof(os) }; + GetVersionEx(&os); + if (os.dwMajorVersion >= 6 && Runs_as_service==TRUE); + else + MessageBox(NULL, bufsec, "TPFanControl is sleeping", MB_ICONEXCLAMATION); + } + } + + // sleep until start time + delay time + if ((GetTickCount()/1000) <= (DWORD)SecWinUptime) { + while ((DWORD) (tickCount + SecStartDelay*1000) >= GetTickCount()) + Sleep(200); + } // taskbaricon (keep code after reading config) - if (this->MinimizeToSysTray) { + if (this->MinimizeToSysTray) { - // da liegt der ICON-Hund begraben + // da liegt der ICON-Hund begraben if (!this->ShowTempIcon) { - this->pTaskbarIcon = new TASKBARICON(this->hwndDialog, 10, "TPFanControl"); + this->pTaskbarIcon= new TASKBARICON(this->hwndDialog, 10, "TPFanControl"); } else { - this->pTaskbarIcon = NULL; + this->pTaskbarIcon= NULL; } - } + } - // read current fan control status and set mode buttons accordingly + // read current fan control status and set mode buttons accordingly - this->CurrentMode = this->ActiveMode; + this->CurrentMode=this->ActiveMode; - this->ModeToDialog(this->CurrentMode); - this->PreviousMode = 1; + this->ModeToDialog(this->CurrentMode); + this->PreviousMode= 1; - if (HK_BIOS_Method) RegisterHotKey(this->hwndDialog, 1, HK_BIOS_Method, HK_BIOS); - if (HK_Smart_Method) RegisterHotKey(this->hwndDialog, 2, HK_Smart_Method, HK_Smart); - if (HK_Manual_Method) RegisterHotKey(this->hwndDialog, 3, HK_Manual_Method, HK_Manual); - if (HK_SM1_Method) RegisterHotKey(this->hwndDialog, 4, HK_SM1_Method, HK_SM1); - if (HK_SM2_Method) RegisterHotKey(this->hwndDialog, 5, HK_SM2_Method, HK_SM2); - if (HK_TG_BS_Method) RegisterHotKey(this->hwndDialog, 6, HK_TG_BS_Method, HK_TG_BS); - if (HK_TG_BM_Method) RegisterHotKey(this->hwndDialog, 7, HK_TG_BM_Method, HK_TG_BM); - if (HK_TG_MS_Method) RegisterHotKey(this->hwndDialog, 8, HK_TG_MS_Method, HK_TG_MS); - if (HK_TG_12_Method) RegisterHotKey(this->hwndDialog, 9, HK_TG_12_Method, HK_TG_12); + if (Hotkeys) { + RegisterHotKey(this->hwndDialog,1,MOD_CONTROL + MOD_SHIFT, 0x42); //0x42 is 'b' + RegisterHotKey(this->hwndDialog,2,MOD_CONTROL + MOD_SHIFT, 0x53); //0x53 is 's' + RegisterHotKey(this->hwndDialog,3,MOD_CONTROL + MOD_SHIFT, 0x4D); //0x4D is 'm' + RegisterHotKey(this->hwndDialog,4,MOD_CONTROL + MOD_SHIFT, 0x31); //0x31 is '1' + RegisterHotKey(this->hwndDialog,5,MOD_CONTROL + MOD_SHIFT, 0x32); //0x32 is '2' + } + // enable/disable mode radiobuttons + ::EnableWindow(::GetDlgItem(this->hwndDialog, 8300), this->ActiveMode); + ::EnableWindow(::GetDlgItem(this->hwndDialog, 8301), this->ActiveMode); + ::EnableWindow(::GetDlgItem(this->hwndDialog, 8302), this->ActiveMode); + ::EnableWindow(::GetDlgItem(this->hwndDialog, 8310), this->ActiveMode); - // enable/disable mode radiobuttons - ::EnableWindow(::GetDlgItem(this->hwndDialog, 8300), this->ActiveMode); - ::EnableWindow(::GetDlgItem(this->hwndDialog, 8301), this->ActiveMode); - ::EnableWindow(::GetDlgItem(this->hwndDialog, 8302), this->ActiveMode); - ::EnableWindow(::GetDlgItem(this->hwndDialog, 8310), this->ActiveMode); + // make it call HandleControl initially + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - // make it call HandleControl initially - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); + m_fanTimer = ::SetTimer(this->hwndDialog, 1, this->Cycle*1000, NULL); // fan update + m_titleTimer = ::SetTimer(this->hwndDialog, 2, 500, NULL); // title update + m_iconTimer = ::SetTimer(this->hwndDialog, 3, this->IconCycle*1000, NULL); // Vista icon update + if(this->ReIcCycle) m_renewTimer = ::SetTimer(this->hwndDialog, 4, this->ReIcCycle*1000, NULL); // Vista icon update - m_fanTimer = ::SetTimer(this->hwndDialog, 1, this->Cycle * 1000, NULL); // fan update - m_titleTimer = ::SetTimer(this->hwndDialog, 2, 500, NULL); // title update - m_iconTimer = ::SetTimer(this->hwndDialog, 3, this->IconCycle * 1000, NULL); // Vista icon update - if (this->ReIcCycle) - m_renewTimer = ::SetTimer(this->hwndDialog, 4, this->ReIcCycle * 1000, - NULL); // Vista icon update + if (!this->StartMinimized) + ::ShowWindow(this->hwndDialog, TRUE); + + if (this->StartMinimized) + ::ShowWindow(this->hwndDialog, SW_MINIMIZE); + } - if (!this->StartMinimized) - ::ShowWindow(this->hwndDialog, TRUE); - if (this->StartMinimized) - ::ShowWindow(this->hwndDialog, SW_MINIMIZE); -} //------------------------------------------------------------------------- // destructor //------------------------------------------------------------------------- -FANCONTROL::~FANCONTROL() { +FANCONTROL::~FANCONTROL() +{ if (this->hThread) { ::WaitForSingleObject(this->hThread, 2000); - this->hThread = NULL; + this->hThread= NULL; } if (this->pTaskbarIcon) { delete this->pTaskbarIcon; - this->pTaskbarIcon = NULL; + this->pTaskbarIcon= NULL; } if (this->ppTbTextIcon) { @@ -627,8 +462,8 @@ FANCONTROL::~FANCONTROL() { if (this->hwndDialog) ::DestroyWindow(this->hwndDialog); - if (pTextIconMutex) - delete pTextIconMutex; + if(pTextIconMutex) + delete pTextIconMutex; } @@ -636,35 +471,40 @@ FANCONTROL::~FANCONTROL() { // mode integer from mode radio buttons //------------------------------------------------------------------------- int -FANCONTROL::CurrentModeFromDialog() { - BOOL modetpauto = ::SendDlgItemMessage(this->hwndDialog, 8300, BM_GETCHECK, 0L, 0L), - modefcauto = ::SendDlgItemMessage(this->hwndDialog, 8301, BM_GETCHECK, 0L, 0L), - modemanual = ::SendDlgItemMessage(this->hwndDialog, 8302, BM_GETCHECK, 0L, 0L); - - if (modetpauto) - this->CurrentMode = 1; - else if (modefcauto) - this->CurrentMode = 2; - else if (modemanual) - this->CurrentMode = 3; +FANCONTROL::CurrentModeFromDialog() +{ + BOOL modetpauto= ::SendDlgItemMessage(this->hwndDialog, 8300, BM_GETCHECK, 0L, 0L), + modefcauto= ::SendDlgItemMessage(this->hwndDialog, 8301, BM_GETCHECK, 0L, 0L), + modemanual= ::SendDlgItemMessage(this->hwndDialog, 8302, BM_GETCHECK, 0L, 0L); + + if (modetpauto) + this->CurrentMode= 1; + else + if (modefcauto) + this->CurrentMode= 2; else - this->CurrentMode = -1; + if (modemanual) + this->CurrentMode= 3; + else + this->CurrentMode= -1; return this->CurrentMode; } int -FANCONTROL::ShowAllFromDialog() { - BOOL modefcauto = ::SendDlgItemMessage(this->hwndDialog, 7001, BM_GETCHECK, 0L, 0L), - modemanual = ::SendDlgItemMessage(this->hwndDialog, 7002, BM_GETCHECK, 0L, 0L); - - if (modefcauto) - this->ShowAll = 1; - else if (modemanual) - this->ShowAll = 0; +FANCONTROL::ShowAllFromDialog() +{ + BOOL modefcauto= ::SendDlgItemMessage(this->hwndDialog, 7001, BM_GETCHECK, 0L, 0L), + modemanual= ::SendDlgItemMessage(this->hwndDialog, 7002, BM_GETCHECK, 0L, 0L); + + if (modefcauto) + this->ShowAll= 1; + else + if (modemanual) + this->ShowAll= 0; else - this->ShowAll = -1; + this->ShowAll= -1; return this->ShowAll; @@ -672,45 +512,48 @@ FANCONTROL::ShowAllFromDialog() { void -FANCONTROL::ModeToDialog(int mode) { - ::SendDlgItemMessage(this->hwndDialog, 8300, BM_SETCHECK, mode == 1, 0L); - ::SendDlgItemMessage(this->hwndDialog, 8301, BM_SETCHECK, mode == 2, 0L); - ::SendDlgItemMessage(this->hwndDialog, 8302, BM_SETCHECK, mode == 3, 0L); +FANCONTROL::ModeToDialog(int mode) +{ + ::SendDlgItemMessage(this->hwndDialog, 8300, BM_SETCHECK, mode==1, 0L); + ::SendDlgItemMessage(this->hwndDialog, 8301, BM_SETCHECK, mode==2, 0L); + ::SendDlgItemMessage(this->hwndDialog, 8302, BM_SETCHECK, mode==3, 0L); } void -FANCONTROL::ShowAllToDialog(int show) { - ::SendDlgItemMessage(this->hwndDialog, 7001, BM_SETCHECK, show == 1, 0L); - ::SendDlgItemMessage(this->hwndDialog, 7002, BM_SETCHECK, show == 0, 0L); +FANCONTROL::ShowAllToDialog(int show) +{ + ::SendDlgItemMessage(this->hwndDialog, 7001, BM_SETCHECK, show==1, 0L); + ::SendDlgItemMessage(this->hwndDialog, 7002, BM_SETCHECK, show==0, 0L); } //------------------------------------------------------------------------- // process main dialog //------------------------------------------------------------------------- -int FANCONTROL::ProcessDialog() { +int FANCONTROL::ProcessDialog() +{ MSG qmsg, qmsg2; - int dlgrc = -1; + int dlgrc= -1; if (this->hwndDialog) { for (;;) { - BOOL nodlgmsg = FALSE; + BOOL nodlgmsg= FALSE; ::GetMessage(&qmsg, NULL, 0L, 0L); // control movements - if (qmsg.message != WM__DISMISSDLG && IsDialogMessage(this->hwndDialog, &qmsg)) { + if (qmsg.message!=WM__DISMISSDLG && IsDialogMessage(this->hwndDialog, &qmsg)) { continue; } - qmsg2 = qmsg; + qmsg2= qmsg; TranslateMessage(&qmsg); DispatchMessage(&qmsg); - if (qmsg2.message == WM__DISMISSDLG && qmsg2.hwnd == this->hwndDialog) { - dlgrc = qmsg2.wParam; + if (qmsg2.message==WM__DISMISSDLG && qmsg2.hwnd==this->hwndDialog) { + dlgrc= qmsg2.wParam; break; } } @@ -720,55 +563,40 @@ int FANCONTROL::ProcessDialog() { } + //------------------------------------------------------------------------- // dialog window procedure (map to class method) //------------------------------------------------------------------------- ULONG CALLBACK -FANCONTROL::BaseDlgProc(HWND - hwnd, - ULONG msg, WPARAM - mp1, - LPARAM mp2 -) +FANCONTROL::BaseDlgProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2) { - ULONG rc = FALSE; + ULONG rc= FALSE; static UINT s_TaskbarCreated; - if (msg == WM_INITDIALOG) + if (msg == WM_INITDIALOG) { s_TaskbarCreated = RegisterWindowMessage("TaskbarCreated"); } - FANCONTROL* This = (FANCONTROL*)GetWindowLong(hwnd, GWL_USERDATA); + FANCONTROL *This= (FANCONTROL*)GetWindowLong(hwnd, GWL_USERDATA); if (This) { if (msg == s_TaskbarCreated) - { - This-> - TaskbarNew = 1; + { This->TaskbarNew=1; if (This->pTaskbarIcon) { - This->pTaskbarIcon-> - RebuildIfNecessary(TRUE); + This->pTaskbarIcon->RebuildIfNecessary(TRUE); } else { - This-> - - RemoveTextIcons(); - - This-> - - ProcessTextIcons(); - - } + This->RemoveTextIcons(); + This->ProcessTextIcons();} } - rc = This->DlgProc(hwnd, msg, mp1, mp2); + rc= This->DlgProc(hwnd, msg, mp1, mp2); } - return - rc; + return rc; } @@ -777,270 +605,149 @@ FANCONTROL::BaseDlgProc(HWND // dialog window procedure as class method //------------------------------------------------------------------------- #define WANTED_MEM_SIZE 65536*12 -BOOL dioicon(TRUE); +BOOL dioicon (TRUE); char szBuffer[BUFFER_SIZE]; char str_value[256]; DWORD cbBytes; -BOOL bResult(FALSE); -BOOL lbResult(FALSE); +BOOL bResult (FALSE); +BOOL lbResult (FALSE); int fanspeed; int fanctrl; int IconFontSize; BOOL _piscreated(FALSE); -char obuftd[256] = "", obuftd2[128] = "", templisttd[512]; -char obuf[256] = "", obuf2[128] = "", templist2[512]; -ULONG -FANCONTROL::DlgProc(HWND - hwnd, - ULONG msg, WPARAM - mp1, - LPARAM mp2 -) +char obuftd[256]= "", obuftd2[128]="", templisttd[512]; +char obuf[256]= "", obuf2[128]="", templist2[512]; +ULONG +FANCONTROL::DlgProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2) { - ULONG rc = 0, ok, res; - char buf[1024]; - - // HANDLE hLockS = CreateMutex(NULL,FALSE,"TPFanControlMutex01"); + ULONG rc= 0, ok, res; +// HANDLE hLockS = CreateMutex(NULL,FALSE,"TPFanControlMutex01"); - switch (msg) { - - case WM_HOTKEY: - switch (mp1) { +switch (msg) { + case WM_HOTKEY: + switch (mp1){ case 1: - this->ModeToDialog(1); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - break; - + this->ModeToDialog(1); + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); + break; case 2: - this->ModeToDialog(2); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - break; - + this->ModeToDialog(2); + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); + break; case 3: - this->ModeToDialog(3); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - break; - + this->ModeToDialog(3); + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); + break; case 4: - this->ModeToDialog(2); - if (this->IndSmartLevel == 1) { - sprintf_s(obuf, - sizeof(obuf), "Activation of Fan Control Profile 'Smart Mode 1'"); - this-> - Trace(obuf); - } - this-> - IndSmartLevel = 0; - - for ( - int i = 0; - i < 32; i++) { - this->SmartLevels[i]. - temp = this->SmartLevels1[i].temp1; - this->SmartLevels[i]. - fan = this->SmartLevels1[i].fan1; - } - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - break; - - case 5: - this->ModeToDialog(2); - if (this->IndSmartLevel == 0) { - sprintf_s(obuf, - sizeof(obuf), "Activation of Fan Control Profile 'Smart Mode 2'"); - this-> - Trace(obuf); - } - this-> - IndSmartLevel = 1; - - for ( - int i = 0; - i < 32; i++) { - this->SmartLevels[i]. - temp = this->SmartLevels2[i].temp2; - this->SmartLevels[i]. - fan = this->SmartLevels2[i].fan2; - } - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - break; - - case 6: - if (this->CurrentMode > 1) { - this->ModeToDialog(1); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - } - - if (this->CurrentMode == 1) { - this->ModeToDialog(2); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - } - break; - - case 7: - if (this->CurrentMode > 1) { - this->ModeToDialog(1); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - } - if (this->CurrentMode == 1) { - this->ModeToDialog(3); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - } - break; - - case 8: - if (this->CurrentMode < 3) { - this->ModeToDialog(3); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - } - if (this->CurrentMode == 3) { - this->ModeToDialog(2); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - } - break; - - case 9: - this->ModeToDialog(2); - switch (IndSmartLevel) { - case 0: - sprintf_s(obuf, - sizeof(obuf), "Activation of Fan Control Profile 'Smart Mode 2'"); - this-> - Trace(obuf); - this-> - IndSmartLevel = 1; - for ( - int i = 0; - i < 32; i++) { - this->SmartLevels[i]. - temp = this->SmartLevels2[i].temp2; - this->SmartLevels[i]. - fan = this->SmartLevels2[i].fan2; - } - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); + this->ModeToDialog(2); + if (this->IndSmartLevel == 1) { + sprintf_s(obuf, sizeof(obuf), "Activation of Fan Control Profile 'Smart Mode 1'"); + this->Trace(obuf);} + this->IndSmartLevel = 0; + + for (int i= 0; i<32; i++) { + this->SmartLevels[i].temp = this->SmartLevels1[i].temp1; + this->SmartLevels[i].fan = this->SmartLevels1[i].fan1; + } + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); break; - case 1: - sprintf_s(obuf, - sizeof(obuf), "Activation of Fan Control Profile 'Smart Mode 1'"); - this-> - Trace(obuf); - this-> - IndSmartLevel = 0; - for ( - int i = 0; - i < 32; i++) { - this->SmartLevels[i]. - temp = this->SmartLevels1[i].temp1; - this->SmartLevels[i]. - fan = this->SmartLevels1[i].fan1; - } - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); + case 5: + this->ModeToDialog(2); + if (this->IndSmartLevel == 0) { + sprintf_s(obuf, sizeof(obuf), "Activation of Fan Control Profile 'Smart Mode 2'"); + this->Trace(obuf);} + this->IndSmartLevel = 1; + + for (int i= 0; i<32; i++) { + this->SmartLevels[i].temp = this->SmartLevels2[i].temp2; + this->SmartLevels[i].fan = this->SmartLevels2[i].fan2; + } + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); break; } - break; - } - - case WM_INITDIALOG: - // placing code here will NOT work! - // (put it into BaseDlgProc instead) - break; - - case WM_TIMER: - - switch (mp1) - { - - case 1: // update fan state - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - if (this->Log2csv == 1) - { - this->Tracecsv(this->CurrentStatuscsv); - } - break; - - case 2: // update window title + case WM_INITDIALOG: + // placing code here will NOT work! + // (put it into BaseDlgProc instead) + break; - // skip ManMode? - if (this->CurrentMode == 3 && this->MaxTemp > this->ManModeExit2) { - this->ModeToDialog(2); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - } + case WM_TIMER: - res = this->IsMinimized(); - if ( - res && strcmp(this->LastTitle, this->Title2) - != 0) - { - strcpy_s(this->LastTitle, sizeof(this->LastTitle), this->Title2); - } - else - if (! - res && strcmp(this->LastTitle, this->Title) - != 0) + switch (mp1) { - ::SetWindowText(this->hwndDialog, this->Title); - strcpy_s(this->LastTitle, sizeof(this->LastTitle), this->Title); - } - if (this->pTaskbarIcon) - { - this->pTaskbarIcon->SetTooltip(this->Title2); - strcpy_s(this->LastTooltip, sizeof(this->LastTooltip), this->Title2); - int icon = -1; + case 1: // update fan state + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); + if (this->Log2csv==1) + { + this->Tracecsv(this->CurrentStatuscsv); + } + break; - if (this-> - CurrentModeFromDialog() + case 2: // update window title - == 1) - { - icon = 10; // gray - } - else - { - icon = 11; // blue - for ( - int i = 0; - i < ARRAYMAX(this->IconLevels); i++) - { - if (this->MaxTemp >= this->IconLevels[i]) + // skip ManMode? + if (this->CurrentMode == 3 && this->MaxTemp > this->ManModeExit2){ + this->ModeToDialog(2); + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0);} + + res= this->IsMinimized(); + if (res && strcmp(this->LastTitle, this->Title2)!=0) { - icon = 12 + i; // yellow, orange, red + strcpy_s(this->LastTitle,sizeof(this->LastTitle), this->Title2); + } + else + if (!res && strcmp(this->LastTitle, this->Title)!=0) + { + ::SetWindowText(this->hwndDialog, this->Title); + strcpy_s(this->LastTitle,sizeof(this->LastTitle), this->Title); } - } - } - - - if (icon != this-> - CurrentIcon && icon - != -1) - { - this->pTaskbarIcon-> - SetIcon(icon); - this-> - CurrentIcon = icon; - if (dioicon && !this->NoBallons) { - this->pTaskbarIcon->SetBalloon(NIIF_INFO, "TPFanControl old symbol icon", - "shows temperature level by color and state in tooltip, left click on icon shows or hides control window, right click shows menue", - 11); - dioicon = FALSE; - } - } - this-> - iFarbeIconB = icon; - } - break; - case 3: // update vista icon + if (this->pTaskbarIcon) + { + this->pTaskbarIcon->SetTooltip(this->Title2); + strcpy_s(this->LastTooltip, sizeof(this->LastTooltip), this->Title2); + int icon= -1; + + if (this->CurrentModeFromDialog()==1) + { + icon= 10; // gray + } + else + { + icon= 11; // blue + for (int i= 0; iIconLevels); i++) + { + if (this->MaxTemp>=this->IconLevels[i]) + { + icon= 12+i; // yellow, orange, red + } + } + } + + + if (icon!=this->CurrentIcon && icon!=-1) + { + this->pTaskbarIcon->SetIcon(icon); + this->CurrentIcon= icon; + if (dioicon && !this->NoBallons) { + this->pTaskbarIcon->SetBalloon(NIIF_INFO, "TPFanControl old symbol icon", + "shows temperature level by color and state in tooltip, left click on icon shows or hides control window, right click shows menue", + 11); + dioicon = FALSE;} + + } + this->iFarbeIconB = icon; + } + break; + case 3: // update vista icon - //************************************************************************************* - //begin named pipe client session - // - if (bResult == - FALSE && lbResult - == TRUE) +//************************************************************************************* +//begin named pipe client session +// + if (bResult == FALSE && lbResult == TRUE) { _piscreated = FALSE; lbResult = FALSE; @@ -1054,222 +761,208 @@ FANCONTROL::DlgProc(HWND CloseHandle(hPipe6); CloseHandle(hPipe7); } - + if (_piscreated == FALSE) { hPipe0 = CreateNamedPipe - ( - g_szPipeName, // pipe name - PIPE_ACCESS_OUTBOUND, // write access - PIPE_TYPE_MESSAGE | // message type pipe - PIPE_READMODE_MESSAGE | // message-read mode - PIPE_NOWAIT, // blocking mode + ( + g_szPipeName, // pipe name + PIPE_ACCESS_OUTBOUND, // write access + PIPE_TYPE_MESSAGE | // message type pipe + PIPE_READMODE_MESSAGE | // message-read mode + PIPE_NOWAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // max. instances - BUFFER_SIZE, // output buffer size - BUFFER_SIZE, // input buffer size - NMPWAIT_USE_DEFAULT_WAIT, // client time-out - NULL); // default security attribute + BUFFER_SIZE, // output buffer size + BUFFER_SIZE, // input buffer size + NMPWAIT_USE_DEFAULT_WAIT, // client time-out + NULL); // default security attribute hPipe1 = CreateNamedPipe - ( - g_szPipeName, // pipe name - PIPE_ACCESS_OUTBOUND, // write access - PIPE_TYPE_MESSAGE | // message type pipe - PIPE_READMODE_MESSAGE | // message-read mode - PIPE_NOWAIT, // blocking mode + ( + g_szPipeName, // pipe name + PIPE_ACCESS_OUTBOUND, // write access + PIPE_TYPE_MESSAGE | // message type pipe + PIPE_READMODE_MESSAGE | // message-read mode + PIPE_NOWAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // max. instances - BUFFER_SIZE, // output buffer size - BUFFER_SIZE, // input buffer size - NMPWAIT_USE_DEFAULT_WAIT, // client time-out - NULL); // default security attribute + BUFFER_SIZE, // output buffer size + BUFFER_SIZE, // input buffer size + NMPWAIT_USE_DEFAULT_WAIT, // client time-out + NULL); // default security attribute hPipe2 = CreateNamedPipe - ( - g_szPipeName, // pipe name - PIPE_ACCESS_OUTBOUND, // write access - PIPE_TYPE_MESSAGE | // message type pipe - PIPE_READMODE_MESSAGE | // message-read mode - PIPE_NOWAIT, // blocking mode + ( + g_szPipeName, // pipe name + PIPE_ACCESS_OUTBOUND, // write access + PIPE_TYPE_MESSAGE | // message type pipe + PIPE_READMODE_MESSAGE | // message-read mode + PIPE_NOWAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // max. instances - BUFFER_SIZE, // output buffer size - BUFFER_SIZE, // input buffer size - NMPWAIT_USE_DEFAULT_WAIT, // client time-out - NULL); // default security attribute + BUFFER_SIZE, // output buffer size + BUFFER_SIZE, // input buffer size + NMPWAIT_USE_DEFAULT_WAIT, // client time-out + NULL); // default security attribute hPipe3 = CreateNamedPipe - ( - g_szPipeName, // pipe name - PIPE_ACCESS_OUTBOUND, // write access - PIPE_TYPE_MESSAGE | // message type pipe - PIPE_READMODE_MESSAGE | // message-read mode - PIPE_NOWAIT, // blocking mode + ( + g_szPipeName, // pipe name + PIPE_ACCESS_OUTBOUND, // write access + PIPE_TYPE_MESSAGE | // message type pipe + PIPE_READMODE_MESSAGE | // message-read mode + PIPE_NOWAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // max. instances - BUFFER_SIZE, // output buffer size - BUFFER_SIZE, // input buffer size - NMPWAIT_USE_DEFAULT_WAIT, // client time-out - NULL); // default security attribute + BUFFER_SIZE, // output buffer size + BUFFER_SIZE, // input buffer size + NMPWAIT_USE_DEFAULT_WAIT, // client time-out + NULL); // default security attribute hPipe4 = CreateNamedPipe - ( - g_szPipeName, // pipe name - PIPE_ACCESS_OUTBOUND, // write access - PIPE_TYPE_MESSAGE | // message type pipe - PIPE_READMODE_MESSAGE | // message-read mode - PIPE_NOWAIT, // blocking mode + ( + g_szPipeName, // pipe name + PIPE_ACCESS_OUTBOUND, // write access + PIPE_TYPE_MESSAGE | // message type pipe + PIPE_READMODE_MESSAGE | // message-read mode + PIPE_NOWAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // max. instances - BUFFER_SIZE, // output buffer size - BUFFER_SIZE, // input buffer size - NMPWAIT_USE_DEFAULT_WAIT, // client time-out - NULL); // default security attribute + BUFFER_SIZE, // output buffer size + BUFFER_SIZE, // input buffer size + NMPWAIT_USE_DEFAULT_WAIT, // client time-out + NULL); // default security attribute hPipe5 = CreateNamedPipe - ( - g_szPipeName, // pipe name - PIPE_ACCESS_OUTBOUND, // write access - PIPE_TYPE_MESSAGE | // message type pipe - PIPE_READMODE_MESSAGE | // message-read mode - PIPE_NOWAIT, // blocking mode + ( + g_szPipeName, // pipe name + PIPE_ACCESS_OUTBOUND, // write access + PIPE_TYPE_MESSAGE | // message type pipe + PIPE_READMODE_MESSAGE | // message-read mode + PIPE_NOWAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // max. instances - BUFFER_SIZE, // output buffer size - BUFFER_SIZE, // input buffer size - NMPWAIT_USE_DEFAULT_WAIT, // client time-out - NULL); // default security attribute + BUFFER_SIZE, // output buffer size + BUFFER_SIZE, // input buffer size + NMPWAIT_USE_DEFAULT_WAIT, // client time-out + NULL); // default security attribute hPipe6 = CreateNamedPipe - ( - g_szPipeName, // pipe name - PIPE_ACCESS_OUTBOUND, // write access - PIPE_TYPE_MESSAGE | // message type pipe - PIPE_READMODE_MESSAGE | // message-read mode - PIPE_NOWAIT, // blocking mode + ( + g_szPipeName, // pipe name + PIPE_ACCESS_OUTBOUND, // write access + PIPE_TYPE_MESSAGE | // message type pipe + PIPE_READMODE_MESSAGE | // message-read mode + PIPE_NOWAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // max. instances - BUFFER_SIZE, // output buffer size - BUFFER_SIZE, // input buffer size - NMPWAIT_USE_DEFAULT_WAIT, // client time-out - NULL); // default security attribute + BUFFER_SIZE, // output buffer size + BUFFER_SIZE, // input buffer size + NMPWAIT_USE_DEFAULT_WAIT, // client time-out + NULL); // default security attribute hPipe7 = CreateNamedPipe - ( - g_szPipeName, // pipe name - PIPE_ACCESS_OUTBOUND, // write access - PIPE_TYPE_MESSAGE | // message type pipe - PIPE_READMODE_MESSAGE | // message-read mode - PIPE_NOWAIT, // blocking mode + ( + g_szPipeName, // pipe name + PIPE_ACCESS_OUTBOUND, // write access + PIPE_TYPE_MESSAGE | // message type pipe + PIPE_READMODE_MESSAGE | // message-read mode + PIPE_NOWAIT, // blocking mode PIPE_UNLIMITED_INSTANCES, // max. instances - BUFFER_SIZE, // output buffer size - BUFFER_SIZE, // input buffer size - NMPWAIT_USE_DEFAULT_WAIT, // client time-out - NULL); // default security attribute - - if (INVALID_HANDLE_VALUE == hPipe0) { - this->Trace("Creating Named Pipe client GUI was NOT successful."); - ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0); - } - if (INVALID_HANDLE_VALUE == hPipe1) { - this->Trace("Creating Named Pipe client GUI was NOT successful."); - ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0); - } - if (INVALID_HANDLE_VALUE == hPipe2) { - this->Trace("Creating Named Pipe client GUI was NOT successful."); - ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0); - } - if (INVALID_HANDLE_VALUE == hPipe3) { - this->Trace("Creating Named Pipe client GUI was NOT successful."); - ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0); - } - if (INVALID_HANDLE_VALUE == hPipe4) { - this->Trace("Creating Named Pipe client GUI was NOT successful."); - ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0); - } - if (INVALID_HANDLE_VALUE == hPipe5) { - this->Trace("Creating Named Pipe client GUI was NOT successful."); - ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0); - } - if (INVALID_HANDLE_VALUE == hPipe6) { - this->Trace("Creating Named Pipe client GUI was NOT successful."); - ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0); - } - if (INVALID_HANDLE_VALUE == hPipe7) { - this->Trace("Creating Named Pipe client GUI was NOT successful."); - ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0); - } - - _piscreated = TRUE; + BUFFER_SIZE, // output buffer size + BUFFER_SIZE, // input buffer size + NMPWAIT_USE_DEFAULT_WAIT, // client time-out + NULL); // default security attribute + + if (INVALID_HANDLE_VALUE == hPipe0){ + this->Trace("Creating Named Pipe client GUI was NOT successful."); + ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0);} + if (INVALID_HANDLE_VALUE == hPipe1){ + this->Trace("Creating Named Pipe client GUI was NOT successful."); + ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0);} + if (INVALID_HANDLE_VALUE == hPipe2){ + this->Trace("Creating Named Pipe client GUI was NOT successful."); + ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0);} + if (INVALID_HANDLE_VALUE == hPipe3){ + this->Trace("Creating Named Pipe client GUI was NOT successful."); + ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0);} + if (INVALID_HANDLE_VALUE == hPipe4){ + this->Trace("Creating Named Pipe client GUI was NOT successful."); + ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0);} + if (INVALID_HANDLE_VALUE == hPipe5){ + this->Trace("Creating Named Pipe client GUI was NOT successful."); + ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0);} + if (INVALID_HANDLE_VALUE == hPipe6){ + this->Trace("Creating Named Pipe client GUI was NOT successful."); + ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0);} + if (INVALID_HANDLE_VALUE == hPipe7){ + this->Trace("Creating Named Pipe client GUI was NOT successful."); + ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0);} + + _piscreated = TRUE; } - // fan speed - if (Fahrenheit) { - if (fanspeed > 0x1fff) - fanspeed = lastfanspeed; - sprintf_s(str_value, - sizeof(str_value), "%d %d %s %d %d %d ", - this->CurrentMode, (this->MaxTemp * 9 / 5 + 32), this->gSensorNames[iMaxTemp], + // fan speed + if(Fahrenheit){ + if (fanspeed > 0x1fff) fanspeed = lastfanspeed; + sprintf_s(str_value, sizeof(str_value),"%d %d %s %d %d %d ", + this->CurrentMode,(this->MaxTemp* 9 /5 +32),this->gSensorNames[iMaxTemp], iFarbeIconB, fanspeed, fanctrl2); } else { - if (fanspeed > 0x1fff) - fanspeed = lastfanspeed; - sprintf_s(str_value, - sizeof(str_value), "%d %d %s %d %d %d ", - this->CurrentMode, (this->MaxTemp), this->gSensorNames[iMaxTemp], + if (fanspeed > 0x1fff) fanspeed = lastfanspeed; + sprintf_s(str_value, sizeof(str_value),"%d %d %s %d %d %d ", + this->CurrentMode,(this->MaxTemp),this->gSensorNames[iMaxTemp], iFarbeIconB, fanspeed, fanctrl2); } - strcpy_s(szBuffer, str_value - ); //write buffer - - - - //send to client - lbResult = bResult; - bResult = WriteFile - ( - hPipe0, // handle to pipe - szBuffer, // buffer to write from - strlen(szBuffer) + 1, // number of bytes to write, include the NULL - &cbBytes, // number of bytes written - NULL); // not overlapped I/O - bResult = WriteFile - ( - hPipe1, // handle to pipe - szBuffer, // buffer to write from - strlen(szBuffer) + 1, // number of bytes to write, include the NULL - &cbBytes, // number of bytes written - NULL); // not overlapped I/O - bResult = WriteFile - ( - hPipe2, // handle to pipe - szBuffer, // buffer to write from - strlen(szBuffer) + 1, // number of bytes to write, include the NULL - &cbBytes, // number of bytes written - NULL); // not overlapped I/O - bResult = WriteFile - ( - hPipe3, // handle to pipe - szBuffer, // buffer to write from - strlen(szBuffer) + 1, // number of bytes to write, include the NULL - &cbBytes, // number of bytes written - NULL); // not overlapped I/O - bResult = WriteFile - ( - hPipe4, // handle to pipe - szBuffer, // buffer to write from - strlen(szBuffer) + 1, // number of bytes to write, include the NULL - &cbBytes, // number of bytes written - NULL); // not overlapped I/O - bResult = WriteFile - ( - hPipe5, // handle to pipe - szBuffer, // buffer to write from - strlen(szBuffer) + 1, // number of bytes to write, include the NULL - &cbBytes, // number of bytes written - NULL); // not overlapped I/O - bResult = WriteFile - ( - hPipe6, // handle to pipe - szBuffer, // buffer to write from - strlen(szBuffer) + 1, // number of bytes to write, include the NULL - &cbBytes, // number of bytes written - NULL); // not overlapped I/O - bResult = WriteFile - ( - hPipe7, // handle to pipe - szBuffer, // buffer to write from - strlen(szBuffer) + 1, // number of bytes to write, include the NULL - &cbBytes, // number of bytes written - NULL); // not overlapped I/O + strcpy_s(szBuffer,str_value); //write buffer + + + //send to client + lbResult = bResult; + bResult = WriteFile + ( + hPipe0, // handle to pipe + szBuffer, // buffer to write from + strlen(szBuffer)+1, // number of bytes to write, include the NULL + &cbBytes, // number of bytes written + NULL); // not overlapped I/O + bResult = WriteFile + ( + hPipe1, // handle to pipe + szBuffer, // buffer to write from + strlen(szBuffer)+1, // number of bytes to write, include the NULL + &cbBytes, // number of bytes written + NULL); // not overlapped I/O + bResult = WriteFile + ( + hPipe2, // handle to pipe + szBuffer, // buffer to write from + strlen(szBuffer)+1, // number of bytes to write, include the NULL + &cbBytes, // number of bytes written + NULL); // not overlapped I/O + bResult = WriteFile + ( + hPipe3, // handle to pipe + szBuffer, // buffer to write from + strlen(szBuffer)+1, // number of bytes to write, include the NULL + &cbBytes, // number of bytes written + NULL); // not overlapped I/O + bResult = WriteFile + ( + hPipe4, // handle to pipe + szBuffer, // buffer to write from + strlen(szBuffer)+1, // number of bytes to write, include the NULL + &cbBytes, // number of bytes written + NULL); // not overlapped I/O + bResult = WriteFile + ( + hPipe5, // handle to pipe + szBuffer, // buffer to write from + strlen(szBuffer)+1, // number of bytes to write, include the NULL + &cbBytes, // number of bytes written + NULL); // not overlapped I/O + bResult = WriteFile + ( + hPipe6, // handle to pipe + szBuffer, // buffer to write from + strlen(szBuffer)+1, // number of bytes to write, include the NULL + &cbBytes, // number of bytes written + NULL); // not overlapped I/O + bResult = WriteFile + ( + hPipe7, // handle to pipe + szBuffer, // buffer to write from + strlen(szBuffer)+1, // number of bytes to write, include the NULL + &cbBytes, // number of bytes written + NULL); // not overlapped I/O //end named pipe client session // @@ -1278,344 +971,273 @@ FANCONTROL::DlgProc(HWND break; - case 4: // renew tempicon - if ( - ShowTempIcon && ReIcCycle - ) { - this-> - - RemoveTextIcons(); - - this-> - - ProcessTextIcons(); - - } - break; + case 4: // renew tempicon + if (ShowTempIcon && ReIcCycle) { + this->RemoveTextIcons(); + this->ProcessTextIcons();} + break; - default: + default: break; } // End switch mp1 - if (this->ShowTempIcon == 1) - { - this-> - - ProcessTextIcons(); //icon Einstieg - } - else { - this-> + if (this->ShowTempIcon==1) + { + this->ProcessTextIcons(); //icon Einstieg + } + else {this->RemoveTextIcons();} - RemoveTextIcons(); + // say windows not to hold much more memspace + // SetProcessWorkingSetSize(GetCurrentProcess(),65536,WANTED_MEM_SIZE); + break; - } - // say windows not to hold much more memspace - // SetProcessWorkingSetSize(GetCurrentProcess(),65536,WANTED_MEM_SIZE); - break; + case WM_COMMAND: + if (HIWORD(mp1)==BN_CLICKED || HIWORD(mp1)==EN_CHANGE) + { + int cmd= LOWORD(mp1); + //display temperature list - case WM_COMMAND: - if ( - HIWORD(mp1) - == BN_CLICKED || - HIWORD(mp1) - == EN_CHANGE) + char obuf[256]= "", obuf2[128]="", templist2[512]; + + strcpy_s(templist2,sizeof(templist2), ""); + + if(cmd==7001 || cmd==7002) { - int cmd = LOWORD(mp1); + this->ShowAllFromDialog(); + int i; + for (i= 0; i<12; i++) + { + int temp= this->State.Sensors[i]; - //display temperature list + if (temp < 128 && temp!= 0) + { + if (Fahrenheit) + sprintf_s(obuf2,sizeof(obuf2), "%d°F", temp* 9 /5 +32); + else + sprintf_s(obuf2, sizeof(obuf2), "%d°C", temp); - char obuf[256] = "", obuf2[128] = "", templist2[512]; + size_t strlen_templist2 = strlen_s(templist2,sizeof(templist2)); - strcpy_s(templist2, - sizeof(templist2), ""); + if (SlimDialog && StayOnTop) + sprintf_s(templist2+strlen_templist2,sizeof(templist2)-strlen_templist2, + "%d %s %s (0x%02x)", i+1,this->State.SensorName[i], + obuf2, this->State.SensorAddr[i]); + else + sprintf_s(templist2+strlen_templist2,sizeof(templist2)-strlen_templist2, + "%d %s %s", i+1,this->State.SensorName[i], + obuf2); - if (cmd == 7001 || cmd == 7002) - { - this-> - ShowAllFromDialog(); - int i; - for ( - i = 0; - i < 12; i++) + strcat_s(templist2,sizeof(templist2), "\r\n"); + } + else { - int temp = this->State.Sensors[i]; - - if (temp < 128 && temp != 0) - { - if (Fahrenheit) - sprintf_s(obuf2, - sizeof(obuf2), "%d° F", temp * 9 / 5 + 32); - else - sprintf_s(obuf2, - sizeof(obuf2), "%d° C", temp); - - size_t strlen_templist2 = strlen_s(templist2, sizeof(templist2)); - - if ( - SlimDialog && StayOnTop - ) - sprintf_s(templist2 - + strlen_templist2, sizeof(templist2) - strlen_templist2, - "%d %s %s (0x%02x)", i + 1, this->State.SensorName[i], - obuf2, this->State.SensorAddr[i]); - else - sprintf_s(templist2 - + strlen_templist2, sizeof(templist2) - strlen_templist2, - "%d %s %s", i + 1, this->State.SensorName[i], - obuf2); - - - strcat_s(templist2, - sizeof(templist2), "\r\n"); - } - else + if (this->ShowAll==1) { - if (this->ShowAll == 1) - { - sprintf_s(obuf2, - sizeof(obuf2), "n/a"); - size_t strlen_templist2 = strlen_s(templist2, sizeof(templist2)); - - if ( - SlimDialog && StayOnTop - ) - sprintf_s(templist2 - + strlen_templist2, sizeof(templist2) - strlen_templist2, - "%d %s %s (0x%02x)", i + 1, this->State.SensorName[i], - obuf2, this->State.SensorAddr[i]); - else - sprintf_s(templist2 - + strlen_templist2, sizeof(templist2) - strlen_templist2, - "%d %s %s", i + 1, this->State.SensorName[i], - obuf2); - - strcat_s(templist2, - sizeof(templist2), "\r\n"); - } + sprintf_s(obuf2, sizeof(obuf2), "n/a"); + size_t strlen_templist2 = strlen_s(templist2,sizeof(templist2)); + + if (SlimDialog && StayOnTop) + sprintf_s(templist2+strlen_templist2,sizeof(templist2)-strlen_templist2, + "%d %s %s (0x%02x)", i+1,this->State.SensorName[i], + obuf2, this->State.SensorAddr[i]); + else + sprintf_s(templist2+strlen_templist2,sizeof(templist2)-strlen_templist2, + "%d %s %s", i+1,this->State.SensorName[i], + obuf2); + + strcat_s(templist2,sizeof(templist2), "\r\n"); } } - ::SetDlgItemText(this->hwndDialog, 8101, templist2); - this-> - icontemp = this->State.Sensors[iMaxTemp]; - }; - //end temp display + } + ::SetDlgItemText(this->hwndDialog, 8101, templist2); + this->icontemp= this->State.Sensors[iMaxTemp]; + }; +//end temp display - if (cmd >= 8300 && cmd <= 8302 || cmd == 8310) { // radio button or manual speed entry - ::PostMessage(hwnd, WM__GETDATA, 0, 0); - } - else - switch (cmd) { - case 5001: // bios - this->ModeToDialog(1); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - break; - - case 5002: // smart - this->ModeToDialog(2); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - break; - - case 5003: // smart1 - this->ModeToDialog(2); - if (this->IndSmartLevel == 1) { - sprintf_s(obuf - + - strlen(obuf), - sizeof(obuf) - - strlen(obuf), - "Activation of Fan Control Profile 'Smart Mode 1'"); - this-> - Trace(obuf); - } - this-> - IndSmartLevel = 0; - // rüberkopieren - for ( - int i = 0; - i < 32; i++) { - this->SmartLevels[i]. - temp = this->SmartLevels1[i].temp1; - this->SmartLevels[i]. - fan = this->SmartLevels1[i].fan1; - } - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - break; - - case 5004: // smart2 - this->ModeToDialog(2); - if (this->IndSmartLevel == 0) { - sprintf_s(obuf - + - strlen(obuf), - sizeof(obuf) - - strlen(obuf), - "Activation of Fan Control Profile 'Smart Mode 2'"); - this-> - Trace(obuf); - } - this-> - IndSmartLevel = 1; - - for ( - int i = 0; - i < 32; i++) { - this->SmartLevels[i]. - temp = this->SmartLevels2[i].temp2; - this->SmartLevels[i]. - fan = this->SmartLevels2[i].fan2; + if (cmd>=8300 && cmd<=8302 || cmd==8310 ) { // radio button or manual speed entry + ::PostMessage(hwnd, WM__GETDATA, 0, 0); } - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - break; - - case 5005: // manual - this->ModeToDialog(3); - ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); - break; - - - case 5010: // show window - ::ShowWindow(this->hwndDialog, TRUE); - ::SetForegroundWindow(this->hwndDialog); - break; - - case 5040: // show window - if (BluetoothEDR) this->SetHdw("Bluetooth", 16, 58, 32); - else this->SetHdw("Bluetooth", 32, 59, 16); - break; - - case 5050: // donate - ::ShellExecute(NULL, - "open", Title5, - NULL, NULL, SW_SHOW); - break; - - case 5070: // show temp icon - this-> - ShowTempIcon = 0; - this-> - pTaskbarIcon = new TASKBARICON(this->hwndDialog, 10, "TPFanControl"); - this->pTaskbarIcon->SetIcon(this->CurrentIcon); - break; - - case 5080: // show temp icon - delete this-> - pTaskbarIcon; - this-> - pTaskbarIcon = NULL; - this-> - ShowTempIcon = 1; - break; - - case 5030: // hide window - ::ShowWindow(this->hwndDialog, SW_MINIMIZE); - break; - - case 5020: // end program - // Wait for the work thread to terminate - if (this->hThread) { - ::WaitForSingleObject(this->hThread, INFINITE); - } - if (!this->EcAccess.Lock(100)) - { - // Something is going on, let's do this later - this->Trace("Delaying close"); - m_needClose = true; + else + switch (cmd) { + case 5001: // bios + this->ModeToDialog(1); + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); break; - } + case 5002: // smart + this->ModeToDialog(2); + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); + break; + + case 5003: // smart1 + this->ModeToDialog(2); + if (this->IndSmartLevel == 1) { + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Activation of Fan Control Profile 'Smart Mode 1'"); + this->Trace(obuf);} + this->IndSmartLevel = 0; +// rüberkopieren + for (int i= 0; i<32; i++) { + this->SmartLevels[i].temp = this->SmartLevels1[i].temp1; + this->SmartLevels[i].fan = this->SmartLevels1[i].fan1; + } + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); + break; - // don't close if we can't set the fan back to bios controlled - if (!this->ActiveMode || this->SetFan("On close", 0x80, true)) { - ::KillTimer(this->hwndDialog, m_fanTimer); - ::KillTimer(this->hwndDialog, m_titleTimer); - ::KillTimer(this->hwndDialog, m_iconTimer); - ::KillTimer(this->hwndDialog, m_renewTimer); - BOOL CloHT = CloseHandle(this->hThread); - // BOOL CloHM=CloseHandle(this->hLock); - // BOOL CloHS=CloseHandle(this->hLockS); - this->Trace("Exiting ProcessDialog"); - ::PostMessage(hwnd, WM__DISMISSDLG, IDCANCEL, 0); // exit from ProcessDialog() - } - else - { - m_needClose = true; - } - this->EcAccess. + case 5004: // smart2 + this->ModeToDialog(2); + if (this->IndSmartLevel == 0) { + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Activation of Fan Control Profile 'Smart Mode 2'"); + this->Trace(obuf);} + this->IndSmartLevel = 1; - Unlock(); + for (int i= 0; i<32; i++) { + this->SmartLevels[i].temp = this->SmartLevels2[i].temp2; + this->SmartLevels[i].fan = this->SmartLevels2[i].fan2; + } + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); + break; - break; + case 5005: // manual + this->ModeToDialog(3); + ::PostMessage(this->hwndDialog, WM__GETDATA, 0, 0); + break; + + + case 5010: // show window + ::ShowWindow(this->hwndDialog, TRUE); + ::SetForegroundWindow(this->hwndDialog); + break; + + case 5040: // show window + if (BluetoothEDR) this->SetHdw("Bluetooth", 16, 58, 32); + else this->SetHdw("Bluetooth", 32, 59, 16); + break; + + case 5050: // donate + ::ShellExecute(NULL, "open", Title5, + NULL, NULL, SW_SHOW); + break; + + case 5060: // hide window + this->SetHdw("Thinklight", 2, 59, 16); + break; + + case 5070: // show temp icon + this->ShowTempIcon = 0; + this->pTaskbarIcon = new TASKBARICON(this->hwndDialog, 10, "TPFanControl"); + this->pTaskbarIcon->SetIcon(this->CurrentIcon); + break; + + case 5080: // show temp icon + delete this->pTaskbarIcon; + this->pTaskbarIcon = NULL; + this->ShowTempIcon = 1; + break; + + case 5030: // hide window + ::ShowWindow(this->hwndDialog, SW_MINIMIZE); + break; + + case 5020: // end program + // Wait for the work thread to terminate + if (this->hThread) { + ::WaitForSingleObject(this->hThread, INFINITE); + } + if(!this->EcAccess.Lock(100)) + { + // Something is going on, let's do this later + this->Trace("Delaying close"); + m_needClose = true; + break; + } + + + // don't close if we can't set the fan back to bios controlled + if (!this->ActiveMode || this->SetFan("On close", 0x80, true)) { + ::KillTimer(this->hwndDialog, m_fanTimer); + ::KillTimer(this->hwndDialog, m_titleTimer); + ::KillTimer(this->hwndDialog, m_iconTimer); + ::KillTimer(this->hwndDialog, m_renewTimer); + BOOL CloHT=CloseHandle(this->hThread); +// BOOL CloHM=CloseHandle(this->hLock); +// BOOL CloHS=CloseHandle(this->hLockS); + this->Trace("Exiting ProcessDialog"); + ::PostMessage(hwnd, WM__DISMISSDLG, IDCANCEL, 0); // exit from ProcessDialog() + } + else + { + m_needClose = true; + } + this->EcAccess.Unlock(); + break; + } } - } - break; - - - case WM_CLOSE: - //if (this->MinimizeOnClose && (this->MinimizeToSysTray || this->Runs_as_service)) // 0.24 new: || this->Runs_as_service) - //{MessageBox(NULL, "will Fenster schließen", "TPFanControl", MB_ICONEXCLAMATION); - ::ShowWindow(this->hwndDialog, SW_MINIMIZE); //} - rc = TRUE; - break; - - - case WM_ENDSESSION: //WM_QUERYENDSESSION? - //if running as service do not end - if (!this->Runs_as_service) { - - // end program - // Wait for the work thread to terminate - if (this->hThread) { - ::WaitForSingleObject(this->hThread, INFINITE); - } - if (!this->EcAccess.Lock(100)) - { - // Something is going on, let's do this later - this->Trace("Delaying close"); - m_needClose = true; break; - } + + case WM_CLOSE: + //if (this->MinimizeOnClose && (this->MinimizeToSysTray || this->Runs_as_service)) // 0.24 new: || this->Runs_as_service) + //{MessageBox(NULL, "will Fenster schließen", "TPFanControl", MB_ICONEXCLAMATION); + ::ShowWindow(this->hwndDialog, SW_MINIMIZE); //} + rc= TRUE; + break; - // don't close if we can't set the fan back to bios controlled - if (!this->ActiveMode || this->SetFan("On close", 0x80, true)) { - ::KillTimer(this->hwndDialog, m_fanTimer); - ::KillTimer(this->hwndDialog, m_titleTimer); - ::KillTimer(this->hwndDialog, m_iconTimer); - ::KillTimer(this->hwndDialog, m_renewTimer); - BOOL CloHT = CloseHandle(this->hThread); - // BOOL CloHM=CloseHandle(this->hLock); - // BOOL CloHS=CloseHandle(this->hLockS); - this->Trace("Exiting ProcessDialog"); - ::PostMessage(hwnd, WM__DISMISSDLG, IDCANCEL, 0); // exit from ProcessDialog() - } - else - { - m_needClose = true; - } - this->EcAccess. - - Unlock(); - - } - break; + + case WM_ENDSESSION: //WM_QUERYENDSESSION? + //if running as service do not end + if(!this->Runs_as_service){ + + // end program + // Wait for the work thread to terminate + if (this->hThread) { + ::WaitForSingleObject(this->hThread, INFINITE); + } + if(!this->EcAccess.Lock(100)) + { + // Something is going on, let's do this later + this->Trace("Delaying close"); + m_needClose = true; + break; + } + + + // don't close if we can't set the fan back to bios controlled + if (!this->ActiveMode || this->SetFan("On close", 0x80, true)) { + ::KillTimer(this->hwndDialog, m_fanTimer); + ::KillTimer(this->hwndDialog, m_titleTimer); + ::KillTimer(this->hwndDialog, m_iconTimer); + ::KillTimer(this->hwndDialog, m_renewTimer); + BOOL CloHT=CloseHandle(this->hThread); +// BOOL CloHM=CloseHandle(this->hLock); +// BOOL CloHS=CloseHandle(this->hLockS); + this->Trace("Exiting ProcessDialog"); + ::PostMessage(hwnd, WM__DISMISSDLG, IDCANCEL, 0); // exit from ProcessDialog() + } + else + { + m_needClose = true; + } + this->EcAccess.Unlock(); + } + break; - // case WM_MOVE: - case WM_SIZE: - if (mp1 == SIZE_MINIMIZED && this->MinimizeToSysTray) { - ::ShowWindow(this->hwndDialog, FALSE); - } - rc = TRUE; - break; +// case WM_MOVE: + case WM_SIZE: + if (mp1==SIZE_MINIMIZED && this->MinimizeToSysTray) { + ::ShowWindow(this->hwndDialog, FALSE); + } + rc= TRUE; + break; - case WM_DESTROY: - break; + case WM_DESTROY: + break; @@ -1624,283 +1246,247 @@ FANCONTROL::DlgProc(HWND // USER messages // - case WM__GETDATA: - if (!this->hThread && !this->FinalSeen) - { - this-> - hThread = this->CreateThread(FANCONTROL_Thread, (ULONG) - this); - } - break; - - - case WM__NEWDATA: - if (this->hThread) { - ::WaitForSingleObject(this->hThread, INFINITE); - if (this->hThread) ::CloseHandle(this->hThread); - else { - this->Trace("Exception detected, closing to BIOS mode"); - ::SendMessage(this->hwndDialog, WM_ENDSESSION, 0, 0); - } - this-> - hThread = 0; - } - - ok = mp1; // equivalent of "ok= this->ReadEcStatus(&this->State);" via thread - - // Notifies program if pending suspension operation has occurred. - if (!DefWindowProc(this->hwndDialog, WM_POWERBROADCAST, PBT_APMSUSPEND, NULL)) { - this->Trace("Systen suspension detected, closing to BIOS mode"); - ::Sleep(1000); - ::SendMessage(this->hwndDialog, WM_ENDSESSION, 0, 0); - } - - if (ok) { - this-> - ReadErrorCount = 0; - this-> - - HandleData(); - - if (m_needClose) + case WM__GETDATA: + if (!this->hThread && !this->FinalSeen) { - this->Trace("Program needs to be closed, changing to BIOS mode"); - ::Sleep(1000); - ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0); - ::SendMessage(this->hwndDialog, WM_ENDSESSION, 0, 0); - m_needClose = false; - } - } - else { - sprintf_s(buf, - sizeof(buf), "Warning: can't read Status, read error count = %d", this->ReadErrorCount); - this-> - Trace(buf); - sprintf_s(buf, - sizeof(buf), "We will close to BIOS-Mode after %d consecutive read errors", this->MaxReadErrors); - this-> - Trace(buf); - this->ReadErrorCount++; - - // after so many consecutive read errors, try to switch back to bios mode - if (this->ReadErrorCount > this->MaxReadErrors) { - this->ModeToDialog(1); - ok = this->SetFan("Max. Errors", 0x80); - if (ok) { - this->Trace("Set to BIOS Mode, to many consecutive read errors"); - ::Sleep(2000); - ::SendMessage(this->hwndDialog, WM_ENDSESSION, 0, 0); - } - } - } - break; - - - case WM__TASKBAR: - - switch (mp2) { - - case WM_LBUTTONDOWN: - - if (!IsWindowVisible(this->hwndDialog)) { - ::ShowWindow(this->hwndDialog, TRUE); - ::SetForegroundWindow(this->hwndDialog); + this->hThread= this->CreateThread(FANCONTROL_Thread, (ULONG)this); } - else ::ShowWindow(this->hwndDialog, SW_MINIMIZE); break; - case WM_LBUTTONUP: - { - BOOL - isshift = ::GetAsyncKeyState(VK_SHIFT) & 0x8000, - isctrl = ::GetAsyncKeyState(VK_CONTROL) & 0x8000; - - int action = -1; - - // some fancy key dependent stuff could be done here. - } - break; - - - case WM_LBUTTONDBLCLK: - - if (!IsWindowVisible(this->hwndDialog)) { - ::ShowWindow(this->hwndDialog, TRUE); - ::SetForegroundWindow(this->hwndDialog); - } - else ::ShowWindow(this->hwndDialog, SW_MINIMIZE); - break; - - char testpara; - case WM_RBUTTONDOWN: - { - MENU m(5000); - - int ok_ecaccess = false; - for ( - int i = 0; - i < 10; i++) { - if ( - ok_ecaccess = this->EcAccess.Lock(100) - )break; - else ::Sleep(100); - } - - if (!ok_ecaccess) { - this->Trace("Could not acquire mutex to read BT/TL status"); - break; - } - - ok = this->ReadByteFromEC(59, &testpara); - if (testpara & 2) m.CheckMenuItem(5060); - - if (this->BluetoothEDR) { - ok = this->ReadByteFromEC(58, &testpara); - if (testpara & 16) m.CheckMenuItem(5040); - } - else { - ok = this->ReadByteFromEC(59, &testpara); - if (testpara & 32) m.CheckMenuItem(5040); - } - - int mode = this->CurrentModeFromDialog(); - if (mode == 1) { - m.CheckMenuItem(5001); + case WM__NEWDATA: + if (this->hThread) { + ::WaitForSingleObject(this->hThread, INFINITE); + ::CloseHandle(this->hThread); + this->hThread= 0; + } - if (this->ActiveMode == 0) { - m.DisableMenuItem(5002); // v0.25 - m.DisableMenuItem(5003); // v0.25 - m.DisableMenuItem(5004); // v0.25 - m.DisableMenuItem(5005); // v0.25 + ok= mp1; // equivalent of "ok= this->ReadEcStatus(&this->State);" via thread + + if (ok) { + this->ReadErrorCount= 0; + this->HandleData(); + if (m_needClose) + { + ::PostMessage(this->hwndDialog, WM_COMMAND, 5020, 0); + m_needClose = false; + } } - } - else + else { + this->Trace("Warning: Can't read Status (possible conflict with other software)"); + this->ReadErrorCount++; + + // after so many consecutive read errors, try to switch back to bios mode + if (this->ReadErrorCount>this->MaxReadErrors) { + this->ModeToDialog(1); + ok= this->SetFan("Max. Errors", 0x80); + if (ok) { + this->Trace("Set to BIOS Mode, to many consecutive read errors"); + // ::SendMessage(this->hwndDialog, WM_CLOSE, 0, 0); + } + } + } + break; - if (mode == 2) - m.CheckMenuItem(5002); - if (mode == 3) - m.CheckMenuItem(5005); + case WM__TASKBAR: - m.InsertItem(this->MenuLabelSM1, 5003, 10); - m.InsertItem(this->MenuLabelSM2, 5004, 11); + switch (mp2) { - if (this->SmartLevels2[0].temp2 == 0) - { - m.DeleteMenuItem(5003); - m.DeleteMenuItem(5004); - } + case WM_LBUTTONDOWN: - if (this->SmartLevels2[0].temp2 != 0) - { - m.DeleteMenuItem(5002); - - if (mode == 2 && this->IndSmartLevel == 0) - m.CheckMenuItem(5003); - - if (mode == 2 && this->IndSmartLevel != 0) - m.CheckMenuItem(5004); - } - - if (Runs_as_service) - m.DeleteMenuItem(5020); + if (!IsWindowVisible(this->hwndDialog)){ + ::ShowWindow(this->hwndDialog, TRUE); + ::SetForegroundWindow(this->hwndDialog); + } + else ::ShowWindow(this->hwndDialog, SW_MINIMIZE); + break; - if (!IsWindowVisible(this->hwndDialog)) - m.DeleteMenuItem(5030); + case WM_LBUTTONUP: + { + BOOL + isshift= ::GetAsyncKeyState(VK_SHIFT) & 0x8000, + isctrl= ::GetAsyncKeyState(VK_CONTROL) & 0x8000; - if (IsWindowVisible(this->hwndDialog)) - m.DeleteMenuItem(5010); + int action= -1; - if (this->ShowTempIcon == 0) - m.DeleteMenuItem(5070); + // some fancy key dependent stuff could be done here. - if (this->ShowTempIcon == 1) - m.DeleteMenuItem(5080); + } + break; - this->EcAccess. - Unlock(); + case WM_LBUTTONDBLCLK: - m.Popup(this->hwndDialog); - } - break; - } - rc = TRUE; - break; + if (!IsWindowVisible(this->hwndDialog)){ + ::ShowWindow(this->hwndDialog, TRUE); + ::SetForegroundWindow(this->hwndDialog); + } + else ::ShowWindow(this->hwndDialog, SW_MINIMIZE); + break; + + char testpara; + case WM_RBUTTONDOWN: + { + MENU m(5000); + + int ok_ecaccess = false; + for (int i = 0; i < 10; i++){ + if ( ok_ecaccess = this->EcAccess.Lock(100))break; + else ::Sleep(100); + } + + if (!ok_ecaccess){ + this->Trace("Could not acquire mutex to read BT/TL status"); + break; + } + + //ok= this->ReadByteFromEC(59, &testpara); + //if (testpara & 2) m.CheckMenuItem(5060); + + //if (this->BluetoothEDR){ + //ok= this->ReadByteFromEC(58, &testpara); + //if (testpara & 16) m.CheckMenuItem(5040); + //} + //else { + //ok= this->ReadByteFromEC(59, &testpara); + //if (testpara & 32) m.CheckMenuItem(5040); + //} + + int mode= this->CurrentModeFromDialog(); + if (mode==1){ + m.CheckMenuItem(5001); + + if (this->ActiveMode==0){ + m.DisableMenuItem(5002); // v0.25 + m.DisableMenuItem(5003); // v0.25 + m.DisableMenuItem(5004); // v0.25 + m.DisableMenuItem(5005); // v0.25 + } + } + else + + if (mode==2) + m.CheckMenuItem(5002); + + if (mode==3) + m.CheckMenuItem(5005); + + m.InsertItem (this->MenuLabelSM1, 5003, 10); + m.InsertItem (this->MenuLabelSM2, 5004, 11); + + if ( this->SmartLevels2[0].temp2 == 0 ) + { + m.DeleteMenuItem(5003); + m.DeleteMenuItem(5004); + } + + if ( this->SmartLevels2[0].temp2 != 0 ) + { + m.DeleteMenuItem(5002); + + if (mode == 2 && this->IndSmartLevel == 0 ) + m.CheckMenuItem(5003); + + if (mode == 2 && this->IndSmartLevel != 0 ) + m.CheckMenuItem(5004); + } + + if (Runs_as_service) + m.DeleteMenuItem(5020); + + if (!IsWindowVisible(this->hwndDialog)) + m.DeleteMenuItem(5030); + + if (IsWindowVisible(this->hwndDialog)) + m.DeleteMenuItem(5010); + + if (this->ShowTempIcon == 0) + m.DeleteMenuItem(5070); + + if (this->ShowTempIcon == 1) + m.DeleteMenuItem(5080); + + this->EcAccess.Unlock(); + + m.Popup(this->hwndDialog); + } + break; + } + rc= TRUE; + break; - default: - break; + default: + break; } - return - rc; + return rc; } + //------------------------------------------------------------------------- // reading the EC status may take a while, hence do it in a thread //------------------------------------------------------------------------- -int -FANCONTROL::WorkThread() { - int ok = this->ReadEcStatus(&this->State); +int +FANCONTROL::WorkThread() +{ + int ok= this->ReadEcStatus(&this->State); ::PostMessage(this->hwndDialog, WM__NEWDATA, ok, 0); return 0; } - // The texticons will be shown depending on variables static const int MAX_TEXT_ICONS = 16; int icon, oldicon; -BOOL dishow(TRUE); -TCHAR myszTip[64]; - -void FANCONTROL::ProcessTextIcons(void) { +BOOL dishow (TRUE); +TCHAR myszTip[64] ; +void FANCONTROL::ProcessTextIcons(void){ oldicon = icon; - if (this->CurrentModeFromDialog() == 1) { - icon = 10; // gray + if (this->CurrentModeFromDialog()==1) { + icon= 10; // gray } else { - icon = 11; // blue - for (int i = 0; i < ARRAYMAX(this->IconLevels); i++) { - if (this->MaxTemp >= this->IconLevels[i]) { - icon = 12 + i; // yellow, orange, red + icon= 11; // blue + for (int i= 0; iIconLevels); i++) { + if (this->MaxTemp>=this->IconLevels[i]) { + icon= 12+i; // yellow, orange, red } } } - + if (this->IconColorFan) { - switch (fanspeed / 1000) { - case 0: + switch (fanspeed/1000) { + case 0: break; - case 1: - icon = 21; //sehr hell grün + case 1: + icon = 21; //sehr hell grün break; - case 2: - icon = 22; //hell grün + case 2: + icon = 22; //hell grün break; - case 3: - icon = 23; //grün + case 3: + icon = 23; //grün break; - case 4: - icon = 24; //dunkel grün + case 4: + icon = 24; //dunkel grün break; - case 5: - icon = 25; //sehr dunkel grün + case 5: + icon = 25; //sehr dunkel grün break; - case 6: - icon = 25; //sehr dunkel grün + case 6: + icon = 25; //sehr dunkel grün break; - case 7: - icon = 25; //sehr dunkel grün + case 7: + icon = 25; //sehr dunkel grün break; - case 8: - icon = 25; //sehr dunkel grün + case 8: + icon = 25; //sehr dunkel grün break; - default: + default: icon = oldicon; break; }; @@ -1909,88 +1495,86 @@ void FANCONTROL::ProcessTextIcons(void) { this->iFarbeIconB = icon; - lstrcpyn(myszTip, this->Title2, sizeof(myszTip) - 1); - - if (pTextIconMutex->Lock(100)) { - //INIT ppTbTextIcon - if (!ppTbTextIcon || this->TaskbarNew) { - this->TaskbarNew = 0; - ppTbTextIcon = new CTaskbarTextIcon * [MAX_TEXT_ICONS]; - for (int i = 0; i < MAX_TEXT_ICONS; ++i) { - ppTbTextIcon[i] = NULL; - } - + lstrcpyn(myszTip, this->Title2, sizeof(myszTip)-1); + + if(pTextIconMutex->Lock(100)) + { + //INIT ppTbTextIcon + if(!ppTbTextIcon || this->TaskbarNew) + { this->TaskbarNew=0; + ppTbTextIcon = new CTaskbarTextIcon*[MAX_TEXT_ICONS]; + for(int i = 0;im_hinstapp, - this->hwndDialog, WM__TASKBAR, 0, "", - "", //WM_APP+5000 -> WM__TASKBAR - this->iFarbeIconB, this->iFontIconB, myszTip); + //erstmal nur eins - if (dishow && !this->NoBallons) { - if (Fahrenheit) { - ppTbTextIcon[0]->DiShowballon( - _T("shows max. temperature in ° F and sensor name, left click on icon shows or hides control window, right click shows menue"), - _T("TPFanControl new text icon"), NIIF_INFO, 11); + ppTbTextIcon[0] = new CTaskbarTextIcon(this->m_hinstapp, + this->hwndDialog,WM__TASKBAR,0,"","", //WM_APP+5000 -> WM__TASKBAR + this->iFarbeIconB, this->iFontIconB, myszTip); + + if (dishow && !this->NoBallons){ + if (Fahrenheit){ + ppTbTextIcon[0]->DiShowballon(_T("shows max. temperature in °F and sensor name, left click on icon shows or hides control window, right click shows menue"), + _T("TPFanControl new text icon"),NIIF_INFO,11); } else { - ppTbTextIcon[0]->DiShowballon( - _T("shows max. temperature in ° C and sensor name, left click on icon shows or hides control window, right click shows menue"), - _T("TPFanControl new text icon"), NIIF_INFO, 11); + ppTbTextIcon[0]->DiShowballon(_T("shows max. temperature in °C and sensor name, left click on icon shows or hides control window, right click shows menue"), + _T("TPFanControl new text icon"),NIIF_INFO,11); } - // Input: - // szText: [in] Text for the balloon tooltip. - // szTitle: [in] Title for the balloon. This text is shown in bold above - // the tooltip text (szText). Pass "" if you don't want a title. - // dwIcon: [in] Specifies an icon to appear in the balloon. Legal values are: - // NIIF_NONE: No icon - // NIIF_INFO: Information - // NIIF_WARNING: Exclamation - // NIIF_ERROR: Critical error (red circle with X) - // uTimeout: [in] Number of seconds for the balloon to remain visible. Can - // be between 10 and 30 inclusive. - // - - dishow = FALSE; - } - } +// Input: +// szText: [in] Text for the balloon tooltip. +// szTitle: [in] Title for the balloon. This text is shown in bold above +// the tooltip text (szText). Pass "" if you don't want a title. +// dwIcon: [in] Specifies an icon to appear in the balloon. Legal values are: +// NIIF_NONE: No icon +// NIIF_INFO: Information +// NIIF_WARNING: Exclamation +// NIIF_ERROR: Critical error (red circle with X) +// uTimeout: [in] Number of seconds for the balloon to remain visible. Can +// be between 10 and 30 inclusive. +// + dishow = FALSE;} + } + char str_value[256]; - // char buf[256]= ""; - // aktualisieren - for (int i = 0; i < MAX_TEXT_ICONS; ++i) { - if (ppTbTextIcon[i]) { - if (Fahrenheit) - _itoa_s((this->icontemp * 9 / 5) + 32, str_value, sizeof(str_value), 10); + // char buf[256]= ""; + // aktualisieren + for(int i = 0;iicontemp* 9/5)+32,str_value,sizeof(str_value),10); else - _itoa_s(this->icontemp, str_value, sizeof(str_value), 10); - sprintf_s(str_value, sizeof(str_value), "%s", str_value); - ppTbTextIcon[i]->ChangeText(str_value, this->gSensorNames[iMaxTemp], iFarbeIconB, iFontIconB, myszTip); - } - } - pTextIconMutex->Unlock(); - //this->Trace(LastTooltip); - } + _itoa_s(this->icontemp,str_value,sizeof(str_value),10); + sprintf_s(str_value, sizeof(str_value),"%s",str_value); + ppTbTextIcon[i]->ChangeText(str_value, this->gSensorNames[iMaxTemp],iFarbeIconB, iFontIconB, myszTip); + } + } + pTextIconMutex->Unlock(); +//this->Trace(LastTooltip); + } } void FANCONTROL::RemoveTextIcons(void) { - if (pTextIconMutex->Lock(10000)) { - if (ppTbTextIcon) { - for (int i = 0; i < MAX_TEXT_ICONS; ++i) { - if (ppTbTextIcon[i]) { - delete ppTbTextIcon[i]; - } - } - delete[] ppTbTextIcon; - ppTbTextIcon = NULL; - } - pTextIconMutex->Unlock(); - } - else { - _ASSERT(false);//Mutex not av within 10 sec - } + if(pTextIconMutex->Lock(10000)) { + if(ppTbTextIcon) { + for(int i = 0;iUnlock(); + } + else { + _ASSERT(false);//Mutex not av within 10 sec + } } diff --git a/fancontrol/fancontrol.h b/fancontrol/fancontrol.h index 590a4ac..53caba8 100644 --- a/fancontrol/fancontrol.h +++ b/fancontrol/fancontrol.h @@ -1,3 +1,4 @@ + // -------------------------------------------------------------- // // Thinkpad Fan Control @@ -19,7 +20,6 @@ #define FANCONTROL_H #include "_prec.h" - #pragma once @@ -27,7 +27,7 @@ #include "TaskbarTextIcon.h" -#define FANCONTROLVERSION "2.1.4 Dual Fan" +#define FANCONTROLVERSION "2.1.4a Dual Fan" #define WM__DISMISSDLG WM_USER+5 #define WM__GETDATA WM_USER+6 @@ -36,7 +36,7 @@ #define setzero(adr, size) memset((void*)(adr), (char)0x00, (size)) #define ARRAYMAX(tab) (sizeof(tab)/sizeof((tab)[0])) -#define NULLSTRUCT { 0, } +#define NULLSTRUCT { 0, } //begin named pipe TPFanControl01 #define g_szPipeName "\\\\.\\Pipe\\TPFanControl01" //Name given to the pipe @@ -46,241 +46,185 @@ #define ACK_MESG_RECV "Message received successfully" //end named pipe TPFanControl01 -class FANCONTROL { -protected: - HINSTANCE hinstapp; - HINSTANCE m_hinstapp; - HWND hwndDialog; - - UINT_PTR m_fanTimer; - UINT_PTR m_titleTimer; - UINT_PTR m_iconTimer; - UINT_PTR m_renewTimer; - - struct FCSTATE { - - char FanCtrl, - FanSpeedLo1, - FanSpeedHi1, - FanSpeedLo2, - FanSpeedHi2; - - char Sensors[12]; - int SensorAddr[12]; - const char* SensorName[12]; - - - } State; - - struct SMARTENTRY { - int temp, fan; - } SmartLevels[32]; - - struct SMARTENTRY1 { - int temp1, fan1; - } SmartLevels1[32]; - - struct SMARTENTRY2 { - int temp2, fan2; - } SmartLevels2[32]; - - struct FSMARTENTRY { //fahrenheit values - int ftemp, ffan; - } FSmartLevels[32]; - - - int IconLevels[3]; // temp levels for coloring the icon - int FIconLevels[3]; // fahrenheit temp levels for coloring the icon - int CurrentIcon; - int IndSmartLevel; - int SensorOffset[16]; - int FSensorOffset[16]; - int iFarbeIconB; - int iFontIconB; - int icontemp; - int Cycle; - int IconCycle; - int ReIcCycle; - int NoExtSensor; - int FanSpeedLowByte; - int ActiveMode, - UseTWR, - ManFanSpeed, - FinalSeen; - int CurrentMode, fanctrl2, - PreviousMode; - int TaskbarNew; - int MaxTemp; - int iMaxTemp; - int fanspeed, lastfanspeed, showfanspeed; - int FanBeepFreq, FanBeepDura; - int MinimizeToSysTray, - Lev64Norm, - IconColorFan, - Fahrenheit, - MinimizeOnClose, - StartMinimized, - NoWaitMessage, - Runs_as_service; - int ReadErrorCount; - int MaxReadErrors; - int SecWinUptime; - int SlimDialog; - int NoBallons, - HK_BIOS_Method, - HK_Manual_Method, - HK_Smart_Method, - HK_SM1_Method, - HK_SM2_Method, - HK_TG_BS_Method, - HK_TG_BM_Method, - HK_TG_MS_Method, - HK_TG_12_Method, - HK_BIOS, - HK_Manual, - HK_Smart, - HK_SM1, - HK_SM2, - HK_TG_BS, - HK_TG_BM, - HK_TG_MS, - HK_TG_12; - int BluetoothEDR; - int ManModeExit; - int ManModeExit2; - int ShowBiasedTemps; - int SecStartDelay; - char gSensorNames[17][4]; - int Log2File; - int Log2csv; - int StayOnTop; - int ShowAll; - int ShowTempIcon; - char IgnoreSensors[256]; - char MenuLabelSM1[32]; - char MenuLabelSM2[32]; - HANDLE hThread; - HANDLE hPipe0; - HANDLE hPipe1; - HANDLE hPipe2; - HANDLE hPipe3; - HANDLE hPipe4; - HANDLE hPipe5; - HANDLE hPipe6; - HANDLE hPipe7; - HANDLE hLock; - HANDLE hLockS; - BOOL Closing; - MUTEXSEM EcAccess; - bool m_needClose; - - char Title[128]; - char Title2[128]; - char Title3[128]; - char Title4[128]; - char Title5[128]; - char LastTitle[128]; - char LastTooltip[128]; - char CurrentStatus[256]; - char CurrentStatuscsv[256]; - - // dialog.cpp - int CurrentModeFromDialog(); - - int ShowAllFromDialog(); - - void ModeToDialog(int mode); - - void ShowAllToDialog(int mode); - - ULONG DlgProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2); - - static ULONG CALLBACK - BaseDlgProc(HWND - hwnd, - ULONG msg, WPARAM - mp1, - LPARAM mp2 - ); - - //The default app-icon with changing colors - TASKBARICON* pTaskbarIcon; - // - CTaskbarTextIcon** ppTbTextIcon; - MUTEXSEM* pTextIconMutex; - - - static int _stdcall - FANCONTROL_Thread(ULONG - parm) \ - { return ((FANCONTROL*)parm)->WorkThread(); } - - int WorkThread(); - - - // fancontrol.cpp - int ReadEcStatus(FCSTATE* pfcstate); - - int ReadEcRaw(FCSTATE* pfcstate); - - int HandleData(); - - int SmartControl(); - - int SetFan(const char* source, int level, BOOL final = false); - - int SetHdw(const char* source, int hdwctrl, int HdwOffset, int AnyWayBit); - - LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam); - - - // misc.cpp - int ReadConfig(const char* filename); - - void Trace(const char* text); - - void Tracecsv(const char* textcsv); - - void Tracecsvod(const char* textcsv); - - BOOL IsMinimized(void); - - void CurrentDateTimeLocalized(char* result, size_t sizeof_result); - - void CurrentTimeLocalized(char* result, size_t sizeof_result); - - HANDLE CreateThread(int(_stdcall - - * fnct)(ULONG), - ULONG p - ); - - - // portio.cpp - int ReadByteFromECint(int offset, char* pdata); - - int ReadByteFromEC(int offset, char* pdata); - - int WriteByteToEC(int offset, char data); - -public: - - FANCONTROL(HINSTANCE hinstapp); - - ~FANCONTROL(); - - void Test(void); - - int ProcessDialog(); - - HWND GetDialogWnd() { return hwndDialog; } - - HANDLE GetWorkThread() { return hThread; } - - // The texticons will be shown depending on variables - void ProcessTextIcons(void); - - void RemoveTextIcons(void); +class FANCONTROL +{ + protected: + HINSTANCE hinstapp; + HINSTANCE m_hinstapp; + HWND hwndDialog; + + UINT_PTR m_fanTimer; + UINT_PTR m_titleTimer; + UINT_PTR m_iconTimer; + UINT_PTR m_renewTimer; + + struct FCSTATE { + + char FanCtrl, + FanSpeedLo, + FanSpeedHi; + + char Sensors[12]; + int SensorAddr[12]; + const char *SensorName[12]; + + + } State; + + struct SMARTENTRY { + int temp, fan; + } SmartLevels[32]; + + struct SMARTENTRY1 { + int temp1, fan1; + } SmartLevels1[32]; + + struct SMARTENTRY2 { + int temp2, fan2; + } SmartLevels2[32]; + + struct FSMARTENTRY { //fahrenheit values + int ftemp, ffan; + } FSmartLevels[32]; + + + int IconLevels[3]; // temp levels for coloring the icon + int FIconLevels[3]; // fahrenheit temp levels for coloring the icon + int CurrentIcon; + int IndSmartLevel; + int SensorOffset[16]; + int FSensorOffset[16]; + int iFarbeIconB; + int iFontIconB; + int icontemp; + int Cycle; + int IconCycle; + int ReIcCycle; + int NoExtSensor; + int FanSpeedLowByte; + int ActiveMode, + ManFanSpeed, + FinalSeen; + int CurrentMode, fanctrl2, + PreviousMode; + int TaskbarNew; + int MaxTemp; + int iMaxTemp; + int fanspeed, lastfanspeed, showfanspeed; + int FanBeepFreq, FanBeepDura; + int MinimizeToSysTray, + Lev64Norm, + IconColorFan, + Fahrenheit, + MinimizeOnClose, + StartMinimized, + NoWaitMessage, + Runs_as_service; + int ReadErrorCount; + int MaxReadErrors; + int SecWinUptime; + int SlimDialog; + int NoBallons; + int Hotkeys; + int BluetoothEDR; + int ManModeExit; + int ManModeExit2; + int ShowBiasedTemps; + int SecStartDelay; + char gSensorNames[17][4]; + int Log2File; + int Log2csv; + int StayOnTop; + int ShowAll; + int ShowTempIcon; + char IgnoreSensors[256]; + char MenuLabelSM1[32]; + char MenuLabelSM2[32]; + HANDLE hThread; + HANDLE hPipe0; + HANDLE hPipe1; + HANDLE hPipe2; + HANDLE hPipe3; + HANDLE hPipe4; + HANDLE hPipe5; + HANDLE hPipe6; + HANDLE hPipe7; + HANDLE hLock; + HANDLE hLockS; + BOOL Closing; + MUTEXSEM EcAccess; + bool m_needClose; + + char Title[128]; + char Title2[128]; + char Title3[128]; + char Title4[128]; + char Title5[128]; + char LastTitle[128]; + char LastTooltip[128]; + char CurrentStatus[256]; + char CurrentStatuscsv[256]; + + // dialog.cpp + int CurrentModeFromDialog(); + int ShowAllFromDialog(); + void ModeToDialog(int mode); + void ShowAllToDialog(int mode); + ULONG DlgProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2); + static ULONG CALLBACK BaseDlgProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2); + + //The default app-icon with changing colors + TASKBARICON *pTaskbarIcon; + // + CTaskbarTextIcon **ppTbTextIcon; + MUTEXSEM *pTextIconMutex; + + + + static int _stdcall FANCONTROL_Thread(ULONG parm) \ + { return ((FANCONTROL *)parm)->WorkThread(); } + + int WorkThread(); + + + // fancontrol.cpp + int ReadEcStatus(FCSTATE *pfcstate); + int ReadEcRaw(FCSTATE *pfcstate); + int HandleData(); + int SmartControl(); + int SetFan(const char *source, int level, BOOL final= false); + int SetFan(const char* source, int fanctrl, int mode, BOOL final); + int SetHdw(const char *source, int hdwctrl, int HdwOffset, int AnyWayBit); + + + // misc.cpp + int ReadConfig(const char *filename); + void Trace(const char *text); + void Tracecsv(const char *textcsv); + void Tracecsvod(const char *textcsv); + BOOL IsMinimized(void); + void CurrentDateTimeLocalized(char *result, size_t sizeof_result); + void CurrentTimeLocalized(char *result, size_t sizeof_result); + HANDLE CreateThread(int (_stdcall *fnct)(ULONG), ULONG p); + + + // portio.cpp + int ReadByteFromECint(int offset, char *pdata); + int ReadByteFromEC(int offset, char *pdata); + int WriteByteToEC(int offset, char data); + + public: + + FANCONTROL(HINSTANCE hinstapp); + ~FANCONTROL(); + + int ProcessDialog(); + + HWND GetDialogWnd() { return hwndDialog; } + HANDLE GetWorkThread() { return hThread; } + // The texticons will be shown depending on variables + void ProcessTextIcons(void); + void RemoveTextIcons(void); }; -#endif // FANCONTROL_H +#endif // FANCONTROL_H \ No newline at end of file diff --git a/fancontrol/fancontrol.sln b/fancontrol/fancontrol.sln index 9c28f68..7b17f9a 100644 --- a/fancontrol/fancontrol.sln +++ b/fancontrol/fancontrol.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32112.339 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fancontrol", "fancontrol.vcxproj", "{45F7E4D3-AF42-4594-80E1-099D3FCE3F37}" EndProject @@ -19,4 +19,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {59BE78AE-1B86-4FEC-9099-5758CAE3E705} + EndGlobalSection EndGlobal diff --git a/fancontrol/fanstuff.cpp b/fancontrol/fanstuff.cpp index 70dd82c..0ba1c59 100644 --- a/fancontrol/fanstuff.cpp +++ b/fancontrol/fanstuff.cpp @@ -1,3 +1,4 @@ + // -------------------------------------------------------------- // // Thinkpad Fan Control @@ -18,67 +19,76 @@ #include "_prec.h" #include "fancontrol.h" #include "tools.h" -#include "TVicPort.h" -#define TP_ECOFFSET_FAN_SWITCH (char)0x31 -#define TP_ECOFFSET_FAN1 (char)0x0000 -#define TP_ECOFFSET_FAN2 (char)0x0001 -#define TP_ECOFFSET_FAN (char)0x2F // 1 byte (binary xyzz zzz) -#define TP_ECOFFSET_FANSPEED (char)0x84 // 16 bit word, lo/hi byte -#define TP_ECOFFSET_TEMP0 (char)0x78 // 8 temp sensor bytes from here -#define TP_ECOFFSET_TEMP1 (char)0xC0 // 4 temp sensor bytes from here +#define TP_ECOFFSET_FAN (char)0x93 // 1 byte (binary xyzz zzz) +#define TP_ECOFFSET_FAN2 (char)0x96 // 1 byte (binary xyzz zzz) +#define TP_MANUAL_SPEED (char)0x14 // 1 byte (binary xyzz zzz) +#define TP_ECOFFSET_FANSPEED (char)0x95 // 16 bit word, lo/hi byte +#define TP_ECOFFSET_TEMP0 (char)0xA8 // 0x78 8 temp sensor bytes from here +#define TP_ECOFFSET_TEMP1 (char)0xB9 // 0xc0 4 temp sensor bytes from here + + + + +// Thanks for the following to "Thinker" on +// http://www.thinkwiki.org/wiki/Talk:ACPI_fan_control_script + + + + + //------------------------------------------------------------------------- // switch fan according to settings //------------------------------------------------------------------------- -int -FANCONTROL::HandleData(void) { - char obuf[256] = "", obuf2[128] = "", - templist[256] = "", templist2[512], - manlevel[16] = "", title2[128] = ""; - int i, maxtemp, imaxtemp, ok = 0; +int +FANCONTROL::HandleData(void) +{ + char obuf[256]= "", obuf2[128]="", + templist[256]= "", templist2[512], + manlevel[16]= "", title2[128]= ""; + int i, maxtemp, imaxtemp, ok= 0; // // determine highest temp. - // + // // build a list of sensors to ignore, separated by "|", e.g. "|XC1|BAT|CPU|" char what[16], list[128]; - sprintf_s(list, sizeof(list), "|%s|", this->IgnoreSensors); - for (i = 0; list[i] != '\0'; i++) { - if (list[i] == ',') - list[i] = '|'; + sprintf_s(list,sizeof(list), "|%s|", this->IgnoreSensors); + for (i= 0; list[i]!='\0'; i++) { + if (list[i]==',') + list[i]= '|'; } - maxtemp = 0; - imaxtemp = 0; + maxtemp= 0; + imaxtemp= 0; int senstemp; - for (i = 0; i < 12; i++) { - sprintf_s(what, sizeof(what), "|%s|", - this->State.SensorName[i]); // name (e.g. "|CPU|") to match against list above + for (i= 0; i<12; i++) { + sprintf_s(what,sizeof(what), "|%s|", this->State.SensorName[i]); // name (e.g. "|CPU|") to match against list above - if (this->State.Sensors[i] != 0x80 && this - State.Sensors[i] != 0x00 && strstr(list, what) == 0) { - int isens = this->State.Sensors[i]; - int ioffs = this->SensorOffset[i]; + if (this->State.Sensors[i]!=0x80 && this-State.Sensors[i]!=0x00 && strstr(list, what)==0) { + int isens=this->State.Sensors[i]; + int ioffs=this->SensorOffset[i]; if (ShowBiasedTemps) - senstemp = isens; + senstemp=isens; else - senstemp = isens - ioffs; + senstemp=isens-ioffs; - if (senstemp < 128) { + if (senstemp < 128){ - maxtemp = __max(senstemp, maxtemp); - if (maxtemp <= senstemp) imaxtemp = i; //this->State.SensorName[this->iMaxTemp] + maxtemp= __max(senstemp, maxtemp); + if (maxtemp <= senstemp) imaxtemp=i; //this->State.SensorName[this->iMaxTemp] } } } - this->MaxTemp = maxtemp; - this->iMaxTemp = imaxtemp; + this->MaxTemp= maxtemp; + this->iMaxTemp=imaxtemp; @@ -87,159 +97,156 @@ FANCONTROL::HandleData(void) { // // title string (for minimized window) - if (Fahrenheit) - sprintf_s(title2, sizeof(title2), "%d° F", this->MaxTemp * 9 / 5 + 32); + if(Fahrenheit) + sprintf_s(title2,sizeof(title2), "%d°F", this->MaxTemp* 9/5 +32); else - sprintf_s(title2, sizeof(title2), "%d° C", this->MaxTemp); + sprintf_s(title2,sizeof(title2), "%d°C", this->MaxTemp); // display fan state - int fanctrl = this->State.FanCtrl; - fanctrl2 = fanctrl; + int fanctrl= this->State.FanCtrl; + fanctrl2= fanctrl; - if (this->SlimDialog == 1) { - sprintf_s(obuf2, sizeof(obuf2), "Fan %d ", fanctrl); - if (fanctrl & 0x80) { - if (!(SlimDialog && StayOnTop)) - strcat_s(obuf2, sizeof(obuf2), "(= BIOS)"); - strcat_s(title2, sizeof(title2), " Default Fan"); - } - else { - if (!(SlimDialog && StayOnTop)) - sprintf_s(obuf2 + strlen(obuf2), sizeof(obuf2) - strlen(obuf2), " Non Bios", fanctrl & 0x3F); - sprintf_s(title2 + strlen(title2), sizeof(title2) - strlen(title2), " Fan %d (%s)", - fanctrl & 0x3F, - this->CurrentModeFromDialog() == 2 ? "Smart" : "Fixed"); - } + if (this->SlimDialog == 1){ + + sprintf_s(obuf2,sizeof(obuf2), "Fan %d ", fanctrl); + if (fanctrl & 0x80) {if (!(SlimDialog && StayOnTop)) + strcat_s(obuf2,sizeof(obuf2), "(= BIOS)"); + strcat_s(title2,sizeof(title2), " Default Fan"); } else { - sprintf_s(obuf2, sizeof(obuf2), "0x%02x (", fanctrl); - if (fanctrl & 0x80) { - strcat_s(obuf2, sizeof(obuf2), "BIOS Controlled)"); - strcat_s(title2, sizeof(title2), " Default Fan"); - } - else { - sprintf_s(obuf2 + strlen(obuf2), sizeof(obuf2) - strlen(obuf2), "Fan Level %d, Non Bios)", fanctrl & 0x3F); - sprintf_s(title2 + strlen(title2), sizeof(title2) - strlen(title2), " Fan %d (%s)", - fanctrl & 0x3F, - this->CurrentModeFromDialog() == 2 ? "Smart" : "Fixed"); - } + if (!(SlimDialog && StayOnTop)) + sprintf_s(obuf2+strlen(obuf2),sizeof(obuf2)-strlen(obuf2), " Non Bios", fanctrl & 0x3F); + sprintf_s(title2+strlen(title2),sizeof(title2)-strlen(title2), " Fan %d (%s)", + fanctrl & 0x3F, + this->CurrentModeFromDialog()==2 ? "Smart" : "Fixed"); + } } - ::SetDlgItemText(this->hwndDialog, 8100, obuf2); + else{ + sprintf_s(obuf2,sizeof(obuf2), "0x%02x (", fanctrl); + if (fanctrl & 0x80) { + strcat_s(obuf2,sizeof(obuf2), "BIOS Controlled)"); + strcat_s(title2,sizeof(title2), " Default Fan"); + } + else { + sprintf_s(obuf2+strlen(obuf2),sizeof(obuf2)-strlen(obuf2), "Fan Level %d, Non Bios)", fanctrl & 0x3F); + sprintf_s(title2+strlen(title2),sizeof(title2)-strlen(title2), " Fan %d (%s)", + fanctrl & 0x3F, + this->CurrentModeFromDialog()==2 ? "Smart" : "Fixed"); + } + } + - strcpy_s(this->Title2, sizeof(this->Title2), title2); + ::SetDlgItemText(this->hwndDialog, 8100, obuf2); + strcpy_s(this->Title2,sizeof(this->Title2), title2); + // display fan speed (experimental, not visible) this->lastfanspeed = this->fanspeed; - this->fanspeed = (this->State.FanSpeedHi1 << 8) | this->State.FanSpeedLo1; + this->fanspeed = (this->State.FanSpeedHi << 8) | this->State.FanSpeedLo; if (this->fanspeed > 0x1fff) fanspeed = lastfanspeed; - sprintf_s(obuf2, sizeof(obuf2), "%d/%d RPM", this->fanspeed, - (this->State.FanSpeedHi2 << 8) | this->State.FanSpeedLo2); + sprintf_s(obuf2,sizeof(obuf2), "%d RPM", this->fanspeed); ::SetDlgItemText(this->hwndDialog, 8102, obuf2); // display temperature list - if (Fahrenheit) - sprintf_s(obuf2, sizeof(obuf2), "%d° F", this->MaxTemp * 9 / 5 + 32); + if(Fahrenheit) + sprintf_s(obuf2,sizeof(obuf2), "%d°F", this->MaxTemp* 9 /5 +32); else - sprintf_s(obuf2, sizeof(obuf2), "%d° C", this->MaxTemp); + sprintf_s(obuf2,sizeof(obuf2), "%d°C", this->MaxTemp); ::SetDlgItemText(this->hwndDialog, 8103, obuf2); - strcpy_s(templist2, sizeof(templist2), ""); - for (i = 0; i < 12; i++) { - int temp = this->State.Sensors[i]; + strcpy_s(templist2,sizeof(templist2), ""); + for (i= 0; i<12; i++) { + int temp= this->State.Sensors[i]; - if (temp < 128 && temp != 0) { - if (Fahrenheit) - sprintf_s(obuf2, sizeof(obuf2), "%d° F", temp * 9 / 5 + 32); + if (temp < 128 && temp!= 0) + { + if(Fahrenheit) + sprintf_s(obuf2,sizeof(obuf2), "%d°F", temp* 9 /5 +32); else - sprintf_s(obuf2, sizeof(obuf2), "%d° C", temp); + sprintf_s(obuf2,sizeof(obuf2), "%d°C", temp); - if (SlimDialog && StayOnTop) - sprintf_s(templist2 + strlen(templist2), sizeof(templist2) - strlen(templist2), "%d %s %s", i + 1, - this->State.SensorName[i], obuf2); - else - sprintf_s(templist2 + strlen(templist2), sizeof(templist2) - strlen(templist2), - "%d %s %s (0x%02x)", i + 1, this->State.SensorName[i], obuf2, this->State.SensorAddr[i]); + if (SlimDialog && StayOnTop) + sprintf_s(templist2+strlen(templist2), sizeof(templist2)-strlen(templist2), "%d %s %s", i+1, + this->State.SensorName[i],obuf2); + else + sprintf_s(templist2+strlen(templist2), sizeof(templist2)-strlen(templist2), + "%d %s %s (0x%02x)", i+1, this->State.SensorName[i], obuf2, this->State.SensorAddr[i]); - strcat_s(templist2, sizeof(templist2), "\r\n"); + strcat_s(templist2,sizeof(templist2), "\r\n"); } else { // strcat_s(templist2,sizeof(templist2), "n/a\r\n"); - if (this->ShowAll == 1) { - sprintf_s(obuf2, sizeof(obuf2), "n/a"); - size_t strlen_templist = strlen_s(templist2, sizeof(templist2)); + if (this->ShowAll==1) + { + sprintf_s(obuf2,sizeof(obuf2), "n/a"); + size_t strlen_templist = strlen_s(templist2,sizeof(templist2)); if (SlimDialog && StayOnTop) - sprintf_s(templist2 + strlen_templist, sizeof(templist2) - strlen_templist, "%d %s %s", i + 1, - this->State.SensorName[i], - obuf2); + sprintf_s(templist2+strlen_templist,sizeof(templist2)-strlen_templist, "%d %s %s", i+1, + this->State.SensorName[i], + obuf2); else - sprintf_s(templist2 + strlen_templist, sizeof(templist2) - strlen_templist, "%d %s %s (0x%02x)", - i + 1, - this->State.SensorName[i], - obuf2, - this->State.SensorAddr[i]); + sprintf_s(templist2+strlen_templist,sizeof(templist2)-strlen_templist, "%d %s %s (0x%02x)", i+1, + this->State.SensorName[i], + obuf2, + this->State.SensorAddr[i]); - strcat_s(templist2, sizeof(templist2), "\r\n"); + strcat_s(templist2,sizeof(templist2), "\r\n"); + } } - } } ::SetDlgItemText(this->hwndDialog, 8101, templist2); - this->icontemp = this->State.Sensors[iMaxTemp]; + this->icontemp= this->State.Sensors[iMaxTemp]; // compact single line status (combined) - strcpy_s(templist, sizeof(templist), ""); - if (Fahrenheit) { - for (i = 0; i < 12; i++) { - if (this->State.Sensors[i] < 128) { - if (this->State.Sensors[i] != 0) - sprintf_s(templist + strlen(templist), sizeof(templist) - strlen(templist), "%d;", - this->State.Sensors[i] * 9 / 5 + 32); - else sprintf_s(templist + strlen(templist), sizeof(templist) - strlen(templist), "%d;", 0); + strcpy_s(templist,sizeof(templist), ""); + if (Fahrenheit){ + for (i= 0; i<12; i++) { + if (this->State.Sensors[i]< 128) { + if (this->State.Sensors[i]!=0) sprintf_s(templist+strlen(templist),sizeof(templist)-strlen(templist), "%d;", this->State.Sensors[i]* 9 /5 +32); + else sprintf_s(templist+strlen(templist),sizeof(templist)-strlen(templist), "%d;", 0); } else { - strcat_s(templist, sizeof(templist), "0;"); + strcat_s(templist,sizeof(templist), "0;"); } } } else { - for (i = 0; i < 12; i++) { - if (this->State.Sensors[i] != 128) { - sprintf_s(templist + strlen(templist), sizeof(templist) - strlen(templist), "%d; ", - this->State.Sensors[i]); + for (i= 0; i<12; i++) { + if (this->State.Sensors[i]!=128) { + sprintf_s(templist+strlen(templist),sizeof(templist)-strlen(templist), "%d; ", this->State.Sensors[i]); } else { - strcat_s(templist, sizeof(templist), "0; "); + strcat_s(templist,sizeof(templist), "0; "); } } } - templist[strlen(templist) - 1] = '\0'; + templist[strlen(templist)-1]= '\0'; if (Fahrenheit) - sprintf_s(CurrentStatus, sizeof(CurrentStatus), "Fan: 0x%02x / Switch: %d° F (%s)", State.FanCtrl, - MaxTemp * 9 / 5 + 32, templist); - else - sprintf_s(CurrentStatus, sizeof(CurrentStatus), "Fan: 0x%02x / Switch: %d° C (%s)", State.FanCtrl, MaxTemp, - templist); + sprintf_s(CurrentStatus, sizeof(CurrentStatus), "Fan: 0x%02x / Switch: %d°F (%s)", State.FanCtrl, MaxTemp* 9 /5 +32, templist); + else + sprintf_s(CurrentStatus, sizeof(CurrentStatus), "Fan: 0x%02x / Switch: %d°C (%s)", State.FanCtrl, MaxTemp, templist); // display fan speed (experimental, not visible) - // fanspeed= (this->State.FanSpeedHi << 8) | this->State.FanSpeedLo; + // fanspeed= (this->State.FanSpeedHi << 8) | this->State.FanSpeedLo; - if (fanspeed > 0x1fff) fanspeed = lastfanspeed; - sprintf_s(obuf2, sizeof(obuf2), "%d", this->fanspeed); + if (fanspeed > 0x1fff) fanspeed = lastfanspeed; + sprintf_s(obuf2,sizeof(obuf2), "%d", this->fanspeed); - sprintf_s(CurrentStatuscsv, sizeof(CurrentStatuscsv), "%s %s; %d; %d; ", templist, obuf2, State.FanCtrl, MaxTemp); + sprintf_s(CurrentStatuscsv,sizeof(CurrentStatuscsv), "%s %s; %d; %d; ",templist,obuf2,State.FanCtrl,MaxTemp); ::SetDlgItemText(this->hwndDialog, 8112, this->CurrentStatus); @@ -254,226 +261,198 @@ FANCONTROL::HandleData(void) { switch (this->CurrentMode) { - case 1: // Bios Auto - if (this->PreviousMode != this->CurrentMode) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Change Mode from "); - if (this->PreviousMode == 1) { sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "BIOS->"); } - if (this->PreviousMode == 2) { sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Smart->"); } - if (this->PreviousMode == 3) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Manual->"); + case 1: // Bios Auto + if (this->PreviousMode != this->CurrentMode) { + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Change Mode from "); + if (this->PreviousMode==1){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "BIOS->");} + if (this->PreviousMode==2){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Smart->");} + if (this->PreviousMode==3){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Manual->");} + if (this->CurrentMode==1){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "BIOS, setting fan speed");} + if (this->CurrentMode==2){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Smart, recalculate fan speed");} + if (this->CurrentMode==3){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Manual, setting fan speed");} + this->Trace(obuf); } - if (this->CurrentMode == 1) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "BIOS, setting fan speed"); - } - if (this->CurrentMode == 2) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Smart, recalculate fan speed"); - } - if (this->CurrentMode == 3) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Manual, setting fan speed"); - } - this->Trace(obuf); - } - if (this->State.FanCtrl != 0x080) - ok = this->SetFan("BIOS", 0x80); - break; + //if (this->State.FanCtrl!=0x80) + ok= this->SetFan("BIOS", 0x04); + break; - case 2: // Smart - this->SmartControl(); - break; + case 2: // Smart + this->SmartControl(); + break; - case 3: // fixed manual - if (this->PreviousMode != this->CurrentMode) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Change Mode from "); - if (this->PreviousMode == 1) { sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "BIOS->"); } - if (this->PreviousMode == 2) { sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Smart->"); } - if (this->PreviousMode == 3) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Manual->"); - } - if (this->CurrentMode == 1) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "BIOS, setting fan speed"); - } - if (this->CurrentMode == 2) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Smart, recalculate fan speed"); - } - if (this->CurrentMode == 3) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Manual, setting fan speed"); - } - this->Trace(obuf); - } + case 3: // fixed manual + if (this->PreviousMode != this->CurrentMode) { + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Change Mode from "); + if (this->PreviousMode==1){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "BIOS->");} + if (this->PreviousMode==2){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Smart->");} + if (this->PreviousMode==3){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Manual->");} + if (this->CurrentMode==1){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "BIOS, setting fan speed");} + if (this->CurrentMode==2){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Smart, recalculate fan speed");} + if (this->CurrentMode==3){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Manual, setting fan speed");} + this->Trace(obuf); + } - ::GetDlgItemText(this->hwndDialog, 8310, manlevel, sizeof(manlevel)); + ::GetDlgItemText(this->hwndDialog, 8310, manlevel, sizeof(manlevel)); - if (isdigit(manlevel[0]) && atoi(manlevel) >= 0 && atoi(manlevel) <= 255) { + if (isdigit(manlevel[0]) && atoi(manlevel)>=0 && atoi(manlevel)<=255) { - if (this->State.FanCtrl != atoi(manlevel)) { - ok = this->SetFan("Manual", atoi(manlevel)); - } - else - ok = true; - } - break; + if (this->State.FanCtrl!=atoi(manlevel)) { + ok= this->SetFan("Manual", atoi(manlevel)); + } + else + ok= true; + } + break; } - this->PreviousMode = this->CurrentMode; + this->PreviousMode= this->CurrentMode; if (this->CurrentMode == 3 && this->MaxTemp > 75) this->CurrentMode = 2; //hello return ok; } + + //------------------------------------------------------------------------- // smart fan control depending on temperature //------------------------------------------------------------------------- -int -FANCONTROL::SmartControl(void) { - int ok = 0, i, - newfanctrl = -1, - fanctrl = this->State.FanCtrl; - char obuf[256] = ""; - - if (this->PreviousMode == 1) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Change Mode from BIOS->"); - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Smart, recalculate fan speed"); - this->Trace(obuf); - } - if (this->PreviousMode == 3) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Change Mode from Manual->"); - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Smart, recalculate fan speed"); - this->Trace(obuf); - } - - newfanctrl = -1; - - if ((fanctrl > 7 && (fanctrl != 64 || !Lev64Norm)) || this->PreviousMode == 3 || this->PreviousMode == 1) { - newfanctrl = 0; - fanctrl = 0; - } - - - for (i = 0; this->SmartLevels[i].temp != -1; i++) { - if (this->MaxTemp >= this->SmartLevels[i].temp && this->SmartLevels[i].fan >= fanctrl) - newfanctrl = this->SmartLevels[i].fan; - } - - // not uptriggered check for downtrigger: - - if (newfanctrl == -1) { - for (i = 0; this->SmartLevels[i].temp != -1; i++) { - if (this->MaxTemp <= this->SmartLevels[i].temp && this->SmartLevels[i].fan < fanctrl) { - newfanctrl = this->SmartLevels[i].fan; - break; +int +FANCONTROL::SmartControl(void) +{ + int ok= 0, i, + newfanctrl= -1, + fanctrl= this->State.FanCtrl; + char obuf[256]= ""; + + if (this->PreviousMode==1){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Change Mode from BIOS->"); + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Smart, recalculate fan speed"); + this->Trace(obuf);} + if (this->PreviousMode==3){sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Change Mode from Manual->"); + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Smart, recalculate fan speed"); + this->Trace(obuf);} + + newfanctrl= -1; + + if ( (fanctrl > 7 && (fanctrl != 64 || !Lev64Norm)) || this->PreviousMode==3 || this->PreviousMode==1 ){newfanctrl = 0; fanctrl = 0; } + + // check for fan-up, end marker for smart levels array: + // this->SmartLevels[lcnt].temp= -1; + // this->SmartLevels[lcnt].fan= 0x80; + + for (i= 0; this->SmartLevels[i].temp!=-1; i++) { + if (this->MaxTemp>=this->SmartLevels[i].temp && this->SmartLevels[i].fan>=fanctrl) + newfanctrl= this->SmartLevels[i].fan; + } + + // not uptriggered check for downtrigger: + + if (newfanctrl==-1) { + for (i= 0; this->SmartLevels[i].temp!=-1; i++) { + if (this->MaxTemp <= this->SmartLevels[i].temp && this->SmartLevels[i].fan < fanctrl) { + newfanctrl= this->SmartLevels[i].fan; + break; + } + } } - } - } - // fan speed needs change? + // fan speed needs change? - if (newfanctrl != -1 && newfanctrl != this->State.FanCtrl) { - //if (newfanctrl==0x80) { // switch to BIOS-auto mode - // //this->ModeToDialog(1); // bios - //} - ok = this->SetFan("Smart", newfanctrl); - } + if (newfanctrl!=-1 && newfanctrl!=this->State.FanCtrl) { + //TODO: Daten für Graph sammeln + //if (newfanctrl==0x80) { // switch to BIOS-auto mode + // //this->ModeToDialog(1); // bios + //} + ok= this->SetFan("Smart", newfanctrl); + } return ok; } + //------------------------------------------------------------------------- // set fan state via EC //------------------------------------------------------------------------- -int -FANCONTROL::SetFan(const char* source, int fanctrl, BOOL final) { - int ok = 0; - int fan1_ok = 0; - int fan2_ok = 0; - char obuf[256] = "", obuf2[256], datebuf[128]; +int +FANCONTROL::SetFan(const char *source, int fanctrl, BOOL final) +{ + int ok= 0; + char obuf[256]= "", obuf2[256], datebuf[128]; if (this->FanBeepFreq && this->FanBeepDura) ::Beep(this->FanBeepFreq, this->FanBeepDura); this->CurrentDateTimeLocalized(datebuf, sizeof(datebuf)); - - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "%s: Set fan control to 0x%02x, ", source, fanctrl); + + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "%s: Set fan control to 0x%02x, ", source, fanctrl); if (this->IndSmartLevel == 1 && this->SmartLevels2[0].temp2 != 0 && source == "Smart") - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Mode 2, "); + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Mode 2, "); if (this->IndSmartLevel == 0 && this->SmartLevels2[0].temp2 != 0 && source == "Smart") - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Mode 1, "); - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Result: "); + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Mode 1, "); + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Result: "); if (this->ActiveMode && !this->FinalSeen) { - + int ok_ecaccess = false; - for (int i = 0; i < 10; i++) { - if (ok_ecaccess = this->EcAccess.Lock(100))break; + for (int i = 0; i < 10; i++){ + if ( ok_ecaccess = this->EcAccess.Lock(100))break; else ::Sleep(100); } - if (!ok_ecaccess) { + if (!ok_ecaccess){ this->Trace("Could not acquire mutex to set fan state"); return 0; } - for (int i = 0; i < 5; i++) { - // set new fan level - ok = this->WriteByteToEC(TP_ECOFFSET_FAN_SWITCH, TP_ECOFFSET_FAN1); - ok = this->WriteByteToEC(TP_ECOFFSET_FAN, fanctrl); - - ::Sleep(100); - - ok = this->WriteByteToEC(TP_ECOFFSET_FAN_SWITCH, TP_ECOFFSET_FAN2); - ok = this->WriteByteToEC(TP_ECOFFSET_FAN, fanctrl); - - ::Sleep(100); - - // verify completion of fan2 - fan2_ok = this->ReadByteFromEC(TP_ECOFFSET_FAN, &this->State.FanCtrl); + for (int i = 0; i < 2; i++) + { + // set new fan level + ok= this->WriteByteToEC(TP_ECOFFSET_FAN, 0x14); + ok= this->WriteByteToEC(TP_ECOFFSET_FAN2, 0x14); + ok= this->WriteByteToEC(TP_ECOFFSET_FAN+1, fanctrl); + ok = this->WriteByteToEC(TP_ECOFFSET_FAN2+1, fanctrl); - ::Sleep(100); + //verify completion + ok= this->ReadByteFromEC(TP_ECOFFSET_FAN+1, &this->State.FanCtrl); - // verify completion of fan1 - ok = this->WriteByteToEC(TP_ECOFFSET_FAN_SWITCH, TP_ECOFFSET_FAN1); - fan1_ok = this->ReadByteFromEC(TP_ECOFFSET_FAN, &this->State.FanCtrl); + if (this->State.FanCtrl == fanctrl) + break; - if (fan1_ok == 1 && fan2_ok == 1) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "[i=%d] ", i); - break; - } - - ::Sleep(300); - } + ::Sleep(300); + } this->EcAccess.Unlock(); - if (this->State.FanCtrl == fanctrl) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "OK"); - ok = true; - if (final) - this->FinalSeen = true; // prevent further changes when setting final mode + if (this->State.FanCtrl==fanctrl) { + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "OK"); + ok= true; + if (final) + this->FinalSeen= true; // prevent further changes when setting final mode } else { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "FAILED!!"); - - /* ::Beep(880, 300); - ::Sleep(200); - ::Beep(880, 300); - ::Sleep(200); - ::Beep(880, 300); - */ - ok = false; + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "FAILED!!"); + +/* ::Beep(880, 300); + ::Sleep(200); + ::Beep(880, 300); + ::Sleep(200); + ::Beep(880, 300); +*/ + ok= false; } } else { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "IGNORED!(passive mode"); + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "IGNORED!(passive mode"); } // display result - sprintf_s(obuf2, sizeof(obuf2), "%s (%s)", obuf, datebuf); + sprintf_s(obuf2,sizeof(obuf2), "%s (%s)", obuf, datebuf); ::SetDlgItemText(this->hwndDialog, 8113, obuf2); this->Trace(this->CurrentStatus); @@ -485,58 +464,57 @@ FANCONTROL::SetFan(const char* source, int fanctrl, BOOL final) { int -FANCONTROL::SetHdw(const char* source, int hdwctrl, int HdwOffset, int AnyWayBit) { - int ok = 0; - char obuf[256] = "", obuf2[256], datebuf[128]; +FANCONTROL::SetHdw(const char *source, int hdwctrl, int HdwOffset, int AnyWayBit) +{ + int ok= 0; + char obuf[256]= "", obuf2[256], datebuf[128]; char newhdwctrl; - + int ok_ecaccess = false; - for (int i = 0; i < 10; i++) { - if (ok_ecaccess = this->EcAccess.Lock(100))break; + for (int i = 0; i < 10; i++){ + if ( ok_ecaccess = this->EcAccess.Lock(100))break; else ::Sleep(100); } - if (!ok_ecaccess) { + if (!ok_ecaccess){ this->Trace("Could not acquire mutex to write EC register"); return 0; } this->CurrentDateTimeLocalized(datebuf, sizeof(datebuf)); - for (int i = 0; i < 5; i++) { - ok = this->ReadByteFromEC(HdwOffset, &newhdwctrl); - if (newhdwctrl & hdwctrl) { - ok = this->WriteByteToEC(HdwOffset, (newhdwctrl - hdwctrl) | AnyWayBit); - hdwctrl = newhdwctrl - hdwctrl; - } - else { - ok = this->WriteByteToEC(HdwOffset, (newhdwctrl + hdwctrl) | AnyWayBit); - hdwctrl = newhdwctrl + hdwctrl; - } + for (int i = 0; i < 5; i++) + { + ok= this->ReadByteFromEC(HdwOffset, &newhdwctrl); + if (newhdwctrl & hdwctrl){ + ok= this->WriteByteToEC(HdwOffset, (newhdwctrl-hdwctrl) | AnyWayBit); + hdwctrl=newhdwctrl-hdwctrl;} + else{ + ok= this->WriteByteToEC(HdwOffset, (newhdwctrl+hdwctrl) | AnyWayBit); + hdwctrl=newhdwctrl+hdwctrl;} - ok = this->ReadByteFromEC(HdwOffset, &newhdwctrl); + ok= this->ReadByteFromEC(HdwOffset, &newhdwctrl); - if (hdwctrl == newhdwctrl) - break; + if (hdwctrl == newhdwctrl) + break; - ::Sleep(300); - } + ::Sleep(300); + } - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "%s: Set EC register 0x%02x to %d, ", source, HdwOffset, - hdwctrl); - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "Result: "); + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "%s: Set EC register 0x%02x to %d, ", source, HdwOffset, hdwctrl); + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "Result: "); - if (hdwctrl == newhdwctrl) { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "OK"); - ok = true; - } - else { - sprintf_s(obuf + strlen(obuf), sizeof(obuf) - strlen(obuf), "COULD NOT SET HARDWARE STATE!!!!"); - ok = false; - } + if (hdwctrl == newhdwctrl) { + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "OK"); + ok= true; + } + else { + sprintf_s(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), "COULD NOT SET HARDWARE STATE!!!!"); + ok= false; + } // display result - sprintf_s(obuf2, sizeof(obuf2), "%s (%s)", obuf, datebuf); + sprintf_s(obuf2,sizeof(obuf2), "%s (%s)", obuf, datebuf); ::SetDlgItemText(this->hwndDialog, 8113, obuf2); this->Trace(obuf); @@ -544,53 +522,54 @@ FANCONTROL::SetHdw(const char* source, int hdwctrl, int HdwOffset, int AnyWayBit return ok; } - //------------------------------------------------------------------------- // read fan and temperatures from embedded controller //------------------------------------------------------------------------- -int -FANCONTROL::ReadEcStatus(FCSTATE* pfcstate) { - DWORD ok = 0, rc = 0; +int +FANCONTROL::ReadEcStatus(FCSTATE *pfcstate) +{ + DWORD ok = 0, rc= 0; - FCSTATE sample; //Änderung "{0, }" wg. fanspeed transient zero - -// setzero(pfcstate, sizeof(*pfcstate)); //Änderung // wg. fanspeed transient zero + FCSTATE sample; //Änderung "{0, }" wg. fanspeed transient zero +// setzero(pfcstate, sizeof(*pfcstate)); //Änderung // wg. fanspeed transient zero + // reading from the EC seems to yield erratic results at times (probably // due to collision with other drivers reading from the port). So try // up to three times to read two samples which look oka and have matching // value - + int ok_ecaccess = false; - for (int i = 0; i < 10; i++) { - if (ok_ecaccess = this->EcAccess.Lock(100))break; + for (int i = 0; i < 10; i++){ + if ( ok_ecaccess = this->EcAccess.Lock(100))break; else ::Sleep(100); } - - if (!ok_ecaccess) { + + if (!ok_ecaccess){ this->Trace("Could not acquire mutex to read EC status"); return ok; } - for (int i = 0; i < 3; i++) { - ok = this->ReadEcRaw(&sample); - /* if (ok) - { - for (int j = 0; j < sizeof(sample.Sensors) / sizeof(*(sample.Sensors)); j++) - { - if (sample.Sensors[j] > 128) - { - ok = false; - break; - } - } - } - */ + for (int i = 0; i < 3; i++) + { + ok = this->ReadEcRaw(&sample); +/* if (ok) + { + for (int j = 0; j < sizeof(sample.Sensors) / sizeof(*(sample.Sensors)); j++) + { + if (sample.Sensors[j] > 128) + { + ok = false; + break; + } + } + } + */ if (ok) - break; - ::Sleep(200); - } + break; + ::Sleep(200); + } this->EcAccess.Unlock(); @@ -602,176 +581,66 @@ FANCONTROL::ReadEcStatus(FCSTATE* pfcstate) { } + //------------------------------------------------------------------------- // read fan and temperatures from embedded controller //------------------------------------------------------------------------- -int -FANCONTROL::ReadEcRaw(FCSTATE* pfcstate) { +int +FANCONTROL::ReadEcRaw(FCSTATE *pfcstate) +{ int i, idxtemp, ok; - // pfcstate->FanSpeedLo= 0; - // pfcstate->FanSpeedHi= 0; - pfcstate->FanCtrl = -1; +// pfcstate->FanSpeedLo= 0; +// pfcstate->FanSpeedHi= 0; + pfcstate->FanCtrl= -1; memset(pfcstate->Sensors, 0, sizeof(pfcstate->Sensors)); - - ok = ReadByteFromEC(TP_ECOFFSET_FAN, &pfcstate->FanCtrl); - - ok = this->WriteByteToEC(TP_ECOFFSET_FAN_SWITCH, TP_ECOFFSET_FAN2); + + ok= ReadByteFromEC(TP_ECOFFSET_FAN, &pfcstate->FanCtrl); if (ok) - ok = ReadByteFromEC(TP_ECOFFSET_FANSPEED, &pfcstate->FanSpeedLo2); - if (!ok) { - this->Trace("failed to read FanSpeedLowByte 2 from EC"); - } - - if (ok) - ok = ReadByteFromEC(TP_ECOFFSET_FANSPEED + 1, &pfcstate->FanSpeedHi2); - if (!ok) { - this->Trace("failed to read FanSpeedHighByte 2 from EC"); - } + ok= ReadByteFromEC(TP_ECOFFSET_FANSPEED, &pfcstate->FanSpeedLo); + if (!ok) + { + this->Trace("Oops, failed to read FanSpeedLowByte from EC"); + } if (ok) - ok = ReadByteFromEC(TP_ECOFFSET_FANSPEED, &pfcstate->FanSpeedLo1); - if (!ok) { - this->Trace("failed to read FanSpeedLowByte 1 from EC"); - } + ok= ReadByteFromEC(TP_ECOFFSET_FANSPEED+1, &pfcstate->FanSpeedHi); + if (!ok) + { + this->Trace("Oops, failed to read FanSpeedHighByte from EC"); + } - if (ok) - ok = ReadByteFromEC(TP_ECOFFSET_FANSPEED + 1, &pfcstate->FanSpeedHi1); - if (!ok) { - this->Trace("failed to read FanSpeedHighByte 1 from EC"); + idxtemp= 0; + for (i= 0; i<8 && ok; i++) { // temp sensors 0x78 - 0x7f + ok= ReadByteFromEC(TP_ECOFFSET_TEMP0+i, &pfcstate->Sensors[idxtemp]); + if (this->ShowBiasedTemps) + pfcstate->Sensors[idxtemp] = pfcstate->Sensors[idxtemp] - this->SensorOffset[idxtemp]; + if (!ok) + { + this->Trace("Oops, failed to read TEMP0 byte from EC"); + } + pfcstate->SensorAddr[idxtemp]= TP_ECOFFSET_TEMP0+i; + pfcstate->SensorName[idxtemp]= this->gSensorNames[idxtemp]; + idxtemp++; } - if (!this->UseTWR) { - idxtemp = 0; - - for (i = 0; i < 8 && ok; i++) { // temp sensors 0x78 - 0x7f - ok = ReadByteFromEC(TP_ECOFFSET_TEMP0 + i, &pfcstate->Sensors[idxtemp]); + for (i= 0; i<4 && ok; i++) { // temp sensors 0xC0 - 0xC4 + pfcstate->SensorAddr[idxtemp]= TP_ECOFFSET_TEMP1+i; + pfcstate->SensorName[idxtemp]= "n/a"; + if (!this->NoExtSensor){ + pfcstate->SensorName[idxtemp]= this->gSensorNames[idxtemp]; + ok= ReadByteFromEC(TP_ECOFFSET_TEMP1+i, &pfcstate->Sensors[idxtemp]); if (this->ShowBiasedTemps) pfcstate->Sensors[idxtemp] = pfcstate->Sensors[idxtemp] - this->SensorOffset[idxtemp]; if (!ok) { - this->Trace("failed to read TEMP0 byte from EC"); + this->Trace("Oops, failed to read TEMP1 byte from EC"); } - pfcstate->SensorAddr[idxtemp] = TP_ECOFFSET_TEMP0 + i; - pfcstate->SensorName[idxtemp] = this->gSensorNames[idxtemp]; - idxtemp++; - } - - for (i = 0; i < 4 && ok; i++) { // temp sensors 0xC0 - 0xC4 - pfcstate->SensorAddr[idxtemp] = TP_ECOFFSET_TEMP1 + i; - pfcstate->SensorName[idxtemp] = "n/a"; - if (!this->NoExtSensor) { - pfcstate->SensorName[idxtemp] = this->gSensorNames[idxtemp]; - ok = ReadByteFromEC(TP_ECOFFSET_TEMP1 + i, &pfcstate->Sensors[idxtemp]); - if (this->ShowBiasedTemps) - pfcstate->Sensors[idxtemp] = pfcstate->Sensors[idxtemp] - this->SensorOffset[idxtemp]; - if (!ok) { - this->Trace("failed to read TEMP1 byte from EC"); - } - } - idxtemp++; } + idxtemp++; } - else { - char data = -1; - char dataOut[16]; - int iOK = false; - int iTimeout = 100; - int iTimeoutBuf = 1000; - int iTime = 0; - int iTick = 10; - int ivers = 0; - - neuerversuch: - - ivers++; - - if (ivers >= 3) { - this->Trace("failed to read temps , EC is not ready for TWR"); - ok = 0; - return ok; - } - - for (iTime = 0; iTime < iTimeoutBuf; iTime += iTick) { // wait for ec ready - data = (char)ReadPort(0x1604) & 0xff; // or timeout iTimeoutBuf = 1000 - if (!data) // ec is ready: ctrlprt = 0 - break; - if (data & 0x50) // some unrequested outputis waiting - ReadPort(0x161f); // clear data output - ::Sleep(iTick); - } - - WritePort(0x1610, 0x20); // tell them we want to read - data = (char)ReadPort(0x1604) & 0xff; - if (!(data & 0x20)) // ec is not ready - goto neuerversuch; - - for (int i = 1; i < 15; i++) { - WritePort(0x1610 + i, 0x00); - } - - WritePort(0x161f, 0x00); - - for (iTime = 0; iTime < iTimeoutBuf; iTime++) { // wait for full buffers to clear - data = (char)ReadPort(0x1604) & 0xff; // or timeout iTimeoutBuf = 1000 - if (data == 0x50) - break; - } - - if (data != 0x50) - goto neuerversuch; - - for (int i = 0; i < 16; i++) { - dataOut[i] = (char)ReadPort(0x1610 + i) & 0xff; - } - - pfcstate->SensorAddr[0] = 0x78; - pfcstate->SensorName[0] = this->gSensorNames[0]; - pfcstate->Sensors[0] = dataOut[0]; - - pfcstate->SensorAddr[1] = 0x79; - pfcstate->SensorName[1] = this->gSensorNames[1]; - pfcstate->Sensors[1] = dataOut[1]; - - pfcstate->SensorAddr[2] = 0x7a; - pfcstate->SensorName[2] = this->gSensorNames[2]; - pfcstate->Sensors[2] = dataOut[2]; - - pfcstate->SensorAddr[3] = 0x7b; - pfcstate->SensorName[3] = this->gSensorNames[3]; - pfcstate->Sensors[3] = dataOut[3]; - - pfcstate->SensorAddr[4] = 0x7c; - pfcstate->SensorName[4] = this->gSensorNames[4]; - pfcstate->Sensors[4] = dataOut[4]; - pfcstate->SensorAddr[5] = 0x7d; - pfcstate->SensorName[5] = this->gSensorNames[5]; - pfcstate->Sensors[5] = dataOut[6]; - - pfcstate->SensorAddr[6] = 0x7e; - pfcstate->SensorName[6] = this->gSensorNames[6]; - pfcstate->Sensors[6] = dataOut[8]; - - pfcstate->SensorAddr[7] = 0x7f; - pfcstate->SensorName[7] = this->gSensorNames[7]; - pfcstate->Sensors[7] = dataOut[9]; - - pfcstate->SensorAddr[8] = 0xc0; - pfcstate->SensorName[8] = this->gSensorNames[8]; - pfcstate->Sensors[8] = dataOut[10]; - - pfcstate->SensorAddr[9] = 0xc1; - pfcstate->SensorName[9] = this->gSensorNames[9]; - pfcstate->Sensors[9] = dataOut[11]; - - pfcstate->SensorAddr[10] = 0xc2; - pfcstate->SensorName[10] = this->gSensorNames[10]; - pfcstate->Sensors[10] = dataOut[12]; - - pfcstate->SensorAddr[11] = 0xc3; - pfcstate->SensorName[11] = this->gSensorNames[11]; - pfcstate->Sensors[11] = dataOut[13]; - } return ok; } + + diff --git a/fancontrol/misc.cpp b/fancontrol/misc.cpp index 095dc6e..4803ed3 100644 --- a/fancontrol/misc.cpp +++ b/fancontrol/misc.cpp @@ -1,4 +1,4 @@ - + // -------------------------------------------------------------- // // Thinkpad Fan Control @@ -24,14 +24,14 @@ // read config file //------------------------------------------------------------------------- int -FANCONTROL::ReadConfig(const char* configfile) +FANCONTROL::ReadConfig(const char *configfile) { char buf[1024]; - int i, ok = false, lcnt = 0, lcnt2 = 0; + int i, ok= false, lcnt= 0, lcnt2= 0; int ProcessPriority = 2; - strncpy_s(this->MenuLabelSM1, sizeof(this->MenuLabelSM1), "Smart Level 1", 14); - strncpy_s(this->MenuLabelSM2, sizeof(this->MenuLabelSM1), "Smart Level 2", 14); + strncpy_s(this->MenuLabelSM1,sizeof(this->MenuLabelSM1), "Smart Level 1", 14); + strncpy_s(this->MenuLabelSM2,sizeof(this->MenuLabelSM1), "Smart Level 2", 14); @@ -42,554 +42,482 @@ FANCONTROL::ReadConfig(const char* configfile) setzero(SensorOffset, sizeof(SensorOffset)); setzero(FSensorOffset, sizeof(FSensorOffset)); - this->State.FanSpeedHi1 = 0x00; - this->State.FanSpeedLo1 = 0x00; - this->State.FanSpeedHi2 = 0x00; - this->State.FanSpeedLo2 = 0x00; + this->State.FanSpeedHi = 0x00; + this->State.FanSpeedLo = 0x00; this->fanspeed = 0; this->IndSmartLevel = 0; // // read from file // - FILE* f; - errno_t errf = fopen_s(&f, configfile, "r"); + FILE *f; + errno_t errf = fopen_s(&f,configfile, "r"); if (!errf) { while (!feof(f)) { - strcpy_s(buf, sizeof(buf), ""); + strcpy_s(buf,sizeof(buf), ""); fgets(buf, sizeof(buf), f); - if (buf[0] == '/' || buf[0] == '#' || buf[0] == ';') + if (buf[0]=='/' || buf[0]=='#' || buf[0]==';') continue; - if (_strnicmp(buf, "UseTWR=", 7) == 0) { - this->UseTWR = atoi(buf + 7); + if (_strnicmp(buf, "Active=", 7)==0) { + this->ActiveMode= atoi(buf+7); + } + else + if (_strnicmp(buf, "ManFanSpeed=", 12)==0) { + this->ManFanSpeed= atoi(buf+12); } - if (_strnicmp(buf, "Active=", 7) == 0) { - this->ActiveMode = atoi(buf + 7); + else + if (_strnicmp(buf, "ProcessPriority=", 16)==0) { + ProcessPriority= atoi(buf+16); + } + else + if (_strnicmp(buf, "cycle=", 6)==0) { + this->Cycle= atoi(buf+6); } else - if (_strnicmp(buf, "ManFanSpeed=", 12) == 0) { - this->ManFanSpeed = atoi(buf + 12); + if (_strnicmp(buf, "IconCycle=", 10)==0) { + this->IconCycle= atoi(buf+10); + } + else + if (_strnicmp(buf, "ReIcCycle=", 10)==0) { + this->ReIcCycle= atoi(buf+10); + } + else + if (_strnicmp(buf, "IconFontSize=", 13)==0) { + this->iFontIconB = atoi(buf+13); + } + + else + + if (_strnicmp(buf, "MenuLabelSM1=", 13)==0){ + char *p= buf+13, *p2= this->MenuLabelSM1; + while (*p != '/') { // copy until '/' excluding tab, carr ret, new line +// if (*p!='*') continue; else break; + if (*p!='\t' && *p!='\r' && *p!='\n') + *p2++= *p; + p++; + } + *p2= '\0'; } - else - if (_strnicmp(buf, "ProcessPriority=", 16) == 0) { - ProcessPriority = atoi(buf + 16); + + else + + if (_strnicmp(buf, "MenuLabelSM2=", 13)==0){ + char *p= buf+13, *p2= this->MenuLabelSM2; + while (*p != '/') { // copy until '/' excluding tab, carr ret, new line + if (*p!='\t' && *p!='\r' && *p!='\n') + *p2++= *p; + p++; } - else - if (_strnicmp(buf, "cycle=", 6) == 0) { - this->Cycle = atoi(buf + 6); - } - else - if (_strnicmp(buf, "IconCycle=", 10) == 0) { - this->IconCycle = atoi(buf + 10); - } - else - if (_strnicmp(buf, "ReIcCycle=", 10) == 0) { - this->ReIcCycle = atoi(buf + 10); - } - else - if (_strnicmp(buf, "IconFontSize=", 13) == 0) { - this->iFontIconB = atoi(buf + 13); - } - - else - - if (_strnicmp(buf, "MenuLabelSM1=", 13) == 0) { - char* p = buf + 13, * p2 = this->MenuLabelSM1; - while (*p != '/') { // copy until '/' excluding tab, carr ret, new line - // if (*p!='*') continue; else break; - if (*p != '\t' && *p != '\r' && *p != '\n') - *p2++ = *p; - p++; - } - *p2 = '\0'; - } - - else - - if (_strnicmp(buf, "MenuLabelSM2=", 13) == 0) { - char* p = buf + 13, * p2 = this->MenuLabelSM2; - while (*p != '/') { // copy until '/' excluding tab, carr ret, new line - if (*p != '\t' && *p != '\r' && *p != '\n') - *p2++ = *p; - p++; - } - *p2 = '\0'; - } - - else - if (_strnicmp(buf, "FanSpeedLowByte=", 16) == 0) { - this->FanSpeedLowByte = atoi(buf + 16); - } - else - if (_strnicmp(buf, "NoExtSensor=", 12) == 0) { - this->NoExtSensor = atoi(buf + 12); - } - else - if (_strnicmp(buf, "SlimDialog=", 11) == 0) { - this->SlimDialog = atoi(buf + 11); - if (this->SlimDialog != 0) this->SlimDialog = 1; - } - else - if (_strnicmp(buf, "level=", 6) == 0) { - sscanf_s(buf + 6, "%d %d", &this->SmartLevels[lcnt].temp, &this->SmartLevels[lcnt].fan); - sscanf_s(buf + 6, "%d %d", &this->SmartLevels1[lcnt].temp1, &this->SmartLevels1[lcnt].fan1); - lcnt++; - } - else - if (_strnicmp(buf, "level2=", 7) == 0) { - sscanf_s(buf + 7, "%d %d", &this->SmartLevels2[lcnt2].temp2, &this->SmartLevels2[lcnt2].fan2); - lcnt2++; - } - else - if (_strnicmp(buf, "fanbeep=", 8) == 0) { - sscanf_s(buf + 8, "%d %d", &this->FanBeepFreq, &this->FanBeepDura); - } - else - if (_strnicmp(buf, "iconlevels=", 11) == 0) { - sscanf_s(buf + 11, "%d %d %d", &this->IconLevels[0], &this->IconLevels[1], &this->IconLevels[2]); - } - - else - if (_strnicmp(buf, "NoWaitMessage=", 14) == 0) { - this->NoWaitMessage = atoi(buf + 14); - } - - else - if (_strnicmp(buf, "StartMinimized=", 15) == 0) { - this->StartMinimized = atoi(buf + 15); - } - else - if (_strnicmp(buf, "NoBallons=", 10) == 0) { - this->NoBallons = atoi(buf + 10); - } - - else - if (_strnicmp(buf, "HK_BIOS=", 8) == 0) { - this->HK_BIOS_Method = buf[8] - 0x30; - this->HK_BIOS = buf[10]; - if ((this->HK_BIOS == 0x46) & (buf[11] > 0x30) & (buf[11] < 0x40)) - this->HK_BIOS = 0x70 + atoi(buf + 11) - 1; - } - - else - if (_strnicmp(buf, "HK_Manual=", 10) == 0) { - this->HK_Manual_Method = buf[10] - 0x30; - this->HK_Manual = buf[12]; - if ((this->HK_Manual == 0x46) & (buf[13] > 0x30) & (buf[13] < 0x40)) - this->HK_Manual = 0x70 + atoi(buf + 13) - 1; - } - - else - if (_strnicmp(buf, "HK_Smart=", 9) == 0) { - this->HK_Smart_Method = buf[9] - 0x30; - this->HK_Smart = buf[11]; - if ((this->HK_Smart == 0x46) & (buf[12] > 0x30) & (buf[12] < 0x40)) - this->HK_Smart = 0x70 + atoi(buf + 12) - 1; - } - - else - if (_strnicmp(buf, "HK_SM1=", 7) == 0) { - this->HK_SM1_Method = buf[7] - 0x30; - this->HK_SM1 = buf[9]; - if ((this->HK_SM1 == 0x46) & (buf[10] > 0x30) & (buf[10] < 0x40)) - this->HK_SM1 = 0x70 + atoi(buf + 10) - 1; - } - - else - if (_strnicmp(buf, "HK_SM2=", 7) == 0) { - this->HK_SM2_Method = buf[7] - 0x30; - this->HK_SM2 = buf[9]; - if ((this->HK_SM2 == 0x46) & (buf[10] > 0x30) & (buf[10] < 0x40)) - this->HK_SM2 = 0x70 + atoi(buf + 10) - 1; - } - - else - if (_strnicmp(buf, "HK_TG_BS=", 9) == 0) { - this->HK_TG_BS_Method = buf[9] - 0x30; - this->HK_TG_BS = buf[11]; - if ((this->HK_TG_BS == 0x46) & (buf[12] > 0x30) & (buf[12] < 0x40)) - this->HK_TG_BS = 0x70 + atoi(buf + 12) - 1; - } - - else - if (_strnicmp(buf, "HK_TG_BM=", 9) == 0) { - this->HK_TG_BM_Method = buf[9] - 0x30; - this->HK_TG_BM = buf[11]; - if ((this->HK_TG_BM == 0x46) & (buf[12] > 0x30) & (buf[12] < 0x40)) - this->HK_TG_BM = 0x70 + atoi(buf + 12) - 1; - } - - else - if (_strnicmp(buf, "HK_TG_MS=", 9) == 0) { - this->HK_TG_MS_Method = buf[9] - 0x30; - this->HK_TG_MS = buf[11]; - if ((this->HK_TG_MS == 0x46) & (buf[12] > 0x30) & (buf[12] < 0x40)) - this->HK_TG_MS = 0x70 + atoi(buf + 12) - 1; - } - - else - if (_strnicmp(buf, "HK_TG_12=", 9) == 0) { - this->HK_TG_12_Method = buf[9] - 0x30; - this->HK_TG_12 = buf[11]; - if ((this->HK_TG_12 == 0x46) & (buf[12] > 0x30) & (buf[12] < 0x40)) - this->HK_TG_12 = 0x70 + atoi(buf + 12) - 1; - } - - else - if (_strnicmp(buf, "IconColorFan=", 13) == 0) { - this->IconColorFan = atoi(buf + 13); - } - - else - if (_strnicmp(buf, "Lev64Norm=", 10) == 0) { - this->Lev64Norm = atoi(buf + 10); - } - - else - if (_strnicmp(buf, "BluetoothEDR=", 13) == 0) { - this->BluetoothEDR = atoi(buf + 13); - } - - else - if (_strnicmp(buf, "ManModeExit=", 12) == 0) { - this->ManModeExit = atoi(buf + 12); - } - - else - if (_strnicmp(buf, "ShowBiasedTemps=", 16) == 0) { - this->ShowBiasedTemps = atoi(buf + 16); - } - - else - if (_strnicmp(buf, "MaxReadErrors=", 14) == 0) { - this->MaxReadErrors = atoi(buf + 14); - } - - else - if (_strnicmp(buf, "SecWinUptime=", 13) == 0) { - this->SecWinUptime = atoi(buf + 13); - } - - else - if (_strnicmp(buf, "SecStartDelay=", 14) == 0) { - this->SecStartDelay = atoi(buf + 14); - } - else - if (_strnicmp(buf, "Log2File=", 9) == 0) { - this->Log2File = atoi(buf + 9); - } - else - if (_strnicmp(buf, "StayOnTop=", 10) == 0) { - this->StayOnTop = atoi(buf + 10); - } - - else - if (_strnicmp(buf, "Log2csv=", 8) == 0) { - this->Log2csv = atoi(buf + 8); - } - - else - if (_strnicmp(buf, "ShowAll=", 8) == 0) { - this->ShowAll = atoi(buf + 8); - } - else - if (_strnicmp(buf, "ShowTempIcon=", 8) == 0) { - this->ShowTempIcon = atoi(buf + 13); - } - - // Read SensorName - else - if (_strnicmp(buf, "SensorName1=", 12) == 0) { - strncpy_s(this->gSensorNames[0], sizeof(this->gSensorNames[0]), buf + 12, 3); - } - else - if (_strnicmp(buf, "SensorName2=", 12) == 0) { - strncpy_s(this->gSensorNames[1], sizeof(this->gSensorNames[1]), buf + 12, 3); - } - else - if (_strnicmp(buf, "SensorName3=", 12) == 0) { - strncpy_s(this->gSensorNames[2], sizeof(this->gSensorNames[2]), buf + 12, 3); - } - else - if (_strnicmp(buf, "SensorName4=", 12) == 0) { - strncpy_s(this->gSensorNames[3], sizeof(this->gSensorNames[3]), buf + 12, 3); - } - else - if (_strnicmp(buf, "SensorName5=", 12) == 0) { - strncpy_s(this->gSensorNames[4], sizeof(this->gSensorNames[4]), buf + 12, 3); - } - else - if (_strnicmp(buf, "SensorName6=", 12) == 0) { - strncpy_s(this->gSensorNames[5], sizeof(this->gSensorNames[5]), buf + 12, 3); - } - else - if (_strnicmp(buf, "SensorName7=", 12) == 0) { - strncpy_s(this->gSensorNames[6], sizeof(this->gSensorNames[6]), buf + 12, 3); - } - else - if (_strnicmp(buf, "SensorName8=", 12) == 0) { - strncpy_s(this->gSensorNames[7], sizeof(this->gSensorNames[7]), buf + 12, 3); - } - else - if (_strnicmp(buf, "SensorName9=", 12) == 0) { - strncpy_s(this->gSensorNames[8], sizeof(this->gSensorNames[8]), buf + 12, 3); - } - else - if (_strnicmp(buf, "SensorName10=", 13) == 0) { - strncpy_s(this->gSensorNames[9], sizeof(this->gSensorNames[9]), buf + 13, 3); - } - else - if (_strnicmp(buf, "SensorName11=", 13) == 0) { - strncpy_s(this->gSensorNames[10], sizeof(this->gSensorNames[10]), buf + 13, 3); - } - else - if (_strnicmp(buf, "SensorName12=", 13) == 0) { - strncpy_s(this->gSensorNames[11], sizeof(this->gSensorNames[11]), buf + 13, 3); - } - else - if (_strnicmp(buf, "SensorName13=", 13) == 0) { - strncpy_s(this->gSensorNames[12], sizeof(this->gSensorNames[12]), buf + 13, 3); - } - else - if (_strnicmp(buf, "SensorName14=", 13) == 0) { - strncpy_s(this->gSensorNames[13], sizeof(this->gSensorNames[13]), buf + 13, 3); - } - else - if (_strnicmp(buf, "SensorName15=", 13) == 0) { - strncpy_s(this->gSensorNames[14], sizeof(this->gSensorNames[14]), buf + 13, 3); - } - else - if (_strnicmp(buf, "SensorName16=", 13) == 0) { - strncpy_s(this->gSensorNames[15], sizeof(this->gSensorNames[15]), buf + 13, 3); - } - // End of Reading Sensor Names - - - // Read SensorOffsets - else - if (_strnicmp(buf, "SensorOffset1=", 14) == 0) - this->SensorOffset[0] = atoi(buf + 14); - else - if (_strnicmp(buf, "SensorOffset2=", 14) == 0) - this->SensorOffset[1] = atoi(buf + 14); - else - if (_strnicmp(buf, "SensorOffset3=", 14) == 0) - this->SensorOffset[2] = atoi(buf + 14); - else - if (_strnicmp(buf, "SensorOffset4=", 14) == 0) - this->SensorOffset[3] = atoi(buf + 14); - else - if (_strnicmp(buf, "SensorOffset5=", 14) == 0) - this->SensorOffset[4] = atoi(buf + 14); - else - if (_strnicmp(buf, "SensorOffset6=", 14) == 0) - this->SensorOffset[5] = atoi(buf + 14); - else - if (_strnicmp(buf, "SensorOffset7=", 14) == 0) - this->SensorOffset[6] = atoi(buf + 14); - else - if (_strnicmp(buf, "SensorOffset8=", 14) == 0) - this->SensorOffset[7] = atoi(buf + 14); - else - if (_strnicmp(buf, "SensorOffset9=", 14) == 0) - this->SensorOffset[8] = atoi(buf + 14); - else - if (_strnicmp(buf, "SensorOffset10=", 15) == 0) - this->SensorOffset[9] = atoi(buf + 15); - else - if (_strnicmp(buf, "SensorOffset11=", 15) == 0) - this->SensorOffset[10] = atoi(buf + 15); - else - if (_strnicmp(buf, "SensorOffset12=", 15) == 0) - this->SensorOffset[11] = atoi(buf + 15); - else - if (_strnicmp(buf, "SensorOffset13=", 15) == 0) - this->SensorOffset[12] = atoi(buf + 15); - else - if (_strnicmp(buf, "SensorOffset14=", 15) == 0) - this->SensorOffset[13] = atoi(buf + 15); - else - if (_strnicmp(buf, "SensorOffset15=", 15) == 0) - this->SensorOffset[14] = atoi(buf + 15); - else - if (_strnicmp(buf, "SensorOffset16=", 15) == 0) - this->SensorOffset[15] = atoi(buf + 15); - - // End of Reading Sensor Offsets - - else - if (_strnicmp(buf, "IgnoreSensors=", 14) == 0) { - char* p = buf + 14, * p2 = this->IgnoreSensors; - - while (*p) { // copy excluding space and tab - if (*p != ' ' && *p != '\t' && *p != '\r' && *p != '\n') - *p2++ = *p; - p++; - } - *p2 = '\0'; - } + *p2= '\0'; + } + + else + if (_strnicmp(buf, "FanSpeedLowByte=", 16)==0) { + this->FanSpeedLowByte= atoi(buf+16); + } + else + if (_strnicmp(buf, "NoExtSensor=", 12)==0) { + this->NoExtSensor= atoi(buf+12); + } + else + if (_strnicmp(buf, "SlimDialog=", 11)==0) { + this->SlimDialog= atoi(buf+11); + if (this->SlimDialog != 0) this->SlimDialog = 1; + } + else + if (_strnicmp(buf, "level=", 6)==0) { + sscanf_s(buf+6, "%d %d", &this->SmartLevels[lcnt].temp, &this->SmartLevels[lcnt].fan); + sscanf_s(buf+6, "%d %d", &this->SmartLevels1[lcnt].temp1, &this->SmartLevels1[lcnt].fan1); + lcnt++; + } + else + if (_strnicmp(buf, "level2=", 7)==0) { + sscanf_s(buf+7, "%d %d", &this->SmartLevels2[lcnt2].temp2, &this->SmartLevels2[lcnt2].fan2); + lcnt2++; + } + else + if (_strnicmp(buf, "fanbeep=", 8)==0) { + sscanf_s(buf+8, "%d %d", &this->FanBeepFreq, &this->FanBeepDura); + } + else + if (_strnicmp(buf, "iconlevels=", 11)==0) { + sscanf_s(buf+11, "%d %d %d", &this->IconLevels[0], &this->IconLevels[1], &this->IconLevels[2]); + } + + else + if (_strnicmp(buf, "NoWaitMessage=", 14)==0) { + this->NoWaitMessage= atoi(buf+14); + } + + else + if (_strnicmp(buf, "StartMinimized=", 15)==0) { + this->StartMinimized= atoi(buf+15); + } + else + if (_strnicmp(buf, "NoBallons=", 10)==0) { + this->NoBallons= atoi(buf+10); + } + + else + if (_strnicmp(buf, "Hotkeys=", 8)==0) { + this->Hotkeys= atoi(buf+8); + } + + else + if (_strnicmp(buf, "IconColorFan=", 13)==0) { + this->IconColorFan= atoi(buf+13); + } + + else + if (_strnicmp(buf, "Lev64Norm=", 10)==0) { + this->Lev64Norm= atoi(buf+10); + } + + else + if (_strnicmp(buf, "BluetoothEDR=", 13)==0) { + this->BluetoothEDR= atoi(buf+13); + } + + else + if (_strnicmp(buf, "ManModeExit=", 12)==0) { + this->ManModeExit= atoi(buf+12); + } + + else + if (_strnicmp(buf, "ShowBiasedTemps=", 16)==0) { + this->ShowBiasedTemps= atoi(buf+16); + } + + else + if (_strnicmp(buf, "MaxReadErrors=", 14)==0) { + this->MaxReadErrors= atoi(buf+14); + } + + else + if (_strnicmp(buf, "SecWinUptime=", 13)==0) { + this->SecWinUptime= atoi(buf+13); + } + + else + if (_strnicmp(buf, "SecStartDelay=", 14)==0) { + this->SecStartDelay= atoi(buf+14); + } + else + if (_strnicmp(buf, "Log2File=", 9)==0) { + this->Log2File= atoi(buf+9); + } + else + if (_strnicmp(buf, "StayOnTop=", 10)==0) { + this->StayOnTop= atoi(buf+10); + } + + else + if (_strnicmp(buf, "Log2csv=", 8)==0) { + this->Log2csv= atoi(buf+8); + } + + else + if (_strnicmp(buf, "ShowAll=", 8)==0) { + this->ShowAll= atoi(buf+8); + } + else + if (_strnicmp(buf, "ShowTempIcon=", 8)==0) { + this->ShowTempIcon= atoi(buf+13); + } + + // Read SensorName + else + if (_strnicmp(buf, "SensorName1=", 12)==0) { + strncpy_s(this->gSensorNames[0],sizeof(this->gSensorNames[0]), buf+12, 3); + } + else + if (_strnicmp(buf, "SensorName2=", 12)==0) { + strncpy_s(this->gSensorNames[1],sizeof(this->gSensorNames[1]), buf+12, 3); + } + else + if (_strnicmp(buf, "SensorName3=", 12)==0) { + strncpy_s(this->gSensorNames[2],sizeof(this->gSensorNames[2]), buf+12, 3); + } + else + if (_strnicmp(buf, "SensorName4=", 12)==0) { + strncpy_s(this->gSensorNames[3],sizeof(this->gSensorNames[3]), buf+12, 3); + } + else + if (_strnicmp(buf, "SensorName5=", 12)==0) { + strncpy_s(this->gSensorNames[4],sizeof(this->gSensorNames[4]), buf+12, 3); + } + else + if (_strnicmp(buf, "SensorName6=", 12)==0) { + strncpy_s(this->gSensorNames[5],sizeof(this->gSensorNames[5]), buf+12, 3); + } + else + if (_strnicmp(buf, "SensorName7=", 12)==0) { + strncpy_s(this->gSensorNames[6],sizeof(this->gSensorNames[6]), buf+12, 3); + } + else + if (_strnicmp(buf, "SensorName8=", 12)==0) { + strncpy_s(this->gSensorNames[7],sizeof(this->gSensorNames[7]), buf+12, 3); + } + else + if (_strnicmp(buf, "SensorName9=", 12)==0) { + strncpy_s(this->gSensorNames[8],sizeof(this->gSensorNames[8]), buf+12, 3); + } + else + if (_strnicmp(buf, "SensorName10=", 13)==0) { + strncpy_s(this->gSensorNames[9],sizeof(this->gSensorNames[9]), buf+13, 3); + } + else + if (_strnicmp(buf, "SensorName11=", 13)==0) { + strncpy_s(this->gSensorNames[10],sizeof(this->gSensorNames[10]), buf+13, 3); + } + else + if (_strnicmp(buf, "SensorName12=", 13)==0) { + strncpy_s(this->gSensorNames[11],sizeof(this->gSensorNames[11]), buf+13, 3); + } + else + if (_strnicmp(buf, "SensorName13=", 13)==0) { + strncpy_s(this->gSensorNames[12],sizeof(this->gSensorNames[12]), buf+13, 3); + } + else + if (_strnicmp(buf, "SensorName14=", 13)==0) { + strncpy_s(this->gSensorNames[13],sizeof(this->gSensorNames[13]), buf+13, 3); + } + else + if (_strnicmp(buf, "SensorName15=", 13)==0) { + strncpy_s(this->gSensorNames[14],sizeof(this->gSensorNames[14]), buf+13, 3); + } + else + if (_strnicmp(buf, "SensorName16=", 13)==0) { + strncpy_s(this->gSensorNames[15],sizeof(this->gSensorNames[15]), buf+13, 3); + } + // End of Reading Sensor Names + + + // Read SensorOffsets + else + if (_strnicmp(buf, "SensorOffset1=", 14)==0) + this->SensorOffset[0]= atoi(buf+14); + else + if (_strnicmp(buf, "SensorOffset2=", 14)==0) + this->SensorOffset[1]= atoi(buf+14); + else + if (_strnicmp(buf, "SensorOffset3=", 14)==0) + this->SensorOffset[2]= atoi(buf+14); + else + if (_strnicmp(buf, "SensorOffset4=", 14)==0) + this->SensorOffset[3]= atoi(buf+14); + else + if (_strnicmp(buf, "SensorOffset5=", 14)==0) + this->SensorOffset[4]= atoi(buf+14); + else + if (_strnicmp(buf, "SensorOffset6=", 14)==0) + this->SensorOffset[5]= atoi(buf+14); + else + if (_strnicmp(buf, "SensorOffset7=", 14)==0) + this->SensorOffset[6]= atoi(buf+14); + else + if (_strnicmp(buf, "SensorOffset8=", 14)==0) + this->SensorOffset[7]= atoi(buf+14); + else + if (_strnicmp(buf, "SensorOffset9=", 14)==0) + this->SensorOffset[8]= atoi(buf+14); + else + if (_strnicmp(buf, "SensorOffset10=", 15)==0) + this->SensorOffset[9]= atoi(buf+15); + else + if (_strnicmp(buf, "SensorOffset11=", 15)==0) + this->SensorOffset[10]= atoi(buf+15); + else + if (_strnicmp(buf, "SensorOffset12=", 15)==0) + this->SensorOffset[11]= atoi(buf+15); + else + if (_strnicmp(buf, "SensorOffset13=", 15)==0) + this->SensorOffset[12]= atoi(buf+15); + else + if (_strnicmp(buf, "SensorOffset14=", 15)==0) + this->SensorOffset[13]= atoi(buf+15); + else + if (_strnicmp(buf, "SensorOffset15=", 15)==0) + this->SensorOffset[14]= atoi(buf+15); + else + if (_strnicmp(buf, "SensorOffset16=", 15)==0) + this->SensorOffset[15]= atoi(buf+15); + + // End of Reading Sensor Offsets + + else + if (_strnicmp(buf, "IgnoreSensors=", 14)==0) { + char *p= buf+14, *p2= this->IgnoreSensors; + + while (*p) { // copy excluding space and tab + if (*p!=' ' && *p!='\t' && *p!='\r' && *p!='\n') + *p2++= *p; + p++; + } + *p2= '\0'; + } } fclose(f); if (this->StayOnTop) - this->hwndDialog = ::CreateDialogParam(hinstapp, - MAKEINTRESOURCE(9000), - HWND_DESKTOP, - (DLGPROC)BaseDlgProc, - (LPARAM)this); + this->hwndDialog= ::CreateDialogParam(hinstapp, + MAKEINTRESOURCE(9000), + HWND_DESKTOP, + (DLGPROC)BaseDlgProc, + (LPARAM)this); else - this->hwndDialog = ::CreateDialogParam(hinstapp, - MAKEINTRESOURCE(9002), - HWND_DESKTOP, - (DLGPROC)BaseDlgProc, - (LPARAM)this); - + this->hwndDialog= ::CreateDialogParam(hinstapp, + MAKEINTRESOURCE(9002), + HWND_DESKTOP, + (DLGPROC)BaseDlgProc, + (LPARAM)this); + // end marker for smart levels array if (lcnt) { - this->SmartLevels[lcnt].temp = -1; - this->SmartLevels1[lcnt].temp1 = -1; - this->SmartLevels[lcnt].fan = 0x80; - this->SmartLevels1[lcnt].fan1 = 0x80; + this->SmartLevels[lcnt].temp= -1; + this->SmartLevels1[lcnt].temp1= -1; + this->SmartLevels[lcnt].fan= 0x80; + this->SmartLevels1[lcnt].fan1= 0x80; } if (lcnt2) { - this->SmartLevels2[lcnt2].temp2 = -1; - this->SmartLevels2[lcnt2].fan2 = 0x80; + this->SmartLevels2[lcnt2].temp2= -1; + this->SmartLevels2[lcnt2].fan2= 0x80; } - ok = true; + ok= true; - this->Trace("Current Config:"); + this->Trace("Current Config:"); } else { this->Trace("TPFanControl.ini missing, default values:"); - } + } //if running as service Runs_as_service= TRUE - HANDLE hLockS = CreateMutex(NULL, FALSE, "TPFanControlMutex01"); - if (hLockS == NULL)Runs_as_service = TRUE; - if (WAIT_OBJECT_0 != WaitForSingleObject(hLockS, 0)) - Runs_as_service = TRUE; - + HANDLE hLockS = CreateMutex(NULL,FALSE,"TPFanControlMutex01"); + if(hLockS == NULL)Runs_as_service= TRUE; + if(WAIT_OBJECT_0 != WaitForSingleObject(hLockS,0)) + Runs_as_service= TRUE; + //Offset Fahrenheit to Celsius - if (this->SmartLevels[0].temp >= 80) Fahrenheit = TRUE; - + if(this->SmartLevels[0].temp >= 80) Fahrenheit = TRUE; + // Set ProcessPriority BOOL _SPC; - switch (ProcessPriority) { - case 5: _SPC = SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); break; - case 4: _SPC = SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); break; - case 3: _SPC = SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); break; + switch (ProcessPriority){ + case 5: _SPC = SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); break; + case 4: _SPC = SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); break; + case 3: _SPC = SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); break; // case 2: _SPC = SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); break; - case 1: _SPC = SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); break; - case 0: _SPC = SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS); break; - default: break; // _SPC = SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); + case 1: _SPC = SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); break; + case 0: _SPC = SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS); break; + default: break; // _SPC = SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); } - + // // display config // if (this->IconCycle <= 0 || this->IconCycle >= 60) this->IconCycle = 1; - sprintf_s(buf, sizeof(buf), " Active= %d, Cycle= %d, FanBeep= %d %d, MaxReadErrors= %d", - this->ActiveMode, this->Cycle, - this->FanBeepFreq, this->FanBeepDura, this->MaxReadErrors); + sprintf_s(buf,sizeof(buf), " Active= %d, Cycle= %d, FanBeep= %d %d, MaxReadErrors= %d", + this->ActiveMode, this->Cycle, + this->FanBeepFreq, this->FanBeepDura, this->MaxReadErrors); this->Trace(buf); - sprintf_s(buf, sizeof(buf), " IconLevels= %d %d %d, NoExtSensor= %d, Lev64Norm= %d", - this->IconLevels[0], this->IconLevels[1], this->IconLevels[2], - this->NoExtSensor, this->Lev64Norm); + sprintf_s(buf,sizeof(buf), " IconLevels= %d %d %d, NoExtSensor= %d, Lev64Norm= %d", + this->IconLevels[0], this->IconLevels[1], this->IconLevels[2], + this->NoExtSensor, this->Lev64Norm); - this->Trace(buf); + this->Trace(buf); - sprintf_s(buf, sizeof(buf), " Log2File= %d, Log2csv= %d, ShowAll= %d, IconColorFan= %d", - this->Log2File, this->Log2csv, this->ShowAll, this->IconColorFan); + sprintf_s(buf,sizeof(buf), " Log2File= %d, Log2csv= %d, ShowAll= %d, IconColorFan= %d", + this->Log2File, this->Log2csv, this-> ShowAll, this->IconColorFan); this->Trace(buf); this->ShowAllToDialog(ShowAll); setzero(buf, sizeof(buf)); - if (Fahrenheit) { - strcpy_s(buf, sizeof(buf), " "); - for (i = 0; this->SmartLevels[i].temp != -1; i++) { - sprintf_s(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s%d° F->", - i > 0 ? ", " : "", this->SmartLevels[i].temp); - if (this->SmartLevels[i].fan != 0x80) - sprintf_s(buf + strlen(buf), sizeof(buf) - strlen(buf), "%d", - this->SmartLevels[i].fan); - else - strcat_s(buf, sizeof(buf), "0x80"); + if (Fahrenheit){ + strcpy_s(buf,sizeof(buf), " "); + for (i= 0; this->SmartLevels[i].temp!=-1; i++) { + sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d°F->", + i>0 ? ", " : "", this->SmartLevels[i].temp); + if (this->SmartLevels[i].fan!=0x80) + sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%d", + this->SmartLevels[i].fan); + else + strcat_s(buf,sizeof(buf), "0x80"); } } else { - strcpy_s(buf, sizeof(buf), " Levels= "); - for (i = 0; this->SmartLevels[i].temp != -1; i++) { - sprintf_s(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s%d° C -> ", - i > 0 ? ", " : "", + strcpy_s(buf,sizeof(buf), " Levels= "); + for (i= 0; this->SmartLevels[i].temp!=-1; i++) { + sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d°C -> ", + i>0 ? ", " : "", this->SmartLevels[i].temp); - if (this->SmartLevels[i].fan != 0x80) - sprintf_s(buf + strlen(buf), sizeof(buf) - strlen(buf), "%d", - this->SmartLevels[i].fan); + if (this->SmartLevels[i].fan!=0x80) + sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%d", + this->SmartLevels[i].fan); else - strcat_s(buf, sizeof(buf), "0x80"); + strcat_s(buf,sizeof(buf), "0x80"); } } - + this->Trace(buf); - + //Levels2 - - if (this->SmartLevels2[0].temp2 != 0) + + if ( this->SmartLevels2[0].temp2 != 0 ) { - if (Fahrenheit) { - strcpy_s(buf, sizeof(buf), " "); - for (i = 0; this->SmartLevels2[i].temp2 != -1; i++) { - sprintf_s(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s%d° F->", - i > 0 ? ", " : "", this->SmartLevels2[i].temp2); - if (this->SmartLevels2[i].fan2 != 0x80) - sprintf_s(buf + strlen(buf), sizeof(buf) - strlen(buf), "%d", - this->SmartLevels2[i].fan2); - else - strcat_s(buf, sizeof(buf), "0x80"); - } + if (Fahrenheit){ + strcpy_s(buf,sizeof(buf), " "); + for (i= 0; this->SmartLevels2[i].temp2!=-1; i++) { + sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d°F->", + i>0 ? ", " : "", this->SmartLevels2[i].temp2); + if (this->SmartLevels2[i].fan2!=0x80) + sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%d", + this->SmartLevels2[i].fan2); + else + strcat_s(buf,sizeof(buf), "0x80"); } - else { - strcpy_s(buf, sizeof(buf), " Levels2= "); - for (i = 0; this->SmartLevels2[i].temp2 != -1; i++) { - sprintf_s(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s%d° C -> ", - i > 0 ? ", " : "", - this->SmartLevels2[i].temp2); - if (this->SmartLevels2[i].fan2 != 0x80) - sprintf_s(buf + strlen(buf), sizeof(buf) - strlen(buf), "%d", - this->SmartLevels2[i].fan2); - else - strcat_s(buf, sizeof(buf), "0x80"); - } + } + else { + strcpy_s(buf,sizeof(buf), " Levels2= "); + for (i= 0; this->SmartLevels2[i].temp2!=-1; i++) { + sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%s%d°C -> ", + i>0 ? ", " : "", + this->SmartLevels2[i].temp2); + if (this->SmartLevels2[i].fan2!=0x80) + sprintf_s(buf+strlen(buf),sizeof(buf)-strlen(buf), "%d", + this->SmartLevels2[i].fan2); + else + strcat_s(buf,sizeof(buf), "0x80"); } - - this->Trace(buf); + } + + this->Trace(buf); } if (Fahrenheit) { - sprintf_s(buf, sizeof(buf), " SensorOffset1-12= %d %d %d %d %d %d %d %d %d %d %d %d ° F", + sprintf_s(buf,sizeof(buf), " SensorOffset1-12= %d %d %d %d %d %d %d %d %d %d %d %d °F", this->SensorOffset[0], this->SensorOffset[1], this->SensorOffset[2], this->SensorOffset[3], this->SensorOffset[4], this->SensorOffset[5], this->SensorOffset[6], this->SensorOffset[7], this->SensorOffset[8], this->SensorOffset[9], this->SensorOffset[10], this->SensorOffset[11]); - - for (i = 0; i < 15; i++) { SensorOffset[i] = SensorOffset[i] * 5 / 9; } + + for (i= 0; i<15; i++) {SensorOffset[i]= SensorOffset[i] * 5/9;} } else { - sprintf_s(buf, sizeof(buf), " SensorOffset1-12= %d %d %d %d %d %d %d %d %d %d %d %d ° C", + sprintf_s(buf,sizeof(buf), " SensorOffset1-12= %d %d %d %d %d %d %d %d %d %d %d %d °C", this->SensorOffset[0], this->SensorOffset[1], this->SensorOffset[2], this->SensorOffset[3], this->SensorOffset[4], this->SensorOffset[5], this->SensorOffset[6], this->SensorOffset[7], this->SensorOffset[8], @@ -597,62 +525,62 @@ FANCONTROL::ReadConfig(const char* configfile) } this->Trace(buf); - - sprintf_s(buf, sizeof(buf), " IgnoreSensors= %s, ProcessPriority= %d, IconCycle= %d", IgnoreSensors, ProcessPriority, IconCycle); + + sprintf_s(buf,sizeof(buf), " IgnoreSensors= %s, ProcessPriority= %d, IconCycle= %d", IgnoreSensors, ProcessPriority, IconCycle); this->Trace(buf); - sprintf_s(buf, sizeof(buf), " BluetoothEDR= %d, NoWaitMessage= %d, ShowBiasedTemps= %d", this->BluetoothEDR, NoWaitMessage, ShowBiasedTemps); + sprintf_s(buf,sizeof(buf), " BluetoothEDR= %d, NoWaitMessage= %d, ShowBiasedTemps= %d", this->BluetoothEDR, NoWaitMessage, ShowBiasedTemps); this->Trace(buf); //ManModeExit Fahrenheit to Celsius and v.v. - if (Fahrenheit && (this->ManModeExit == 80)) - this->ManModeExit = (this->ManModeExit * 9 / 5) + 32; + if (Fahrenheit && (this->ManModeExit == 80)) + this->ManModeExit = (this->ManModeExit* 9/5) + 32 ; - if (Fahrenheit) - this->ManModeExit2 = (this->ManModeExit - 32) * 5 / 9; - else + if (Fahrenheit) + this->ManModeExit2 = (this->ManModeExit - 32) * 5/9; + else this->ManModeExit2 = this->ManModeExit; - sprintf_s(buf, sizeof(buf), " ManModeExit= %d, SecWinUptime= %d, SecStartDelay= %d", this->ManModeExit, this->SecWinUptime, this->SecStartDelay); + sprintf_s(buf,sizeof(buf), " ManModeExit= %d, SecWinUptime= %d, SecStartDelay= %d", this->ManModeExit, this->SecWinUptime, this->SecStartDelay); this->Trace(buf); //Offset& Smartlevels Fahrenheit to Celsius if (Fahrenheit) { - for (i = 0; this->SmartLevels[i].temp != -1; i++) { this->SmartLevels[i].temp = (this->SmartLevels[i].temp - 32) * 5 / 9; } - for (i = 0; this->SmartLevels1[i].temp1 != -1; i++) { this->SmartLevels1[i].temp1 = (this->SmartLevels1[i].temp1 - 32) * 5 / 9; } - if (this->SmartLevels2[0].temp2 == 0); // Indikator für 2.Profil - else this->SmartLevels2[0].temp2 = (this->SmartLevels2[0].temp2 - 32) * 5 / 9; - for (i = 1; this->SmartLevels2[i].temp2 != -1; i++) { this->SmartLevels2[i].temp2 = (this->SmartLevels2[i].temp2 - 32) * 5 / 9; } - // for (i= 0; i<15; i++) {SensorOffset[i]= SensorOffset[i] * 5/9;} - this->IconLevels[0] = (this->IconLevels[0] - 32) * 5 / 9; - this->IconLevels[1] = (this->IconLevels[1] - 32) * 5 / 9; - this->IconLevels[2] = (this->IconLevels[2] - 32) * 5 / 9; + for (i= 0; this->SmartLevels[i].temp!=-1; i++) {this->SmartLevels[i].temp = (this->SmartLevels[i].temp - 32) * 5/9;} + for (i= 0; this->SmartLevels1[i].temp1!=-1; i++) {this->SmartLevels1[i].temp1 = (this->SmartLevels1[i].temp1 - 32) * 5/9;} + if (this->SmartLevels2[0].temp2==0); // Indikator für 2.Profil + else this->SmartLevels2[0].temp2 = (this->SmartLevels2[0].temp2 - 32) * 5/9; + for (i= 1; this->SmartLevels2[i].temp2!=-1; i++) {this->SmartLevels2[i].temp2 = (this->SmartLevels2[i].temp2 - 32) * 5/9;} +// for (i= 0; i<15; i++) {SensorOffset[i]= SensorOffset[i] * 5/9;} + this->IconLevels[0]= (this->IconLevels[0] - 32) * 5/9; + this->IconLevels[1]= (this->IconLevels[1] - 32) * 5/9; + this->IconLevels[2]= (this->IconLevels[2] - 32) * 5/9; } this->Trace(""); - if (this->Log2csv == 1) { - int - delfile = system - ( - "del TPFanControl_last_csv.txt && ren TPFanControl_csv.txt TPFanControl_last_csv.txt" - ); - sprintf_s(buf, sizeof(buf), "time;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;rpm;fan;switch;", - this->gSensorNames[0], this->gSensorNames[1], this->gSensorNames[2], - this->gSensorNames[3], this->gSensorNames[4], this->gSensorNames[5], - this->gSensorNames[6], this->gSensorNames[7], this->gSensorNames[8], - this->gSensorNames[9], this->gSensorNames[10], this->gSensorNames[11]); - - this->Tracecsvod(buf); + if (this->Log2csv==1) { + int + delfile = system + ( + "del TPFanControl_last_csv.txt && ren TPFanControl_csv.txt TPFanControl_last_csv.txt" + ); + sprintf_s(buf,sizeof(buf), "time;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;rpm;fan;switch;", + this->gSensorNames[0], this->gSensorNames[1], this->gSensorNames[2], + this->gSensorNames[3], this->gSensorNames[4], this->gSensorNames[5], + this->gSensorNames[6], this->gSensorNames[7], this->gSensorNames[8], + this->gSensorNames[9], this->gSensorNames[10], this->gSensorNames[11]); + + this->Tracecsvod(buf); } // initial values - this->TaskbarNew = 0; + this->TaskbarNew=0; this->MaxTemp = 0; this->iMaxTemp = 0; - this->iFarbeIconB = 10; + this->iFarbeIconB =10; this->iFontIconB = 9; this->lastfanspeed = 0; this->fanspeed = 0; @@ -667,12 +595,12 @@ FANCONTROL::ReadConfig(const char* configfile) // localized date&time //------------------------------------------------------------------------- void -FANCONTROL::CurrentDateTimeLocalized(char* result, size_t sizeof_result) +FANCONTROL::CurrentDateTimeLocalized(char *result,size_t sizeof_result) { SYSTEMTIME s; ::GetLocalTime(&s); - char otfmt[64] = "HH:mm:ss", otime[64]; + char otfmt[64]= "HH:mm:ss", otime[64]; char odfmt[128], odate[64]; @@ -682,24 +610,24 @@ FANCONTROL::CurrentDateTimeLocalized(char* result, size_t sizeof_result) ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, odfmt, sizeof(odfmt)); - ::GetDateFormat(LOCALE_USER_DEFAULT, 0, &s, odfmt, odate, sizeof(odate)); + ::GetDateFormat(LOCALE_USER_DEFAULT, 0, &s, odfmt, odate, sizeof(odate)); setzero(result, sizeof_result); - strncpy_s(result, sizeof_result, odate, sizeof_result - 2); - strcat_s(result, sizeof_result, " "); - strncat_s(result, sizeof_result, otime, sizeof_result - strlen(result) - 1); + strncpy_s(result,sizeof_result, odate, sizeof_result-2); + strcat_s(result,sizeof_result, " "); + strncat_s(result,sizeof_result, otime, sizeof_result-strlen(result)-1); } //------------------------------------------------------------------------- // localized time //------------------------------------------------------------------------- void -FANCONTROL::CurrentTimeLocalized(char* result, size_t sizeof_result) +FANCONTROL::CurrentTimeLocalized(char *result, size_t sizeof_result) { SYSTEMTIME s; ::GetLocalTime(&s); - char otfmt[64] = "HH:mm:ss", otime[64]; + char otfmt[64]= "HH:mm:ss", otime[64]; // char odfmt[128], odate[64]; @@ -714,7 +642,7 @@ FANCONTROL::CurrentTimeLocalized(char* result, size_t sizeof_result) setzero(result, sizeof_result); // strncpy_s(result,sizeof_result, odate, sizeof_result-2); // strcat_s(result,sizeof_result, " "); - strncat_s(result, sizeof_result, otime, sizeof_result - 1); + strncat_s(result,sizeof_result, otime, sizeof_result-1); // strncat_s(result,sizeof_result, otime, sizeof_result-strlen(result)-1); } @@ -723,14 +651,14 @@ FANCONTROL::CurrentTimeLocalized(char* result, size_t sizeof_result) //------------------------------------------------------------------------- // //------------------------------------------------------------------------- -BOOL +BOOL FANCONTROL::IsMinimized(void) { - WINDOWPLACEMENT wp = NULLSTRUCT; + WINDOWPLACEMENT wp= NULLSTRUCT; ::GetWindowPlacement(this->hwndDialog, &wp); - return wp.showCmd == SW_SHOWMINIMIZED; + return wp.showCmd==SW_SHOWMINIMIZED; } @@ -739,32 +667,32 @@ FANCONTROL::IsMinimized(void) //------------------------------------------------------------------------- // show trace output in lower window part //------------------------------------------------------------------------- -void -FANCONTROL::Trace(const char* text) +void +FANCONTROL::Trace(const char *text) { - char trace[16384] = "", datebuf[128] = "", line[256] = "", linecsv[256] = ""; + char trace[16384]= "", datebuf[128]= "", line[256]= "", linecsv[256]= ""; this->CurrentDateTimeLocalized(datebuf, sizeof(datebuf)); - if (strlen(text)) - sprintf_s(line, sizeof(line), "[%s] %s\r\n", datebuf, text); // probably acpi reading conflict + if (strlen(text)) + sprintf_s(line,sizeof(line), "[%s] %s\r\n", datebuf, text); // probably acpi reading conflict else - strcpy_s(line, sizeof(line), "\r\n"); - - ::GetDlgItemText(this->hwndDialog, 9200, trace, sizeof(trace) - strlen(line) - 1); - strcat_s(trace, sizeof(trace), line); + strcpy_s(line,sizeof(line), "\r\n"); + ::GetDlgItemText(this->hwndDialog, 9200, trace, sizeof(trace)-strlen(line)-1); + strcat_s(trace,sizeof(trace), line); + // // display 100 lines max // - char* p = trace + strlen(trace); - int linecount = 0; + char *p= trace + strlen(trace); + int linecount= 0; - while (p >= trace) { + while (p>= trace) { - if (*p == '\n') { + if (*p=='\n') { linecount++; - if (linecount > 100) + if (linecount>100) break; } @@ -775,67 +703,67 @@ FANCONTROL::Trace(const char* text) // // write logfile // - if (this->Log2File == 1) { - FILE* flog; - errno_t errflog = fopen_s(&flog, "TPFanControl.log", "ab"); + if (this->Log2File==1) { + FILE *flog; + errno_t errflog = fopen_s(&flog,"TPFanControl.log", "ab"); if (!errflog) { //TODO: fwrite_s - fwrite(line, strlen(line), 1, flog); - fclose(flog); - } + fwrite(line, strlen(line), 1, flog); + fclose(flog); + } } // // redisplay log and scroll to bottom // - ::SetDlgItemText(this->hwndDialog, 9200, p + 1); - ::SendDlgItemMessage(this->hwndDialog, 9200, EM_SETSEL, strlen(trace) - 2, strlen(trace) - 2); + ::SetDlgItemText(this->hwndDialog,9200, p+1); + ::SendDlgItemMessage(this->hwndDialog, 9200, EM_SETSEL, strlen(trace)-2, strlen(trace)-2); ::SendDlgItemMessage(this->hwndDialog, 9200, EM_LINESCROLL, 0, 9999); } -void -FANCONTROL::Tracecsv(const char* text) +void +FANCONTROL::Tracecsv(const char *text) { - char trace[16384] = "", datebuf[128] = "", line[256] = ""; + char trace[16384]= "", datebuf[128]= "", line[256]= ""; this->CurrentTimeLocalized(datebuf, sizeof(datebuf)); - if (strlen(text)) - sprintf_s(line, sizeof(line), "%s; %s\r\n", datebuf, text); // probably acpi reading conflict + if (strlen(text)) + sprintf_s(line,sizeof(line), "%s; %s\r\n", datebuf, text); // probably acpi reading conflict else - strcpy_s(line, sizeof(line), "\r\n"); + strcpy_s(line,sizeof(line), "\r\n"); // write logfile // - if (this->Log2csv == 1) { - FILE* flogcsv; - errno_t errflogcsv = fopen_s(&flogcsv, "TPFanControl_csv.txt", "ab"); - if (!errflogcsv) { fwrite(line, strlen_s(line, sizeof(line)), 1, flogcsv); fclose(flogcsv); } + if (this->Log2csv==1) { + FILE *flogcsv; + errno_t errflogcsv = fopen_s(&flogcsv,"TPFanControl_csv.txt", "ab"); + if (!errflogcsv) {fwrite(line, strlen_s(line,sizeof(line)), 1, flogcsv);fclose(flogcsv);} } } -void -FANCONTROL::Tracecsvod(const char* text) +void +FANCONTROL::Tracecsvod(const char *text) { - char trace[16384] = "", datebuf[128] = "", line[256] = ""; + char trace[16384]= "", datebuf[128]= "", line[256]= ""; this->CurrentDateTimeLocalized(datebuf, sizeof(datebuf)); - if (strlen(text)) - sprintf_s(line, sizeof(line), "%s\r\n", text); // probably acpi reading conflict + if (strlen(text)) + sprintf_s(line,sizeof(line), "%s\r\n", text); // probably acpi reading conflict else - strcpy_s(line, sizeof(line), "\r\n"); + strcpy_s(line,sizeof(line), "\r\n"); // write logfile // - if (this->Log2csv == 1) { - FILE* flogcsv; - errno_t errflogcsv = fopen_s(&flogcsv, "TPFanControl_csv.txt", "ab"); - if (!errflogcsv) { fwrite(line, strlen(line), 1, flogcsv); fclose(flogcsv); } + if (this->Log2csv==1) { + FILE *flogcsv; + errno_t errflogcsv = fopen_s(&flogcsv,"TPFanControl_csv.txt", "ab"); + if (!errflogcsv) {fwrite(line, strlen(line), 1, flogcsv);fclose(flogcsv);} } } @@ -844,11 +772,11 @@ FANCONTROL::Tracecsvod(const char* text) // create a thread //------------------------------------------------------------------------- HANDLE -FANCONTROL::CreateThread(int(_stdcall* fnct)(ULONG), ULONG p) +FANCONTROL::CreateThread(int (_stdcall *fnct)(ULONG), ULONG p) { - LPTHREAD_START_ROUTINE thread = (LPTHREAD_START_ROUTINE)fnct; - DWORD tid; - HANDLE hThread; - hThread = ::CreateThread(NULL, 8 * 4096, thread, (void*)p, 0, &tid); - return hThread; + LPTHREAD_START_ROUTINE thread= (LPTHREAD_START_ROUTINE)fnct; + DWORD tid; + HANDLE hThread; + hThread= ::CreateThread(NULL, 8*4096, thread, (void*)p, 0, &tid); + return hThread; } \ No newline at end of file diff --git a/fancontrol/portio.cpp b/fancontrol/portio.cpp index 10d3a60..1e6d5a8 100644 --- a/fancontrol/portio.cpp +++ b/fancontrol/portio.cpp @@ -1,4 +1,4 @@ -// -------------------------------------------------------------- +// -------------------------------------------------------------- // // Thinkpad Fan Control // @@ -21,237 +21,186 @@ // Registers of the embedded controller -#define EC_DATAPORT 0x1600 // EC data io-port 0x62 -#define EC_CTRLPORT 0x1604 // EC control io-port 0x66 +#define EC_DATAPORT 0x62 // EC data io-port +#define EC_CTRLPORT 0x66 // EC control io-port // Embedded controller status register bits -#define EC_STAT_OBF 0x01 // Output buffer full -#define EC_STAT_IBF 0x02 // Input buffer full -#define EC_STAT_CMD 0x08 // Last write was a command write (0=data) +#define EC_STAT_OBF 0x01 // Output buffer full +#define EC_STAT_IBF 0x02 // Input buffer full +#define EC_STAT_CMD 0x08 // Last write was a command write (0=data) // Embedded controller commands // (write to EC_CTRLPORT to initiate read/write operation) -#define EC_CTRLPORT_READ (char)0x80 -#define EC_CTRLPORT_WRITE (char)0x81 -#define EC_CTRLPORT_QUERY (char)0x84 - +#define EC_CTRLPORT_READ (char)0x80 +#define EC_CTRLPORT_WRITE (char)0x81 +#define EC_CTRLPORT_QUERY (char)0x84 -int verbosity = 0; // verbosity for the logbuf (0= nothing) -char lasterrorstring[256] = "", -logbuf[8192] = ""; //------------------------------------------------------------------------- -// read a byte from the embedded controller (EC) via port io +// read control port and wait for set/clear of a status bit //------------------------------------------------------------------------- -int FANCONTROL::ReadByteFromEC(int offset, char* pdata) { - char data = -1; - int numToTrySetup = 50; - int iOK = false; - int iTimeout = 100; - int iTimeoutBuf = 1000; - int iTime = 0; - int iTick = 10; - - while (numToTrySetup > 0) { - - for (iTime = 0; iTime < iTimeoutBuf; iTime += iTick) { // wait for full buffers to clear - data = (char)ReadPort(EC_CTRLPORT) & 0xff; // or timeout iTimeoutBuf = 1000 - if (!(data & (EC_STAT_IBF | EC_STAT_OBF))) break; - ::Sleep(iTick); +int +waitportstatus(int bits, int onoff= false, int timeout= 1000) { + int ok= false, + port= EC_CTRLPORT, + time= 0, + tick= 10; + + // + // wait until input on control port has desired state or times out + // + for (time= 0; time 0) sprintf(logbuf + strlen(logbuf), "readec: offset= %x, data= %02x\n", offset, *pdata); +//------------------------------------------------------------------------- +// write a character to an io port through WinIO device +//------------------------------------------------------------------------- +int +writeport(int port, char data) { + WritePort(port, data); return 1; } //------------------------------------------------------------------------- -// write a byte to the embedded controller (EC) via port io +// read a character from an io port through WinIO device //------------------------------------------------------------------------- -int FANCONTROL::WriteByteToEC(int offset, char NewData) { - char data = -1; - char data2 = -1; - int iOK = false; - int iTimeout = 100; - int iTimeoutBuf = 1000; - int iTime = 0; - int iTick = 10; - int numToTrySetup = 5; - - while (numToTrySetup > 0) { - - for (iTime = 0; iTime < iTimeoutBuf; iTime += iTick) { // wait for full buffers to clear - data = (char)ReadPort(EC_CTRLPORT) & 0xff; // or timeout iTimeoutBuf = 1000 - if (!(data & (EC_STAT_IBF | EC_STAT_OBF))) break; - ::Sleep(iTick); - } - - if (data & EC_STAT_OBF) data2 = (char)ReadPort(EC_DATAPORT); //clear OBF if full - - for (iTime = 0; iTime < iTimeout; iTime += iTick) { // wait for IOBF to clear - data = (char)ReadPort(EC_CTRLPORT) & 0xff; - if (!(data & EC_STAT_OBF)) { - iOK = true; - break; - } - ::Sleep(iTick); - } // try again after a moment - - if (!iOK) return 0; - iOK = false; +int +readport(int port, char *pdata) { + DWORD data= -1; + data = ReadPort(port); + *pdata= (char)data; + return 1; +} - WritePort(EC_CTRLPORT, EC_CTRLPORT_WRITE); // tell 'em we want to "WRITE" - for (iTime = 0; iTime < iTimeout; iTime += iTick) { // wait for IBF and OBF to clear - data = (char)ReadPort(EC_CTRLPORT) & 0xff; - if (!(data & (EC_STAT_IBF | EC_STAT_OBF))) { - iOK = true; - break; +//------------------------------------------------------------------------- +// read a byte from the embedded controller (EC) via port io +//------------------------------------------------------------------------- +int +FANCONTROL::ReadByteFromECint(int offset, char *pdata) { + int ok; + + // wait for IBF and OBF to clear + ok= waitportstatus(EC_STAT_IBF | EC_STAT_OBF, false); + if (ok) { + + // tell 'em we want to "READ" + ok= writeport(EC_CTRLPORT, EC_CTRLPORT_READ); + if (ok) { + + // wait for IBF to clear (command byte removed from EC's input queue) + ok= waitportstatus(EC_STAT_IBF, false); + if (ok) { + + // tell 'em where we want to read from + ok= writeport(EC_DATAPORT, offset); + if (ok) { + + // wait for IBF to clear (address byte removed from EC's input queue) + // Note: Techically we should waitportstatus(OBF,TRUE) here,(a byte being + // in the EC's output buffer being ready to read). For some reason + // this never seems to happen + ok= waitportstatus(EC_STAT_IBF, false); + if (ok) { + char data= -1; + + // read result (EC byte at offset) + ok= readport(EC_DATAPORT, &data); + if (ok) + *pdata= data; + } + } } - ::Sleep(iTick); - } // try again after a moment - - if (!iOK) return 0; - iOK = false; + } + } - WritePort(EC_DATAPORT, offset); // tell 'em where we want to write to + return ok; +} - for (iTime = 0; iTime < iTimeout; iTime += iTick) { // wait for IBF and OBF to clear - data = (char)ReadPort(EC_CTRLPORT) & 0xff; - if (!(data & (EC_STAT_IBF | EC_STAT_OBF))) { - iOK = true; - numToTrySetup = 1; - break; +int +FANCONTROL::ReadByteFromEC(int offset, char *pdata){ + int ok = 1; + while (ok) { + char b; + ok = ReadByteFromECint(offset, &b); + + if (ok) { + Sleep(10); + char b2; + ok = ReadByteFromECint(offset, &b2); + + if (ok && b == b2) { + *pdata = b; + return ok; } - ::Sleep(iTick); - } // try again after a moment - numToTrySetup -= 1; + } + ::Sleep(50); } - - if (!iOK) return 0; - - WritePort(EC_DATAPORT, NewData); // tell 'em what we want to write there - - return 1; + return ok; } //------------------------------------------------------------------------- -// experimental code +// write a byte to the embedded controller (EC) via port io //------------------------------------------------------------------------- -void -FANCONTROL::Test(void) { - - /* - // - // defines from various DDK sources - // - - #define IOCTL_ACPI_ASYNC_EVAL_METHOD CTL_CODE(FILE_DEVICE_ACPI, 0, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) - #define IOCTL_ACPI_EVAL_METHOD CTL_CODE(FILE_DEVICE_ACPI, 1, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) - #define IOCTL_ACPI_ACQUIRE_GLOBAL_LOCK CTL_CODE(FILE_DEVICE_ACPI, 4, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) - #define IOCTL_ACPI_RELEASE_GLOBAL_LOCK CTL_CODE(FILE_DEVICE_ACPI, 5, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) - - #define FILE_DEVICE_ACPI 0x00000032 - - #define CTL_CODE( DeviceType, Function, Method, Access ) ( \ - ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \ - ) - - #define METHOD_BUFFERED 0 - #define METHOD_IN_DIRECT 1 - #define METHOD_OUT_DIRECT 2 - #define METHOD_NEITHER 3 - - - #define FILE_ANY_ACCESS 0 - #define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS) - #define FILE_READ_ACCESS ( 0x0001 ) // file & pipe - #define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe - - - - - // - // try to communicate with the ACPI driver via IOCTL - // (doesn't work, driver won't open on CreateFile under - // any name) - // - - HANDLE hDevice= ::CreateFile( "\\\\.\\DRIVER\\ACPI", - GENERIC_WRITE, - FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - 0, - NULL ); - - if (hDevice!=INVALID_HANDLE_VALUE) { - - USHORT t[2]; - ULONG howmany= 0; - ULONG ret= 0; - BOOL ioctlresult= 0; - - t[0] = (USHORT)0; - t[1] = (USHORT)0; - - ioctlresult= DeviceIoControl( - hDevice, - IOCTL_ACPI_ACQUIRE_GLOBAL_LOCK, - t, - sizeof(ULONG), - &ret, - sizeof(ULONG), - &howmany, - NULL ); - - - - ::CloseHandle(hDevice); +int +FANCONTROL::WriteByteToEC(int offset, char data) +{ + int ok; + + // wait for IBF and OBF to clear + ok= waitportstatus(EC_STAT_IBF| EC_STAT_OBF, false); + if (ok) { + + // tell 'em we want to "WRITE" + ok= writeport(EC_CTRLPORT, EC_CTRLPORT_WRITE); + if (ok) { + + // wait for IBF to clear (command byte removed from EC's input queue) + ok= waitportstatus(EC_STAT_IBF, false); + if (ok) { + + // tell 'em where we want to write to + ok= writeport(EC_DATAPORT, offset); + if (ok) { + + // wait for IBF to clear (address byte removed from EC's input queue) + ok= waitportstatus(EC_STAT_IBF, false); + if (ok) { + // tell 'em what we want to write there + ok= writeport(EC_DATAPORT, data); + if (ok) { + // wait for IBF to clear (data byte removed from EC's input queue) + ok= waitportstatus(EC_STAT_IBF, false); + } + } + } + } } + } - */ + return ok; } diff --git a/fancontrol/res/RCa14368 b/fancontrol/res/RCa19608 similarity index 87% rename from fancontrol/res/RCa14368 rename to fancontrol/res/RCa19608 index 2c5a85a..6ce4066 100644 Binary files a/fancontrol/res/RCa14368 and b/fancontrol/res/RCa19608 differ diff --git a/fancontrol/res/RCb14368 b/fancontrol/res/RCb14368 deleted file mode 100644 index 2c5a85a..0000000 Binary files a/fancontrol/res/RCb14368 and /dev/null differ diff --git a/fancontrol/res/TPFC2.png b/fancontrol/res/TPFC2.png deleted file mode 100644 index 2f65990..0000000 Binary files a/fancontrol/res/TPFC2.png and /dev/null differ diff --git a/fancontrol/res/fancontrol.rc b/fancontrol/res/fancontrol.rc index 1d557ec..1df5a4f 100644 --- a/fancontrol/res/fancontrol.rc +++ b/fancontrol/res/fancontrol.rc @@ -1,348 +1,338 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource." - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Neutral (Default) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD) -LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -9000 DIALOGEX 30, 20, 571, 140 -STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_TOPMOST | WS_EX_TOOLWINDOW -CAPTION "TPFanControl " -FONT 8, "MS Sans Serif", 400, 0, 0x0 -BEGIN - GROUPBOX "TPFanControl",IDC_STATIC,97,7,157,95 - LTEXT "State",IDC_STATIC,103,24,21,8 - EDITTEXT 8100,126,22,121,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Switch",IDC_STATIC,103,40,21,8 - EDITTEXT 8103,126,38,29,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Mode",IDC_STATIC,103,54,21,8 - CONTROL "BIOS (embedded controller)",8300,"Button",BS_AUTORADIOBUTTON,129,55,99,10 - CONTROL "Smart (TPFanControl.ini)",8301,"Button",BS_AUTORADIOBUTTON,129,68,96,10 - CONTROL "Manual ",8302,"Button",BS_AUTORADIOBUTTON,129,82,38,10 - EDITTEXT 8310,171,79,32,14,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "(0-7)",IDC_STATIC,207,81,15,8 - LTEXT "Speed",IDC_STATIC,160,40,21,8 - EDITTEXT 8102,183,38,64,13,ES_AUTOHSCROLL | ES_READONLY - GROUPBOX "Temperatures",IDC_STATIC,7,7,85,110 - EDITTEXT 8101,15,18,70,82,ES_MULTILINE | ES_READONLY - GROUPBOX "Status",9199,97,106,467,27 - EDITTEXT 8112,103,115,218,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Last",IDC_STATIC,324,116,15,8 - EDITTEXT 8113,340,115,219,13,ES_AUTOHSCROLL | ES_READONLY - GROUPBOX "Log (see TPFanControl.log)",9201,260,7,303,95 - EDITTEXT 9200,269,18,287,78,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL - CONTROL "all",7001,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,20,103,20,10 - CONTROL "active",7002,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,45,103,31,10 -END - -9001 DIALOGEX 0, 0, 54, 266 -STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_TOPMOST | WS_EX_TOOLWINDOW -CAPTION "TPFC" -FONT 8, "MS Sans Serif", 400, 0, 0x0 -BEGIN - GROUPBOX "Fan Control",IDC_STATIC,0,128,51,135 - LTEXT "State",IDC_STATIC,3,137,21,8 - EDITTEXT 8100,2,146,47,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Switch",IDC_STATIC,3,160,29,8 - EDITTEXT 8103,2,169,47,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Mode",IDC_STATIC,3,207,19,8 - CONTROL "BIOS",8300,"Button",BS_AUTORADIOBUTTON,3,215,37,10 - CONTROL "Smart",8301,"Button",BS_AUTORADIOBUTTON,3,224,36,10 - CONTROL "Manual",8302,"Button",BS_AUTORADIOBUTTON,3,234,36,10 - EDITTEXT 8310,3,244,21,14,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "(0-7)",IDC_STATIC,25,247,15,8 - LTEXT "Speed",IDC_STATIC,3,182,29,8 - EDITTEXT 8102,2,190,47,13,ES_AUTOHSCROLL | ES_READONLY - GROUPBOX "Temps",IDC_STATIC,0,0,49,115 - EDITTEXT 8101,2,11,49,102,ES_MULTILINE | ES_READONLY - CONTROL "all",7001,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,3,116,20,10 - CONTROL "act",7002,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,25,116,20,10 -END - -9002 DIALOGEX 30, 20, 571, 141 -STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU -CAPTION "TPFanControl " -FONT 8, "MS Sans Serif", 400, 0, 0x0 -BEGIN - GROUPBOX "TPFanControl",IDC_STATIC,97,7,155,95 - LTEXT "State",IDC_STATIC,103,24,21,8 - EDITTEXT 8100,126,22,121,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Switch",IDC_STATIC,103,40,21,8 - EDITTEXT 8103,126,38,29,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Mode",IDC_STATIC,103,54,21,8 - CONTROL "BIOS (embedded controller)",8300,"Button",BS_AUTORADIOBUTTON,129,55,99,10 - CONTROL "Smart (TPFanControl.ini)",8301,"Button",BS_AUTORADIOBUTTON,129,68,96,10 - CONTROL "Manual ",8302,"Button",BS_AUTORADIOBUTTON,129,82,36,10 - EDITTEXT 8310,171,79,25,14,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "(0-7)",IDC_STATIC,199,81,15,8 - LTEXT "Speed",IDC_STATIC,160,40,21,8 - EDITTEXT 8102,183,38,64,13,ES_AUTOHSCROLL | ES_READONLY - GROUPBOX "Temperatures",IDC_STATIC,7,7,85,126 - EDITTEXT 8101,15,18,70,102,ES_MULTILINE | ES_READONLY - GROUPBOX "Status",9199,97,106,467,27 - EDITTEXT 8112,103,115,218,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Last",IDC_STATIC,324,116,15,8 - EDITTEXT 8113,340,115,219,13,ES_AUTOHSCROLL | ES_READONLY - GROUPBOX "Log (see TPFanControl.log)",9201,256,7,307,95 - EDITTEXT 9200,266,18,290,78,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL - CONTROL "all",7001,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,21,121,20,10 - CONTROL "active",7002,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,46,121,31,10 -END - -9003 DIALOGEX 0, 0, 70, 266 -STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU -CAPTION "TPFC" -FONT 8, "MS Sans Serif", 400, 0, 0x0 -BEGIN - GROUPBOX "Fan Control",IDC_STATIC,0,128,70,135 - LTEXT "State",IDC_STATIC,3,137,21,8 - EDITTEXT 8100,4,146,62,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Switch",IDC_STATIC,3,160,29,8 - EDITTEXT 8103,3,168,63,13,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Mode",IDC_STATIC,3,207,19,8 - CONTROL "BIOS",8300,"Button",BS_AUTORADIOBUTTON,3,215,37,10 - CONTROL "Smart",8301,"Button",BS_AUTORADIOBUTTON,3,224,36,10 - CONTROL "Manual",8302,"Button",BS_AUTORADIOBUTTON,3,234,44,10 - EDITTEXT 8310,3,244,25,14,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "(0-7)",IDC_STATIC,35,247,15,8 - LTEXT "Speed",IDC_STATIC,3,182,29,8 - EDITTEXT 8102,3,190,63,13,ES_AUTOHSCROLL | ES_READONLY - GROUPBOX "Temperatures",IDC_STATIC,0,1,70,114 - EDITTEXT 8101,2,11,65,102,ES_MULTILINE | ES_READONLY - CONTROL "all",7001,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,43,118,18,10 - CONTROL "active",7002,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,6,118,31,10 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -5000 MENU -BEGIN - MENUITEM "Bluetooth", 5040 - MENUITEM SEPARATOR - MENUITEM "Show Window", 5010 - MENUITEM "Hide Window", 5030 - MENUITEM "Symbol Icon", 5070 - MENUITEM "Text Icon", 5080 - MENUITEM SEPARATOR - MENUITEM "BIOS Mode", 5001 - MENUITEM "Smart Mode", 5002 - MENUITEM "Manual Mode", 5005 - MENUITEM "End Program", 5020 - MENUITEM SEPARATOR - MENUITEM "FAQs / Google", 5050 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -1 ICON "app.ico" - -21 ICON "ico21.ico" - -22 ICON "ico22.ico" - -23 ICON "ico23.ico" - -24 ICON "ico24.ico" - -25 ICON "ico25.ico" - -10 ICON "bw.ico" - -11 ICON "blue.ico" - -12 ICON "yellow.ico" - -13 ICON "orange.ico" - -14 ICON "red.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// RT_MANIFEST -// - -1 RT_MANIFEST "xp-manifest.txt" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -1 VERSIONINFO - FILEVERSION 1,0,0,63 - PRODUCTVERSION 1,0,0,63 - FILEFLAGSMASK 0x8L -#ifdef _DEBUG - FILEFLAGS 0x9L -#else - FILEFLAGS 0x8L -#endif - FILEOS 0x4L - FILETYPE 0x0L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040704b0" - BEGIN - VALUE "Comments", "Usage on own risk!" - VALUE "FileDescription", "Fan Control Software" - VALUE "FileVersion", "1, 0, 0, 63" - VALUE "InternalName", "TPFanControl 2" - VALUE "LegalTrademarks", "TPFanControl" - VALUE "OriginalFilename", "TPFanControl.exe" - VALUE "PrivateBuild", "Fan Control Software" - VALUE "ProductName", "TPFanControl" - VALUE "ProductVersion", "1, 0, 0, 63" - VALUE "SpecialBuild", "easy easy setup" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x407, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - 9000, DIALOG - BEGIN - END - - 9001, DIALOG - BEGIN - RIGHTMARGIN, 50 - BOTTOMMARGIN, 265 - HORZGUIDE, 126 - END - - 9002, DIALOG - BEGIN - BOTTOMMARGIN, 140 - END - - 9003, DIALOG - BEGIN - BOTTOMMARGIN, 265 - HORZGUIDE, 128 - END -END -#endif // APSTUDIO_INVOKED - -#endif // Neutral (Default) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// German (Germany) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // German (Germany) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -1 ICON "app.ico" - -10 ICON "bw.ico" - -11 ICON "blue.ico" - -12 ICON "yellow.ico" - -13 ICON "orange.ico" - -14 ICON "red.ico" - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "windows.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Neutral (Standard) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +9000 DIALOGEX 30, 20, 571, 140 +STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_TOPMOST | WS_EX_TOOLWINDOW +CAPTION "TPFanControl " +FONT 8, "MS Sans Serif", 400, 0, 0x0 +BEGIN + GROUPBOX "TPFanControl",IDC_STATIC,97,7,143,95 + LTEXT "State",IDC_STATIC,103,24,21,8 + EDITTEXT 8100,126,22,107,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Switch",IDC_STATIC,103,40,21,8 + EDITTEXT 8103,126,38,29,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Mode",IDC_STATIC,103,54,21,8 + CONTROL "BIOS (embedded controller)",8300,"Button",BS_AUTORADIOBUTTON,129,55,99,10 + CONTROL "Smart (TPFanControl.ini)",8301,"Button",BS_AUTORADIOBUTTON,129,68,96,10 + CONTROL "Manual ",8302,"Button",BS_AUTORADIOBUTTON,129,82,38,10 + EDITTEXT 8310,171,79,25,14,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "(0-7)",IDC_STATIC,199,81,15,8 + LTEXT "Speed",IDC_STATIC,160,40,21,8 + EDITTEXT 8102,183,38,50,13,ES_AUTOHSCROLL | ES_READONLY + GROUPBOX "Temperatures",IDC_STATIC,7,7,85,126 + EDITTEXT 8101,15,18,70,102,ES_MULTILINE | ES_READONLY + GROUPBOX "Status",9199,97,106,467,27 + EDITTEXT 8112,103,115,218,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Last",IDC_STATIC,324,116,15,8 + EDITTEXT 8113,340,115,219,13,ES_AUTOHSCROLL | ES_READONLY + GROUPBOX "Log (see TPFanControl.log)",9201,246,7,317,95 + EDITTEXT 9200,254,18,302,78,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL + CONTROL "all",7001,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,21,121,20,10 + CONTROL "active",7002,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,46,121,31,10 +END + +9001 DIALOGEX 0, 0, 50, 265 +STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_TOPMOST | WS_EX_TOOLWINDOW +CAPTION "TPFC" +FONT 8, "MS Sans Serif", 400, 0, 0x0 +BEGIN + GROUPBOX "Fan Control",IDC_STATIC,0,128,49,135 + LTEXT "State",IDC_STATIC,3,137,21,8 + EDITTEXT 8100,2,146,45,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Switch",IDC_STATIC,3,160,29,8 + EDITTEXT 8103,2,169,45,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Mode",IDC_STATIC,3,207,19,8 + CONTROL "BIOS",8300,"Button",BS_AUTORADIOBUTTON,3,215,37,10 + CONTROL "Smart",8301,"Button",BS_AUTORADIOBUTTON,3,224,36,10 + CONTROL "Manual",8302,"Button",BS_AUTORADIOBUTTON,3,234,36,10 + EDITTEXT 8310,3,244,21,14,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "(255-0)",IDC_STATIC,25,247,15,8 + LTEXT "Speed",IDC_STATIC,3,182,29,8 + EDITTEXT 8102,2,190,45,13,ES_AUTOHSCROLL | ES_READONLY + GROUPBOX "Temps",IDC_STATIC,0,0,49,115 + EDITTEXT 8101,2,11,46,102,ES_MULTILINE | ES_READONLY + CONTROL "all",7001,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,3,116,20,10 + CONTROL "act",7002,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,25,116,20,10 +END + +9002 DIALOGEX 30, 20, 571, 141 +STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +CAPTION "TPFanControl " +FONT 8, "MS Sans Serif", 400, 0, 0x0 +BEGIN + GROUPBOX "TPFanControl",IDC_STATIC,97,7,143,95 + LTEXT "State",IDC_STATIC,103,24,21,8 + EDITTEXT 8100,126,22,107,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Switch",IDC_STATIC,103,40,21,8 + EDITTEXT 8103,126,38,29,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Mode",IDC_STATIC,103,54,21,8 + CONTROL "BIOS (embedded controller)",8300,"Button",BS_AUTORADIOBUTTON,129,55,99,10 + CONTROL "Smart (TPFanControl.ini)",8301,"Button",BS_AUTORADIOBUTTON,129,68,96,10 + CONTROL "Manual ",8302,"Button",BS_AUTORADIOBUTTON,129,82,36,10 + EDITTEXT 8310,171,79,25,14,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "(255-0)",IDC_STATIC,199,81,15,8 + LTEXT "Speed",IDC_STATIC,160,40,21,8 + EDITTEXT 8102,183,38,50,13,ES_AUTOHSCROLL | ES_READONLY + GROUPBOX "Temperatures",IDC_STATIC,7,7,85,126 + EDITTEXT 8101,15,18,70,102,ES_MULTILINE | ES_READONLY + GROUPBOX "Status",9199,97,106,467,27 + EDITTEXT 8112,103,115,218,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Last",IDC_STATIC,324,116,15,8 + EDITTEXT 8113,340,115,219,13,ES_AUTOHSCROLL | ES_READONLY + GROUPBOX "Log (see TPFanControl.log)",9201,246,7,317,95 + EDITTEXT 9200,254,18,302,78,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL + CONTROL "all",7001,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,21,121,20,10 + CONTROL "active",7002,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,46,121,31,10 +END + +9003 DIALOGEX 0, 0, 70, 266 +STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU +CAPTION "TPFC" +FONT 8, "MS Sans Serif", 400, 0, 0x0 +BEGIN + GROUPBOX "Fan Control",IDC_STATIC,0,128,70,135 + LTEXT "State",IDC_STATIC,3,137,21,8 + EDITTEXT 8100,4,146,62,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Switch",IDC_STATIC,3,160,29,8 + EDITTEXT 8103,3,168,63,13,ES_AUTOHSCROLL | ES_READONLY + LTEXT "Mode",IDC_STATIC,3,207,19,8 + CONTROL "BIOS",8300,"Button",BS_AUTORADIOBUTTON,3,215,37,10 + CONTROL "Smart",8301,"Button",BS_AUTORADIOBUTTON,3,224,36,10 + CONTROL "Manual",8302,"Button",BS_AUTORADIOBUTTON,3,234,44,10 + EDITTEXT 8310,3,244,25,14,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "(255-0)",IDC_STATIC,35,247,15,8 + LTEXT "Speed",IDC_STATIC,3,182,29,8 + EDITTEXT 8102,3,190,63,13,ES_AUTOHSCROLL | ES_READONLY + GROUPBOX "Temperatures",IDC_STATIC,0,1,70,114 + EDITTEXT 8101,2,11,65,102,ES_MULTILINE | ES_READONLY + CONTROL "all",7001,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,43,118,18,10 + CONTROL "active",7002,"Button",BS_AUTORADIOBUTTON | BS_RIGHT,6,118,31,10 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +5000 MENU +BEGIN + MENUITEM "Thinklight", 5060 + MENUITEM "Bluetooth", 5040 + MENUITEM SEPARATOR + MENUITEM "Show Window", 5010 + MENUITEM "Hide Window", 5030 + MENUITEM "Symbol Icon", 5070 + MENUITEM "Text Icon", 5080 + MENUITEM SEPARATOR + MENUITEM "BIOS Mode", 5001 + MENUITEM "Smart Mode", 5002 +// MENUITEM "Smart Mode 1", 5003 +// MENUITEM "Smart Mode 2", 5004 + MENUITEM "Manual Mode", 5005 + MENUITEM "End Program", 5020 + MENUITEM SEPARATOR + MENUITEM "FAQs / Google", 5050 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +1 ICON "app.ico" +21 ICON "ico21.ico" +22 ICON "ico22.ico" +23 ICON "ico23.ico" +24 ICON "ico24.ico" +25 ICON "ico25.ico" +10 ICON "bw.ico" +11 ICON "blue.ico" +12 ICON "yellow.ico" +13 ICON "orange.ico" +14 ICON "red.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// RT_MANIFEST +// + +1 RT_MANIFEST "xp-manifest.txt" + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +1 VERSIONINFO + FILEVERSION 1,0,0,62 + PRODUCTVERSION 1,0,0,62 + FILEFLAGSMASK 0x8L +#ifdef _DEBUG + FILEFLAGS 0x9L +#else + FILEFLAGS 0x8L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040704b0" + BEGIN + VALUE "Comments", "Usage on own risk!" + VALUE "CompanyName", "troubadix" + VALUE "FileDescription", "Fan Control Software" + VALUE "FileVersion", "1, 0, 0, 62" + VALUE "InternalName", "TPFanControl" + VALUE "LegalCopyright", "Copyright (C) 2009 by troubadix" + VALUE "LegalTrademarks", "TPFanControl" + VALUE "OriginalFilename", "TPFanControl.exe" + VALUE "PrivateBuild", "Fan Control Software" + VALUE "ProductName", "TPFanControl" + VALUE "ProductVersion", "1, 0, 0, 62" + VALUE "SpecialBuild", "easy easy setup" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x407, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + 9001, DIALOG + BEGIN + BOTTOMMARGIN, 264 + HORZGUIDE, 126 + END + + 9002, DIALOG + BEGIN + BOTTOMMARGIN, 140 + END + + 9003, DIALOG + BEGIN + BOTTOMMARGIN, 265 + HORZGUIDE, 128 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Neutral (Standard) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Deutsch (Deutschland) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Deutsch (Deutschland) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// Englisch (USA) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +1 ICON "app.ico" +10 ICON "bw.ico" +11 ICON "blue.ico" +12 ICON "yellow.ico" +13 ICON "orange.ico" +14 ICON "red.ico" +#endif // Englisch (USA) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/fancontrol/res/resource b/fancontrol/res/resource index a7686bb..f2986b6 100644 --- a/fancontrol/res/resource +++ b/fancontrol/res/resource @@ -2,22 +2,14 @@ // Microsoft Visual C++ generated include file. // Used by fancontrol.rc // -#define IDI_ICON1 109 -#define IDC_RADIOBUTTON1 1002 -#define IDC_RADIOBUTTON2 1003 -#define IDC_EDIT1 1003 -#define IDC_BUTTON1 1009 -#define IDC_BUTTON2 1010 -#define IDC_STATIC -1 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 110 +#define _APS_NEXT_RESOURCE_VALUE 101 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1011 +#define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/fancontrol/res/signatur.txt b/fancontrol/res/signatur.txt index 8b4e3a0..2744daa 100644 --- a/fancontrol/res/signatur.txt +++ b/fancontrol/res/signatur.txt @@ -2,14 +2,16 @@ Open an elevated command prompt (VS Command) NOTE: These instructions assume you have visual studio installed and are using a command prompt that has all the environment variables set to find SDK utilities such as makecert and signtool. If not, you will need to find these tools on your hard drive before running them. -- In the command shell, execute the following commands: +- In the command shell, execute the following commands: makecert -r -pe -n "CN=TPFanControl 2" -ss PrivateCertStore tpfccert.cer - + makecert -r -pe -n "CN=TPFanControl by Troubadix" -ss PrivateCertStore tpfccert.cer + signtool signwizard - -oder: + +or: - In the command shell, browse to the location of your exe SignTool sign /v /s PrivateCertStore /n "TPFanControl 2" /a /t http://timestamp.globalsign.com/scripts/timstamp.dll fancontrol.exe +SignTool sign /v /s PrivateCertStore /n "TPFanControl by Troubadix" /t http://timestamp.verisign.com/scripts/timestamp.dll fancontrol.exe diff --git a/fancontrol/winstuff.cpp b/fancontrol/winstuff.cpp index 056deb6..7ad8a40 100644 --- a/fancontrol/winstuff.cpp +++ b/fancontrol/winstuff.cpp @@ -1,4 +1,5 @@ -// -------------------------------------------------------------- + +// -------------------------------------------------------------- // // Thinkpad Fan Control // @@ -36,31 +37,35 @@ extern HINSTANCE hInstApp, hInstRes; // Create/Delete/Lock/Unlock mutually exclusive semaphores //------------------------------------------------------------------------- -MUTEXSEM::MUTEXSEM(int state, const char* name) { - this->hmux = ::CreateMutex(NULL, (state ? TRUE : FALSE), name); +MUTEXSEM::MUTEXSEM(int state, const char *name) +{ + this->hmux= ::CreateMutex(NULL, (state ? TRUE : FALSE), name); } -MUTEXSEM::~MUTEXSEM() { - int ok = FALSE; +MUTEXSEM::~MUTEXSEM() +{ + int ok= FALSE; - HANDLE h = this->hmux; - this->hmux = NULL; - ok = ::CloseHandle(h); + HANDLE h= this->hmux; + this->hmux= NULL; + ok= ::CloseHandle(h); } int -MUTEXSEM::Lock(int millies) { - int ok = FALSE; +MUTEXSEM::Lock(int millies) +{ + int ok= FALSE; - int rc = this->hmux ? ::WaitForSingleObject(this->hmux, millies) : WAIT_FAILED; - ok = rc == WAIT_OBJECT_0; // returns posted TRUE/FALSE + int rc= this->hmux ? ::WaitForSingleObject(this->hmux, millies) : WAIT_FAILED; + ok= rc==WAIT_OBJECT_0; // returns posted TRUE/FALSE - return ok; + return ok; } void -MUTEXSEM::Unlock() { - int ok = ::ReleaseMutex(this->hmux); +MUTEXSEM::Unlock() +{ + int ok= ::ReleaseMutex(this->hmux); } @@ -76,143 +81,149 @@ MUTEXSEM::Unlock() { struct NOTIFYICONDATAV5 { NOTIFYICONDATA nof; - TCHAR szTipExtra[64]; //Version 5.0 - DWORD dwState; //Version 5.0 - DWORD dwStateMask; //Version 5.0 - TCHAR szInfo[256]; //Version 5.0 - union { - UINT uTimeout; //Version 5.0 - UINT uVersion; //Version 5.0 - } DUMMYUNIONNAME; - TCHAR szInfoTitle[64]; //Version 5.0 - DWORD dwInfoFlags; //Version 5.0 + TCHAR szTipExtra[64]; //Version 5.0 + DWORD dwState; //Version 5.0 + DWORD dwStateMask; //Version 5.0 + TCHAR szInfo[256]; //Version 5.0 + union { + UINT uTimeout; //Version 5.0 + UINT uVersion; //Version 5.0 + } DUMMYUNIONNAME; + TCHAR szInfoTitle[64]; //Version 5.0 + DWORD dwInfoFlags; //Version 5.0 }; struct NOTIFYICONDATAV6 { DWORD cbSize; - HWND hWnd; - UINT uID; - UINT uFlags; - UINT uCallbackMessage; - HICON hIcon; - TCHAR szTip[64]; - DWORD dwState; - DWORD dwStateMask; - TCHAR szInfo[256]; - union { - UINT uTimeout; - UINT uVersion; - }; - TCHAR szInfoTitle[64]; - DWORD dwInfoFlags; - GUID guidItem; - HICON hBalloonIcon; + HWND hWnd; + UINT uID; + UINT uFlags; + UINT uCallbackMessage; + HICON hIcon; + TCHAR szTip[64]; + DWORD dwState; + DWORD dwStateMask; + TCHAR szInfo[256]; + union { + UINT uTimeout; + UINT uVersion; + }; + TCHAR szInfoTitle[64]; + DWORD dwInfoFlags; + GUID guidItem; + HICON hBalloonIcon; }; -struct OSVERSIONINFOV4 { - DWORD dwOSVersionInfoSize; - DWORD dwMajorVersion; - DWORD dwMinorVersion; - DWORD dwBuildNumber; - DWORD dwPlatformId; - TCHAR szCSDVersion[128]; +struct OSVERSIONINFOV4 { + DWORD dwOSVersionInfoSize; + DWORD dwMajorVersion; + DWORD dwMinorVersion; + DWORD dwBuildNumber; + DWORD dwPlatformId; + TCHAR szCSDVersion[128]; }; //------------------------------------------------------------------------- // Represent a window in the taskbar //------------------------------------------------------------------------- -TASKBARICON::TASKBARICON(HWND hwndowner, int idicon, const char* tooltip) - : Owner(hwndowner), - Id(idicon), - IconId(idicon), - osVersion(0) { +TASKBARICON::TASKBARICON(HWND hwndowner, int idicon, const char *tooltip) + : Owner(hwndowner), + Id(idicon), + IconId(idicon), + osVersion(0) +{ // ampersand must be escaped - strcpy_s(this->Tooltip, sizeof(Tooltip), tooltip ? tooltip : ""); + strcpy_s(this->Tooltip,sizeof(Tooltip), tooltip ? tooltip : ""); this->Construct(); } -TASKBARICON::~TASKBARICON() { +TASKBARICON::~TASKBARICON() +{ this->Destroy(); } -BOOL -TASKBARICON::Construct() { - NOTIFYICONDATAV5 nofv5 = NULLSTRUCT; - NOTIFYICONDATA& nof = nofv5.nof; +BOOL +TASKBARICON::Construct() +{ + NOTIFYICONDATAV5 nofv5= NULLSTRUCT; + NOTIFYICONDATA &nof= nofv5.nof; - this->osVersion = 0; + this->osVersion= 0; - nof.cbSize = sizeof(nof); - nof.hWnd = this->Owner; - nof.uID = this->Id; - nof.uFlags = NIF_MESSAGE; - nof.uCallbackMessage = WM__TASKBAR; + nof.cbSize= sizeof(nof); + nof.hWnd= this->Owner; + nof.uID= this->Id; + nof.uFlags= NIF_MESSAGE; + nof.uCallbackMessage= WM__TASKBAR; if (this->IconId) { - nof.hIcon = (HICON) - ::LoadImage(hInstRes, MAKEINTRESOURCE(this->IconId), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - nof.uFlags |= NIF_ICON; + nof.hIcon= (HICON)::LoadImage(hInstRes, MAKEINTRESOURCE(this->IconId), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + nof.uFlags|= NIF_ICON; } if (strlen(this->Tooltip)) { - lstrcpyn(nof.szTip, this->Tooltip, sizeof(nof.szTip) - 1); - nof.uFlags |= NIF_TIP; + lstrcpyn(nof.szTip, this->Tooltip, sizeof(nof.szTip)-1); + nof.uFlags|= NIF_TIP; } // // try a version 5 init (Shell_NotifyIcon has different behaviour from up win2000=version 5) - // - nof.cbSize = sizeof(nofv5); - this->UpAndRunning = ::Shell_NotifyIcon(NIM_ADD, &nof); + // + nof.cbSize= sizeof(nofv5); + this->UpAndRunning= ::Shell_NotifyIcon(NIM_ADD, &nof); - if (this->UpAndRunning) - this->osVersion = 5; + if (this->UpAndRunning) + this->osVersion= 5; else - this->UpAndRunning = ::Shell_NotifyIcon(NIM_ADD, &nof); + this->UpAndRunning= ::Shell_NotifyIcon(NIM_ADD, &nof); if (nof.hIcon) { ::DestroyIcon(nof.hIcon); - nof.hIcon = NULL; + nof.hIcon= NULL; } return this->UpAndRunning; } void -TASKBARICON::Destroy(BOOL keep) { - NOTIFYICONDATA nof = NULLSTRUCT; +TASKBARICON::Destroy(BOOL keep) +{ + NOTIFYICONDATA nof= NULLSTRUCT; - nof.cbSize = sizeof(nof); - nof.hWnd = this->Owner; - nof.uID = this->Id; + nof.cbSize= sizeof(nof); + nof.hWnd= this->Owner; + nof.uID= this->Id; ::Shell_NotifyIcon(NIM_DELETE, &nof); if (!keep) { - this->Owner = 0; - this->Id = 0; - this->IconId = 0; - strcpy_s(this->Tooltip, sizeof(Tooltip), ""); + this->Owner= 0; + this->Id= 0; + this->IconId= 0; + strcpy_s(this->Tooltip,sizeof(Tooltip), ""); } } BOOL -TASKBARICON::IsUpAndRunning() { +TASKBARICON::IsUpAndRunning() +{ return this->UpAndRunning; } -BOOL -TASKBARICON::HasExtendedFeatures(void) { - return this->osVersion >= 5; //maybee we want to implement version 6 from up vista +BOOL +TASKBARICON::HasExtendedFeatures(void) +{ + return this->osVersion>=5; //maybee we want to implement version 6 from up vista } -BOOL -TASKBARICON::RebuildIfNecessary(BOOL force) { +BOOL +TASKBARICON::RebuildIfNecessary(BOOL force) +{ char tt[256]; - strcpy_s(tt, sizeof(tt), this->Tooltip); // avoid selfassignment + strcpy_s(tt,sizeof(tt), this->Tooltip); // avoid selfassignment if (force || !this->SetTooltip(tt)) { this->Destroy(TRUE); @@ -223,25 +234,25 @@ TASKBARICON::RebuildIfNecessary(BOOL force) { } -int -TASKBARICON::SetIcon(int iconid) { +int +TASKBARICON::SetIcon(int iconid) +{ BOOL ok; - NOTIFYICONDATA nof = NULLSTRUCT; + NOTIFYICONDATA nof= NULLSTRUCT; - this->IconId = iconid; + this->IconId= iconid; - nof.cbSize = sizeof(nof); - nof.hWnd = this->Owner; - nof.uID = this->Id; - nof.uFlags = NIF_ICON; - nof.hIcon = (HICON) - ::LoadImage(hInstRes, MAKEINTRESOURCE(this->IconId), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + nof.cbSize= sizeof(nof); + nof.hWnd= this->Owner; + nof.uID= this->Id; + nof.uFlags= NIF_ICON; + nof.hIcon= (HICON)::LoadImage(hInstRes, MAKEINTRESOURCE(this->IconId), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - ok = ::Shell_NotifyIcon(NIM_MODIFY, &nof); + ok= ::Shell_NotifyIcon(NIM_MODIFY, &nof); if (nof.hIcon) { ::DestroyIcon(nof.hIcon); - nof.hIcon = NULL; + nof.hIcon= NULL; } // try to rebuild if SetIcon failed @@ -251,56 +262,59 @@ TASKBARICON::SetIcon(int iconid) { return ok; } -int -TASKBARICON::GetIcon(void) { +int +TASKBARICON::GetIcon(void) +{ return this->IconId; } -int -TASKBARICON::SetTooltip(const char* tooltip) { - BOOL ok = 0; - +int +TASKBARICON::SetTooltip(const char *tooltip) +{ + BOOL ok= 0; - if (strcmp(this->Tooltip, tooltip) != 0) { - strcpy_s(this->Tooltip, sizeof(Tooltip), tooltip); + + if (strcmp(this->Tooltip, tooltip)!=0) { + strcpy_s(this->Tooltip,sizeof(Tooltip), tooltip); - NOTIFYICONDATA nof = NULLSTRUCT; + NOTIFYICONDATA nof= NULLSTRUCT; - nof.cbSize = sizeof(nof); - nof.hWnd = this->Owner; - nof.uID = this->Id; - nof.uFlags = NIF_TIP; - lstrcpyn(nof.szTip, this->Tooltip, sizeof(nof.szTip) - 1); + nof.cbSize= sizeof(nof); + nof.hWnd= this->Owner; + nof.uID= this->Id; + nof.uFlags= NIF_TIP; + lstrcpyn(nof.szTip, this->Tooltip, sizeof(nof.szTip)-1); - ok = ::Shell_NotifyIcon(NIM_MODIFY, &nof); + ok= ::Shell_NotifyIcon(NIM_MODIFY, &nof); // try to rebuild if SetTooltip failed if (!ok && !this->InsideTooltipRebuild) { - this->InsideTooltipRebuild = TRUE; + this->InsideTooltipRebuild= TRUE; this->RebuildIfNecessary(TRUE); - this->InsideTooltipRebuild = FALSE; + this->InsideTooltipRebuild= FALSE; } } return ok; } -int -TASKBARICON::SetBalloon(ULONG flags, const char* title, const char* text, int timeout) { +int +TASKBARICON::SetBalloon(ULONG flags, const char *title, const char *text, int timeout) +{ BOOL ok; - NOTIFYICONDATA nof = NULLSTRUCT; + NOTIFYICONDATA nof= NULLSTRUCT; - nof.cbSize = sizeof(NOTIFYICONDATA); - nof.hWnd = this->Owner; - nof.uID = this->Id; - nof.uFlags = NIF_INFO; + nof.cbSize= sizeof(NOTIFYICONDATA); + nof.hWnd= this->Owner; + nof.uID= this->Id; + nof.uFlags= NIF_INFO; nof.dwInfoFlags = flags; nof.uTimeout = timeout; - lstrcpyn(nof.szInfo, text, sizeof(nof.szInfo) - 1); - lstrcpyn(nof.szInfoTitle, title, sizeof(nof.szInfoTitle) - 1); + lstrcpyn(nof.szInfo, text, sizeof(nof.szInfo)-1); + lstrcpyn(nof.szInfoTitle, title, sizeof(nof.szInfoTitle)-1); return Shell_NotifyIcon(NIM_MODIFY, &nof); @@ -329,41 +343,47 @@ TASKBARICON::SetBalloon(ULONG flags, const char* title, const char* text, int ti ////////////////////////////////////////////////////////////////////////////// MENU::MENU(HWND w) - : hMenu(::GetMenu(w)), - hWndOwner(w), - IsLoaded(FALSE) { + : hMenu(::GetMenu(w)), + hWndOwner(w), + IsLoaded(FALSE) +{ } MENU::MENU(HMENU hmenu) : hMenu(hmenu), - hWndOwner(NULL), - IsLoaded(FALSE) { + hWndOwner(NULL), + IsLoaded(FALSE) +{ } MENU::MENU(int id, HINSTANCE hdll) - : hMenu(::LoadMenu(((ULONG)hdll == (ULONG)-1) ? hInstRes : hdll, MAKEINTRESOURCE(id))), - hWndOwner(NULL), - IsLoaded(TRUE) { + : hMenu(::LoadMenu(((ULONG)hdll==(ULONG)-1)? hInstRes : hdll, MAKEINTRESOURCE(id))), + hWndOwner(NULL), + IsLoaded(TRUE) +{ } void -MENU::EnableMenuItem(int id, int status) { - ::EnableMenuItem(*this, id, - MF_BYCOMMAND | (status ? MF_ENABLED : MF_GRAYED)); +MENU::EnableMenuItem(int id, int status) +{ + ::EnableMenuItem(*this, id, + MF_BYCOMMAND | (status ? MF_ENABLED : MF_GRAYED)); } void -MENU::DisableMenuItem(int id) { +MENU::DisableMenuItem(int id) +{ this->EnableMenuItem(id, FALSE); } int -MENU::DeleteMenuItem(int id, BOOL idispos) { - int rc = ::DeleteMenu(*this, id, idispos ? MF_BYPOSITION : MF_BYCOMMAND); +MENU::DeleteMenuItem(int id, BOOL idispos) +{ + int rc= ::DeleteMenu(*this, id, idispos ? MF_BYPOSITION : MF_BYCOMMAND); if (this->hWndOwner) ::DrawMenuBar(this->hWndOwner); @@ -371,45 +391,53 @@ MENU::DeleteMenuItem(int id, BOOL idispos) { } void -MENU::CheckMenuItem(int id, int status) { - ::CheckMenuItem(*this, id, - MF_BYCOMMAND | (status ? MF_CHECKED : MF_UNCHECKED)); +MENU::CheckMenuItem(int id, int status) +{ + ::CheckMenuItem(*this, id, + MF_BYCOMMAND | (status ? MF_CHECKED : MF_UNCHECKED)); } void -MENU::UncheckMenuItem(int id) { +MENU::UncheckMenuItem(int id) +{ this->CheckMenuItem(id, FALSE); } BOOL -MENU::IsFlags(int id, int flags) { - return ((::GetMenuState(*this, id, MF_BYCOMMAND) & flags) != 0); +MENU::IsFlags(int id, int flags) +{ + return ((::GetMenuState(*this, id, MF_BYCOMMAND) & flags)!=0); } BOOL -MENU::IsMenuItemSeparator(int pos) { - MENUITEMINFO mii = { sizeof(mii), MIIM_TYPE, }; +MENU::IsMenuItemSeparator(int pos) +{ + MENUITEMINFO mii= {sizeof(mii), MIIM_TYPE, }; ::GetMenuItemInfo(*this, pos, TRUE, &mii); - return mii.fType == MFT_SEPARATOR; + return mii.fType==MFT_SEPARATOR; } BOOL -MENU::IsMenuItemEnabled(int id) { - return !this->IsFlags(id, MF_DISABLED | MF_GRAYED); +MENU::IsMenuItemEnabled(int id) +{ + return !this->IsFlags(id, MF_DISABLED|MF_GRAYED); } BOOL -MENU::IsMenuItemDisabled(int id) { - return this->IsFlags(id, MF_DISABLED | MF_GRAYED); +MENU::IsMenuItemDisabled(int id) +{ + return this->IsFlags(id, MF_DISABLED|MF_GRAYED); } BOOL -MENU::IsMenuItemChecked(int id) { +MENU::IsMenuItemChecked(int id) +{ return this->IsFlags(id, MF_CHECKED); } int -MENU::GetNumMenuItems() { +MENU::GetNumMenuItems() +{ return ::GetMenuItemCount(*this); } @@ -417,11 +445,12 @@ MENU::GetNumMenuItems() { //-------------------------------------------------------------------- // return the sub-menu handle of a menu item at a given position //-------------------------------------------------------------------- -HMENU -MENU::GetSubmenuFromPos(int pos) { - HMENU rc = NULL; +HMENU +MENU::GetSubmenuFromPos(int pos) +{ + HMENU rc= NULL; - rc = (HMENU)GetSubMenu(*this, pos); + rc= (HMENU)GetSubMenu(*this, pos); return rc; } @@ -430,16 +459,17 @@ MENU::GetSubmenuFromPos(int pos) { //-------------------------------------------------------------------- // return the item pos of a menu entry (search by id) //-------------------------------------------------------------------- -int -MENU::GetMenuPosFromID(int id) { - int rc = -1; +int +MENU::GetMenuPosFromID(int id) +{ + int rc= -1; - int i, mid, numof = ::GetMenuItemCount(*this); + int i, mid, numof= ::GetMenuItemCount(*this); - for (i = 0; i < numof; i++) { - mid = ::GetMenuItemID(*this, i); - if (mid == id) { - rc = i; + for (i=0; ihMenu, "BLUB"); - hmenuShow = ::GetSubMenu(hmenu, 0); - RECT r = { 0, 0, 10, 10 }; + hmenu= CreateMenu(); + ::AppendMenu(hmenu, MF_POPUP | MF_STRING, (UINT)this->hMenu, "BLUB"); + hmenuShow= ::GetSubMenu(hmenu, 0); + RECT r= { 0, 0, 10, 10 }; if (hwndowner) ::SetForegroundWindow(hwndowner); - ULONG flags = TPM_LEFTALIGN | TPM_LEFTBUTTON; + ULONG flags= TPM_LEFTALIGN | TPM_LEFTBUTTON; - if (synchtrack & 1) - flags |= TPM_RETURNCMD; + if (synchtrack & 1) + flags|= TPM_RETURNCMD; - if (synchtrack & TPM_RIGHTALIGN) - flags |= TPM_RIGHTALIGN; + if (synchtrack & TPM_RIGHTALIGN) + flags|= TPM_RIGHTALIGN; - int rc = ::TrackPopupMenu(hmenuShow, flags, - point.x, point.y, 0, - hwndowner, &r); + int rc= ::TrackPopupMenu(hmenuShow, flags, + point.x,point.y, 0, + hwndowner, &r); if (hwndowner) ::PostMessage(hwndowner, WM_NULL, 0, 0); @@ -514,3 +545,6 @@ MENU::Popup(HWND hwndowner, POINT* ppoint, BOOL synchtrack) { return rc; } + + + diff --git a/fancontrol/winstuff.h b/fancontrol/winstuff.h index e552a1f..cb7fc44 100644 --- a/fancontrol/winstuff.h +++ b/fancontrol/winstuff.h @@ -23,144 +23,118 @@ #include "_prec.h" -#ifndef NIF_STATE // NotifyIcon V5 defines -#define NIF_STATE 0x00000008 -#define NIF_INFO 0x00000010 -#define NIF_GUID 0x00000020 - -#define NIIF_INFO 0x00000001 -#define NIIF_WARNING 0x00000002 -#define NIIF_ERROR 0x00000003 -#define NIIF_ICON_MASK 0x0000000F -#define NIIF_NOSOUND 0x00000010 +#ifndef NIF_STATE // NotifyIcon V5 defines + #define NIF_STATE 0x00000008 + #define NIF_INFO 0x00000010 + #define NIF_GUID 0x00000020 + + #define NIIF_INFO 0x00000001 + #define NIIF_WARNING 0x00000002 + #define NIIF_ERROR 0x00000003 + #define NIIF_ICON_MASK 0x0000000F + #define NIIF_NOSOUND 0x00000010 #endif + //------------------------------------------------------------------------- // //------------------------------------------------------------------------- class MUTEXSEM { -private: - HANDLE hmux; - - MUTEXSEM(MUTEXSEM&); // disallow argument passing - void operator=(MUTEXSEM&) {}; // disallow assignment - -protected: - -public: - MUTEXSEM(int state = FALSE, const char* name = "Access_Thinkpad_EC"); - - ~MUTEXSEM(); + private: + HANDLE hmux; - int Lock(int millies = 0xFFFFFFFF); + MUTEXSEM(MUTEXSEM &); // disallow argument passing + void operator=(MUTEXSEM &) { }; // disallow assignment - void Unlock(); + protected: - HANDLE Handle(void) { return this->hmux; } + public: + MUTEXSEM(int state= FALSE, const char *name= "Access_Thinkpad_EC"); + ~MUTEXSEM(); + int Lock(int millies= 0xFFFFFFFF); + void Unlock(); - operator HANDLE(void) { return this->hmux; } + HANDLE Handle(void) + { return this->hmux; } + operator HANDLE(void) + { return this->hmux; } }; class TASKBARICON { -private: - BOOL UpAndRunning; - -protected: - HWND Owner; - int Id, IconId; - char Tooltip[256]; - int osVersion; //TODO: war drin? - volatile BOOL InsideTooltipRebuild; //should be declared as volatile for concurrency reasons - - -public: - TASKBARICON(HWND hwndowner, int id, const char* tooltip); - - ~TASKBARICON(void); + private: + BOOL UpAndRunning; - BOOL Construct(void); + protected: + HWND Owner; + int Id, IconId; + char Tooltip[256]; + int osVersion; //TODO: war drin? + volatile BOOL InsideTooltipRebuild; //should be declared as volatile for concurrency reasons - void Destroy(BOOL keep = FALSE); - BOOL RebuildIfNecessary(BOOL); + public: + TASKBARICON(HWND hwndowner, int id, const char *tooltip); + ~TASKBARICON(void); - BOOL HasExtendedFeatures(void); + BOOL Construct(void); + void Destroy(BOOL keep= FALSE); - BOOL IsUpAndRunning(void); + BOOL RebuildIfNecessary(BOOL); + BOOL HasExtendedFeatures(void); - int SetIcon(int iconid); - - int GetIcon(void); - - int SetTooltip(const char* tip); - - int SetBalloon(ULONG flags, const char* title, const char* text, int timeout = 2); -}; + BOOL IsUpAndRunning(void); + int SetIcon(int iconid); + int GetIcon(void); + int SetTooltip(const char *tip); + int SetBalloon(ULONG flags, const char *title, const char *text, int timeout= 2); +}; class MENU { -private: - -protected: - BOOL IsLoaded; - HMENU hMenu; - HWND hWndOwner; - -public: - MENU(HWND hwnd); - - MENU(HMENU hm); - - MENU(int id, HINSTANCE hdll = (HINSTANCE)(ULONG)-1); - - ~MENU() { - if (this->IsLoaded) ::DestroyMenu(this->hMenu); - this->hMenu = NULL; - } - - operator HMENU(void) const { - return (HMENU) - this->hMenu; - } - - int GetNumMenuItems(void); - - BOOL IsMenuItemSeparator(int pos); - - void EnableMenuItem(int id, int status = TRUE); - - void DisableMenuItem(int id); - - int DeleteMenuItem(int id, BOOL idispos = FALSE); - - BOOL InsertItem(const char* text, int id, int pos = -1); - - BOOL InsertMenuItem(const char* text, int id, int pos = -1) { return this->InsertItem(text, id, pos); } - - BOOL InsertSeparator(int pos) { return this->InsertItem(NULL, 0, pos); } - - void CheckMenuItem(int id, int status = TRUE); - - void UncheckMenuItem(int id); - - BOOL IsFlags(int id, int flags); - - BOOL IsMenuItemEnabled(int id); - - BOOL IsMenuItemDisabled(int id); - - BOOL IsMenuItemChecked(int id); - - HMENU GetSubmenuFromPos(int pos); - - int GetMenuPosFromID(int id); - - int Popup(HWND hwnd, POINT* ppoint = NULL, BOOL synchtrack = FALSE); + private: + + protected: + BOOL IsLoaded; + HMENU hMenu; + HWND hWndOwner; + + public: + MENU(HWND hwnd); + MENU(HMENU hm); + MENU(int id, HINSTANCE hdll= (HINSTANCE)(ULONG)-1); + ~MENU() + { if (this->IsLoaded) ::DestroyMenu(this->hMenu); this->hMenu= NULL; } + + operator HMENU(void) const + { return (HMENU)this->hMenu; } + + int GetNumMenuItems(void); + BOOL IsMenuItemSeparator(int pos); + + void EnableMenuItem(int id, int status= TRUE); + void DisableMenuItem(int id); + int DeleteMenuItem(int id, BOOL idispos= FALSE); + BOOL InsertItem(const char *text, int id, int pos= -1); + BOOL InsertMenuItem(const char *text, int id, int pos= -1) + { return this->InsertItem(text, id, pos); } + BOOL InsertSeparator(int pos) + { return this->InsertItem(NULL, 0, pos); } + void CheckMenuItem(int id, int status= TRUE); + void UncheckMenuItem(int id); + BOOL IsFlags(int id, int flags); + BOOL IsMenuItemEnabled(int id); + BOOL IsMenuItemDisabled(int id); + BOOL IsMenuItemChecked(int id); + + HMENU GetSubmenuFromPos(int pos); + int GetMenuPosFromID(int id); + + int Popup(HWND hwnd, POINT *ppoint= NULL, BOOL synchtrack= FALSE); }; #endif // WINCONTROLS_H