├── TPFCIcon ├── SystemTraySDK.cpp ├── SystemTraySDK.h ├── TPFCIcon.sln ├── TPFCIcon.vcproj ├── TaskbarTextIcon.h ├── _prec.cpp ├── _prec.h ├── approot.cpp ├── dynamicicon.cpp ├── dynamicicon.h ├── fancontrol.cpp ├── fancontrol.h ├── green.pal ├── misc.cpp ├── portio.cpp ├── res │ ├── FanControl.rc │ ├── app.bmp │ ├── app.ico │ ├── blue.bmp │ ├── blue.ico │ ├── bw.bmp │ ├── bw.ico │ ├── error.bmp │ ├── error.ico │ ├── ico16.ico │ ├── ico17.ico │ ├── ico18.ico │ ├── ico19.ico │ ├── ico20.ico │ ├── ico21.ico │ ├── ico22.ico │ ├── ico23.ico │ ├── ico24.ico │ ├── ico25.ico │ ├── orange.bmp │ ├── orange.ico │ ├── red.bmp │ ├── red.ico │ ├── resource.h │ ├── xp-manifest.txt │ ├── yellow.bmp │ └── yellow.ico ├── winstuff.cpp └── winstuff.h ├── TPFCIcon_noballons ├── SystemTraySDK.cpp ├── SystemTraySDK.h ├── TPFCIcon.sln ├── TPFCIcon.vcproj ├── TaskbarTextIcon.h ├── _prec.cpp ├── _prec.h ├── approot.cpp ├── dynamicicon.cpp ├── dynamicicon.h ├── fancontrol.cpp ├── fancontrol.h ├── misc.cpp ├── portio.cpp ├── res │ ├── FanControl.rc │ ├── app.bmp │ ├── app.ico │ ├── blue.bmp │ ├── blue.ico │ ├── bw.bmp │ ├── bw.ico │ ├── error.bmp │ ├── error.ico │ ├── ico16.ico │ ├── ico17.ico │ ├── ico18.ico │ ├── ico19.ico │ ├── ico20.ico │ ├── ico21.ico │ ├── ico22.ico │ ├── ico23.ico │ ├── ico24.ico │ ├── ico25.ico │ ├── orange.bmp │ ├── orange.ico │ ├── red.bmp │ ├── red.ico │ ├── resource.h │ ├── xp-manifest.txt │ ├── yellow.bmp │ └── yellow.ico ├── winstuff.cpp └── winstuff.h └── fancontrol ├── Debug └── TPFanControl.ini ├── Release └── TPFanControl.ini ├── SystemTraySDK.cpp ├── SystemTraySDK.h ├── TPFanControl.ini ├── TVicPort.h ├── TVicPort.lib ├── TaskbarTextIcon.h ├── _prec.cpp ├── _prec.h ├── approot.cpp ├── approot.h ├── dynamicicon.cpp ├── dynamicicon.h ├── fancontrol.cpp ├── fancontrol.h ├── fancontrol.sln ├── fancontrol.vcproj ├── fanstuff.cpp ├── misc.cpp ├── portio.cpp ├── res ├── RCa03996 ├── RCb03996 ├── app.bmp ├── app.ico ├── blue.bmp ├── blue.ico ├── bw.bmp ├── bw.ico ├── fancontrol.rc ├── ico21.ico ├── ico22.ico ├── ico23.ico ├── ico24.ico ├── ico25.ico ├── orange.bmp ├── orange.ico ├── red.bmp ├── red.ico ├── resource ├── resource.h ├── signatur.txt ├── tom.bmp ├── xp-manifest.txt ├── yellow.bmp └── yellow.ico ├── tools.h ├── winstuff.cpp └── winstuff.h /TPFCIcon/SystemTraySDK.h: -------------------------------------------------------------------------------- 1 | // TrayIcon.h: interface for the CSystemTray class. 2 | // 3 | // Written by Chris Maunder (cmaunder@mail.com) 4 | // Copyright (c) 1998. 5 | // 6 | // This code may be used in compiled form in any way you desire. This 7 | // file may be redistributed unmodified by any means PROVIDING it is 8 | // not sold for profit without the authors written consent, and 9 | // providing that this notice and the authors name is included. If 10 | // the source code in this file is used in any commercial application 11 | // then acknowledgement must be made to the author of this file 12 | // (in whatever form you wish). 13 | // 14 | // This file is provided "as is" with no expressed or implied warranty. 15 | // 16 | // Expect bugs. 17 | // 18 | // Please use and enjoy. Please let me know of any bugs/mods/improvements 19 | // that you have found/implemented and I will fix/incorporate them into this 20 | // file. 21 | // 22 | ////////////////////////////////////////////////////////////////////// 23 | 24 | #if !defined(AFX_TRAYICON_H__43104212_F2C1_11D2_A9E9_8EA47C000000__INCLUDED_) 25 | #define AFX_TRAYICON_H__43104212_F2C1_11D2_A9E9_8EA47C000000__INCLUDED_ 26 | 27 | #include 28 | 29 | #if _MSC_VER > 1000 30 | #pragma once 31 | #endif // _MSC_VER > 1000 32 | 33 | // The debugger can't handle symbols more than 255 characters long. 34 | // STL often creates symbols longer than that. 35 | // When symbols are longer than 255 characters, the warning is disabled. 36 | #pragma warning(disable:4786) 37 | #include 38 | #include 39 | using namespace std; 40 | typedef vector ICONVECTOR; 41 | 42 | #ifdef NOTIFYICONDATA_V1_SIZE // If NOTIFYICONDATA_V1_SIZE, then we can use fun stuff 43 | #define SYSTEMTRAY_USEW2K 44 | #else 45 | #define NIIF_NONE 0 46 | #endif 47 | 48 | class CSystemTray 49 | { 50 | // Construction/destruction 51 | public: 52 | CSystemTray(); 53 | 54 | CSystemTray( 55 | HINSTANCE hInst, 56 | HWND hParent, 57 | UINT uCallbackMessage, 58 | LPCTSTR szTip, 59 | HICON icon, 60 | UINT uID, 61 | BOOL bhidden = FALSE, 62 | LPCTSTR szBalloonTip = NULL, 63 | LPCTSTR szBalloonTitle = NULL, 64 | DWORD dwBalloonIcon = NIIF_NONE, 65 | UINT uBalloonTimeout = 10); 66 | 67 | virtual ~CSystemTray(); 68 | 69 | // Operations 70 | public: 71 | BOOL Enabled() { return m_bEnabled; } 72 | BOOL Visible() { return !m_bHidden; } 73 | 74 | // Create the tray icon 75 | BOOL Create( 76 | HINSTANCE hInst, 77 | HWND hParent, 78 | UINT uCallbackMessage, 79 | LPCTSTR szTip, 80 | HICON icon, 81 | UINT uID, 82 | BOOL bHidden = FALSE, 83 | LPCTSTR szBalloonTip = NULL, 84 | LPCTSTR szBalloonTitle = NULL, 85 | DWORD dwBalloonIcon = NIIF_NONE, 86 | UINT uBalloonTimeout = 10); 87 | 88 | // Change or retrieve the Tooltip text 89 | BOOL SetTooltipText(LPCTSTR pszTooltipText); 90 | BOOL SetTooltipText(UINT nID); 91 | LPTSTR GetTooltipText() const; 92 | 93 | // Change or retrieve the icon displayed 94 | BOOL SetIcon(HICON hIcon); 95 | BOOL SetIcon(LPCTSTR lpszIconName); 96 | BOOL SetIcon(UINT nIDResource); 97 | BOOL SetStandardIcon(LPCTSTR lpIconName); 98 | BOOL SetStandardIcon(UINT nIDResource); 99 | HICON GetIcon() const; 100 | BOOL ChangeIconTip(UINT nIconID, LPCTSTR strTip); 101 | 102 | void SetFocus(); 103 | BOOL HideIcon(); 104 | BOOL ShowIcon(); 105 | BOOL AddIcon(); 106 | BOOL RemoveIcon(); 107 | BOOL MoveToRight(); 108 | 109 | BOOL ShowBalloon(LPCTSTR szText, LPCTSTR szTitle = NULL, 110 | DWORD dwIcon = NIIF_NONE, UINT uTimeout = 10); 111 | 112 | // For icon animation 113 | BOOL SetIconList(UINT uFirstIconID, UINT uLastIconID); 114 | BOOL SetIconList(HICON* pHIconList, UINT nNumIcons); 115 | BOOL Animate(UINT nDelayMilliSeconds, int nNumSeconds = -1); 116 | BOOL StepAnimation(); 117 | BOOL StopAnimation(); 118 | 119 | // Change menu default item 120 | void GetMenuDefaultItem(UINT& uItem, BOOL& bByPos); 121 | BOOL SetMenuDefaultItem(UINT uItem, BOOL bByPos); 122 | 123 | // Change or retrieve the window to send icon notification messages to 124 | BOOL SetNotificationWnd(HWND hNotifyWnd); 125 | HWND GetNotificationWnd() const; 126 | 127 | // Change or retrieve the window to send menu commands to 128 | BOOL SetTargetWnd(HWND hTargetWnd); 129 | HWND GetTargetWnd() const; 130 | 131 | // Change or retrieve notification messages sent to the window 132 | BOOL SetCallbackMessage(UINT uCallbackMessage); 133 | UINT GetCallbackMessage() const; 134 | 135 | HWND GetSafeHwnd() const { return (this)? m_hWnd : NULL; } 136 | UINT_PTR GetTimerID() const { return m_nTimerID; } 137 | 138 | // Static functions 139 | public: 140 | static void MinimiseToTray(HWND hWnd); 141 | static void MaximiseFromTray(HWND hWnd); 142 | 143 | public: 144 | // Default handler for tray notification message 145 | virtual LRESULT OnTrayNotification(WPARAM uID, LPARAM lEvent); 146 | 147 | // Overrides 148 | // ClassWizard generated virtual function overrides 149 | //{{AFX_VIRTUAL(CSystemTray) 150 | //}}AFX_VIRTUAL 151 | 152 | // Static callback functions and data 153 | public: 154 | static LRESULT PASCAL WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 155 | static CSystemTray* m_pThis; 156 | void InstallIconPending(); 157 | 158 | // Implementation 159 | protected: 160 | void Initialise(); 161 | ATOM RegisterClass(HINSTANCE hInstance); 162 | 163 | virtual void CustomizeMenu(HMENU) {} 164 | 165 | // Implementation 166 | protected: 167 | NOTIFYICONDATA m_tnd; 168 | HINSTANCE m_hInstance; 169 | HWND m_hWnd; 170 | HWND m_hTargetWnd; // Window that menu commands are sent 171 | 172 | BOOL m_bEnabled; // does O/S support tray icon? 173 | BOOL m_bHidden; // Has the icon been hidden? 174 | BOOL m_bRemoved; // Has the icon been removed? 175 | BOOL m_bShowIconPending; // Show the icon once that taskbar has been created 176 | BOOL m_bWin2K; // Use new W2K features? 177 | 178 | ICONVECTOR m_IconList; 179 | UINT_PTR m_uIDTimer; 180 | unsigned int m_nCurrentIcon; 181 | time_t m_StartTime; 182 | int m_nAnimationPeriod; 183 | HICON m_hSavedIcon; 184 | UINT m_DefaultMenuItemID; 185 | BOOL m_DefaultMenuItemByPos; 186 | UINT m_uCreationFlags; 187 | 188 | // Static data 189 | protected: 190 | static BOOL RemoveTaskbarIcon(HWND hWnd); 191 | 192 | static const UINT m_nTimerID; 193 | static UINT m_nMaxTooltipLength; 194 | static const UINT m_nTaskbarCreatedMsg; 195 | static HWND m_hWndInvisible; 196 | 197 | static BOOL GetW2K(); 198 | #ifndef _WIN32_WCE 199 | static void GetTrayWndRect(LPRECT lprect); 200 | static BOOL GetDoWndAnimation(); 201 | #endif 202 | 203 | // message map functions 204 | public: 205 | LRESULT OnTimer(UINT nIDEvent); 206 | LRESULT OnTaskbarCreated(WPARAM wParam, LPARAM lParam); 207 | #ifndef _WIN32_WCE 208 | LRESULT OnSettingChange(UINT uFlags, LPCTSTR lpszSection); 209 | #endif 210 | }; 211 | 212 | 213 | #endif // !defined(AFX_TRAYICON_H__43104212_F2C1_11D2_A9E9_8EA47C000000__INCLUDED_) 214 | -------------------------------------------------------------------------------- /TPFCIcon/TPFCIcon.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TPFCIcon", "TPFCIcon.vcproj", "{23F70D81-8A0A-4C2B-B426-C74C9AA85039}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {23F70D81-8A0A-4C2B-B426-C74C9AA85039}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {23F70D81-8A0A-4C2B-B426-C74C9AA85039}.Debug|Win32.Build.0 = Debug|Win32 14 | {23F70D81-8A0A-4C2B-B426-C74C9AA85039}.Release|Win32.ActiveCfg = Release|Win32 15 | {23F70D81-8A0A-4C2B-B426-C74C9AA85039}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /TPFCIcon/TPFCIcon.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 26 | 29 | 32 | 35 | 38 | 43 | 59 | 62 | 67 | 70 | 81 | 84 | 87 | 90 | 95 | 98 | 101 | 104 | 107 | 108 | 118 | 121 | 124 | 127 | 130 | 135 | 151 | 154 | 159 | 162 | 172 | 175 | 178 | 181 | 186 | 189 | 192 | 195 | 198 | 199 | 200 | 201 | 202 | 203 | 207 | 210 | 211 | 214 | 217 | 221 | 222 | 225 | 229 | 230 | 231 | 234 | 235 | 238 | 241 | 245 | 246 | 249 | 253 | 254 | 255 | 258 | 261 | 265 | 266 | 269 | 273 | 274 | 275 | 278 | 279 | 282 | 285 | 289 | 290 | 293 | 297 | 298 | 299 | 300 | 304 | 307 | 308 | 311 | 312 | 315 | 316 | 319 | 320 | 323 | 324 | 327 | 328 | 331 | 332 | 333 | 337 | 340 | 341 | 344 | 345 | 348 | 349 | 352 | 353 | 356 | 359 | 364 | 365 | 368 | 373 | 374 | 375 | 378 | 379 | 382 | 383 | 386 | 387 | 390 | 391 | 394 | 395 | 398 | 399 | 402 | 403 | 406 | 407 | 408 | 411 | 412 | 413 | 414 | 415 | 416 | -------------------------------------------------------------------------------- /TPFCIcon/TaskbarTextIcon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "systemtraysdk.h" 4 | #include "DynamicIcon.h" 5 | #include 6 | 7 | 8 | class CTaskbarTextIcon 9 | { 10 | private: 11 | 12 | CDynamicIcon *m_pDicon; 13 | int iFarbeIconC; 14 | LPCTSTR aTooltipC; 15 | 16 | void _createdicon(const int iFarbeIconC, LPCTSTR aTooltipC) 17 | { 18 | if(m_pSystray) m_pSystray->SetTooltipText(aTooltipC); 19 | CDynamicIcon* pDiconTemp = new CDynamicIcon(m_line1, m_line2, iFarbeIconC); 20 | if(m_pSystray) m_pSystray->SetIcon(pDiconTemp->GetHIcon()); 21 | if(m_pDicon)delete m_pDicon; 22 | m_pDicon = pDiconTemp; 23 | }; 24 | 25 | void _ballondicon(LPCTSTR szText,LPCTSTR szTitle,DWORD dwIcon,UINT uTimeout) 26 | { 27 | if(m_pDicon) m_pSystray->ShowBalloon(szText, szTitle, dwIcon, uTimeout); 28 | }; 29 | 30 | void _createsystray 31 | ( 32 | HINSTANCE hInst, 33 | HWND hWnd, 34 | UINT uCallbackMessage, 35 | UINT uID, 36 | LPCTSTR aTooltipC 37 | ) 38 | { 39 | if(m_pSystray) delete m_pSystray; 40 | m_pSystray = new CSystemTray(); 41 | m_pSystray->Create 42 | ( 43 | hInst, 44 | hWnd, 45 | uCallbackMessage, 46 | aTooltipC, // tooltip 47 | m_pDicon->GetHIcon(), 48 | 0 49 | ); 50 | }; 51 | 52 | 53 | protected: 54 | 55 | static const int LINESLEN = 4; 56 | CSystemTray *m_pSystray; 57 | char m_line1[LINESLEN],m_line2[LINESLEN]; 58 | //TODO: implement set/get/use 59 | COLORREF m_TextColor, m_BgColor; 60 | bool m_BgTransparent; 61 | 62 | void _setlines(const char* line1,const char* line2) 63 | { 64 | strncpy_s(m_line1,sizeof(m_line1),line1,3); 65 | strncpy_s(m_line2,sizeof(m_line2),line2,3); 66 | m_line1[LINESLEN-1] = 0; 67 | m_line2[LINESLEN-1] = 0; 68 | }; 69 | 70 | public: 71 | 72 | CTaskbarTextIcon 73 | ( 74 | HINSTANCE hInst, 75 | HWND hWnd, 76 | UINT uCallbackMessage, 77 | UINT uID, 78 | const char * line1 = 0, //can be 3 chars 79 | const char * line2 = 0, //can be 3 chars 80 | int iFarbeIconC = 0, 81 | LPCTSTR aTooltipC = _T("") 82 | ) 83 | : 84 | m_pSystray(NULL), 85 | m_pDicon(NULL), 86 | m_TextColor(RGB(0,0,0)), 87 | m_BgColor(RGB(255,0,0)), 88 | m_BgTransparent(false) 89 | { 90 | _setlines(line1,line2); 91 | _createdicon(iFarbeIconC,aTooltipC); 92 | _createsystray(hInst, hWnd, uCallbackMessage, uID, aTooltipC); 93 | }; 94 | 95 | ~CTaskbarTextIcon(void) 96 | { 97 | if(m_pSystray)delete m_pSystray; 98 | if(m_pDicon)delete m_pDicon; 99 | }; 100 | 101 | void ChangeText 102 | ( 103 | const char * line1, 104 | const char * line2 = 0, 105 | const int iFarbeIconC = 0, 106 | LPCTSTR aTooltipC =_T("/0") 107 | ) 108 | { 109 | _setlines(line1,line2); 110 | _createdicon(iFarbeIconC,aTooltipC); 111 | } 112 | 113 | void DiShowballon 114 | ( 115 | LPCTSTR szText , 116 | LPCTSTR szTitle , 117 | DWORD dwIcon , 118 | UINT uTimeout 119 | ) 120 | { 121 | _ballondicon( szText, szTitle, dwIcon, uTimeout); 122 | } 123 | 124 | 125 | 126 | }; 127 | -------------------------------------------------------------------------------- /TPFCIcon/_prec.cpp: -------------------------------------------------------------------------------- 1 | //this file generates the pch-file 2 | #include "_prec.h" -------------------------------------------------------------------------------- /TPFCIcon/_prec.h: -------------------------------------------------------------------------------- 1 | //systemheaders in one file for using precompiled headers. 2 | 3 | //be compatible downto win2k 4 | #define _WIN32_WINNT 0x0500 5 | //only most neccessary things from windows 6 | #define WIN32_LEAN_AND_MEAN 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | -------------------------------------------------------------------------------- /TPFCIcon/approot.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "_prec.h" 4 | #include "fancontrol.h" 5 | 6 | HINSTANCE hInstApp, 7 | hInstRes; 8 | 9 | HWND g_dialogWnd = NULL; 10 | 11 | int APIENTRY 12 | WinMain(HINSTANCE instance, HINSTANCE , LPSTR aArgs, int ) 13 | { 14 | DWORD rc= 0; 15 | 16 | hInstRes=GetModuleHandle(NULL); 17 | hInstApp=hInstRes; 18 | 19 | 20 | ::InitCommonControls(); 21 | 22 | FANCONTROL fc(hInstApp); 23 | 24 | g_dialogWnd = fc.GetDialogWnd(); 25 | 26 | fc.ProcessDialog(); 27 | 28 | ::PostMessage(g_dialogWnd, WM_COMMAND, 5020, 0); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /TPFCIcon/dynamicicon.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/dynamicicon.cpp -------------------------------------------------------------------------------- /TPFCIcon/dynamicicon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class CDynamicIcon { 7 | public: 8 | 9 | CDynamicIcon(const char line1[3],const char line2[3],const int iFarbeIconA); 10 | ~CDynamicIcon(); 11 | HICON GetHIcon(); 12 | private: 13 | 14 | HDC memDC1_; 15 | HDC memDC2_; 16 | HBITMAP oldBmp_1; 17 | HBITMAP oldBmp_2; 18 | HBITMAP iconBmp_; 19 | HBITMAP iconMaskBmp_; 20 | HBRUSH hOldBrush; 21 | HRGN rgn; 22 | HICON icon_; 23 | static const int iconWidth_= 16; 24 | static const int iconHeight_= 16; 25 | private: 26 | __inline static HFONT CreateFont(const HDC hDC); 27 | //default und copy verbergen 28 | __inline CDynamicIcon(){}; 29 | __inline CDynamicIcon(const CDynamicIcon&){}; 30 | }; 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /TPFCIcon/fancontrol.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/fancontrol.cpp -------------------------------------------------------------------------------- /TPFCIcon/fancontrol.h: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #ifndef FANCONTROL_H 20 | #define FANCONTROL_H 21 | 22 | #pragma once 23 | #include "_prec.h" 24 | #include "winstuff.h" 25 | #include "TaskbarTextIcon.h" 26 | 27 | 28 | 29 | #define FANCONTROLVERSION "0.60" 30 | 31 | #define WM__DISMISSDLG WM_USER+5 32 | #define WM__GETDATA WM_USER+6 33 | #define WM__NEWDATA WM_USER+7 34 | #define WM__TASKBAR WM_USER+8 35 | 36 | #define setzero(adr, size) memset((void*)(adr), (char)0x00, (size)) 37 | #define ARRAYMAX(tab) (sizeof(tab)/sizeof((tab)[0])) 38 | #define NULLSTRUCT { 0, } 39 | 40 | //named pipe TPFanControl01 41 | #define g_szPipeName "\\\\.\\Pipe\\TPFanControl01" //Name given to the pipe 42 | #define BUFFER_SIZE 1024 //1k 43 | 44 | class FANCONTROL 45 | { 46 | protected: 47 | HINSTANCE m_hinstapp; 48 | HWND hwndDialog; 49 | 50 | UINT_PTR m_titleTimer; 51 | 52 | int iFarbeIconB; 53 | int MaxTemp; 54 | int iMaxTemp; 55 | int TaskbarNew; 56 | int fanspeed, showfanspeed; 57 | int Log2File; 58 | int ShowTempIcon; 59 | HANDLE hThread; 60 | HANDLE hPipe; 61 | char Title[128]; 62 | char Title2[128]; 63 | char Title3[128]; 64 | char Title4[128]; 65 | 66 | // dialog.cpp 67 | ULONG DlgProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2); 68 | static ULONG CALLBACK BaseDlgProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2); 69 | 70 | //The default app-icon with changing colors 71 | TASKBARICON *pTaskbarIcon; 72 | //Digital Text icon with changing colors 73 | CTaskbarTextIcon **ppTbTextIcon; 74 | 75 | 76 | static int _stdcall FANCONTROL_Thread(ULONG parm) \ 77 | { return ((FANCONTROL *)parm)->WorkThread(); } 78 | 79 | int WorkThread(); 80 | 81 | 82 | // misc.cpp 83 | void Trace(const char *text); 84 | BOOL IsMinimized(void); 85 | void CurrentDateTimeLocalized(char *result, size_t sizeof_result); 86 | void CurrentTimeLocalized(char *result, size_t sizeof_result); 87 | HANDLE CreateThread(int (_stdcall *fnct)(ULONG), ULONG p); 88 | 89 | public: 90 | FANCONTROL(HINSTANCE hinstapp); 91 | ~FANCONTROL(); 92 | 93 | int ProcessDialog(); 94 | 95 | HWND GetDialogWnd() { return hwndDialog; } 96 | HANDLE GetWorkThread() { return hThread; } 97 | 98 | // The texticons will be shown depending on variables 99 | void ProcessTextIcons(); 100 | void RemoveTextIcons(void); 101 | }; 102 | 103 | #endif // FANCONTROL_H -------------------------------------------------------------------------------- /TPFCIcon/green.pal: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/green.pal -------------------------------------------------------------------------------- /TPFCIcon/misc.cpp: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | #include "_prec.h" 19 | #include "fancontrol.h" 20 | 21 | 22 | //------------------------------------------------------------------------- 23 | // localized date&time 24 | //------------------------------------------------------------------------- 25 | void 26 | FANCONTROL::CurrentDateTimeLocalized(char *result,size_t sizeof_result) 27 | { 28 | SYSTEMTIME s; 29 | ::GetLocalTime(&s); 30 | 31 | char otfmt[64]= "HH:mm:ss", otime[64]; 32 | char odfmt[128], odate[64]; 33 | 34 | 35 | ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, otfmt, sizeof(otfmt)); 36 | 37 | ::GetTimeFormat(LOCALE_USER_DEFAULT, 0, &s, otfmt, otime, sizeof(otime)); 38 | 39 | ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, odfmt, sizeof(odfmt)); 40 | 41 | ::GetDateFormat(LOCALE_USER_DEFAULT, 0, &s, odfmt, odate, sizeof(odate)); 42 | 43 | setzero(result, sizeof_result); 44 | strncpy_s(result,sizeof_result, odate, sizeof_result-2); 45 | strcat_s(result,sizeof_result, " "); 46 | strncat_s(result,sizeof_result, otime, sizeof_result-strlen(result)-1); 47 | } 48 | 49 | //------------------------------------------------------------------------- 50 | // localized time 51 | //------------------------------------------------------------------------- 52 | void 53 | FANCONTROL::CurrentTimeLocalized(char *result, size_t sizeof_result) 54 | { 55 | SYSTEMTIME s; 56 | ::GetLocalTime(&s); 57 | 58 | char otfmt[64]= "HH:mm:ss", otime[64]; 59 | // char odfmt[128], odate[64]; 60 | 61 | 62 | ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, otfmt, sizeof(otfmt)); 63 | 64 | ::GetTimeFormat(LOCALE_USER_DEFAULT, 0, &s, otfmt, otime, sizeof(otime)); 65 | 66 | // ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, odfmt, sizeof(odfmt)); 67 | 68 | // ::GetDateFormat(LOCALE_USER_DEFAULT, 0, &s, odfmt, odate, sizeof(odate)); 69 | 70 | setzero(result, sizeof_result); 71 | // strncpy_s(result,sizeof_result, odate, sizeof_result-2); 72 | // strcat_s(result,sizeof_result, " "); 73 | strncat_s(result,sizeof_result, otime, sizeof_result-1); 74 | // strncat_s(result,sizeof_result, otime, sizeof_result-strlen(result)-1); 75 | } 76 | 77 | 78 | 79 | //------------------------------------------------------------------------- 80 | // 81 | //------------------------------------------------------------------------- 82 | BOOL 83 | FANCONTROL::IsMinimized(void) 84 | { 85 | WINDOWPLACEMENT wp= NULLSTRUCT; 86 | 87 | ::GetWindowPlacement(this->hwndDialog, &wp); 88 | 89 | return wp.showCmd==SW_SHOWMINIMIZED; 90 | } 91 | 92 | //------------------------------------------------------------------------- 93 | // show trace output in lower window part 94 | //------------------------------------------------------------------------- 95 | void 96 | FANCONTROL::Trace(const char *text) 97 | { 98 | char trace[16384]= "", datebuf[128]= "", line[256]= "", linecsv[256]= ""; 99 | 100 | this->CurrentDateTimeLocalized(datebuf, sizeof(datebuf)); 101 | 102 | if (strlen(text)) 103 | sprintf_s(line,sizeof(line), "[%s] %s\r\n", datebuf, text); // probably acpi reading conflict 104 | else 105 | strcpy_s(line,sizeof(line), "\r\n"); 106 | 107 | ::GetDlgItemText(this->hwndDialog, 9200, trace, sizeof(trace)-strlen(line)-1); 108 | strcat_s(trace,sizeof(trace), line); 109 | 110 | // 111 | // display 100 lines max 112 | // 113 | char *p= trace + strlen(trace); 114 | int linecount= 0; 115 | 116 | while (p>= trace) { 117 | 118 | if (*p=='\n') { 119 | linecount++; 120 | if (linecount>100) 121 | break; 122 | } 123 | 124 | p--; 125 | } 126 | 127 | 128 | // 129 | // write logfile 130 | // 131 | if (this->Log2File==1) { 132 | FILE *flog; 133 | errno_t errflog = fopen_s(&flog,"fancontrol.log", "ab"); 134 | if (!errflog) { 135 | //TODO: fwrite_s 136 | fwrite(line, strlen(line), 1, flog); 137 | fclose(flog); 138 | } 139 | } 140 | 141 | // 142 | // redisplay log and scroll to bottom 143 | // 144 | ::SetDlgItemText(this->hwndDialog,9200, p+1); 145 | ::SendDlgItemMessage(this->hwndDialog, 9200, EM_SETSEL, strlen(trace)-2, strlen(trace)-2); 146 | ::SendDlgItemMessage(this->hwndDialog, 9200, EM_LINESCROLL, 0, 9999); 147 | } 148 | 149 | 150 | //------------------------------------------------------------------------- 151 | // create a thread 152 | //------------------------------------------------------------------------- 153 | HANDLE 154 | FANCONTROL::CreateThread(int (_stdcall *fnct)(ULONG), ULONG p) 155 | { 156 | LPTHREAD_START_ROUTINE thread= (LPTHREAD_START_ROUTINE)fnct; 157 | DWORD tid; 158 | HANDLE hThread; 159 | hThread= ::CreateThread(NULL, 8*4096, thread, (void*)p, 0, &tid); 160 | return hThread; 161 | } -------------------------------------------------------------------------------- /TPFCIcon/portio.cpp: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #include "_prec.h" 20 | #include "fancontrol.h" 21 | #include "winio.h" 22 | 23 | 24 | // Registers of the embedded controller 25 | #define EC_DATAPORT 0x62 // EC data io-port 26 | #define EC_CTRLPORT 0x66 // EC control io-port 27 | 28 | 29 | // Embedded controller status register bits 30 | #define EC_STAT_OBF 0x01 // Output buffer full 31 | #define EC_STAT_IBF 0x02 // Input buffer full 32 | #define EC_STAT_CMD 0x08 // Last write was a command write (0=data) 33 | 34 | 35 | // Embedded controller commands 36 | // (write to EC_CTRLPORT to initiate read/write operation) 37 | #define EC_CTRLPORT_READ (char)0x80 38 | #define EC_CTRLPORT_WRITE (char)0x81 39 | #define EC_CTRLPORT_QUERY (char)0x84 40 | 41 | 42 | 43 | 44 | 45 | int verbosity= 0; // verbosity for the logbuf (0= nothing) 46 | const size_t logbuf_n = 8192; 47 | char lasterrorstring[256]= "", 48 | logbuf[logbuf_n]= ""; 49 | 50 | 51 | -------------------------------------------------------------------------------- /TPFCIcon/res/FanControl.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #define APSTUDIO_HIDDEN_SYMBOLS 11 | #include "windows.h" 12 | #undef APSTUDIO_HIDDEN_SYMBOLS 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // Neutral (Standard) resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD) 21 | #ifdef _WIN32 22 | LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT 23 | #pragma code_page(1252) 24 | #endif //_WIN32 25 | 26 | ///////////////////////////////////////////////////////////////////////////// 27 | // 28 | // RT_MANIFEST 29 | // 30 | 31 | 1 RT_MANIFEST "xp-manifest.txt" 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | // 35 | // Menu 36 | // 37 | 38 | 5000 MENU 39 | BEGIN 40 | MENUITEM "Show Window", 5010 41 | MENUITEM "Hide Window", 5030 42 | MENUITEM "Symbol Icon", 5070 43 | MENUITEM "Text Icon", 5080 44 | MENUITEM SEPARATOR 45 | MENUITEM "End Program", 5020 46 | MENUITEM SEPARATOR 47 | MENUITEM "Donate / FAQ", 5050 48 | END 49 | 50 | 51 | ///////////////////////////////////////////////////////////////////////////// 52 | // 53 | // Dialog 54 | // 55 | 56 | 9000 DIALOGEX 50, 50, 366, 98 57 | STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU 58 | EXSTYLE WS_EX_TOOLWINDOW 59 | CAPTION "Thinkpad Fancontrol Icon" 60 | FONT 8, "MS Sans Serif", 400, 0, 0x0 61 | BEGIN 62 | GROUPBOX "server message",9201,5,3,356,88 63 | EDITTEXT 9200,12,14,342,70,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN 64 | END 65 | 66 | 67 | #ifdef APSTUDIO_INVOKED 68 | ///////////////////////////////////////////////////////////////////////////// 69 | // 70 | // TEXTINCLUDE 71 | // 72 | 73 | 1 TEXTINCLUDE 74 | BEGIN 75 | "resource.h\0" 76 | END 77 | 78 | 2 TEXTINCLUDE 79 | BEGIN 80 | "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" 81 | "#include ""windows.h""\r\n" 82 | "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" 83 | "\0" 84 | END 85 | 86 | 3 TEXTINCLUDE 87 | BEGIN 88 | "\r\n" 89 | "\0" 90 | END 91 | 92 | #endif // APSTUDIO_INVOKED 93 | 94 | 95 | ///////////////////////////////////////////////////////////////////////////// 96 | // 97 | // DESIGNINFO 98 | // 99 | 100 | #ifdef APSTUDIO_INVOKED 101 | GUIDELINES DESIGNINFO 102 | BEGIN 103 | 9000, DIALOG 104 | BEGIN 105 | LEFTMARGIN, 5 106 | RIGHTMARGIN, 361 107 | TOPMARGIN, 3 108 | BOTTOMMARGIN, 91 109 | HORZGUIDE, 3 110 | END 111 | END 112 | #endif // APSTUDIO_INVOKED 113 | 114 | #endif // Neutral (Standard) resources 115 | ///////////////////////////////////////////////////////////////////////////// 116 | 117 | 118 | ///////////////////////////////////////////////////////////////////////////// 119 | // Deutsch (Deutschland) resources 120 | 121 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) 122 | #ifdef _WIN32 123 | LANGUAGE LANG_GERMAN, SUBLANG_GERMAN 124 | #pragma code_page(1252) 125 | #endif //_WIN32 126 | 127 | ///////////////////////////////////////////////////////////////////////////// 128 | // 129 | // Version 130 | // 131 | 132 | VS_VERSION_INFO VERSIONINFO 133 | FILEVERSION 1,0,0,60 134 | PRODUCTVERSION 1,0,0,60 135 | FILEFLAGSMASK 0x17L 136 | #ifdef _DEBUG 137 | FILEFLAGS 0x1L 138 | #else 139 | FILEFLAGS 0x0L 140 | #endif 141 | FILEOS 0x4L 142 | FILETYPE 0x0L 143 | FILESUBTYPE 0x0L 144 | BEGIN 145 | BLOCK "StringFileInfo" 146 | BEGIN 147 | BLOCK "040704b0" 148 | BEGIN 149 | VALUE "Comments", "usage on your own risk" 150 | VALUE "CompanyName", "troubadix" 151 | VALUE "FileDescription", "Fan Control Software" 152 | VALUE "FileVersion", "1, 0, 0, 60" 153 | VALUE "InternalName", "TPFanControl" 154 | VALUE "LegalCopyright", "Copyright (C) 2009 by troubadix" 155 | VALUE "OriginalFilename", "FanControl.rc" 156 | VALUE "ProductName", "FanControl" 157 | VALUE "ProductVersion", "1, 0, 0, 60" 158 | END 159 | END 160 | BLOCK "VarFileInfo" 161 | BEGIN 162 | VALUE "Translation", 0x407, 1200 163 | END 164 | END 165 | 166 | #endif // Deutsch (Deutschland) resources 167 | ///////////////////////////////////////////////////////////////////////////// 168 | 169 | 170 | ///////////////////////////////////////////////////////////////////////////// 171 | // Englisch (USA) resources 172 | 173 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 174 | #ifdef _WIN32 175 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 176 | #pragma code_page(1252) 177 | #endif //_WIN32 178 | 179 | ///////////////////////////////////////////////////////////////////////////// 180 | // 181 | // Icon 182 | // 183 | 184 | // Icon with lowest ID value placed first to ensure application icon 185 | // remains consistent on all systems. 186 | 1 ICON "app.ico" 187 | 10 ICON "bw.ico" 188 | 11 ICON "blue.ico" 189 | 12 ICON "yellow.ico" 190 | 13 ICON "orange.ico" 191 | 14 ICON "red.ico" 192 | 15 ICON "error.ico" 193 | 21 ICON "ico16.ico" 194 | 22 ICON "ico17.ico" 195 | 25 ICON "ico18.ico" 196 | 24 ICON "ico19.ico" 197 | 23 ICON "ico20.ico" 198 | #endif // Englisch (USA) resources 199 | ///////////////////////////////////////////////////////////////////////////// 200 | 201 | 202 | 203 | #ifndef APSTUDIO_INVOKED 204 | ///////////////////////////////////////////////////////////////////////////// 205 | // 206 | // Generated from the TEXTINCLUDE 3 resource. 207 | // 208 | 209 | 210 | ///////////////////////////////////////////////////////////////////////////// 211 | #endif // not APSTUDIO_INVOKED 212 | 213 | -------------------------------------------------------------------------------- /TPFCIcon/res/app.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/app.bmp -------------------------------------------------------------------------------- /TPFCIcon/res/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/app.ico -------------------------------------------------------------------------------- /TPFCIcon/res/blue.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/blue.bmp -------------------------------------------------------------------------------- /TPFCIcon/res/blue.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/blue.ico -------------------------------------------------------------------------------- /TPFCIcon/res/bw.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/bw.bmp -------------------------------------------------------------------------------- /TPFCIcon/res/bw.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/bw.ico -------------------------------------------------------------------------------- /TPFCIcon/res/error.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/error.bmp -------------------------------------------------------------------------------- /TPFCIcon/res/error.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/error.ico -------------------------------------------------------------------------------- /TPFCIcon/res/ico16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/ico16.ico -------------------------------------------------------------------------------- /TPFCIcon/res/ico17.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/ico17.ico -------------------------------------------------------------------------------- /TPFCIcon/res/ico18.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/ico18.ico -------------------------------------------------------------------------------- /TPFCIcon/res/ico19.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/ico19.ico -------------------------------------------------------------------------------- /TPFCIcon/res/ico20.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/ico20.ico -------------------------------------------------------------------------------- /TPFCIcon/res/ico21.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/ico21.ico -------------------------------------------------------------------------------- /TPFCIcon/res/ico22.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/ico22.ico -------------------------------------------------------------------------------- /TPFCIcon/res/ico23.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/ico23.ico -------------------------------------------------------------------------------- /TPFCIcon/res/ico24.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/ico24.ico -------------------------------------------------------------------------------- /TPFCIcon/res/ico25.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/ico25.ico -------------------------------------------------------------------------------- /TPFCIcon/res/orange.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/orange.bmp -------------------------------------------------------------------------------- /TPFCIcon/res/orange.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/orange.ico -------------------------------------------------------------------------------- /TPFCIcon/res/red.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/red.bmp -------------------------------------------------------------------------------- /TPFCIcon/res/red.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/red.ico -------------------------------------------------------------------------------- /TPFCIcon/res/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by FanControl.rc 4 | // 5 | #define IDI_ICON2 109 6 | #define IDC_RADIOBUTTON1 1002 7 | #define IDC_RADIOBUTTON2 1003 8 | #define IDC_EDIT1 1003 9 | #define IDC_STATIC -1 10 | 11 | // Next default values for new objects 12 | // 13 | #ifdef APSTUDIO_INVOKED 14 | #ifndef APSTUDIO_READONLY_SYMBOLS 15 | #define _APS_NO_MFC 1 16 | #define _APS_NEXT_RESOURCE_VALUE 110 17 | #define _APS_NEXT_COMMAND_VALUE 40001 18 | #define _APS_NEXT_CONTROL_VALUE 1009 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /TPFCIcon/res/xp-manifest.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /TPFCIcon/res/yellow.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/yellow.bmp -------------------------------------------------------------------------------- /TPFCIcon/res/yellow.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon/res/yellow.ico -------------------------------------------------------------------------------- /TPFCIcon/winstuff.cpp: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #include "_prec.h" 20 | 21 | #include "fancontrol.h" 22 | #include "winstuff.h" 23 | #include "DynamicIcon.h" 24 | 25 | extern HINSTANCE hInstApp, hInstRes; 26 | 27 | ////////////////////////////////////////////////////////////////////////////// 28 | // // 29 | // TASKBARICON // 30 | // // 31 | // // 32 | // // 33 | // // 34 | ////////////////////////////////////////////////////////////////////////////// 35 | 36 | struct NOTIFYICONDATAV5 { 37 | NOTIFYICONDATA nof; 38 | TCHAR szTipExtra[64]; //Version 5.0 39 | DWORD dwState; //Version 5.0 40 | DWORD dwStateMask; //Version 5.0 41 | TCHAR szInfo[256]; //Version 5.0 42 | union { 43 | UINT uTimeout; //Version 5.0 44 | UINT uVersion; //Version 5.0 45 | } DUMMYUNIONNAME; 46 | TCHAR szInfoTitle[64]; //Version 5.0 47 | DWORD dwInfoFlags; //Version 5.0 48 | }; 49 | 50 | struct NOTIFYICONDATAV6 { 51 | DWORD cbSize; 52 | HWND hWnd; 53 | UINT uID; 54 | UINT uFlags; 55 | UINT uCallbackMessage; 56 | HICON hIcon; 57 | TCHAR szTip[64]; 58 | DWORD dwState; 59 | DWORD dwStateMask; 60 | TCHAR szInfo[256]; 61 | union { 62 | UINT uTimeout; 63 | UINT uVersion; 64 | }; 65 | TCHAR szInfoTitle[64]; 66 | DWORD dwInfoFlags; 67 | GUID guidItem; 68 | HICON hBalloonIcon; 69 | }; 70 | 71 | struct OSVERSIONINFOV4 { 72 | DWORD dwOSVersionInfoSize; 73 | DWORD dwMajorVersion; 74 | DWORD dwMinorVersion; 75 | DWORD dwBuildNumber; 76 | DWORD dwPlatformId; 77 | TCHAR szCSDVersion[128]; 78 | }; 79 | 80 | //------------------------------------------------------------------------- 81 | // Represent a window in the taskbar 82 | //------------------------------------------------------------------------- 83 | TASKBARICON::TASKBARICON(HWND hwndowner, int idicon, const char *tooltip) 84 | : Owner(hwndowner), 85 | Id(idicon), 86 | IconId(idicon), 87 | osVersion(0) 88 | { 89 | // ampersand must be escaped 90 | strcpy_s(this->Tooltip,sizeof(Tooltip), tooltip ? tooltip : ""); 91 | 92 | this->Construct(); 93 | } 94 | 95 | TASKBARICON::~TASKBARICON() 96 | { 97 | this->Destroy(); 98 | } 99 | 100 | 101 | BOOL 102 | TASKBARICON::Construct() 103 | { 104 | NOTIFYICONDATAV5 nofv5= NULLSTRUCT; 105 | NOTIFYICONDATA &nof= nofv5.nof; 106 | 107 | this->osVersion= 0; 108 | 109 | nof.cbSize= sizeof(nof); 110 | nof.hWnd= this->Owner; 111 | nof.uID= this->Id; 112 | nof.uFlags= NIF_MESSAGE; 113 | nof.uCallbackMessage= WM__TASKBAR; 114 | 115 | if (this->IconId) { 116 | nof.hIcon= (HICON)::LoadImage(hInstRes, MAKEINTRESOURCE(this->IconId), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); 117 | nof.uFlags|= NIF_ICON; 118 | } 119 | 120 | if (strlen(this->Tooltip)) { 121 | lstrcpyn(nof.szTip, this->Tooltip, sizeof(nof.szTip)-1); 122 | nof.uFlags|= NIF_TIP; 123 | } 124 | 125 | // 126 | // try a version 5 init (Shell_NotifyIcon has different behaviour from up win2000=version 5) 127 | // 128 | nof.cbSize= sizeof(nofv5); 129 | this->UpAndRunning= ::Shell_NotifyIcon(NIM_ADD, &nof); 130 | 131 | if (this->UpAndRunning) 132 | this->osVersion= 5; 133 | else 134 | this->UpAndRunning= ::Shell_NotifyIcon(NIM_ADD, &nof); 135 | 136 | if (nof.hIcon) { 137 | ::DestroyIcon(nof.hIcon); 138 | nof.hIcon= NULL; 139 | } 140 | 141 | return this->UpAndRunning; 142 | } 143 | 144 | void 145 | TASKBARICON::Destroy(BOOL keep) 146 | { 147 | NOTIFYICONDATA nof= NULLSTRUCT; 148 | 149 | nof.cbSize= sizeof(nof); 150 | nof.hWnd= this->Owner; 151 | nof.uID= this->Id; 152 | ::Shell_NotifyIcon(NIM_DELETE, &nof); 153 | 154 | if (!keep) { 155 | this->Owner= 0; 156 | this->Id= 0; 157 | this->IconId= 0; 158 | strcpy_s(this->Tooltip,sizeof(Tooltip), ""); 159 | } 160 | } 161 | 162 | BOOL 163 | TASKBARICON::IsUpAndRunning() 164 | { 165 | return this->UpAndRunning; 166 | } 167 | 168 | BOOL 169 | TASKBARICON::RebuildIfNecessary(BOOL force) 170 | { 171 | char tt[256]; 172 | 173 | strcpy_s(tt,sizeof(tt), this->Tooltip); // avoid selfassignment 174 | 175 | if (force || !this->SetTooltip(tt)) { 176 | this->Destroy(TRUE); 177 | this->Construct(); 178 | } 179 | 180 | return this->SetTooltip(tt); 181 | } 182 | 183 | 184 | int 185 | TASKBARICON::SetIcon(int iconid) 186 | { 187 | BOOL ok; 188 | NOTIFYICONDATA nof= NULLSTRUCT; 189 | 190 | this->IconId= iconid; 191 | 192 | nof.cbSize= sizeof(nof); 193 | nof.hWnd= this->Owner; 194 | nof.uID= this->Id; 195 | nof.uFlags= NIF_ICON; 196 | nof.hIcon= (HICON)::LoadImage(hInstRes, MAKEINTRESOURCE(this->IconId), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); 197 | 198 | ok= ::Shell_NotifyIcon(NIM_MODIFY, &nof); 199 | 200 | if (nof.hIcon) { 201 | ::DestroyIcon(nof.hIcon); 202 | nof.hIcon= NULL; 203 | } 204 | 205 | // try to rebuild if SetIcon failed 206 | if (!ok) 207 | this->RebuildIfNecessary(TRUE); 208 | 209 | return ok; 210 | } 211 | 212 | int 213 | TASKBARICON::SetTooltip(const char *tooltip) 214 | { 215 | BOOL ok= 0; 216 | 217 | 218 | if (strcmp(this->Tooltip, tooltip)!=0) { 219 | strcpy_s(this->Tooltip,sizeof(Tooltip), tooltip); 220 | 221 | 222 | NOTIFYICONDATA nof= NULLSTRUCT; 223 | 224 | nof.cbSize= sizeof(nof); 225 | nof.hWnd= this->Owner; 226 | nof.uID= this->Id; 227 | nof.uFlags= NIF_TIP; 228 | lstrcpyn(nof.szTip, this->Tooltip, sizeof(nof.szTip)-1); 229 | 230 | 231 | ok= ::Shell_NotifyIcon(NIM_MODIFY, &nof); 232 | 233 | // try to rebuild if SetTooltip failed 234 | if (!ok && !this->InsideTooltipRebuild) { 235 | this->InsideTooltipRebuild= TRUE; 236 | this->RebuildIfNecessary(TRUE); 237 | this->InsideTooltipRebuild= FALSE; 238 | } 239 | } 240 | return ok; 241 | } 242 | 243 | 244 | int 245 | TASKBARICON::SetBalloon(ULONG flags, const char *title, const char *text, int timeout) 246 | { 247 | BOOL ok; 248 | 249 | NOTIFYICONDATA nof= NULLSTRUCT; 250 | 251 | nof.cbSize= sizeof(NOTIFYICONDATA); 252 | nof.hWnd= this->Owner; 253 | nof.uID= this->Id; 254 | nof.uFlags= NIF_INFO; 255 | nof.dwInfoFlags = flags; 256 | nof.uTimeout = timeout; 257 | lstrcpyn(nof.szInfo, text, sizeof(nof.szInfo)-1); 258 | lstrcpyn(nof.szInfoTitle, title, sizeof(nof.szInfoTitle)-1); 259 | 260 | return Shell_NotifyIcon(NIM_MODIFY, &nof); 261 | 262 | // try to rebuild if SetBalloon failed 263 | 264 | if (!ok) 265 | 266 | this->RebuildIfNecessary(TRUE); 267 | 268 | return ok; 269 | } 270 | 271 | 272 | ////////////////////////////////////////////////////////////////////////////// 273 | // // 274 | // MENU // 275 | // // 276 | // // 277 | // // 278 | // // 279 | ////////////////////////////////////////////////////////////////////////////// 280 | 281 | MENU::MENU(HWND w) 282 | : hMenu(::GetMenu(w)), 283 | hWndOwner(w), 284 | IsLoaded(FALSE) 285 | { 286 | 287 | } 288 | 289 | MENU::MENU(HMENU hmenu) 290 | : hMenu(hmenu), 291 | hWndOwner(NULL), 292 | IsLoaded(FALSE) 293 | { 294 | 295 | } 296 | 297 | MENU::MENU(int id, HINSTANCE hdll) 298 | : hMenu(::LoadMenu(((ULONG)hdll==(ULONG)-1)? hInstRes : hdll, MAKEINTRESOURCE(id))), 299 | hWndOwner(NULL), 300 | IsLoaded(TRUE) 301 | { 302 | 303 | } 304 | 305 | 306 | void 307 | MENU::EnableMenuItem(int id, int status) 308 | { 309 | ::EnableMenuItem(*this, id, 310 | MF_BYCOMMAND | (status ? MF_ENABLED : MF_GRAYED)); 311 | } 312 | 313 | void 314 | MENU::DisableMenuItem(int id) 315 | { 316 | this->EnableMenuItem(id, FALSE); 317 | } 318 | 319 | int 320 | MENU::DeleteMenuItem(int id, BOOL idispos) 321 | { 322 | int rc= ::DeleteMenu(*this, id, idispos ? MF_BYPOSITION : MF_BYCOMMAND); 323 | if (this->hWndOwner) 324 | ::DrawMenuBar(this->hWndOwner); 325 | 326 | return rc; 327 | } 328 | 329 | void 330 | MENU::CheckMenuItem(int id, int status) 331 | { 332 | ::CheckMenuItem(*this, id, 333 | MF_BYCOMMAND | (status ? MF_CHECKED : MF_UNCHECKED)); 334 | } 335 | 336 | void 337 | MENU::UncheckMenuItem(int id) 338 | { 339 | this->CheckMenuItem(id, FALSE); 340 | } 341 | 342 | BOOL 343 | MENU::IsFlags(int id, int flags) 344 | { 345 | return ((::GetMenuState(*this, id, MF_BYCOMMAND) & flags)!=0); 346 | } 347 | 348 | BOOL 349 | MENU::IsMenuItemSeparator(int pos) 350 | { 351 | MENUITEMINFO mii= {sizeof(mii), MIIM_TYPE, }; 352 | ::GetMenuItemInfo(*this, pos, TRUE, &mii); 353 | return mii.fType==MFT_SEPARATOR; 354 | } 355 | 356 | BOOL 357 | MENU::IsMenuItemEnabled(int id) 358 | { 359 | return !this->IsFlags(id, MF_DISABLED|MF_GRAYED); 360 | } 361 | 362 | BOOL 363 | MENU::IsMenuItemDisabled(int id) 364 | { 365 | return this->IsFlags(id, MF_DISABLED|MF_GRAYED); 366 | } 367 | 368 | BOOL 369 | MENU::IsMenuItemChecked(int id) 370 | { 371 | return this->IsFlags(id, MF_CHECKED); 372 | } 373 | 374 | int 375 | MENU::GetNumMenuItems() 376 | { 377 | return ::GetMenuItemCount(*this); 378 | } 379 | 380 | 381 | //-------------------------------------------------------------------- 382 | // return the sub-menu handle of a menu item at a given position 383 | //-------------------------------------------------------------------- 384 | HMENU 385 | MENU::GetSubmenuFromPos(int pos) 386 | { 387 | HMENU rc= NULL; 388 | 389 | rc= (HMENU)GetSubMenu(*this, pos); 390 | 391 | return rc; 392 | } 393 | 394 | 395 | //-------------------------------------------------------------------- 396 | // return the item pos of a menu entry (search by id) 397 | //-------------------------------------------------------------------- 398 | int 399 | MENU::GetMenuPosFromID(int id) 400 | { 401 | int rc= -1; 402 | 403 | int i, mid, numof= ::GetMenuItemCount(*this); 404 | 405 | for (i=0; ihMenu, "BLUB"); 457 | hmenuShow= ::GetSubMenu(hmenu, 0); 458 | RECT r= { 0, 0, 10, 10 }; 459 | 460 | if (hwndowner) 461 | ::SetForegroundWindow(hwndowner); 462 | 463 | 464 | ULONG flags= TPM_LEFTALIGN | TPM_LEFTBUTTON; 465 | 466 | if (synchtrack & 1) 467 | flags|= TPM_RETURNCMD; 468 | 469 | if (synchtrack & TPM_RIGHTALIGN) 470 | flags|= TPM_RIGHTALIGN; 471 | 472 | int rc= ::TrackPopupMenu(hmenuShow, flags, 473 | point.x,point.y, 0, 474 | hwndowner, &r); 475 | 476 | if (hwndowner) 477 | ::PostMessage(hwndowner, WM_NULL, 0, 0); 478 | 479 | ::RemoveMenu(hmenu, 0, MF_BYPOSITION); 480 | ::DestroyMenu(hmenu); 481 | 482 | return rc; 483 | } 484 | -------------------------------------------------------------------------------- /TPFCIcon/winstuff.h: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #ifndef WINCONTROLS_H 20 | #define WINCONTROLS_H 21 | 22 | #pragma once 23 | 24 | #include "_prec.h" 25 | 26 | 27 | #ifndef NIF_STATE // NotifyIcon V5 defines 28 | #define NIF_STATE 0x00000008 29 | #define NIF_INFO 0x00000010 30 | #define NIF_GUID 0x00000020 31 | 32 | #define NIIF_INFO 0x00000001 33 | #define NIIF_WARNING 0x00000002 34 | #define NIIF_ERROR 0x00000003 35 | #define NIIF_ICON_MASK 0x0000000F 36 | #define NIIF_NOSOUND 0x00000010 37 | #endif 38 | 39 | 40 | class TASKBARICON { 41 | 42 | private: 43 | BOOL UpAndRunning; 44 | 45 | protected: 46 | HWND Owner; 47 | int Id, IconId; 48 | char Tooltip[256]; 49 | int osVersion; //TODO: war drin? 50 | volatile BOOL InsideTooltipRebuild; //should be declared as volatile for concurrency reasons 51 | 52 | 53 | public: 54 | TASKBARICON(HWND hwndowner, int id, const char *tooltip); 55 | ~TASKBARICON(void); 56 | 57 | BOOL Construct(void); 58 | void Destroy(BOOL keep= FALSE); 59 | 60 | BOOL RebuildIfNecessary(BOOL); 61 | 62 | BOOL IsUpAndRunning(void); 63 | int SetIcon(int iconid); 64 | int SetTooltip(const char *tip); 65 | int SetBalloon(ULONG flags, const char *title, const char *text, int timeout= 2); 66 | }; 67 | 68 | 69 | class MENU { 70 | 71 | private: 72 | 73 | protected: 74 | BOOL IsLoaded; 75 | HMENU hMenu; 76 | HWND hWndOwner; 77 | 78 | public: 79 | MENU(HWND hwnd); 80 | MENU(HMENU hm); 81 | MENU(int id, HINSTANCE hdll= (HINSTANCE)(ULONG)-1); 82 | ~MENU() 83 | { if (this->IsLoaded) ::DestroyMenu(this->hMenu); this->hMenu= NULL; } 84 | 85 | operator HMENU(void) const 86 | { return (HMENU)this->hMenu; } 87 | 88 | int GetNumMenuItems(void); 89 | BOOL IsMenuItemSeparator(int pos); 90 | 91 | void EnableMenuItem(int id, int status= TRUE); 92 | void DisableMenuItem(int id); 93 | int DeleteMenuItem(int id, BOOL idispos= FALSE); 94 | BOOL InsertItem(const char *text, int id, int pos= -1); 95 | BOOL InsertMenuItem(const char *text, int id, int pos= -1) 96 | { return this->InsertItem(text, id, pos); } 97 | BOOL InsertSeparator(int pos) 98 | { return this->InsertItem(NULL, 0, pos); } 99 | void CheckMenuItem(int id, int status= TRUE); 100 | void UncheckMenuItem(int id); 101 | BOOL IsFlags(int id, int flags); 102 | BOOL IsMenuItemEnabled(int id); 103 | BOOL IsMenuItemDisabled(int id); 104 | BOOL IsMenuItemChecked(int id); 105 | 106 | HMENU GetSubmenuFromPos(int pos); 107 | int GetMenuPosFromID(int id); 108 | 109 | int Popup(HWND hwnd, POINT *ppoint= NULL, BOOL synchtrack= FALSE); 110 | }; 111 | 112 | #endif // WINCONTROLS_H -------------------------------------------------------------------------------- /TPFCIcon_noballons/SystemTraySDK.h: -------------------------------------------------------------------------------- 1 | // TrayIcon.h: interface for the CSystemTray class. 2 | // 3 | // Written by Chris Maunder (cmaunder@mail.com) 4 | // Copyright (c) 1998. 5 | // 6 | // This code may be used in compiled form in any way you desire. This 7 | // file may be redistributed unmodified by any means PROVIDING it is 8 | // not sold for profit without the authors written consent, and 9 | // providing that this notice and the authors name is included. If 10 | // the source code in this file is used in any commercial application 11 | // then acknowledgement must be made to the author of this file 12 | // (in whatever form you wish). 13 | // 14 | // This file is provided "as is" with no expressed or implied warranty. 15 | // 16 | // Expect bugs. 17 | // 18 | // Please use and enjoy. Please let me know of any bugs/mods/improvements 19 | // that you have found/implemented and I will fix/incorporate them into this 20 | // file. 21 | // 22 | ////////////////////////////////////////////////////////////////////// 23 | 24 | #if !defined(AFX_TRAYICON_H__43104212_F2C1_11D2_A9E9_8EA47C000000__INCLUDED_) 25 | #define AFX_TRAYICON_H__43104212_F2C1_11D2_A9E9_8EA47C000000__INCLUDED_ 26 | 27 | #include 28 | 29 | #if _MSC_VER > 1000 30 | #pragma once 31 | #endif // _MSC_VER > 1000 32 | 33 | // The debugger can't handle symbols more than 255 characters long. 34 | // STL often creates symbols longer than that. 35 | // When symbols are longer than 255 characters, the warning is disabled. 36 | #pragma warning(disable:4786) 37 | #include 38 | #include 39 | using namespace std; 40 | typedef vector ICONVECTOR; 41 | 42 | #ifdef NOTIFYICONDATA_V1_SIZE // If NOTIFYICONDATA_V1_SIZE, then we can use fun stuff 43 | #define SYSTEMTRAY_USEW2K 44 | #else 45 | #define NIIF_NONE 0 46 | #endif 47 | 48 | class CSystemTray 49 | { 50 | // Construction/destruction 51 | public: 52 | CSystemTray(); 53 | 54 | CSystemTray( 55 | HINSTANCE hInst, 56 | HWND hParent, 57 | UINT uCallbackMessage, 58 | LPCTSTR szTip, 59 | HICON icon, 60 | UINT uID, 61 | BOOL bhidden = FALSE, 62 | LPCTSTR szBalloonTip = NULL, 63 | LPCTSTR szBalloonTitle = NULL, 64 | DWORD dwBalloonIcon = NIIF_NONE, 65 | UINT uBalloonTimeout = 10); 66 | 67 | virtual ~CSystemTray(); 68 | 69 | // Operations 70 | public: 71 | BOOL Enabled() { return m_bEnabled; } 72 | BOOL Visible() { return !m_bHidden; } 73 | 74 | // Create the tray icon 75 | BOOL Create( 76 | HINSTANCE hInst, 77 | HWND hParent, 78 | UINT uCallbackMessage, 79 | LPCTSTR szTip, 80 | HICON icon, 81 | UINT uID, 82 | BOOL bHidden = FALSE, 83 | LPCTSTR szBalloonTip = NULL, 84 | LPCTSTR szBalloonTitle = NULL, 85 | DWORD dwBalloonIcon = NIIF_NONE, 86 | UINT uBalloonTimeout = 10); 87 | 88 | // Change or retrieve the Tooltip text 89 | BOOL SetTooltipText(LPCTSTR pszTooltipText); 90 | BOOL SetTooltipText(UINT nID); 91 | LPTSTR GetTooltipText() const; 92 | 93 | // Change or retrieve the icon displayed 94 | BOOL SetIcon(HICON hIcon); 95 | BOOL SetIcon(LPCTSTR lpszIconName); 96 | BOOL SetIcon(UINT nIDResource); 97 | BOOL SetStandardIcon(LPCTSTR lpIconName); 98 | BOOL SetStandardIcon(UINT nIDResource); 99 | HICON GetIcon() const; 100 | BOOL ChangeIconTip(UINT nIconID, LPCTSTR strTip); 101 | 102 | void SetFocus(); 103 | BOOL HideIcon(); 104 | BOOL ShowIcon(); 105 | BOOL AddIcon(); 106 | BOOL RemoveIcon(); 107 | BOOL MoveToRight(); 108 | 109 | BOOL ShowBalloon(LPCTSTR szText, LPCTSTR szTitle = NULL, 110 | DWORD dwIcon = NIIF_NONE, UINT uTimeout = 10); 111 | 112 | // For icon animation 113 | BOOL SetIconList(UINT uFirstIconID, UINT uLastIconID); 114 | BOOL SetIconList(HICON* pHIconList, UINT nNumIcons); 115 | BOOL Animate(UINT nDelayMilliSeconds, int nNumSeconds = -1); 116 | BOOL StepAnimation(); 117 | BOOL StopAnimation(); 118 | 119 | // Change menu default item 120 | void GetMenuDefaultItem(UINT& uItem, BOOL& bByPos); 121 | BOOL SetMenuDefaultItem(UINT uItem, BOOL bByPos); 122 | 123 | // Change or retrieve the window to send icon notification messages to 124 | BOOL SetNotificationWnd(HWND hNotifyWnd); 125 | HWND GetNotificationWnd() const; 126 | 127 | // Change or retrieve the window to send menu commands to 128 | BOOL SetTargetWnd(HWND hTargetWnd); 129 | HWND GetTargetWnd() const; 130 | 131 | // Change or retrieve notification messages sent to the window 132 | BOOL SetCallbackMessage(UINT uCallbackMessage); 133 | UINT GetCallbackMessage() const; 134 | 135 | HWND GetSafeHwnd() const { return (this)? m_hWnd : NULL; } 136 | UINT_PTR GetTimerID() const { return m_nTimerID; } 137 | 138 | // Static functions 139 | public: 140 | static void MinimiseToTray(HWND hWnd); 141 | static void MaximiseFromTray(HWND hWnd); 142 | 143 | public: 144 | // Default handler for tray notification message 145 | virtual LRESULT OnTrayNotification(WPARAM uID, LPARAM lEvent); 146 | 147 | // Overrides 148 | // ClassWizard generated virtual function overrides 149 | //{{AFX_VIRTUAL(CSystemTray) 150 | //}}AFX_VIRTUAL 151 | 152 | // Static callback functions and data 153 | public: 154 | static LRESULT PASCAL WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 155 | static CSystemTray* m_pThis; 156 | void InstallIconPending(); 157 | 158 | // Implementation 159 | protected: 160 | void Initialise(); 161 | ATOM RegisterClass(HINSTANCE hInstance); 162 | 163 | virtual void CustomizeMenu(HMENU) {} 164 | 165 | // Implementation 166 | protected: 167 | NOTIFYICONDATA m_tnd; 168 | HINSTANCE m_hInstance; 169 | HWND m_hWnd; 170 | HWND m_hTargetWnd; // Window that menu commands are sent 171 | 172 | BOOL m_bEnabled; // does O/S support tray icon? 173 | BOOL m_bHidden; // Has the icon been hidden? 174 | BOOL m_bRemoved; // Has the icon been removed? 175 | BOOL m_bShowIconPending; // Show the icon once that taskbar has been created 176 | BOOL m_bWin2K; // Use new W2K features? 177 | 178 | ICONVECTOR m_IconList; 179 | UINT_PTR m_uIDTimer; 180 | unsigned int m_nCurrentIcon; 181 | time_t m_StartTime; 182 | int m_nAnimationPeriod; 183 | HICON m_hSavedIcon; 184 | UINT m_DefaultMenuItemID; 185 | BOOL m_DefaultMenuItemByPos; 186 | UINT m_uCreationFlags; 187 | 188 | // Static data 189 | protected: 190 | static BOOL RemoveTaskbarIcon(HWND hWnd); 191 | 192 | static const UINT m_nTimerID; 193 | static UINT m_nMaxTooltipLength; 194 | static const UINT m_nTaskbarCreatedMsg; 195 | static HWND m_hWndInvisible; 196 | 197 | static BOOL GetW2K(); 198 | #ifndef _WIN32_WCE 199 | static void GetTrayWndRect(LPRECT lprect); 200 | static BOOL GetDoWndAnimation(); 201 | #endif 202 | 203 | // message map functions 204 | public: 205 | LRESULT OnTimer(UINT nIDEvent); 206 | LRESULT OnTaskbarCreated(WPARAM wParam, LPARAM lParam); 207 | #ifndef _WIN32_WCE 208 | LRESULT OnSettingChange(UINT uFlags, LPCTSTR lpszSection); 209 | #endif 210 | }; 211 | 212 | 213 | #endif // !defined(AFX_TRAYICON_H__43104212_F2C1_11D2_A9E9_8EA47C000000__INCLUDED_) 214 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/TPFCIcon.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TPFCIcon", "TPFCIcon.vcproj", "{23F70D81-8A0A-4C2B-B426-C74C9AA85039}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {23F70D81-8A0A-4C2B-B426-C74C9AA85039}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {23F70D81-8A0A-4C2B-B426-C74C9AA85039}.Debug|Win32.Build.0 = Debug|Win32 14 | {23F70D81-8A0A-4C2B-B426-C74C9AA85039}.Release|Win32.ActiveCfg = Release|Win32 15 | {23F70D81-8A0A-4C2B-B426-C74C9AA85039}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/TPFCIcon.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 26 | 29 | 32 | 35 | 38 | 43 | 59 | 62 | 67 | 70 | 81 | 84 | 87 | 90 | 95 | 98 | 101 | 104 | 107 | 108 | 118 | 121 | 124 | 127 | 130 | 135 | 151 | 154 | 159 | 162 | 172 | 175 | 178 | 181 | 186 | 189 | 192 | 195 | 198 | 199 | 200 | 201 | 202 | 203 | 207 | 210 | 211 | 214 | 217 | 221 | 222 | 225 | 229 | 230 | 231 | 234 | 235 | 238 | 241 | 245 | 246 | 249 | 253 | 254 | 255 | 258 | 261 | 265 | 266 | 269 | 273 | 274 | 275 | 278 | 279 | 282 | 285 | 289 | 290 | 293 | 297 | 298 | 299 | 300 | 304 | 307 | 308 | 311 | 312 | 315 | 316 | 319 | 320 | 323 | 324 | 327 | 328 | 331 | 332 | 333 | 337 | 340 | 341 | 344 | 345 | 348 | 349 | 352 | 353 | 356 | 359 | 364 | 365 | 368 | 373 | 374 | 375 | 378 | 379 | 382 | 383 | 386 | 387 | 390 | 391 | 394 | 395 | 398 | 399 | 402 | 403 | 406 | 407 | 408 | 411 | 412 | 413 | 414 | 415 | 416 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/TaskbarTextIcon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "systemtraysdk.h" 4 | #include "DynamicIcon.h" 5 | #include 6 | 7 | 8 | class CTaskbarTextIcon 9 | { 10 | private: 11 | 12 | CDynamicIcon *m_pDicon; 13 | int iFarbeIconC; 14 | LPCTSTR aTooltipC; 15 | 16 | void _createdicon(const int iFarbeIconC, LPCTSTR aTooltipC) 17 | { 18 | if(m_pSystray) m_pSystray->SetTooltipText(aTooltipC); 19 | CDynamicIcon* pDiconTemp = new CDynamicIcon(m_line1, m_line2, iFarbeIconC); 20 | if(m_pSystray) m_pSystray->SetIcon(pDiconTemp->GetHIcon()); 21 | if(m_pDicon)delete m_pDicon; 22 | m_pDicon = pDiconTemp; 23 | }; 24 | 25 | void _ballondicon(LPCTSTR szText,LPCTSTR szTitle,DWORD dwIcon,UINT uTimeout) 26 | { 27 | if(m_pDicon) m_pSystray->ShowBalloon(szText, szTitle, dwIcon, uTimeout); 28 | }; 29 | 30 | void _createsystray 31 | ( 32 | HINSTANCE hInst, 33 | HWND hWnd, 34 | UINT uCallbackMessage, 35 | UINT uID, 36 | LPCTSTR aTooltipC 37 | ) 38 | { 39 | if(m_pSystray) delete m_pSystray; 40 | m_pSystray = new CSystemTray(); 41 | m_pSystray->Create 42 | ( 43 | hInst, 44 | hWnd, 45 | uCallbackMessage, 46 | aTooltipC, // tooltip 47 | m_pDicon->GetHIcon(), 48 | 0 49 | ); 50 | }; 51 | 52 | 53 | protected: 54 | 55 | static const int LINESLEN = 4; 56 | CSystemTray *m_pSystray; 57 | char m_line1[LINESLEN],m_line2[LINESLEN]; 58 | //TODO: implement set/get/use 59 | COLORREF m_TextColor, m_BgColor; 60 | bool m_BgTransparent; 61 | 62 | void _setlines(const char* line1,const char* line2) 63 | { 64 | strncpy_s(m_line1,sizeof(m_line1),line1,3); 65 | strncpy_s(m_line2,sizeof(m_line2),line2,3); 66 | m_line1[LINESLEN-1] = 0; 67 | m_line2[LINESLEN-1] = 0; 68 | }; 69 | 70 | public: 71 | 72 | CTaskbarTextIcon 73 | ( 74 | HINSTANCE hInst, 75 | HWND hWnd, 76 | UINT uCallbackMessage, 77 | UINT uID, 78 | const char * line1 = 0, //can be 3 chars 79 | const char * line2 = 0, //can be 3 chars 80 | int iFarbeIconC = 0, 81 | LPCTSTR aTooltipC = _T("") 82 | ) 83 | : 84 | m_pSystray(NULL), 85 | m_pDicon(NULL), 86 | m_TextColor(RGB(0,0,0)), 87 | m_BgColor(RGB(255,0,0)), 88 | m_BgTransparent(false) 89 | { 90 | _setlines(line1,line2); 91 | _createdicon(iFarbeIconC,aTooltipC); 92 | _createsystray(hInst, hWnd, uCallbackMessage, uID, aTooltipC); 93 | }; 94 | 95 | ~CTaskbarTextIcon(void) 96 | { 97 | if(m_pSystray)delete m_pSystray; 98 | if(m_pDicon)delete m_pDicon; 99 | }; 100 | 101 | void ChangeText 102 | ( 103 | const char * line1, 104 | const char * line2 = 0, 105 | const int iFarbeIconC = 0, 106 | LPCTSTR aTooltipC =_T("/0") 107 | ) 108 | { 109 | _setlines(line1,line2); 110 | _createdicon(iFarbeIconC,aTooltipC); 111 | } 112 | 113 | void DiShowballon 114 | ( 115 | LPCTSTR szText , 116 | LPCTSTR szTitle , 117 | DWORD dwIcon , 118 | UINT uTimeout 119 | ) 120 | { 121 | _ballondicon( szText, szTitle, dwIcon, uTimeout); 122 | } 123 | 124 | 125 | 126 | }; 127 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/_prec.cpp: -------------------------------------------------------------------------------- 1 | //this file generates the pch-file 2 | #include "_prec.h" -------------------------------------------------------------------------------- /TPFCIcon_noballons/_prec.h: -------------------------------------------------------------------------------- 1 | //systemheaders in one file for using precompiled headers. 2 | 3 | //be compatible downto win2k 4 | #define _WIN32_WINNT 0x0500 5 | //only most neccessary things from windows 6 | #define WIN32_LEAN_AND_MEAN 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/approot.cpp: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #include "_prec.h" 20 | #include "fancontrol.h" 21 | 22 | HINSTANCE hInstApp, 23 | hInstRes; 24 | 25 | HWND g_dialogWnd = NULL; 26 | 27 | int APIENTRY 28 | WinMain(HINSTANCE instance, HINSTANCE , LPSTR aArgs, int ) 29 | { 30 | DWORD rc= 0; 31 | 32 | hInstRes=GetModuleHandle(NULL); 33 | hInstApp=hInstRes; 34 | 35 | 36 | ::InitCommonControls(); 37 | 38 | FANCONTROL fc(hInstApp); 39 | 40 | g_dialogWnd = fc.GetDialogWnd(); 41 | 42 | fc.ProcessDialog(); 43 | 44 | ::PostMessage(g_dialogWnd, WM_COMMAND, 5020, 0); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/dynamicicon.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/dynamicicon.cpp -------------------------------------------------------------------------------- /TPFCIcon_noballons/dynamicicon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class CDynamicIcon { 7 | public: 8 | 9 | CDynamicIcon(const char line1[3],const char line2[3],const int iFarbeIconA); 10 | ~CDynamicIcon(); 11 | HICON GetHIcon(); 12 | private: 13 | 14 | HDC memDC1_; 15 | HDC memDC2_; 16 | HBITMAP oldBmp_1; 17 | HBITMAP oldBmp_2; 18 | HBITMAP iconBmp_; 19 | HBITMAP iconMaskBmp_; 20 | HBRUSH hOldBrush; 21 | HRGN rgn; 22 | HICON icon_; 23 | static const int iconWidth_= 16; 24 | static const int iconHeight_= 16; 25 | private: 26 | __inline static HFONT CreateFont(const HDC hDC); 27 | //default und copy verbergen 28 | __inline CDynamicIcon(){}; 29 | __inline CDynamicIcon(const CDynamicIcon&){}; 30 | }; 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/fancontrol.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/fancontrol.cpp -------------------------------------------------------------------------------- /TPFCIcon_noballons/fancontrol.h: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #ifndef FANCONTROL_H 20 | #define FANCONTROL_H 21 | 22 | #pragma once 23 | #include "_prec.h" 24 | #include "winstuff.h" 25 | #include "TaskbarTextIcon.h" 26 | 27 | 28 | 29 | #define FANCONTROLVERSION "0.60" 30 | 31 | #define WM__DISMISSDLG WM_USER+5 32 | #define WM__GETDATA WM_USER+6 33 | #define WM__NEWDATA WM_USER+7 34 | #define WM__TASKBAR WM_USER+8 35 | 36 | #define setzero(adr, size) memset((void*)(adr), (char)0x00, (size)) 37 | #define ARRAYMAX(tab) (sizeof(tab)/sizeof((tab)[0])) 38 | #define NULLSTRUCT { 0, } 39 | 40 | //named pipe TPFanControl01 41 | #define g_szPipeName "\\\\.\\Pipe\\TPFanControl01" //Name given to the pipe 42 | #define BUFFER_SIZE 1024 //1k 43 | 44 | class FANCONTROL 45 | { 46 | protected: 47 | HINSTANCE m_hinstapp; 48 | HWND hwndDialog; 49 | 50 | UINT_PTR m_titleTimer; 51 | 52 | int iFarbeIconB; 53 | int MaxTemp; 54 | int iMaxTemp; 55 | int TaskbarNew; 56 | int fanspeed, showfanspeed; 57 | int Log2File; 58 | int ShowTempIcon; 59 | HANDLE hThread; 60 | HANDLE hPipe; 61 | char Title[128]; 62 | char Title2[128]; 63 | char Title3[128]; 64 | char Title4[128]; 65 | 66 | // dialog.cpp 67 | ULONG DlgProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2); 68 | static ULONG CALLBACK BaseDlgProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2); 69 | 70 | //The default app-icon with changing colors 71 | TASKBARICON *pTaskbarIcon; 72 | //Digital Text icon with changing colors 73 | CTaskbarTextIcon **ppTbTextIcon; 74 | 75 | 76 | static int _stdcall FANCONTROL_Thread(ULONG parm) \ 77 | { return ((FANCONTROL *)parm)->WorkThread(); } 78 | 79 | int WorkThread(); 80 | 81 | 82 | // misc.cpp 83 | void Trace(const char *text); 84 | BOOL IsMinimized(void); 85 | void CurrentDateTimeLocalized(char *result, size_t sizeof_result); 86 | void CurrentTimeLocalized(char *result, size_t sizeof_result); 87 | HANDLE CreateThread(int (_stdcall *fnct)(ULONG), ULONG p); 88 | 89 | public: 90 | FANCONTROL(HINSTANCE hinstapp); 91 | ~FANCONTROL(); 92 | 93 | int ProcessDialog(); 94 | 95 | HWND GetDialogWnd() { return hwndDialog; } 96 | HANDLE GetWorkThread() { return hThread; } 97 | 98 | // The texticons will be shown depending on variables 99 | void ProcessTextIcons(); 100 | void RemoveTextIcons(void); 101 | }; 102 | 103 | #endif // FANCONTROL_H -------------------------------------------------------------------------------- /TPFCIcon_noballons/misc.cpp: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | #include "_prec.h" 19 | #include "fancontrol.h" 20 | 21 | 22 | //------------------------------------------------------------------------- 23 | // localized date&time 24 | //------------------------------------------------------------------------- 25 | void 26 | FANCONTROL::CurrentDateTimeLocalized(char *result,size_t sizeof_result) 27 | { 28 | SYSTEMTIME s; 29 | ::GetLocalTime(&s); 30 | 31 | char otfmt[64]= "HH:mm:ss", otime[64]; 32 | char odfmt[128], odate[64]; 33 | 34 | 35 | ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, otfmt, sizeof(otfmt)); 36 | 37 | ::GetTimeFormat(LOCALE_USER_DEFAULT, 0, &s, otfmt, otime, sizeof(otime)); 38 | 39 | ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, odfmt, sizeof(odfmt)); 40 | 41 | ::GetDateFormat(LOCALE_USER_DEFAULT, 0, &s, odfmt, odate, sizeof(odate)); 42 | 43 | setzero(result, sizeof_result); 44 | strncpy_s(result,sizeof_result, odate, sizeof_result-2); 45 | strcat_s(result,sizeof_result, " "); 46 | strncat_s(result,sizeof_result, otime, sizeof_result-strlen(result)-1); 47 | } 48 | 49 | //------------------------------------------------------------------------- 50 | // localized time 51 | //------------------------------------------------------------------------- 52 | void 53 | FANCONTROL::CurrentTimeLocalized(char *result, size_t sizeof_result) 54 | { 55 | SYSTEMTIME s; 56 | ::GetLocalTime(&s); 57 | 58 | char otfmt[64]= "HH:mm:ss", otime[64]; 59 | // char odfmt[128], odate[64]; 60 | 61 | 62 | ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, otfmt, sizeof(otfmt)); 63 | 64 | ::GetTimeFormat(LOCALE_USER_DEFAULT, 0, &s, otfmt, otime, sizeof(otime)); 65 | 66 | // ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, odfmt, sizeof(odfmt)); 67 | 68 | // ::GetDateFormat(LOCALE_USER_DEFAULT, 0, &s, odfmt, odate, sizeof(odate)); 69 | 70 | setzero(result, sizeof_result); 71 | // strncpy_s(result,sizeof_result, odate, sizeof_result-2); 72 | // strcat_s(result,sizeof_result, " "); 73 | strncat_s(result,sizeof_result, otime, sizeof_result-1); 74 | // strncat_s(result,sizeof_result, otime, sizeof_result-strlen(result)-1); 75 | } 76 | 77 | 78 | 79 | //------------------------------------------------------------------------- 80 | // 81 | //------------------------------------------------------------------------- 82 | BOOL 83 | FANCONTROL::IsMinimized(void) 84 | { 85 | WINDOWPLACEMENT wp= NULLSTRUCT; 86 | 87 | ::GetWindowPlacement(this->hwndDialog, &wp); 88 | 89 | return wp.showCmd==SW_SHOWMINIMIZED; 90 | } 91 | 92 | //------------------------------------------------------------------------- 93 | // show trace output in lower window part 94 | //------------------------------------------------------------------------- 95 | void 96 | FANCONTROL::Trace(const char *text) 97 | { 98 | char trace[16384]= "", datebuf[128]= "", line[256]= "", linecsv[256]= ""; 99 | 100 | this->CurrentDateTimeLocalized(datebuf, sizeof(datebuf)); 101 | 102 | if (strlen(text)) 103 | sprintf_s(line,sizeof(line), "[%s] %s\r\n", datebuf, text); // probably acpi reading conflict 104 | else 105 | strcpy_s(line,sizeof(line), "\r\n"); 106 | 107 | ::GetDlgItemText(this->hwndDialog, 9200, trace, sizeof(trace)-strlen(line)-1); 108 | strcat_s(trace,sizeof(trace), line); 109 | 110 | // 111 | // display 100 lines max 112 | // 113 | char *p= trace + strlen(trace); 114 | int linecount= 0; 115 | 116 | while (p>= trace) { 117 | 118 | if (*p=='\n') { 119 | linecount++; 120 | if (linecount>100) 121 | break; 122 | } 123 | 124 | p--; 125 | } 126 | 127 | 128 | // 129 | // write logfile 130 | // 131 | if (this->Log2File==1) { 132 | FILE *flog; 133 | errno_t errflog = fopen_s(&flog,"fancontrol.log", "ab"); 134 | if (!errflog) { 135 | //TODO: fwrite_s 136 | fwrite(line, strlen(line), 1, flog); 137 | fclose(flog); 138 | } 139 | } 140 | 141 | // 142 | // redisplay log and scroll to bottom 143 | // 144 | ::SetDlgItemText(this->hwndDialog,9200, p+1); 145 | ::SendDlgItemMessage(this->hwndDialog, 9200, EM_SETSEL, strlen(trace)-2, strlen(trace)-2); 146 | ::SendDlgItemMessage(this->hwndDialog, 9200, EM_LINESCROLL, 0, 9999); 147 | } 148 | 149 | 150 | //------------------------------------------------------------------------- 151 | // create a thread 152 | //------------------------------------------------------------------------- 153 | HANDLE 154 | FANCONTROL::CreateThread(int (_stdcall *fnct)(ULONG), ULONG p) 155 | { 156 | LPTHREAD_START_ROUTINE thread= (LPTHREAD_START_ROUTINE)fnct; 157 | DWORD tid; 158 | HANDLE hThread; 159 | hThread= ::CreateThread(NULL, 8*4096, thread, (void*)p, 0, &tid); 160 | return hThread; 161 | } -------------------------------------------------------------------------------- /TPFCIcon_noballons/portio.cpp: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #include "_prec.h" 20 | #include "fancontrol.h" 21 | #include "winio.h" 22 | 23 | 24 | // Registers of the embedded controller 25 | #define EC_DATAPORT 0x62 // EC data io-port 26 | #define EC_CTRLPORT 0x66 // EC control io-port 27 | 28 | 29 | // Embedded controller status register bits 30 | #define EC_STAT_OBF 0x01 // Output buffer full 31 | #define EC_STAT_IBF 0x02 // Input buffer full 32 | #define EC_STAT_CMD 0x08 // Last write was a command write (0=data) 33 | 34 | 35 | // Embedded controller commands 36 | // (write to EC_CTRLPORT to initiate read/write operation) 37 | #define EC_CTRLPORT_READ (char)0x80 38 | #define EC_CTRLPORT_WRITE (char)0x81 39 | #define EC_CTRLPORT_QUERY (char)0x84 40 | 41 | 42 | 43 | 44 | 45 | int verbosity= 0; // verbosity for the logbuf (0= nothing) 46 | const size_t logbuf_n = 8192; 47 | char lasterrorstring[256]= "", 48 | logbuf[logbuf_n]= ""; 49 | 50 | 51 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/FanControl.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #define APSTUDIO_HIDDEN_SYMBOLS 11 | #include "windows.h" 12 | #undef APSTUDIO_HIDDEN_SYMBOLS 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | #undef APSTUDIO_READONLY_SYMBOLS 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // Neutral (Standard) resources 19 | 20 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD) 21 | #ifdef _WIN32 22 | LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT 23 | #pragma code_page(1252) 24 | #endif //_WIN32 25 | 26 | ///////////////////////////////////////////////////////////////////////////// 27 | // 28 | // RT_MANIFEST 29 | // 30 | 31 | 1 RT_MANIFEST "xp-manifest.txt" 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | // 35 | // Menu 36 | // 37 | 38 | 5000 MENU 39 | BEGIN 40 | MENUITEM "Show Window", 5010 41 | MENUITEM "Hide Window", 5030 42 | MENUITEM "Symbol Icon", 5070 43 | MENUITEM "Text Icon", 5080 44 | MENUITEM SEPARATOR 45 | MENUITEM "End Program", 5020 46 | MENUITEM SEPARATOR 47 | MENUITEM "Donate / FAQ", 5050 48 | END 49 | 50 | 51 | ///////////////////////////////////////////////////////////////////////////// 52 | // 53 | // Dialog 54 | // 55 | 56 | 9000 DIALOGEX 50, 50, 366, 98 57 | STYLE DS_SETFONT | DS_MODALFRAME | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU 58 | EXSTYLE WS_EX_TOOLWINDOW 59 | CAPTION "Thinkpad Fancontrol Icon" 60 | FONT 8, "MS Sans Serif", 400, 0, 0x0 61 | BEGIN 62 | GROUPBOX "server message",9201,5,3,356,88 63 | EDITTEXT 9200,12,14,342,70,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | ES_WANTRETURN 64 | END 65 | 66 | 67 | #ifdef APSTUDIO_INVOKED 68 | ///////////////////////////////////////////////////////////////////////////// 69 | // 70 | // TEXTINCLUDE 71 | // 72 | 73 | 1 TEXTINCLUDE 74 | BEGIN 75 | "resource.h\0" 76 | END 77 | 78 | 2 TEXTINCLUDE 79 | BEGIN 80 | "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" 81 | "#include ""windows.h""\r\n" 82 | "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" 83 | "\0" 84 | END 85 | 86 | 3 TEXTINCLUDE 87 | BEGIN 88 | "\r\n" 89 | "\0" 90 | END 91 | 92 | #endif // APSTUDIO_INVOKED 93 | 94 | 95 | ///////////////////////////////////////////////////////////////////////////// 96 | // 97 | // DESIGNINFO 98 | // 99 | 100 | #ifdef APSTUDIO_INVOKED 101 | GUIDELINES DESIGNINFO 102 | BEGIN 103 | 9000, DIALOG 104 | BEGIN 105 | LEFTMARGIN, 5 106 | RIGHTMARGIN, 361 107 | TOPMARGIN, 3 108 | BOTTOMMARGIN, 91 109 | HORZGUIDE, 3 110 | END 111 | END 112 | #endif // APSTUDIO_INVOKED 113 | 114 | #endif // Neutral (Standard) resources 115 | ///////////////////////////////////////////////////////////////////////////// 116 | 117 | 118 | ///////////////////////////////////////////////////////////////////////////// 119 | // Deutsch (Deutschland) resources 120 | 121 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) 122 | #ifdef _WIN32 123 | LANGUAGE LANG_GERMAN, SUBLANG_GERMAN 124 | #pragma code_page(1252) 125 | #endif //_WIN32 126 | 127 | ///////////////////////////////////////////////////////////////////////////// 128 | // 129 | // Version 130 | // 131 | 132 | VS_VERSION_INFO VERSIONINFO 133 | FILEVERSION 1,0,0,60 134 | PRODUCTVERSION 1,0,0,60 135 | FILEFLAGSMASK 0x17L 136 | #ifdef _DEBUG 137 | FILEFLAGS 0x1L 138 | #else 139 | FILEFLAGS 0x0L 140 | #endif 141 | FILEOS 0x4L 142 | FILETYPE 0x0L 143 | FILESUBTYPE 0x0L 144 | BEGIN 145 | BLOCK "StringFileInfo" 146 | BEGIN 147 | BLOCK "040704b0" 148 | BEGIN 149 | VALUE "Comments", "usage on your own risk" 150 | VALUE "CompanyName", "troubadix" 151 | VALUE "FileDescription", "TPFanControl" 152 | VALUE "FileVersion", "1, 0, 0, 60" 153 | VALUE "InternalName", "Fan Control Software" 154 | VALUE "LegalCopyright", "Copyright (C) 2009 by troubadix" 155 | VALUE "OriginalFilename", "FanControl.rc" 156 | VALUE "ProductName", "TPFanControl" 157 | VALUE "ProductVersion", "1, 0, 0, 60" 158 | END 159 | END 160 | BLOCK "VarFileInfo" 161 | BEGIN 162 | VALUE "Translation", 0x407, 1200 163 | END 164 | END 165 | 166 | #endif // Deutsch (Deutschland) resources 167 | ///////////////////////////////////////////////////////////////////////////// 168 | 169 | 170 | ///////////////////////////////////////////////////////////////////////////// 171 | // Englisch (USA) resources 172 | 173 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 174 | #ifdef _WIN32 175 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 176 | #pragma code_page(1252) 177 | #endif //_WIN32 178 | 179 | ///////////////////////////////////////////////////////////////////////////// 180 | // 181 | // Icon 182 | // 183 | 184 | // Icon with lowest ID value placed first to ensure application icon 185 | // remains consistent on all systems. 186 | 1 ICON "app.ico" 187 | 10 ICON "bw.ico" 188 | 11 ICON "blue.ico" 189 | 12 ICON "yellow.ico" 190 | 13 ICON "orange.ico" 191 | 14 ICON "red.ico" 192 | 15 ICON "error.ico" 193 | 21 ICON "ico16.ico" 194 | 22 ICON "ico17.ico" 195 | 25 ICON "ico18.ico" 196 | 24 ICON "ico19.ico" 197 | 23 ICON "ico20.ico" 198 | #endif // Englisch (USA) resources 199 | ///////////////////////////////////////////////////////////////////////////// 200 | 201 | 202 | 203 | #ifndef APSTUDIO_INVOKED 204 | ///////////////////////////////////////////////////////////////////////////// 205 | // 206 | // Generated from the TEXTINCLUDE 3 resource. 207 | // 208 | 209 | 210 | ///////////////////////////////////////////////////////////////////////////// 211 | #endif // not APSTUDIO_INVOKED 212 | 213 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/app.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/app.bmp -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/app.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/blue.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/blue.bmp -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/blue.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/blue.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/bw.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/bw.bmp -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/bw.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/bw.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/error.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/error.bmp -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/error.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/error.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/ico16.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/ico16.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/ico17.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/ico17.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/ico18.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/ico18.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/ico19.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/ico19.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/ico20.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/ico20.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/ico21.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/ico21.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/ico22.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/ico22.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/ico23.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/ico23.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/ico24.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/ico24.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/ico25.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/ico25.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/orange.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/orange.bmp -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/orange.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/orange.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/red.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/red.bmp -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/red.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/red.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by FanControl.rc 4 | // 5 | #define IDI_ICON2 109 6 | #define IDC_RADIOBUTTON1 1002 7 | #define IDC_RADIOBUTTON2 1003 8 | #define IDC_EDIT1 1003 9 | #define IDC_STATIC -1 10 | 11 | // Next default values for new objects 12 | // 13 | #ifdef APSTUDIO_INVOKED 14 | #ifndef APSTUDIO_READONLY_SYMBOLS 15 | #define _APS_NO_MFC 1 16 | #define _APS_NEXT_RESOURCE_VALUE 110 17 | #define _APS_NEXT_COMMAND_VALUE 40001 18 | #define _APS_NEXT_CONTROL_VALUE 1009 19 | #define _APS_NEXT_SYMED_VALUE 101 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/xp-manifest.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/yellow.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/yellow.bmp -------------------------------------------------------------------------------- /TPFCIcon_noballons/res/yellow.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/TPFCIcon_noballons/res/yellow.ico -------------------------------------------------------------------------------- /TPFCIcon_noballons/winstuff.cpp: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #include "_prec.h" 20 | 21 | #include "fancontrol.h" 22 | #include "winstuff.h" 23 | #include "DynamicIcon.h" 24 | 25 | extern HINSTANCE hInstApp, hInstRes; 26 | 27 | ////////////////////////////////////////////////////////////////////////////// 28 | // // 29 | // TASKBARICON // 30 | // // 31 | // // 32 | // // 33 | // // 34 | ////////////////////////////////////////////////////////////////////////////// 35 | 36 | struct NOTIFYICONDATAV5 { 37 | NOTIFYICONDATA nof; 38 | TCHAR szTipExtra[64]; //Version 5.0 39 | DWORD dwState; //Version 5.0 40 | DWORD dwStateMask; //Version 5.0 41 | TCHAR szInfo[256]; //Version 5.0 42 | union { 43 | UINT uTimeout; //Version 5.0 44 | UINT uVersion; //Version 5.0 45 | } DUMMYUNIONNAME; 46 | TCHAR szInfoTitle[64]; //Version 5.0 47 | DWORD dwInfoFlags; //Version 5.0 48 | }; 49 | 50 | struct NOTIFYICONDATAV6 { 51 | DWORD cbSize; 52 | HWND hWnd; 53 | UINT uID; 54 | UINT uFlags; 55 | UINT uCallbackMessage; 56 | HICON hIcon; 57 | TCHAR szTip[64]; 58 | DWORD dwState; 59 | DWORD dwStateMask; 60 | TCHAR szInfo[256]; 61 | union { 62 | UINT uTimeout; 63 | UINT uVersion; 64 | }; 65 | TCHAR szInfoTitle[64]; 66 | DWORD dwInfoFlags; 67 | GUID guidItem; 68 | HICON hBalloonIcon; 69 | }; 70 | 71 | struct OSVERSIONINFOV4 { 72 | DWORD dwOSVersionInfoSize; 73 | DWORD dwMajorVersion; 74 | DWORD dwMinorVersion; 75 | DWORD dwBuildNumber; 76 | DWORD dwPlatformId; 77 | TCHAR szCSDVersion[128]; 78 | }; 79 | 80 | //------------------------------------------------------------------------- 81 | // Represent a window in the taskbar 82 | //------------------------------------------------------------------------- 83 | TASKBARICON::TASKBARICON(HWND hwndowner, int idicon, const char *tooltip) 84 | : Owner(hwndowner), 85 | Id(idicon), 86 | IconId(idicon), 87 | osVersion(0) 88 | { 89 | // ampersand must be escaped 90 | strcpy_s(this->Tooltip,sizeof(Tooltip), tooltip ? tooltip : ""); 91 | 92 | this->Construct(); 93 | } 94 | 95 | TASKBARICON::~TASKBARICON() 96 | { 97 | this->Destroy(); 98 | } 99 | 100 | 101 | BOOL 102 | TASKBARICON::Construct() 103 | { 104 | NOTIFYICONDATAV5 nofv5= NULLSTRUCT; 105 | NOTIFYICONDATA &nof= nofv5.nof; 106 | 107 | this->osVersion= 0; 108 | 109 | nof.cbSize= sizeof(nof); 110 | nof.hWnd= this->Owner; 111 | nof.uID= this->Id; 112 | nof.uFlags= NIF_MESSAGE; 113 | nof.uCallbackMessage= WM__TASKBAR; 114 | 115 | if (this->IconId) { 116 | nof.hIcon= (HICON)::LoadImage(hInstRes, MAKEINTRESOURCE(this->IconId), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); 117 | nof.uFlags|= NIF_ICON; 118 | } 119 | 120 | if (strlen(this->Tooltip)) { 121 | lstrcpyn(nof.szTip, this->Tooltip, sizeof(nof.szTip)-1); 122 | nof.uFlags|= NIF_TIP; 123 | } 124 | 125 | // 126 | // try a version 5 init (Shell_NotifyIcon has different behaviour from up win2000=version 5) 127 | // 128 | nof.cbSize= sizeof(nofv5); 129 | this->UpAndRunning= ::Shell_NotifyIcon(NIM_ADD, &nof); 130 | 131 | if (this->UpAndRunning) 132 | this->osVersion= 5; 133 | else 134 | this->UpAndRunning= ::Shell_NotifyIcon(NIM_ADD, &nof); 135 | 136 | if (nof.hIcon) { 137 | ::DestroyIcon(nof.hIcon); 138 | nof.hIcon= NULL; 139 | } 140 | 141 | return this->UpAndRunning; 142 | } 143 | 144 | void 145 | TASKBARICON::Destroy(BOOL keep) 146 | { 147 | NOTIFYICONDATA nof= NULLSTRUCT; 148 | 149 | nof.cbSize= sizeof(nof); 150 | nof.hWnd= this->Owner; 151 | nof.uID= this->Id; 152 | ::Shell_NotifyIcon(NIM_DELETE, &nof); 153 | 154 | if (!keep) { 155 | this->Owner= 0; 156 | this->Id= 0; 157 | this->IconId= 0; 158 | strcpy_s(this->Tooltip,sizeof(Tooltip), ""); 159 | } 160 | } 161 | 162 | BOOL 163 | TASKBARICON::IsUpAndRunning() 164 | { 165 | return this->UpAndRunning; 166 | } 167 | 168 | BOOL 169 | TASKBARICON::RebuildIfNecessary(BOOL force) 170 | { 171 | char tt[256]; 172 | 173 | strcpy_s(tt,sizeof(tt), this->Tooltip); // avoid selfassignment 174 | 175 | if (force || !this->SetTooltip(tt)) { 176 | this->Destroy(TRUE); 177 | this->Construct(); 178 | } 179 | 180 | return this->SetTooltip(tt); 181 | } 182 | 183 | 184 | int 185 | TASKBARICON::SetIcon(int iconid) 186 | { 187 | BOOL ok; 188 | NOTIFYICONDATA nof= NULLSTRUCT; 189 | 190 | this->IconId= iconid; 191 | 192 | nof.cbSize= sizeof(nof); 193 | nof.hWnd= this->Owner; 194 | nof.uID= this->Id; 195 | nof.uFlags= NIF_ICON; 196 | nof.hIcon= (HICON)::LoadImage(hInstRes, MAKEINTRESOURCE(this->IconId), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); 197 | 198 | ok= ::Shell_NotifyIcon(NIM_MODIFY, &nof); 199 | 200 | if (nof.hIcon) { 201 | ::DestroyIcon(nof.hIcon); 202 | nof.hIcon= NULL; 203 | } 204 | 205 | // try to rebuild if SetIcon failed 206 | if (!ok) 207 | this->RebuildIfNecessary(TRUE); 208 | 209 | return ok; 210 | } 211 | 212 | int 213 | TASKBARICON::SetTooltip(const char *tooltip) 214 | { 215 | BOOL ok= 0; 216 | 217 | 218 | if (strcmp(this->Tooltip, tooltip)!=0) { 219 | strcpy_s(this->Tooltip,sizeof(Tooltip), tooltip); 220 | 221 | 222 | NOTIFYICONDATA nof= NULLSTRUCT; 223 | 224 | nof.cbSize= sizeof(nof); 225 | nof.hWnd= this->Owner; 226 | nof.uID= this->Id; 227 | nof.uFlags= NIF_TIP; 228 | lstrcpyn(nof.szTip, this->Tooltip, sizeof(nof.szTip)-1); 229 | 230 | 231 | ok= ::Shell_NotifyIcon(NIM_MODIFY, &nof); 232 | 233 | // try to rebuild if SetTooltip failed 234 | if (!ok && !this->InsideTooltipRebuild) { 235 | this->InsideTooltipRebuild= TRUE; 236 | this->RebuildIfNecessary(TRUE); 237 | this->InsideTooltipRebuild= FALSE; 238 | } 239 | } 240 | return ok; 241 | } 242 | 243 | 244 | int 245 | TASKBARICON::SetBalloon(ULONG flags, const char *title, const char *text, int timeout) 246 | { 247 | BOOL ok; 248 | 249 | NOTIFYICONDATA nof= NULLSTRUCT; 250 | 251 | nof.cbSize= sizeof(NOTIFYICONDATA); 252 | nof.hWnd= this->Owner; 253 | nof.uID= this->Id; 254 | nof.uFlags= NIF_INFO; 255 | nof.dwInfoFlags = flags; 256 | nof.uTimeout = timeout; 257 | lstrcpyn(nof.szInfo, text, sizeof(nof.szInfo)-1); 258 | lstrcpyn(nof.szInfoTitle, title, sizeof(nof.szInfoTitle)-1); 259 | 260 | return Shell_NotifyIcon(NIM_MODIFY, &nof); 261 | 262 | // try to rebuild if SetBalloon failed 263 | 264 | if (!ok) 265 | 266 | this->RebuildIfNecessary(TRUE); 267 | 268 | return ok; 269 | } 270 | 271 | 272 | ////////////////////////////////////////////////////////////////////////////// 273 | // // 274 | // MENU // 275 | // // 276 | // // 277 | // // 278 | // // 279 | ////////////////////////////////////////////////////////////////////////////// 280 | 281 | MENU::MENU(HWND w) 282 | : hMenu(::GetMenu(w)), 283 | hWndOwner(w), 284 | IsLoaded(FALSE) 285 | { 286 | 287 | } 288 | 289 | MENU::MENU(HMENU hmenu) 290 | : hMenu(hmenu), 291 | hWndOwner(NULL), 292 | IsLoaded(FALSE) 293 | { 294 | 295 | } 296 | 297 | MENU::MENU(int id, HINSTANCE hdll) 298 | : hMenu(::LoadMenu(((ULONG)hdll==(ULONG)-1)? hInstRes : hdll, MAKEINTRESOURCE(id))), 299 | hWndOwner(NULL), 300 | IsLoaded(TRUE) 301 | { 302 | 303 | } 304 | 305 | 306 | void 307 | MENU::EnableMenuItem(int id, int status) 308 | { 309 | ::EnableMenuItem(*this, id, 310 | MF_BYCOMMAND | (status ? MF_ENABLED : MF_GRAYED)); 311 | } 312 | 313 | void 314 | MENU::DisableMenuItem(int id) 315 | { 316 | this->EnableMenuItem(id, FALSE); 317 | } 318 | 319 | int 320 | MENU::DeleteMenuItem(int id, BOOL idispos) 321 | { 322 | int rc= ::DeleteMenu(*this, id, idispos ? MF_BYPOSITION : MF_BYCOMMAND); 323 | if (this->hWndOwner) 324 | ::DrawMenuBar(this->hWndOwner); 325 | 326 | return rc; 327 | } 328 | 329 | void 330 | MENU::CheckMenuItem(int id, int status) 331 | { 332 | ::CheckMenuItem(*this, id, 333 | MF_BYCOMMAND | (status ? MF_CHECKED : MF_UNCHECKED)); 334 | } 335 | 336 | void 337 | MENU::UncheckMenuItem(int id) 338 | { 339 | this->CheckMenuItem(id, FALSE); 340 | } 341 | 342 | BOOL 343 | MENU::IsFlags(int id, int flags) 344 | { 345 | return ((::GetMenuState(*this, id, MF_BYCOMMAND) & flags)!=0); 346 | } 347 | 348 | BOOL 349 | MENU::IsMenuItemSeparator(int pos) 350 | { 351 | MENUITEMINFO mii= {sizeof(mii), MIIM_TYPE, }; 352 | ::GetMenuItemInfo(*this, pos, TRUE, &mii); 353 | return mii.fType==MFT_SEPARATOR; 354 | } 355 | 356 | BOOL 357 | MENU::IsMenuItemEnabled(int id) 358 | { 359 | return !this->IsFlags(id, MF_DISABLED|MF_GRAYED); 360 | } 361 | 362 | BOOL 363 | MENU::IsMenuItemDisabled(int id) 364 | { 365 | return this->IsFlags(id, MF_DISABLED|MF_GRAYED); 366 | } 367 | 368 | BOOL 369 | MENU::IsMenuItemChecked(int id) 370 | { 371 | return this->IsFlags(id, MF_CHECKED); 372 | } 373 | 374 | int 375 | MENU::GetNumMenuItems() 376 | { 377 | return ::GetMenuItemCount(*this); 378 | } 379 | 380 | 381 | //-------------------------------------------------------------------- 382 | // return the sub-menu handle of a menu item at a given position 383 | //-------------------------------------------------------------------- 384 | HMENU 385 | MENU::GetSubmenuFromPos(int pos) 386 | { 387 | HMENU rc= NULL; 388 | 389 | rc= (HMENU)GetSubMenu(*this, pos); 390 | 391 | return rc; 392 | } 393 | 394 | 395 | //-------------------------------------------------------------------- 396 | // return the item pos of a menu entry (search by id) 397 | //-------------------------------------------------------------------- 398 | int 399 | MENU::GetMenuPosFromID(int id) 400 | { 401 | int rc= -1; 402 | 403 | int i, mid, numof= ::GetMenuItemCount(*this); 404 | 405 | for (i=0; ihMenu, "BLUB"); 457 | hmenuShow= ::GetSubMenu(hmenu, 0); 458 | RECT r= { 0, 0, 10, 10 }; 459 | 460 | if (hwndowner) 461 | ::SetForegroundWindow(hwndowner); 462 | 463 | 464 | ULONG flags= TPM_LEFTALIGN | TPM_LEFTBUTTON; 465 | 466 | if (synchtrack & 1) 467 | flags|= TPM_RETURNCMD; 468 | 469 | if (synchtrack & TPM_RIGHTALIGN) 470 | flags|= TPM_RIGHTALIGN; 471 | 472 | int rc= ::TrackPopupMenu(hmenuShow, flags, 473 | point.x,point.y, 0, 474 | hwndowner, &r); 475 | 476 | if (hwndowner) 477 | ::PostMessage(hwndowner, WM_NULL, 0, 0); 478 | 479 | ::RemoveMenu(hmenu, 0, MF_BYPOSITION); 480 | ::DestroyMenu(hmenu); 481 | 482 | return rc; 483 | } 484 | -------------------------------------------------------------------------------- /TPFCIcon_noballons/winstuff.h: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #ifndef WINCONTROLS_H 20 | #define WINCONTROLS_H 21 | 22 | #pragma once 23 | 24 | #include "_prec.h" 25 | 26 | 27 | #ifndef NIF_STATE // NotifyIcon V5 defines 28 | #define NIF_STATE 0x00000008 29 | #define NIF_INFO 0x00000010 30 | #define NIF_GUID 0x00000020 31 | 32 | #define NIIF_INFO 0x00000001 33 | #define NIIF_WARNING 0x00000002 34 | #define NIIF_ERROR 0x00000003 35 | #define NIIF_ICON_MASK 0x0000000F 36 | #define NIIF_NOSOUND 0x00000010 37 | #endif 38 | 39 | 40 | class TASKBARICON { 41 | 42 | private: 43 | BOOL UpAndRunning; 44 | 45 | protected: 46 | HWND Owner; 47 | int Id, IconId; 48 | char Tooltip[256]; 49 | int osVersion; //TODO: war drin? 50 | volatile BOOL InsideTooltipRebuild; //should be declared as volatile for concurrency reasons 51 | 52 | 53 | public: 54 | TASKBARICON(HWND hwndowner, int id, const char *tooltip); 55 | ~TASKBARICON(void); 56 | 57 | BOOL Construct(void); 58 | void Destroy(BOOL keep= FALSE); 59 | 60 | BOOL RebuildIfNecessary(BOOL); 61 | 62 | BOOL IsUpAndRunning(void); 63 | int SetIcon(int iconid); 64 | int SetTooltip(const char *tip); 65 | int SetBalloon(ULONG flags, const char *title, const char *text, int timeout= 2); 66 | }; 67 | 68 | 69 | class MENU { 70 | 71 | private: 72 | 73 | protected: 74 | BOOL IsLoaded; 75 | HMENU hMenu; 76 | HWND hWndOwner; 77 | 78 | public: 79 | MENU(HWND hwnd); 80 | MENU(HMENU hm); 81 | MENU(int id, HINSTANCE hdll= (HINSTANCE)(ULONG)-1); 82 | ~MENU() 83 | { if (this->IsLoaded) ::DestroyMenu(this->hMenu); this->hMenu= NULL; } 84 | 85 | operator HMENU(void) const 86 | { return (HMENU)this->hMenu; } 87 | 88 | int GetNumMenuItems(void); 89 | BOOL IsMenuItemSeparator(int pos); 90 | 91 | void EnableMenuItem(int id, int status= TRUE); 92 | void DisableMenuItem(int id); 93 | int DeleteMenuItem(int id, BOOL idispos= FALSE); 94 | BOOL InsertItem(const char *text, int id, int pos= -1); 95 | BOOL InsertMenuItem(const char *text, int id, int pos= -1) 96 | { return this->InsertItem(text, id, pos); } 97 | BOOL InsertSeparator(int pos) 98 | { return this->InsertItem(NULL, 0, pos); } 99 | void CheckMenuItem(int id, int status= TRUE); 100 | void UncheckMenuItem(int id); 101 | BOOL IsFlags(int id, int flags); 102 | BOOL IsMenuItemEnabled(int id); 103 | BOOL IsMenuItemDisabled(int id); 104 | BOOL IsMenuItemChecked(int id); 105 | 106 | HMENU GetSubmenuFromPos(int pos); 107 | int GetMenuPosFromID(int id); 108 | 109 | int Popup(HWND hwnd, POINT *ppoint= NULL, BOOL synchtrack= FALSE); 110 | }; 111 | 112 | #endif // WINCONTROLS_H -------------------------------------------------------------------------------- /fancontrol/Debug/TPFanControl.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/fancontrol/Debug/TPFanControl.ini -------------------------------------------------------------------------------- /fancontrol/Release/TPFanControl.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/fancontrol/Release/TPFanControl.ini -------------------------------------------------------------------------------- /fancontrol/SystemTraySDK.h: -------------------------------------------------------------------------------- 1 | // TrayIcon.h: interface for the CSystemTray class. 2 | // 3 | // Written by Chris Maunder (cmaunder@mail.com) 4 | // Copyright (c) 1998. 5 | // 6 | // This code may be used in compiled form in any way you desire. This 7 | // file may be redistributed unmodified by any means PROVIDING it is 8 | // not sold for profit without the authors written consent, and 9 | // providing that this notice and the authors name is included. If 10 | // the source code in this file is used in any commercial application 11 | // then acknowledgement must be made to the author of this file 12 | // (in whatever form you wish). 13 | // 14 | // This file is provided "as is" with no expressed or implied warranty. 15 | // 16 | // Expect bugs. 17 | // 18 | // Please use and enjoy. Please let me know of any bugs/mods/improvements 19 | // that you have found/implemented and I will fix/incorporate them into this 20 | // file. 21 | // 22 | ////////////////////////////////////////////////////////////////////// 23 | 24 | #if !defined(AFX_TRAYICON_H__43104212_F2C1_11D2_A9E9_8EA47C000000__INCLUDED_) 25 | #define AFX_TRAYICON_H__43104212_F2C1_11D2_A9E9_8EA47C000000__INCLUDED_ 26 | 27 | #include 28 | 29 | #if _MSC_VER > 1000 30 | #pragma once 31 | #endif // _MSC_VER > 1000 32 | 33 | // The debugger can't handle symbols more than 255 characters long. 34 | // STL often creates symbols longer than that. 35 | // When symbols are longer than 255 characters, the warning is disabled. 36 | #pragma warning(disable:4786) 37 | #include 38 | #include 39 | using namespace std; 40 | typedef vector ICONVECTOR; 41 | 42 | #ifdef NOTIFYICONDATA_V1_SIZE // If NOTIFYICONDATA_V1_SIZE, then we can use fun stuff 43 | #define SYSTEMTRAY_USEW2K 44 | #else 45 | #define NIIF_NONE 0 46 | #endif 47 | 48 | class CSystemTray 49 | { 50 | // Construction/destruction 51 | public: 52 | CSystemTray(); 53 | 54 | CSystemTray( 55 | HINSTANCE hInst, 56 | HWND hParent, 57 | UINT uCallbackMessage, 58 | LPCTSTR szTip, 59 | HICON icon, 60 | UINT uID, 61 | BOOL bhidden = FALSE, 62 | LPCTSTR szBalloonTip = NULL, 63 | LPCTSTR szBalloonTitle = NULL, 64 | DWORD dwBalloonIcon = NIIF_NONE, 65 | UINT uBalloonTimeout = 10); 66 | 67 | virtual ~CSystemTray(); 68 | 69 | // Operations 70 | public: 71 | BOOL Enabled() { return m_bEnabled; } 72 | BOOL Visible() { return !m_bHidden; } 73 | 74 | // Create the tray icon 75 | BOOL Create( 76 | HINSTANCE hInst, 77 | HWND hParent, 78 | UINT uCallbackMessage, 79 | LPCTSTR szTip, 80 | HICON icon, 81 | UINT uID, 82 | BOOL bHidden = FALSE, 83 | LPCTSTR szBalloonTip = NULL, 84 | LPCTSTR szBalloonTitle = NULL, 85 | DWORD dwBalloonIcon = NIIF_NONE, 86 | UINT uBalloonTimeout = 10); 87 | 88 | // Change or retrieve the Tooltip text 89 | BOOL SetTooltipText(LPCTSTR pszTooltipText); 90 | BOOL SetTooltipText(UINT nID); 91 | LPTSTR GetTooltipText() const; 92 | 93 | // Change or retrieve the icon displayed 94 | BOOL SetIcon(HICON hIcon); 95 | BOOL SetIcon(LPCTSTR lpszIconName); 96 | BOOL SetIcon(UINT nIDResource); 97 | BOOL SetStandardIcon(LPCTSTR lpIconName); 98 | BOOL SetStandardIcon(UINT nIDResource); 99 | HICON GetIcon() const; 100 | BOOL ChangeIconTip(UINT nIconID, LPCTSTR strTip); 101 | 102 | void SetFocus(); 103 | BOOL HideIcon(); 104 | BOOL ShowIcon(); 105 | BOOL AddIcon(); 106 | BOOL RemoveIcon(); 107 | BOOL MoveToRight(); 108 | 109 | BOOL ShowBalloon(LPCTSTR szText, LPCTSTR szTitle = NULL, 110 | DWORD dwIcon = NIIF_NONE, UINT uTimeout = 10); 111 | 112 | // For icon animation 113 | BOOL SetIconList(UINT uFirstIconID, UINT uLastIconID); 114 | BOOL SetIconList(HICON* pHIconList, UINT nNumIcons); 115 | BOOL Animate(UINT nDelayMilliSeconds, int nNumSeconds = -1); 116 | BOOL StepAnimation(); 117 | BOOL StopAnimation(); 118 | 119 | // Change menu default item 120 | void GetMenuDefaultItem(UINT& uItem, BOOL& bByPos); 121 | BOOL SetMenuDefaultItem(UINT uItem, BOOL bByPos); 122 | 123 | // Change or retrieve the window to send icon notification messages to 124 | BOOL SetNotificationWnd(HWND hNotifyWnd); 125 | HWND GetNotificationWnd() const; 126 | 127 | // Change or retrieve the window to send menu commands to 128 | BOOL SetTargetWnd(HWND hTargetWnd); 129 | HWND GetTargetWnd() const; 130 | 131 | // Change or retrieve notification messages sent to the window 132 | BOOL SetCallbackMessage(UINT uCallbackMessage); 133 | UINT GetCallbackMessage() const; 134 | 135 | HWND GetSafeHwnd() const { return (this)? m_hWnd : NULL; } 136 | UINT_PTR GetTimerID() const { return m_nTimerID; } 137 | 138 | // Static functions 139 | public: 140 | static void MinimiseToTray(HWND hWnd); 141 | static void MaximiseFromTray(HWND hWnd); 142 | 143 | public: 144 | // Default handler for tray notification message 145 | virtual LRESULT OnTrayNotification(WPARAM uID, LPARAM lEvent); 146 | 147 | // Overrides 148 | // ClassWizard generated virtual function overrides 149 | //{{AFX_VIRTUAL(CSystemTray) 150 | //}}AFX_VIRTUAL 151 | 152 | // Static callback functions and data 153 | public: 154 | static LRESULT PASCAL WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 155 | static CSystemTray* m_pThis; 156 | void InstallIconPending(); 157 | 158 | // Implementation 159 | protected: 160 | void Initialise(); 161 | ATOM RegisterClass(HINSTANCE hInstance); 162 | 163 | virtual void CustomizeMenu(HMENU) {} 164 | 165 | // Implementation 166 | protected: 167 | NOTIFYICONDATA m_tnd; 168 | HINSTANCE m_hInstance; 169 | HWND m_hWnd; 170 | HWND m_hTargetWnd; // Window that menu commands are sent 171 | 172 | BOOL m_bEnabled; // does O/S support tray icon? 173 | BOOL m_bHidden; // Has the icon been hidden? 174 | BOOL m_bRemoved; // Has the icon been removed? 175 | BOOL m_bShowIconPending; // Show the icon once that taskbar has been created 176 | BOOL m_bWin2K; // Use new W2K features? 177 | 178 | ICONVECTOR m_IconList; 179 | UINT_PTR m_uIDTimer; 180 | unsigned int m_nCurrentIcon; 181 | time_t m_StartTime; 182 | int m_nAnimationPeriod; 183 | HICON m_hSavedIcon; 184 | UINT m_DefaultMenuItemID; 185 | BOOL m_DefaultMenuItemByPos; 186 | UINT m_uCreationFlags; 187 | 188 | // Static data 189 | protected: 190 | static BOOL RemoveTaskbarIcon(HWND hWnd); 191 | 192 | static const UINT m_nTimerID; 193 | static UINT m_nMaxTooltipLength; 194 | static const UINT m_nTaskbarCreatedMsg; 195 | static HWND m_hWndInvisible; 196 | 197 | static BOOL GetW2K(); 198 | #ifndef _WIN32_WCE 199 | static void GetTrayWndRect(LPRECT lprect); 200 | static BOOL GetDoWndAnimation(); 201 | #endif 202 | 203 | // message map functions 204 | public: 205 | LRESULT OnTimer(UINT nIDEvent); 206 | LRESULT OnTaskbarCreated(WPARAM wParam, LPARAM lParam); 207 | #ifndef _WIN32_WCE 208 | LRESULT OnSettingChange(UINT uFlags, LPCTSTR lpszSection); 209 | #endif 210 | }; 211 | 212 | 213 | #endif // !defined(AFX_TRAYICON_H__43104212_F2C1_11D2_A9E9_8EA47C000000__INCLUDED_) 214 | -------------------------------------------------------------------------------- /fancontrol/TPFanControl.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/fancontrol/TPFanControl.ini -------------------------------------------------------------------------------- /fancontrol/TVicPort.h: -------------------------------------------------------------------------------- 1 | // ======================================================================== 2 | // ================= TVicPort DLL interface ==================== 3 | // ========== Version 4.0 =========== 4 | // ========== Copyright (c) 1997-2005, EnTech Taiwan =========== 5 | // ======================================================================== 6 | // ========== http://www.entechtaiwan.com =========== 7 | // ========== mailto: tools@entechtaiwan.com =========== 8 | // ======================================================================== 9 | 10 | 11 | #ifndef __TVicPort_H 12 | #define __TVicPort_H 13 | 14 | #define VICFN __stdcall 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | #pragma pack(1) 21 | 22 | typedef struct _HDDInfo { 23 | ULONG BufferSize; 24 | ULONG DoubleTransfer; 25 | ULONG ControllerType; 26 | ULONG ECCMode; 27 | ULONG SectorsPerInterrupt; 28 | ULONG Cylinders; 29 | ULONG Heads; 30 | ULONG SectorsPerTrack; 31 | char Model[41]; 32 | char SerialNumber[21]; 33 | char Revision[9]; 34 | } HDDInfo, *pHDDInfo; 35 | 36 | 37 | 38 | void VICFN CloseTVicPort(); 39 | BOOL VICFN OpenTVicPort(); 40 | BOOL VICFN IsDriverOpened(); 41 | 42 | BOOL VICFN TestHardAccess(); 43 | void VICFN SetHardAccess(BOOL bNewValue); 44 | 45 | UCHAR VICFN ReadPort (USHORT PortAddr); 46 | void VICFN WritePort (USHORT PortAddr, UCHAR nNewValue); 47 | USHORT VICFN ReadPortW (USHORT PortAddr); 48 | void VICFN WritePortW(USHORT PortAddr, USHORT nNewValue); 49 | ULONG VICFN ReadPortL (USHORT PortAddr); 50 | void VICFN WritePortL(USHORT PortAddr, ULONG nNewValue); 51 | 52 | void VICFN ReadPortFIFO (USHORT PortAddr, ULONG NumPorts, UCHAR * Buffer); 53 | void VICFN WritePortFIFO (USHORT PortAddr, ULONG NumPorts, UCHAR * Buffer); 54 | void VICFN ReadPortWFIFO (USHORT PortAddr, ULONG NumPorts, USHORT * Buffer); 55 | void VICFN WritePortWFIFO(USHORT PortAddr, ULONG NumPorts, USHORT * Buffer); 56 | void VICFN ReadPortLFIFO (USHORT PortAddr, ULONG NumPorts, ULONG * Buffer); 57 | void VICFN WritePortLFIFO(USHORT PortAddr, ULONG NumPorts, ULONG * Buffer); 58 | 59 | USHORT VICFN GetLPTNumber(); 60 | void VICFN SetLPTNumber(USHORT nNewValue); 61 | USHORT VICFN GetLPTNumPorts(); 62 | USHORT VICFN GetLPTBasePort(); 63 | UCHAR VICFN AddNewLPT(USHORT PortBaseAddress); 64 | 65 | BOOL VICFN GetPin(USHORT nPin); 66 | void VICFN SetPin(USHORT nPin, BOOL bNewValue); 67 | 68 | BOOL VICFN GetLPTAckwl(); 69 | BOOL VICFN GetLPTBusy(); 70 | BOOL VICFN GetLPTPaperEnd(); 71 | BOOL VICFN GetLPTSlct(); 72 | BOOL VICFN GetLPTError(); 73 | 74 | void VICFN LPTInit(); 75 | void VICFN LPTSlctIn(); 76 | void VICFN LPTStrobe(); 77 | void VICFN LPTAutofd(BOOL Flag); 78 | 79 | void VICFN GetHDDInfo (UCHAR IdeNumber, UCHAR Master, pHDDInfo Info); 80 | 81 | ULONG VICFN MapPhysToLinear(ULONG PhAddr, ULONG PhSize); 82 | void VICFN UnmapMemory (ULONG PhAddr, ULONG PhSize); 83 | 84 | UCHAR VICFN GetMem (ULONG MappedAddr, ULONG Offset); 85 | void VICFN SetMem (ULONG MappedAddr, ULONG Offset, UCHAR nNewValue); 86 | USHORT VICFN GetMemW(ULONG MappedAddr, ULONG Offset); 87 | void VICFN SetMemW(ULONG MappedAddr, ULONG Offset, USHORT nNewValue); 88 | ULONG VICFN GetMemL(ULONG MappedAddr, ULONG Offset); 89 | void VICFN SetMemL(ULONG MappedAddr, ULONG Offset, ULONG nNewValue); 90 | 91 | void VICFN SetLPTReadMode(); 92 | void VICFN SetLPTWriteMode(); 93 | 94 | void VICFN LaunchWeb(); 95 | void VICFN LaunchMail(); 96 | 97 | int VICFN EvaluationDaysLeft(); 98 | 99 | #pragma pack() 100 | 101 | #ifdef __cplusplus 102 | } // extern "C" 103 | #endif 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /fancontrol/TVicPort.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/fancontrol/TVicPort.lib -------------------------------------------------------------------------------- /fancontrol/TaskbarTextIcon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "systemtraysdk.h" 4 | #include "DynamicIcon.h" 5 | #include 6 | 7 | 8 | class CTaskbarTextIcon 9 | { 10 | private: 11 | 12 | CDynamicIcon *m_pDicon; 13 | int iFarbeIconC; 14 | int iFontIconC; 15 | LPCTSTR aTooltipC; 16 | 17 | void _createdicon(const int iFarbeIconC, LPCTSTR aTooltipC, const int iFontIconC) 18 | { 19 | if(m_pSystray) m_pSystray->SetTooltipText(aTooltipC); 20 | CDynamicIcon* pDiconTemp = new CDynamicIcon(m_line1, m_line2, iFarbeIconC, iFontIconC); 21 | if(m_pSystray) m_pSystray->SetIcon(pDiconTemp->GetHIcon()); 22 | if(m_pDicon)delete m_pDicon; 23 | m_pDicon = pDiconTemp; 24 | }; 25 | 26 | void _ballondicon(LPCTSTR szText,LPCTSTR szTitle,DWORD dwIcon,UINT uTimeout) 27 | { 28 | if(m_pDicon) m_pSystray->ShowBalloon(szText, szTitle, dwIcon, uTimeout); 29 | }; 30 | 31 | void _createsystray 32 | ( 33 | HINSTANCE hInst, 34 | HWND hWnd, 35 | UINT uCallbackMessage, 36 | UINT uID, 37 | LPCTSTR aTooltipC 38 | ) 39 | { 40 | if(m_pSystray) delete m_pSystray; 41 | m_pSystray = new CSystemTray(); 42 | m_pSystray->Create 43 | ( 44 | hInst, 45 | hWnd, 46 | uCallbackMessage, 47 | aTooltipC, // tooltip 48 | m_pDicon->GetHIcon(), 49 | 0 50 | ); 51 | }; 52 | 53 | 54 | protected: 55 | 56 | static const int LINESLEN = 4; 57 | CSystemTray *m_pSystray; 58 | char m_line1[LINESLEN],m_line2[LINESLEN]; 59 | //TODO: implement set/get/use 60 | COLORREF m_TextColor, m_BgColor; 61 | bool m_BgTransparent; 62 | 63 | void _setlines(const char* line1,const char* line2) 64 | { 65 | strncpy_s(m_line1,sizeof(m_line1),line1,3); 66 | strncpy_s(m_line2,sizeof(m_line2),line2,3); 67 | m_line1[LINESLEN-1] = 0; 68 | m_line2[LINESLEN-1] = 0; 69 | }; 70 | 71 | public: 72 | 73 | CTaskbarTextIcon 74 | ( 75 | HINSTANCE hInst, 76 | HWND hWnd, 77 | UINT uCallbackMessage, 78 | UINT uID, 79 | const char * line1 = 0, //can be 3 chars 80 | const char * line2 = 0, //can be 3 chars 81 | int iFarbeIconC = 0, 82 | int iFontIconC = 11, 83 | LPCTSTR aTooltipC = _T("") 84 | ) 85 | : 86 | m_pSystray(NULL), 87 | m_pDicon(NULL), 88 | m_TextColor(RGB(0,0,0)), 89 | m_BgColor(RGB(255,0,0)), 90 | m_BgTransparent(false) 91 | { 92 | _setlines(line1,line2); 93 | _createdicon(iFarbeIconC, aTooltipC, iFontIconC); 94 | _createsystray(hInst, hWnd, uCallbackMessage, uID, aTooltipC); 95 | }; 96 | 97 | ~CTaskbarTextIcon(void) 98 | { 99 | if(m_pSystray)delete m_pSystray; 100 | if(m_pDicon)delete m_pDicon; 101 | }; 102 | 103 | void ChangeText 104 | ( 105 | const char * line1, 106 | const char * line2 = 0, 107 | const int iFarbeIconC = 0, 108 | const int iFontIconC = 9, 109 | LPCTSTR aTooltipC =_T("/0") 110 | ) 111 | { 112 | _setlines(line1,line2); 113 | _createdicon(iFarbeIconC,aTooltipC,iFontIconC); 114 | } 115 | 116 | void DiShowballon 117 | ( 118 | LPCTSTR szText , 119 | LPCTSTR szTitle , 120 | DWORD dwIcon , 121 | UINT uTimeout 122 | ) 123 | { 124 | _ballondicon( szText, szTitle, dwIcon, uTimeout); 125 | } 126 | 127 | 128 | 129 | }; 130 | -------------------------------------------------------------------------------- /fancontrol/_prec.cpp: -------------------------------------------------------------------------------- 1 | //this file generates the pch-file 2 | #include "_prec.h" -------------------------------------------------------------------------------- /fancontrol/_prec.h: -------------------------------------------------------------------------------- 1 | //systemheaders in one file for using precompiled headers. 2 | 3 | //be compatible downto win2k 4 | #define _WIN32_WINNT 0x0500 5 | //only most neccessary things from windows 6 | #define WIN32_LEAN_AND_MEAN 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | -------------------------------------------------------------------------------- /fancontrol/approot.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/fancontrol/approot.cpp -------------------------------------------------------------------------------- /fancontrol/approot.h: -------------------------------------------------------------------------------- 1 | #include "_prec.h" 2 | 3 | //begin named pipe TPFanControl01 4 | #define g_szPipeName "\\\\.\\Pipe\\TPFanControl01" //Name given to the pipe 5 | HANDLE hPipe1; 6 | HANDLE hPipe2; 7 | HANDLE hPipe3; 8 | HANDLE hPipe4; 9 | //Pipe name format - \\.\pipe\pipename 10 | 11 | HINSTANCE hInstApp, hInstRes; 12 | 13 | LPSTR g_ServiceName = "TPFanControl"; 14 | SERVICE_STATUS g_SvcStatus = {0}; 15 | SERVICE_STATUS_HANDLE g_SvcHandle = NULL; 16 | HWND g_dialogWnd = NULL; 17 | HANDLE g_workerThread = NULL; 18 | 19 | void ShowError(DWORD ec, const char *description); 20 | void ShowMessage(const char *title, const char *description); 21 | void ShowHelp(); 22 | DWORD InstallService(bool quiet); 23 | DWORD UninstallService(bool quiet); 24 | VOID WINAPI Handler(DWORD fdwControl); 25 | VOID WINAPI ServiceMain(DWORD aArgc, LPTSTR* aArgv); 26 | void StartWorkerThread(); 27 | void StopWorkerThread(); 28 | void WorkerThread(void *dummy); 29 | 30 | void debug(const char *msg); -------------------------------------------------------------------------------- /fancontrol/dynamicicon.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/fancontrol/dynamicicon.cpp -------------------------------------------------------------------------------- /fancontrol/dynamicicon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class CDynamicIcon { 7 | public: 8 | 9 | CDynamicIcon(const char line1[3],const char line2[3],const int iFarbeIconA, const int iFontIconA); 10 | ~CDynamicIcon(); 11 | 12 | HICON GetHIcon(); 13 | private: 14 | 15 | HDC memDC1_; 16 | HDC memDC2_; 17 | HBITMAP oldBmp_1; 18 | HBITMAP oldBmp_2; 19 | HBITMAP iconBmp_; 20 | HBITMAP iconMaskBmp_; 21 | HBRUSH hOldBrush; 22 | HRGN rgn; 23 | HICON icon_; 24 | static const int iconWidth_= 16; 25 | static const int iconHeight_= 16; 26 | 27 | private: 28 | __inline static HFONT CreateFont(const HDC hDC); 29 | //default und copy verbergen 30 | __inline CDynamicIcon(){}; 31 | __inline CDynamicIcon(const CDynamicIcon&){}; 32 | }; 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /fancontrol/fancontrol.h: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #ifndef FANCONTROL_H 20 | #define FANCONTROL_H 21 | 22 | #include "_prec.h" 23 | #pragma once 24 | 25 | 26 | #include "winstuff.h" 27 | #include "TaskbarTextIcon.h" 28 | 29 | 30 | 31 | #define FANCONTROLVERSION "0.63 multiHotKey" 32 | 33 | #define WM__DISMISSDLG WM_USER+5 34 | #define WM__GETDATA WM_USER+6 35 | #define WM__NEWDATA WM_USER+7 36 | #define WM__TASKBAR WM_USER+8 37 | 38 | #define setzero(adr, size) memset((void*)(adr), (char)0x00, (size)) 39 | #define ARRAYMAX(tab) (sizeof(tab)/sizeof((tab)[0])) 40 | #define NULLSTRUCT { 0, } 41 | 42 | //begin named pipe TPFanControl01 43 | #define g_szPipeName "\\\\.\\Pipe\\TPFanControl01" //Name given to the pipe 44 | //Pipe name format - \\.\pipe\pipename 45 | 46 | #define BUFFER_SIZE 1024 //1k 47 | #define ACK_MESG_RECV "Message received successfully" 48 | //end named pipe TPFanControl01 49 | 50 | class FANCONTROL 51 | { 52 | protected: 53 | HINSTANCE hinstapp; 54 | HINSTANCE m_hinstapp; 55 | HWND hwndDialog; 56 | 57 | UINT_PTR m_fanTimer; 58 | UINT_PTR m_titleTimer; 59 | UINT_PTR m_iconTimer; 60 | UINT_PTR m_renewTimer; 61 | 62 | struct FCSTATE { 63 | 64 | char FanCtrl, 65 | FanSpeedLo, 66 | FanSpeedHi; 67 | 68 | char Sensors[12]; 69 | int SensorAddr[12]; 70 | const char *SensorName[12]; 71 | 72 | 73 | } State; 74 | 75 | struct SMARTENTRY { 76 | int temp, fan; 77 | } SmartLevels[32]; 78 | 79 | struct SMARTENTRY1 { 80 | int temp1, fan1; 81 | } SmartLevels1[32]; 82 | 83 | struct SMARTENTRY2 { 84 | int temp2, fan2; 85 | } SmartLevels2[32]; 86 | 87 | struct FSMARTENTRY { //fahrenheit values 88 | int ftemp, ffan; 89 | } FSmartLevels[32]; 90 | 91 | 92 | int IconLevels[3]; // temp levels for coloring the icon 93 | int FIconLevels[3]; // fahrenheit temp levels for coloring the icon 94 | int CurrentIcon; 95 | int IndSmartLevel; 96 | int SensorOffset[16]; 97 | int FSensorOffset[16]; 98 | int iFarbeIconB; 99 | int iFontIconB; 100 | int icontemp; 101 | int Cycle; 102 | int IconCycle; 103 | int ReIcCycle; 104 | int NoExtSensor; 105 | int FanSpeedLowByte; 106 | int ActiveMode, 107 | UseTWR, 108 | ManFanSpeed, 109 | FinalSeen; 110 | int CurrentMode, fanctrl2, 111 | PreviousMode; 112 | int TaskbarNew; 113 | int MaxTemp; 114 | int iMaxTemp; 115 | int fanspeed, lastfanspeed, showfanspeed; 116 | int FanBeepFreq, FanBeepDura; 117 | int MinimizeToSysTray, 118 | Lev64Norm, 119 | IconColorFan, 120 | Fahrenheit, 121 | MinimizeOnClose, 122 | StartMinimized, 123 | NoWaitMessage, 124 | Runs_as_service; 125 | int ReadErrorCount; 126 | int MaxReadErrors; 127 | int SecWinUptime; 128 | int SlimDialog; 129 | int NoBallons, 130 | HK_BIOS_Method, 131 | HK_Manual_Method, 132 | HK_Smart_Method, 133 | HK_SM1_Method, 134 | HK_SM2_Method, 135 | HK_TG_BS_Method, 136 | HK_TG_BM_Method, 137 | HK_TG_MS_Method, 138 | HK_TG_12_Method, 139 | HK_BIOS, 140 | HK_Manual, 141 | HK_Smart, 142 | HK_SM1, 143 | HK_SM2, 144 | HK_TG_BS, 145 | HK_TG_BM, 146 | HK_TG_MS, 147 | HK_TG_12; 148 | int BluetoothEDR; 149 | int ManModeExit; 150 | int ManModeExit2; 151 | int ShowBiasedTemps; 152 | int SecStartDelay; 153 | char gSensorNames[17][4]; 154 | int Log2File; 155 | int Log2csv; 156 | int StayOnTop; 157 | int ShowAll; 158 | int ShowTempIcon; 159 | char IgnoreSensors[256]; 160 | char MenuLabelSM1[32]; 161 | char MenuLabelSM2[32]; 162 | HANDLE hThread; 163 | HANDLE hPipe0; 164 | HANDLE hPipe1; 165 | HANDLE hPipe2; 166 | HANDLE hPipe3; 167 | HANDLE hPipe4; 168 | HANDLE hPipe5; 169 | HANDLE hPipe6; 170 | HANDLE hPipe7; 171 | HANDLE hLock; 172 | HANDLE hLockS; 173 | BOOL Closing; 174 | MUTEXSEM EcAccess; 175 | bool m_needClose; 176 | 177 | char Title[128]; 178 | char Title2[128]; 179 | char Title3[128]; 180 | char Title4[128]; 181 | char Title5[128]; 182 | char LastTitle[128]; 183 | char LastTooltip[128]; 184 | char CurrentStatus[256]; 185 | char CurrentStatuscsv[256]; 186 | 187 | // dialog.cpp 188 | int CurrentModeFromDialog(); 189 | int ShowAllFromDialog(); 190 | void ModeToDialog(int mode); 191 | void ShowAllToDialog(int mode); 192 | ULONG DlgProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2); 193 | static ULONG CALLBACK BaseDlgProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2); 194 | 195 | //The default app-icon with changing colors 196 | TASKBARICON *pTaskbarIcon; 197 | // 198 | CTaskbarTextIcon **ppTbTextIcon; 199 | MUTEXSEM *pTextIconMutex; 200 | 201 | 202 | 203 | static int _stdcall FANCONTROL_Thread(ULONG parm) \ 204 | { return ((FANCONTROL *)parm)->WorkThread(); } 205 | 206 | int WorkThread(); 207 | 208 | 209 | // fancontrol.cpp 210 | int ReadEcStatus(FCSTATE *pfcstate); 211 | int ReadEcRaw(FCSTATE *pfcstate); 212 | int HandleData(); 213 | int SmartControl(); 214 | int SetFan(const char *source, int level, BOOL final= false); 215 | int SetHdw(const char *source, int hdwctrl, int HdwOffset, int AnyWayBit); 216 | 217 | 218 | // misc.cpp 219 | int ReadConfig(const char *filename); 220 | void Trace(const char *text); 221 | void Tracecsv(const char *textcsv); 222 | void Tracecsvod(const char *textcsv); 223 | BOOL IsMinimized(void); 224 | void CurrentDateTimeLocalized(char *result, size_t sizeof_result); 225 | void CurrentTimeLocalized(char *result, size_t sizeof_result); 226 | HANDLE CreateThread(int (_stdcall *fnct)(ULONG), ULONG p); 227 | 228 | 229 | // portio.cpp 230 | int ReadByteFromECint(int offset, char *pdata); 231 | int ReadByteFromEC(int offset, char *pdata); 232 | int WriteByteToEC(int offset, char data); 233 | 234 | public: 235 | 236 | FANCONTROL(HINSTANCE hinstapp); 237 | ~FANCONTROL(); 238 | 239 | void Test(void); 240 | 241 | int ProcessDialog(); 242 | 243 | HWND GetDialogWnd() { return hwndDialog; } 244 | HANDLE GetWorkThread() { return hThread; } 245 | // The texticons will be shown depending on variables 246 | void ProcessTextIcons(void); 247 | void RemoveTextIcons(void); 248 | }; 249 | 250 | #endif // FANCONTROL_H -------------------------------------------------------------------------------- /fancontrol/fancontrol.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual C++ Express 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fancontrol", "fancontrol.vcproj", "{45F7E4D3-AF42-4594-80E1-099D3FCE3F37}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {45F7E4D3-AF42-4594-80E1-099D3FCE3F37}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {45F7E4D3-AF42-4594-80E1-099D3FCE3F37}.Debug|Win32.Build.0 = Debug|Win32 14 | {45F7E4D3-AF42-4594-80E1-099D3FCE3F37}.Release|Win32.ActiveCfg = Release|Win32 15 | {45F7E4D3-AF42-4594-80E1-099D3FCE3F37}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /fancontrol/fancontrol.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 29 | 32 | 35 | 38 | 41 | 50 | 68 | 71 | 76 | 79 | 97 | 100 | 103 | 106 | 109 | 112 | 115 | 118 | 121 | 122 | 132 | 135 | 138 | 141 | 144 | 153 | 169 | 172 | 177 | 180 | 191 | 194 | 197 | 200 | 203 | 206 | 209 | 212 | 215 | 216 | 217 | 218 | 219 | 220 | 224 | 227 | 230 | 235 | 236 | 239 | 243 | 244 | 245 | 248 | 249 | 252 | 253 | 256 | 259 | 263 | 264 | 267 | 271 | 272 | 273 | 276 | 279 | 283 | 284 | 287 | 291 | 292 | 293 | 296 | 299 | 303 | 304 | 307 | 311 | 312 | 313 | 316 | 319 | 323 | 324 | 327 | 331 | 332 | 333 | 336 | 337 | 340 | 341 | 342 | 346 | 349 | 350 | 353 | 354 | 357 | 358 | 361 | 362 | 365 | 366 | 369 | 370 | 373 | 374 | 377 | 378 | 381 | 382 | 385 | 386 | 387 | 391 | 394 | 395 | 398 | 399 | 402 | 403 | 406 | 407 | 410 | 411 | 414 | 415 | 418 | 419 | 422 | 423 | 426 | 427 | 430 | 431 | 434 | 435 | 438 | 439 | 440 | 443 | 444 | 447 | 448 | 451 | 452 | 453 | 454 | 455 | 456 | -------------------------------------------------------------------------------- /fancontrol/fanstuff.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/fancontrol/fanstuff.cpp -------------------------------------------------------------------------------- /fancontrol/misc.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/fancontrol/misc.cpp -------------------------------------------------------------------------------- /fancontrol/portio.cpp: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #include "_prec.h" 20 | #include "fancontrol.h" 21 | #include "TVicPort.h" 22 | 23 | 24 | // Registers of the embedded controller 25 | #define EC_DATAPORT 0x1600 // EC data io-port 0x62 26 | #define EC_CTRLPORT 0x1604 // EC control io-port 0x66 27 | 28 | 29 | // Embedded controller status register bits 30 | #define EC_STAT_OBF 0x01 // Output buffer full 31 | #define EC_STAT_IBF 0x02 // Input buffer full 32 | #define EC_STAT_CMD 0x08 // Last write was a command write (0=data) 33 | 34 | 35 | // Embedded controller commands 36 | // (write to EC_CTRLPORT to initiate read/write operation) 37 | #define EC_CTRLPORT_READ (char)0x80 38 | #define EC_CTRLPORT_WRITE (char)0x81 39 | #define EC_CTRLPORT_QUERY (char)0x84 40 | 41 | 42 | int verbosity= 0; // verbosity for the logbuf (0= nothing) 43 | char lasterrorstring[256]= "", 44 | logbuf[8192]= ""; 45 | 46 | 47 | //------------------------------------------------------------------------- 48 | // read a byte from the embedded controller (EC) via port io 49 | //------------------------------------------------------------------------- 50 | int FANCONTROL::ReadByteFromEC(int offset, char *pdata) 51 | { 52 | char data= -1; 53 | char data2= -1; 54 | int iOK = false; 55 | int iTimeout = 100; 56 | int iTimeoutBuf = 1000; 57 | int iTime= 0; 58 | int iTick= 10; 59 | 60 | for (iTime = 0; iTime < iTimeoutBuf; iTime+= iTick) { // wait for full buffers to clear 61 | data = (char)ReadPort(EC_CTRLPORT) & 0xff; // or timeout iTimeoutBuf = 1000 62 | if ( !(data & (EC_STAT_IBF | EC_STAT_OBF)) ) break; 63 | ::Sleep(iTick);} 64 | 65 | if (data & EC_STAT_OBF) data2 = (char)ReadPort(EC_DATAPORT); //clear OBF if full 66 | 67 | WritePort(EC_CTRLPORT, EC_CTRLPORT_READ); // tell 'em we want to "READ" 68 | 69 | for (iTime = 0; iTime < iTimeout; iTime += iTick) { // wait for IBF and OBF to clear 70 | data = (char)ReadPort(EC_CTRLPORT) & 0xff; 71 | if ( !(data & (EC_STAT_IBF | EC_STAT_OBF)) ) { 72 | iOK= true; 73 | break;} 74 | ::Sleep(iTick);} // try again after a moment 75 | 76 | if (!iOK) return 0; 77 | iOK = false; 78 | 79 | WritePort(EC_DATAPORT, offset); // tell 'em where we want to read from 80 | 81 | if ( !(data & EC_STAT_OBF) ) { 82 | for (iTime= 0; iTime0) sprintf(logbuf+strlen(logbuf), "readec: offset= %x, data= %02x\n", offset, *pdata); 93 | 94 | return 1; 95 | } 96 | 97 | 98 | //------------------------------------------------------------------------- 99 | // write a byte to the embedded controller (EC) via port io 100 | //------------------------------------------------------------------------- 101 | int FANCONTROL::WriteByteToEC(int offset, char NewData) 102 | { 103 | char data= -1; 104 | char data2= -1; 105 | int iOK = false; 106 | int iTimeout = 100; 107 | int iTimeoutBuf = 1000; 108 | int iTime= 0; 109 | int iTick= 10; 110 | 111 | for (iTime = 0; iTime < iTimeoutBuf; iTime+= iTick) { // wait for full buffers to clear 112 | data = (char)ReadPort(EC_CTRLPORT) & 0xff; // or timeout iTimeoutBuf = 1000 113 | if ( !(data & (EC_STAT_IBF | EC_STAT_OBF)) ) break; 114 | ::Sleep(iTick);} 115 | 116 | if (data & EC_STAT_OBF) data2 = (char)ReadPort(EC_DATAPORT); //clear OBF if full 117 | 118 | for (iTime= 0; iTime 2 | 3 | 4 | Thinkpad Fan Control 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /fancontrol/res/yellow.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/fancontrol/res/yellow.bmp -------------------------------------------------------------------------------- /fancontrol/res/yellow.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThinkPad-Forum/TPFanControl/e90605a279c63b405c278c5007b84a774dd21aa7/fancontrol/res/yellow.ico -------------------------------------------------------------------------------- /fancontrol/tools.h: -------------------------------------------------------------------------------- 1 | #include "_prec.h" 2 | 3 | /// sets last byte to zero first 4 | inline size_t strlen_s(const char * str,const size_t SourceLen) { 5 | (const_cast(str))[SourceLen-1] = 0; 6 | return strnlen(str,SourceLen); 7 | } -------------------------------------------------------------------------------- /fancontrol/winstuff.cpp: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #include "_prec.h" 20 | 21 | #include "fancontrol.h" 22 | #include "winstuff.h" 23 | #include "DynamicIcon.h" 24 | 25 | extern HINSTANCE hInstApp, hInstRes; 26 | 27 | ////////////////////////////////////////////////////////////////////////////// 28 | // // 29 | // MUTEX SEMAPHORES // 30 | // // 31 | // // 32 | // // 33 | // // 34 | ////////////////////////////////////////////////////////////////////////////// 35 | 36 | //------------------------------------------------------------------------- 37 | // Create/Delete/Lock/Unlock mutually exclusive semaphores 38 | //------------------------------------------------------------------------- 39 | 40 | MUTEXSEM::MUTEXSEM(int state, const char *name) 41 | { 42 | this->hmux= ::CreateMutex(NULL, (state ? TRUE : FALSE), name); 43 | } 44 | 45 | MUTEXSEM::~MUTEXSEM() 46 | { 47 | int ok= FALSE; 48 | 49 | HANDLE h= this->hmux; 50 | this->hmux= NULL; 51 | ok= ::CloseHandle(h); 52 | } 53 | 54 | int 55 | MUTEXSEM::Lock(int millies) 56 | { 57 | int ok= FALSE; 58 | 59 | int rc= this->hmux ? ::WaitForSingleObject(this->hmux, millies) : WAIT_FAILED; 60 | ok= rc==WAIT_OBJECT_0; // returns posted TRUE/FALSE 61 | 62 | return ok; 63 | } 64 | 65 | void 66 | MUTEXSEM::Unlock() 67 | { 68 | int ok= ::ReleaseMutex(this->hmux); 69 | } 70 | 71 | 72 | 73 | ////////////////////////////////////////////////////////////////////////////// 74 | // // 75 | // TASKBARICON // 76 | // // 77 | // // 78 | // // 79 | // // 80 | ////////////////////////////////////////////////////////////////////////////// 81 | 82 | struct NOTIFYICONDATAV5 { 83 | NOTIFYICONDATA nof; 84 | TCHAR szTipExtra[64]; //Version 5.0 85 | DWORD dwState; //Version 5.0 86 | DWORD dwStateMask; //Version 5.0 87 | TCHAR szInfo[256]; //Version 5.0 88 | union { 89 | UINT uTimeout; //Version 5.0 90 | UINT uVersion; //Version 5.0 91 | } DUMMYUNIONNAME; 92 | TCHAR szInfoTitle[64]; //Version 5.0 93 | DWORD dwInfoFlags; //Version 5.0 94 | }; 95 | 96 | struct NOTIFYICONDATAV6 { 97 | DWORD cbSize; 98 | HWND hWnd; 99 | UINT uID; 100 | UINT uFlags; 101 | UINT uCallbackMessage; 102 | HICON hIcon; 103 | TCHAR szTip[64]; 104 | DWORD dwState; 105 | DWORD dwStateMask; 106 | TCHAR szInfo[256]; 107 | union { 108 | UINT uTimeout; 109 | UINT uVersion; 110 | }; 111 | TCHAR szInfoTitle[64]; 112 | DWORD dwInfoFlags; 113 | GUID guidItem; 114 | HICON hBalloonIcon; 115 | }; 116 | 117 | struct OSVERSIONINFOV4 { 118 | DWORD dwOSVersionInfoSize; 119 | DWORD dwMajorVersion; 120 | DWORD dwMinorVersion; 121 | DWORD dwBuildNumber; 122 | DWORD dwPlatformId; 123 | TCHAR szCSDVersion[128]; 124 | }; 125 | 126 | //------------------------------------------------------------------------- 127 | // Represent a window in the taskbar 128 | //------------------------------------------------------------------------- 129 | TASKBARICON::TASKBARICON(HWND hwndowner, int idicon, const char *tooltip) 130 | : Owner(hwndowner), 131 | Id(idicon), 132 | IconId(idicon), 133 | osVersion(0) 134 | { 135 | // ampersand must be escaped 136 | strcpy_s(this->Tooltip,sizeof(Tooltip), tooltip ? tooltip : ""); 137 | 138 | this->Construct(); 139 | } 140 | 141 | TASKBARICON::~TASKBARICON() 142 | { 143 | this->Destroy(); 144 | } 145 | 146 | 147 | BOOL 148 | TASKBARICON::Construct() 149 | { 150 | NOTIFYICONDATAV5 nofv5= NULLSTRUCT; 151 | NOTIFYICONDATA &nof= nofv5.nof; 152 | 153 | this->osVersion= 0; 154 | 155 | nof.cbSize= sizeof(nof); 156 | nof.hWnd= this->Owner; 157 | nof.uID= this->Id; 158 | nof.uFlags= NIF_MESSAGE; 159 | nof.uCallbackMessage= WM__TASKBAR; 160 | 161 | if (this->IconId) { 162 | nof.hIcon= (HICON)::LoadImage(hInstRes, MAKEINTRESOURCE(this->IconId), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); 163 | nof.uFlags|= NIF_ICON; 164 | } 165 | 166 | if (strlen(this->Tooltip)) { 167 | lstrcpyn(nof.szTip, this->Tooltip, sizeof(nof.szTip)-1); 168 | nof.uFlags|= NIF_TIP; 169 | } 170 | 171 | // 172 | // try a version 5 init (Shell_NotifyIcon has different behaviour from up win2000=version 5) 173 | // 174 | nof.cbSize= sizeof(nofv5); 175 | this->UpAndRunning= ::Shell_NotifyIcon(NIM_ADD, &nof); 176 | 177 | if (this->UpAndRunning) 178 | this->osVersion= 5; 179 | else 180 | this->UpAndRunning= ::Shell_NotifyIcon(NIM_ADD, &nof); 181 | 182 | if (nof.hIcon) { 183 | ::DestroyIcon(nof.hIcon); 184 | nof.hIcon= NULL; 185 | } 186 | 187 | return this->UpAndRunning; 188 | } 189 | 190 | void 191 | TASKBARICON::Destroy(BOOL keep) 192 | { 193 | NOTIFYICONDATA nof= NULLSTRUCT; 194 | 195 | nof.cbSize= sizeof(nof); 196 | nof.hWnd= this->Owner; 197 | nof.uID= this->Id; 198 | ::Shell_NotifyIcon(NIM_DELETE, &nof); 199 | 200 | if (!keep) { 201 | this->Owner= 0; 202 | this->Id= 0; 203 | this->IconId= 0; 204 | strcpy_s(this->Tooltip,sizeof(Tooltip), ""); 205 | } 206 | } 207 | 208 | BOOL 209 | TASKBARICON::IsUpAndRunning() 210 | { 211 | return this->UpAndRunning; 212 | } 213 | 214 | BOOL 215 | TASKBARICON::HasExtendedFeatures(void) 216 | { 217 | return this->osVersion>=5; //maybee we want to implement version 6 from up vista 218 | } 219 | 220 | 221 | BOOL 222 | TASKBARICON::RebuildIfNecessary(BOOL force) 223 | { 224 | char tt[256]; 225 | 226 | strcpy_s(tt,sizeof(tt), this->Tooltip); // avoid selfassignment 227 | 228 | if (force || !this->SetTooltip(tt)) { 229 | this->Destroy(TRUE); 230 | this->Construct(); 231 | } 232 | 233 | return this->SetTooltip(tt); 234 | } 235 | 236 | 237 | int 238 | TASKBARICON::SetIcon(int iconid) 239 | { 240 | BOOL ok; 241 | NOTIFYICONDATA nof= NULLSTRUCT; 242 | 243 | this->IconId= iconid; 244 | 245 | nof.cbSize= sizeof(nof); 246 | nof.hWnd= this->Owner; 247 | nof.uID= this->Id; 248 | nof.uFlags= NIF_ICON; 249 | nof.hIcon= (HICON)::LoadImage(hInstRes, MAKEINTRESOURCE(this->IconId), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); 250 | 251 | ok= ::Shell_NotifyIcon(NIM_MODIFY, &nof); 252 | 253 | if (nof.hIcon) { 254 | ::DestroyIcon(nof.hIcon); 255 | nof.hIcon= NULL; 256 | } 257 | 258 | // try to rebuild if SetIcon failed 259 | if (!ok) 260 | this->RebuildIfNecessary(TRUE); 261 | 262 | return ok; 263 | } 264 | 265 | int 266 | TASKBARICON::GetIcon(void) 267 | { 268 | return this->IconId; 269 | } 270 | 271 | int 272 | TASKBARICON::SetTooltip(const char *tooltip) 273 | { 274 | BOOL ok= 0; 275 | 276 | 277 | if (strcmp(this->Tooltip, tooltip)!=0) { 278 | strcpy_s(this->Tooltip,sizeof(Tooltip), tooltip); 279 | 280 | 281 | NOTIFYICONDATA nof= NULLSTRUCT; 282 | 283 | nof.cbSize= sizeof(nof); 284 | nof.hWnd= this->Owner; 285 | nof.uID= this->Id; 286 | nof.uFlags= NIF_TIP; 287 | lstrcpyn(nof.szTip, this->Tooltip, sizeof(nof.szTip)-1); 288 | 289 | 290 | ok= ::Shell_NotifyIcon(NIM_MODIFY, &nof); 291 | 292 | // try to rebuild if SetTooltip failed 293 | if (!ok && !this->InsideTooltipRebuild) { 294 | this->InsideTooltipRebuild= TRUE; 295 | this->RebuildIfNecessary(TRUE); 296 | this->InsideTooltipRebuild= FALSE; 297 | } 298 | } 299 | return ok; 300 | } 301 | 302 | 303 | int 304 | TASKBARICON::SetBalloon(ULONG flags, const char *title, const char *text, int timeout) 305 | { 306 | BOOL ok; 307 | 308 | NOTIFYICONDATA nof= NULLSTRUCT; 309 | 310 | nof.cbSize= sizeof(NOTIFYICONDATA); 311 | nof.hWnd= this->Owner; 312 | nof.uID= this->Id; 313 | nof.uFlags= NIF_INFO; 314 | nof.dwInfoFlags = flags; 315 | nof.uTimeout = timeout; 316 | lstrcpyn(nof.szInfo, text, sizeof(nof.szInfo)-1); 317 | lstrcpyn(nof.szInfoTitle, title, sizeof(nof.szInfoTitle)-1); 318 | 319 | return Shell_NotifyIcon(NIM_MODIFY, &nof); 320 | 321 | // try to rebuild if SetBalloon failed 322 | 323 | if (!ok) 324 | 325 | this->RebuildIfNecessary(TRUE); 326 | 327 | return ok; 328 | } 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | ////////////////////////////////////////////////////////////////////////////// 337 | // // 338 | // MENU // 339 | // // 340 | // // 341 | // // 342 | // // 343 | ////////////////////////////////////////////////////////////////////////////// 344 | 345 | MENU::MENU(HWND w) 346 | : hMenu(::GetMenu(w)), 347 | hWndOwner(w), 348 | IsLoaded(FALSE) 349 | { 350 | 351 | } 352 | 353 | MENU::MENU(HMENU hmenu) 354 | : hMenu(hmenu), 355 | hWndOwner(NULL), 356 | IsLoaded(FALSE) 357 | { 358 | 359 | } 360 | 361 | MENU::MENU(int id, HINSTANCE hdll) 362 | : hMenu(::LoadMenu(((ULONG)hdll==(ULONG)-1)? hInstRes : hdll, MAKEINTRESOURCE(id))), 363 | hWndOwner(NULL), 364 | IsLoaded(TRUE) 365 | { 366 | 367 | } 368 | 369 | 370 | void 371 | MENU::EnableMenuItem(int id, int status) 372 | { 373 | ::EnableMenuItem(*this, id, 374 | MF_BYCOMMAND | (status ? MF_ENABLED : MF_GRAYED)); 375 | } 376 | 377 | void 378 | MENU::DisableMenuItem(int id) 379 | { 380 | this->EnableMenuItem(id, FALSE); 381 | } 382 | 383 | int 384 | MENU::DeleteMenuItem(int id, BOOL idispos) 385 | { 386 | int rc= ::DeleteMenu(*this, id, idispos ? MF_BYPOSITION : MF_BYCOMMAND); 387 | if (this->hWndOwner) 388 | ::DrawMenuBar(this->hWndOwner); 389 | 390 | return rc; 391 | } 392 | 393 | void 394 | MENU::CheckMenuItem(int id, int status) 395 | { 396 | ::CheckMenuItem(*this, id, 397 | MF_BYCOMMAND | (status ? MF_CHECKED : MF_UNCHECKED)); 398 | } 399 | 400 | void 401 | MENU::UncheckMenuItem(int id) 402 | { 403 | this->CheckMenuItem(id, FALSE); 404 | } 405 | 406 | BOOL 407 | MENU::IsFlags(int id, int flags) 408 | { 409 | return ((::GetMenuState(*this, id, MF_BYCOMMAND) & flags)!=0); 410 | } 411 | 412 | BOOL 413 | MENU::IsMenuItemSeparator(int pos) 414 | { 415 | MENUITEMINFO mii= {sizeof(mii), MIIM_TYPE, }; 416 | ::GetMenuItemInfo(*this, pos, TRUE, &mii); 417 | return mii.fType==MFT_SEPARATOR; 418 | } 419 | 420 | BOOL 421 | MENU::IsMenuItemEnabled(int id) 422 | { 423 | return !this->IsFlags(id, MF_DISABLED|MF_GRAYED); 424 | } 425 | 426 | BOOL 427 | MENU::IsMenuItemDisabled(int id) 428 | { 429 | return this->IsFlags(id, MF_DISABLED|MF_GRAYED); 430 | } 431 | 432 | BOOL 433 | MENU::IsMenuItemChecked(int id) 434 | { 435 | return this->IsFlags(id, MF_CHECKED); 436 | } 437 | 438 | int 439 | MENU::GetNumMenuItems() 440 | { 441 | return ::GetMenuItemCount(*this); 442 | } 443 | 444 | 445 | //-------------------------------------------------------------------- 446 | // return the sub-menu handle of a menu item at a given position 447 | //-------------------------------------------------------------------- 448 | HMENU 449 | MENU::GetSubmenuFromPos(int pos) 450 | { 451 | HMENU rc= NULL; 452 | 453 | rc= (HMENU)GetSubMenu(*this, pos); 454 | 455 | return rc; 456 | } 457 | 458 | 459 | //-------------------------------------------------------------------- 460 | // return the item pos of a menu entry (search by id) 461 | //-------------------------------------------------------------------- 462 | int 463 | MENU::GetMenuPosFromID(int id) 464 | { 465 | int rc= -1; 466 | 467 | int i, mid, numof= ::GetMenuItemCount(*this); 468 | 469 | for (i=0; ihMenu, "BLUB"); 521 | hmenuShow= ::GetSubMenu(hmenu, 0); 522 | RECT r= { 0, 0, 10, 10 }; 523 | 524 | if (hwndowner) 525 | ::SetForegroundWindow(hwndowner); 526 | 527 | 528 | ULONG flags= TPM_LEFTALIGN | TPM_LEFTBUTTON; 529 | 530 | if (synchtrack & 1) 531 | flags|= TPM_RETURNCMD; 532 | 533 | if (synchtrack & TPM_RIGHTALIGN) 534 | flags|= TPM_RIGHTALIGN; 535 | 536 | int rc= ::TrackPopupMenu(hmenuShow, flags, 537 | point.x,point.y, 0, 538 | hwndowner, &r); 539 | 540 | if (hwndowner) 541 | ::PostMessage(hwndowner, WM_NULL, 0, 0); 542 | 543 | ::RemoveMenu(hmenu, 0, MF_BYPOSITION); 544 | ::DestroyMenu(hmenu); 545 | 546 | return rc; 547 | } 548 | 549 | 550 | 551 | -------------------------------------------------------------------------------- /fancontrol/winstuff.h: -------------------------------------------------------------------------------- 1 | 2 | // -------------------------------------------------------------- 3 | // 4 | // Thinkpad Fan Control 5 | // 6 | // -------------------------------------------------------------- 7 | // 8 | // This program and source code is in the public domain. 9 | // 10 | // The author claims no copyright, copyleft, license or 11 | // whatsoever for the program itself (with exception of 12 | // WinIO driver). You may use, reuse or distribute it's 13 | // binaries or source code in any desired way or form, 14 | // Useage of binaries or source shall be entirely and 15 | // without exception at your own risk. 16 | // 17 | // -------------------------------------------------------------- 18 | 19 | #ifndef WINCONTROLS_H 20 | #define WINCONTROLS_H 21 | 22 | #pragma once 23 | 24 | #include "_prec.h" 25 | 26 | 27 | #ifndef NIF_STATE // NotifyIcon V5 defines 28 | #define NIF_STATE 0x00000008 29 | #define NIF_INFO 0x00000010 30 | #define NIF_GUID 0x00000020 31 | 32 | #define NIIF_INFO 0x00000001 33 | #define NIIF_WARNING 0x00000002 34 | #define NIIF_ERROR 0x00000003 35 | #define NIIF_ICON_MASK 0x0000000F 36 | #define NIIF_NOSOUND 0x00000010 37 | #endif 38 | 39 | 40 | 41 | //------------------------------------------------------------------------- 42 | // 43 | //------------------------------------------------------------------------- 44 | class MUTEXSEM { 45 | 46 | private: 47 | HANDLE hmux; 48 | 49 | MUTEXSEM(MUTEXSEM &); // disallow argument passing 50 | void operator=(MUTEXSEM &) { }; // disallow assignment 51 | 52 | protected: 53 | 54 | public: 55 | MUTEXSEM(int state= FALSE, const char *name= "Access_Thinkpad_EC"); 56 | ~MUTEXSEM(); 57 | int Lock(int millies= 0xFFFFFFFF); 58 | void Unlock(); 59 | 60 | HANDLE Handle(void) 61 | { return this->hmux; } 62 | operator HANDLE(void) 63 | { return this->hmux; } 64 | }; 65 | 66 | 67 | class TASKBARICON { 68 | 69 | private: 70 | BOOL UpAndRunning; 71 | 72 | protected: 73 | HWND Owner; 74 | int Id, IconId; 75 | char Tooltip[256]; 76 | int osVersion; //TODO: war drin? 77 | volatile BOOL InsideTooltipRebuild; //should be declared as volatile for concurrency reasons 78 | 79 | 80 | public: 81 | TASKBARICON(HWND hwndowner, int id, const char *tooltip); 82 | ~TASKBARICON(void); 83 | 84 | BOOL Construct(void); 85 | void Destroy(BOOL keep= FALSE); 86 | 87 | BOOL RebuildIfNecessary(BOOL); 88 | BOOL HasExtendedFeatures(void); 89 | 90 | BOOL IsUpAndRunning(void); 91 | int SetIcon(int iconid); 92 | int GetIcon(void); 93 | int SetTooltip(const char *tip); 94 | int SetBalloon(ULONG flags, const char *title, const char *text, int timeout= 2); 95 | }; 96 | 97 | 98 | class MENU { 99 | 100 | private: 101 | 102 | protected: 103 | BOOL IsLoaded; 104 | HMENU hMenu; 105 | HWND hWndOwner; 106 | 107 | public: 108 | MENU(HWND hwnd); 109 | MENU(HMENU hm); 110 | MENU(int id, HINSTANCE hdll= (HINSTANCE)(ULONG)-1); 111 | ~MENU() 112 | { if (this->IsLoaded) ::DestroyMenu(this->hMenu); this->hMenu= NULL; } 113 | 114 | operator HMENU(void) const 115 | { return (HMENU)this->hMenu; } 116 | 117 | int GetNumMenuItems(void); 118 | BOOL IsMenuItemSeparator(int pos); 119 | 120 | void EnableMenuItem(int id, int status= TRUE); 121 | void DisableMenuItem(int id); 122 | int DeleteMenuItem(int id, BOOL idispos= FALSE); 123 | BOOL InsertItem(const char *text, int id, int pos= -1); 124 | BOOL InsertMenuItem(const char *text, int id, int pos= -1) 125 | { return this->InsertItem(text, id, pos); } 126 | BOOL InsertSeparator(int pos) 127 | { return this->InsertItem(NULL, 0, pos); } 128 | void CheckMenuItem(int id, int status= TRUE); 129 | void UncheckMenuItem(int id); 130 | BOOL IsFlags(int id, int flags); 131 | BOOL IsMenuItemEnabled(int id); 132 | BOOL IsMenuItemDisabled(int id); 133 | BOOL IsMenuItemChecked(int id); 134 | 135 | HMENU GetSubmenuFromPos(int pos); 136 | int GetMenuPosFromID(int id); 137 | 138 | int Popup(HWND hwnd, POINT *ppoint= NULL, BOOL synchtrack= FALSE); 139 | }; 140 | 141 | #endif // WINCONTROLS_H --------------------------------------------------------------------------------