https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3fc702b5882d7acbc0fd61232a9a839eed43b96a

commit 3fc702b5882d7acbc0fd61232a9a839eed43b96a
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Thu Jun 15 12:43:36 2023 +0200
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Thu Jun 15 12:43:36 2023 +0200

    Revert "[TASKMGR] Follow-up of 'Refactor trayicon.c' (99fb812)"
    
    This reverts commit ec93c2340d648c15ff3c1f6d56c993b96c33204b.
    
    Revert "[TASKMGR] Refactor trayicon.c"
    
    This reverts commit 99fb812be4ba86139438bf7961f2030ac9e016be.
---
 base/applications/taskmgr/trayicon.c | 56 ++++++++++++++++++++++++------------
 1 file changed, 37 insertions(+), 19 deletions(-)

diff --git a/base/applications/taskmgr/trayicon.c 
b/base/applications/taskmgr/trayicon.c
index dcff4a00f28..e34e4578743 100644
--- a/base/applications/taskmgr/trayicon.c
+++ b/base/applications/taskmgr/trayicon.c
@@ -1,16 +1,28 @@
 /*
- * PROJECT:     ReactOS Task Manager
- * LICENSE:     LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
- * PURPOSE:     Task Manager for ReactOS
- * COPYRIGHT:   Copyright (C) 1999 - 2001 Brian Palmer <[email protected]>
- *              Copyright (C) 2005 Klemens Friedl <[email protected]>
- *              Copyright (C) 2023 Katayama Hirofumi MZ 
<[email protected]>
+ *  ReactOS Task Manager
+ *
+ *  trayicon.c
+ *
+ *  Copyright (C) 1999 - 2001  Brian Palmer  <[email protected]>
+ *                2005         Klemens Friedl <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
  */
 
 #include "precomp.h"
 
-#include <strsafe.h>
-
 HICON TrayIcon_GetProcessorUsageIcon(void)
 {
     HICON     hTrayIcon = NULL;
@@ -117,13 +129,14 @@ done:
 BOOL TrayIcon_ShellAddTrayIcon(void)
 {
     NOTIFYICONDATAW nid;
-    HICON           hIcon;
+    HICON           hIcon = NULL;
     BOOL            bRetVal;
     WCHAR           szMsg[64];
 
+    memset(&nid, 0, sizeof(NOTIFYICONDATAW));
+
     hIcon = TrayIcon_GetProcessorUsageIcon();
 
-    ZeroMemory(&nid, sizeof(nid));
     nid.cbSize = sizeof(NOTIFYICONDATAW);
     nid.hWnd = hMainWnd;
     nid.uID = 0;
@@ -131,8 +144,9 @@ BOOL TrayIcon_ShellAddTrayIcon(void)
     nid.uCallbackMessage = WM_ONTRAYICON;
     nid.hIcon = hIcon;
 
-    LoadStringW(NULL, IDS_MSG_TRAYICONCPUUSAGE, szMsg, _countof(szMsg));
-    StringCchPrintfW(nid.szTip, _countof(nid.szTip), szMsg, 
PerfDataGetProcessorUsage());
+
+    LoadStringW( GetModuleHandleW(NULL), IDS_MSG_TRAYICONCPUUSAGE, szMsg, 
sizeof(szMsg) / sizeof(szMsg[0]));
+    wsprintfW(nid.szTip, szMsg, PerfDataGetProcessorUsage());
 
     bRetVal = Shell_NotifyIconW(NIM_ADD, &nid);
 
@@ -145,36 +159,40 @@ BOOL TrayIcon_ShellAddTrayIcon(void)
 BOOL TrayIcon_ShellRemoveTrayIcon(void)
 {
     NOTIFYICONDATAW nid;
+    BOOL            bRetVal;
+
+    memset(&nid, 0, sizeof(NOTIFYICONDATAW));
 
-    ZeroMemory(&nid, sizeof(nid));
     nid.cbSize = sizeof(NOTIFYICONDATAW);
     nid.hWnd = hMainWnd;
     nid.uID = 0;
     nid.uFlags = 0;
     nid.uCallbackMessage = WM_ONTRAYICON;
 
-    return Shell_NotifyIconW(NIM_DELETE, &nid);
+    bRetVal = Shell_NotifyIconW(NIM_DELETE, &nid);
+
+    return bRetVal;
 }
 
 BOOL TrayIcon_ShellUpdateTrayIcon(void)
 {
     NOTIFYICONDATAW nid;
-    HICON           hIcon;
+    HICON           hIcon = NULL;
     BOOL            bRetVal;
     WCHAR           szTemp[64];
 
+    memset(&nid, 0, sizeof(NOTIFYICONDATAW));
+
     hIcon = TrayIcon_GetProcessorUsageIcon();
 
-    ZeroMemory(&nid, sizeof(nid));
     nid.cbSize = sizeof(NOTIFYICONDATAW);
     nid.hWnd = hMainWnd;
     nid.uID = 0;
     nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
     nid.uCallbackMessage = WM_ONTRAYICON;
     nid.hIcon = hIcon;
-
-    LoadStringW(NULL, IDS_MSG_TRAYICONCPUUSAGE, szTemp, _countof(szTemp));
-    StringCchPrintfW(nid.szTip, _countof(nid.szTip), szTemp, 
PerfDataGetProcessorUsage());
+    LoadStringW(hInst, IDS_MSG_TRAYICONCPUUSAGE, szTemp, 
sizeof(szTemp)/sizeof(szTemp[0]));
+    wsprintfW(nid.szTip, szTemp, PerfDataGetProcessorUsage());
 
     bRetVal = Shell_NotifyIconW(NIM_MODIFY, &nid);
 

Reply via email to