Revert "[TASKMGR] Follow-up of 'Refactor trayicon.c' (99fb812)"

This reverts commit ec93c2340d.

Revert "[TASKMGR] Refactor trayicon.c"

This reverts commit 99fb812be4.
This commit is contained in:
Hermès Bélusca-Maïto 2023-06-15 12:43:36 +02:00
parent 36aea8e56e
commit 3fc702b588
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -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 <brianp@reactos.org>
* Copyright (C) 2005 Klemens Friedl <frik85@reactos.at>
* Copyright (C) 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
* ReactOS Task Manager
*
* trayicon.c
*
* Copyright (C) 1999 - 2001 Brian Palmer <brianp@reactos.org>
* 2005 Klemens Friedl <frik85@reactos.at>
*
* 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);