mirror of
https://github.com/reactos/reactos.git
synced 2025-07-28 00:52:17 +00:00
[TASKMGR] Simplify status-bar display when menus are shown (#5578)
CORE-19061
Following PR #5571 (commit 2d53e953c
), it became apparent that the
management of the status-bar when showing the menu hints could be
simplified further.
Use "simple-text" status-bar display mode when showing menu hints.
The original status-bar panes state is "remembered" and are automatically
restored when the "simple-text" mode is disabled.
This commit is contained in:
parent
3ae0ccdccb
commit
cdba812252
3 changed files with 44 additions and 65 deletions
|
@ -8,8 +8,6 @@
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
|
|
||||||
extern BOOL bInMenuLoop; /* Tells us if we are in the menu loop - from taskmgr.c */
|
|
||||||
|
|
||||||
TM_GRAPH_CONTROL PerformancePageCpuUsageHistoryGraph;
|
TM_GRAPH_CONTROL PerformancePageCpuUsageHistoryGraph;
|
||||||
TM_GRAPH_CONTROL PerformancePageMemUsageHistoryGraph;
|
TM_GRAPH_CONTROL PerformancePageMemUsageHistoryGraph;
|
||||||
|
|
||||||
|
@ -328,6 +326,8 @@ DWORD WINAPI PerformancePageRefreshThread(PVOID Parameter)
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
extern BOOL bTrackMenu; // From taskmgr.c
|
||||||
|
|
||||||
int nBarsUsed1;
|
int nBarsUsed1;
|
||||||
int nBarsUsed2;
|
int nBarsUsed2;
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ DWORD WINAPI PerformancePageRefreshThread(PVOID Parameter)
|
||||||
szChargeLimitFormat,
|
szChargeLimitFormat,
|
||||||
ARRAYSIZE(szChargeLimitFormat));
|
ARRAYSIZE(szChargeLimitFormat));
|
||||||
|
|
||||||
if (!bInMenuLoop)
|
if (!bTrackMenu)
|
||||||
{
|
{
|
||||||
wsprintfW(Text, szMemUsage, szChargeTotalFormat, szChargeLimitFormat,
|
wsprintfW(Text, szMemUsage, szChargeTotalFormat, szChargeLimitFormat,
|
||||||
(CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0));
|
(CommitChargeLimit ? ((CommitChargeTotal * 100) / CommitChargeLimit) : 0));
|
||||||
|
@ -406,7 +406,7 @@ DWORD WINAPI PerformancePageRefreshThread(PVOID Parameter)
|
||||||
SetWindowTextW(hTotalsThreadCountEdit, Text);
|
SetWindowTextW(hTotalsThreadCountEdit, Text);
|
||||||
_ultow(TotalProcesses, Text, 10);
|
_ultow(TotalProcesses, Text, 10);
|
||||||
SetWindowTextW(hTotalsProcessCountEdit, Text);
|
SetWindowTextW(hTotalsProcessCountEdit, Text);
|
||||||
if (!bInMenuLoop)
|
if (!bTrackMenu)
|
||||||
{
|
{
|
||||||
wsprintfW(Text, szProcesses, TotalProcesses);
|
wsprintfW(Text, szProcesses, TotalProcesses);
|
||||||
SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)Text);
|
SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)Text);
|
||||||
|
@ -424,7 +424,7 @@ DWORD WINAPI PerformancePageRefreshThread(PVOID Parameter)
|
||||||
CpuUsage = PerfDataGetProcessorUsage();
|
CpuUsage = PerfDataGetProcessorUsage();
|
||||||
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
CpuKernelUsage = PerfDataGetProcessorSystemUsage();
|
||||||
|
|
||||||
if (!bInMenuLoop)
|
if (!bTrackMenu)
|
||||||
{
|
{
|
||||||
wsprintfW(Text, szCpuUsage, CpuUsage);
|
wsprintfW(Text, szCpuUsage, CpuUsage);
|
||||||
SendMessageW(hStatusWnd, SB_SETTEXT, 1, (LPARAM)Text);
|
SendMessageW(hStatusWnd, SB_SETTEXT, 1, (LPARAM)Text);
|
||||||
|
|
|
@ -31,7 +31,7 @@ int nMinimumHeight; /* Minimum height of the dialog (OnSize()'s cy)
|
||||||
int nOldWidth; /* Holds the previous client area width */
|
int nOldWidth; /* Holds the previous client area width */
|
||||||
int nOldHeight; /* Holds the previous client area height */
|
int nOldHeight; /* Holds the previous client area height */
|
||||||
|
|
||||||
BOOL bInMenuLoop = FALSE; /* Tells us if we are in the menu loop */
|
BOOL bTrackMenu = FALSE; /* Signals when we display menu hints */
|
||||||
BOOL bWasKeyboardInput = FALSE; /* TabChange by Keyboard or Mouse ? */
|
BOOL bWasKeyboardInput = FALSE; /* TabChange by Keyboard or Mouse ? */
|
||||||
|
|
||||||
TASKMANAGER_SETTINGS TaskManagerSettings;
|
TASKMANAGER_SETTINGS TaskManagerSettings;
|
||||||
|
@ -482,24 +482,10 @@ TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
TrayIcon_UpdateIcon();
|
TrayIcon_UpdateIcon();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_INITMENUPOPUP:
|
|
||||||
/* Do not disable the status bar if we opened the system menu */
|
|
||||||
if (!HIWORD(lParam))
|
|
||||||
TaskManager_DisableStatusBar(hDlg);
|
|
||||||
else
|
|
||||||
TaskManager_EnableStatusBar(hDlg);
|
|
||||||
break;
|
|
||||||
case WM_ENTERMENULOOP:
|
|
||||||
bInMenuLoop = TRUE;
|
|
||||||
break;
|
|
||||||
case WM_EXITMENULOOP:
|
|
||||||
bInMenuLoop = FALSE;
|
|
||||||
TaskManager_EnableStatusBar(hDlg);
|
|
||||||
break;
|
|
||||||
case WM_MENUSELECT:
|
case WM_MENUSELECT:
|
||||||
if (!(HIWORD(wParam) & MF_SYSMENU))
|
|
||||||
TaskManager_OnMenuSelect(hDlg, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam);
|
TaskManager_OnMenuSelect(hDlg, LOWORD(wParam), HIWORD(wParam), (HMENU)lParam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SYSCOLORCHANGE:
|
case WM_SYSCOLORCHANGE:
|
||||||
/* Forward WM_SYSCOLORCHANGE to common controls */
|
/* Forward WM_SYSCOLORCHANGE to common controls */
|
||||||
SendMessage(hApplicationPageListCtrl, WM_SYSCOLORCHANGE, 0, 0);
|
SendMessage(hApplicationPageListCtrl, WM_SYSCOLORCHANGE, 0, 0);
|
||||||
|
@ -569,7 +555,7 @@ BOOL OnCreate(HWND hWnd)
|
||||||
nParts[0] = STATUS_SIZE1;
|
nParts[0] = STATUS_SIZE1;
|
||||||
nParts[1] = STATUS_SIZE2;
|
nParts[1] = STATUS_SIZE2;
|
||||||
nParts[2] = STATUS_SIZE3;
|
nParts[2] = STATUS_SIZE3;
|
||||||
SendMessageW(hStatusWnd, SB_SETPARTS, 3, (LPARAM) (LPINT) nParts);
|
SendMessageW(hStatusWnd, SB_SETPARTS, _countof(nParts), (LPARAM)(LPINT)nParts);
|
||||||
|
|
||||||
/* Create tab pages */
|
/* Create tab pages */
|
||||||
hTabWnd = GetDlgItem(hWnd, IDC_TAB);
|
hTabWnd = GetDlgItem(hWnd, IDC_TAB);
|
||||||
|
@ -759,9 +745,7 @@ void OnSize( WPARAM nType, int cx, int cy )
|
||||||
if (nType == SIZE_MINIMIZED)
|
if (nType == SIZE_MINIMIZED)
|
||||||
{
|
{
|
||||||
if (TaskManagerSettings.HideWhenMinimized)
|
if (TaskManagerSettings.HideWhenMinimized)
|
||||||
{
|
|
||||||
ShowWindow(hMainWnd, SW_HIDE);
|
ShowWindow(hMainWnd, SW_HIDE);
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -775,10 +759,10 @@ void OnSize( WPARAM nType, int cx, int cy )
|
||||||
SendMessageW(hStatusWnd, WM_SIZE, nType, MAKELPARAM(cx,rc.bottom - rc.top));
|
SendMessageW(hStatusWnd, WM_SIZE, nType, MAKELPARAM(cx,rc.bottom - rc.top));
|
||||||
|
|
||||||
/* Update the status bar pane sizes */
|
/* Update the status bar pane sizes */
|
||||||
nParts[0] = bInMenuLoop ? -1 : STATUS_SIZE1;
|
nParts[0] = STATUS_SIZE1;
|
||||||
nParts[1] = STATUS_SIZE2;
|
nParts[1] = STATUS_SIZE2;
|
||||||
nParts[2] = cx;
|
nParts[2] = cx;
|
||||||
SendMessageW(hStatusWnd, SB_SETPARTS, bInMenuLoop ? 1 : 3, (LPARAM) (LPINT) nParts);
|
SendMessageW(hStatusWnd, SB_SETPARTS, _countof(nParts), (LPARAM)(LPINT)nParts);
|
||||||
|
|
||||||
/* Resize the tab control */
|
/* Resize the tab control */
|
||||||
GetWindowRect(hTabWnd, &rc);
|
GetWindowRect(hTabWnd, &rc);
|
||||||
|
@ -896,46 +880,43 @@ void TaskManager_OnRestoreMainWindow(void)
|
||||||
SetWindowPos(hMainWnd, (OnTop ? HWND_TOPMOST : HWND_TOP), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
|
SetWindowPos(hMainWnd, (OnTop ? HWND_TOPMOST : HWND_TOP), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskManager_DisableStatusBar(HWND hWnd)
|
|
||||||
{
|
|
||||||
int nParts;
|
|
||||||
|
|
||||||
/* Update the status bar pane sizes */
|
|
||||||
nParts = -1;
|
|
||||||
SendMessageW(hStatusWnd, SB_SETPARTS, 1, (LPARAM) (LPINT)&nParts);
|
|
||||||
SendMessageW(hStatusWnd, SB_SETTEXT, (WPARAM)0, (LPARAM)L"");
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager_EnableStatusBar(HWND hWnd)
|
|
||||||
{
|
|
||||||
RECT rc;
|
|
||||||
int nParts[3];
|
|
||||||
|
|
||||||
/* Update the status bar pane sizes */
|
|
||||||
GetClientRect(hWnd, &rc);
|
|
||||||
nParts[0] = STATUS_SIZE1;
|
|
||||||
nParts[1] = STATUS_SIZE2;
|
|
||||||
nParts[2] = rc.right;
|
|
||||||
SendMessageW(hStatusWnd, SB_SETPARTS, 3, (LPARAM) (LPINT) nParts);
|
|
||||||
|
|
||||||
/* trigger update of status bar columns and performance page asynchronously */
|
|
||||||
RefreshPerformancePage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
|
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
|
||||||
{
|
{
|
||||||
WCHAR str[100];
|
WCHAR str[100] = L"";
|
||||||
|
|
||||||
wcscpy(str, L"");
|
/*
|
||||||
if (LoadStringW(hInst, nItemID, str, 100)) {
|
* Reset the status bar if we close the current menu, or
|
||||||
/* load appropriate string */
|
* we open the system menu or hover above a menu separator.
|
||||||
LPWSTR lpsz = str;
|
* Adapted from comctl32!MenuHelp().
|
||||||
/* first newline terminates actual string */
|
*/
|
||||||
lpsz = wcschr(lpsz, '\n');
|
if ((LOWORD(nFlags) == 0xFFFF && hSysMenu == NULL) ||
|
||||||
|
(nFlags & (MF_SEPARATOR | MF_SYSMENU)))
|
||||||
|
{
|
||||||
|
/* Set the status bar for multiple-parts output */
|
||||||
|
SendMessageW(hStatusWnd, SB_SIMPLE, (WPARAM)FALSE, (LPARAM)0);
|
||||||
|
bTrackMenu = FALSE;
|
||||||
|
|
||||||
|
/* Trigger update of status bar columns and performance page asynchronously */
|
||||||
|
RefreshPerformancePage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise, retrieve the appropriate menu hint string */
|
||||||
|
if (LoadStringW(hInst, nItemID, str, _countof(str)))
|
||||||
|
{
|
||||||
|
/* First newline terminates actual string */
|
||||||
|
LPWSTR lpsz = wcschr(str, '\n');
|
||||||
if (lpsz != NULL)
|
if (lpsz != NULL)
|
||||||
*lpsz = '\0';
|
*lpsz = '\0';
|
||||||
}
|
}
|
||||||
SendMessageW(hStatusWnd, SB_SETTEXT, 0, (LPARAM)str);
|
|
||||||
|
/* Set the status bar for single-part output, if needed... */
|
||||||
|
if (!bTrackMenu)
|
||||||
|
SendMessageW(hStatusWnd, SB_SIMPLE, (WPARAM)TRUE, (LPARAM)0);
|
||||||
|
bTrackMenu = TRUE;
|
||||||
|
|
||||||
|
/* ... and display the menu hint */
|
||||||
|
SendMessageW(hStatusWnd, SB_SETTEXT, SB_SIMPLEID | SBT_NOBORDERS, (LPARAM)str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskManager_OnViewUpdateSpeed(DWORD dwSpeed)
|
void TaskManager_OnViewUpdateSpeed(DWORD dwSpeed)
|
||||||
|
|
|
@ -94,8 +94,6 @@ void FillSolidRect(HDC hDC, LPCRECT lpRect, COLORREF clr);
|
||||||
void LoadSettings(void);
|
void LoadSettings(void);
|
||||||
void SaveSettings(void);
|
void SaveSettings(void);
|
||||||
void TaskManager_OnRestoreMainWindow(void);
|
void TaskManager_OnRestoreMainWindow(void);
|
||||||
void TaskManager_DisableStatusBar(HWND hWnd);
|
|
||||||
void TaskManager_EnableStatusBar(HWND hWnd);
|
|
||||||
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu);
|
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu);
|
||||||
void TaskManager_OnViewUpdateSpeed(DWORD);
|
void TaskManager_OnViewUpdateSpeed(DWORD);
|
||||||
void TaskManager_OnTabWndSelChange(void);
|
void TaskManager_OnTabWndSelChange(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue