Commit ec9024ca authored by Thomas Weidenmueller's avatar Thomas Weidenmueller Committed by Alexandre Julliard

Hook up "Hide on Minimize" & Add context menu to the tray icon.

parent 63308e5a
......@@ -129,10 +129,13 @@ END
IDR_TRAY_POPUP MENU DISCARDABLE
BEGIN
MENUITEM "&Restore", ID_RESTORE
MENUITEM "&Close", ID_FILE_EXIT
MENUITEM SEPARATOR
MENUITEM "&Always On Top", ID_OPTIONS_ALWAYSONTOP, CHECKED
POPUP "DUMMY"
BEGIN
MENUITEM "&Restore", ID_RESTORE
MENUITEM "&Close", ID_FILE_EXIT
MENUITEM SEPARATOR
MENUITEM "&Always On Top", ID_OPTIONS_ALWAYSONTOP
END
END
IDR_PROCESS_PAGE_CONTEXT MENU DISCARDABLE
......
......@@ -37,8 +37,6 @@
#include "taskmgr.h"
#define OPTIONS_MENU_INDEX 1
void TaskManager_OnOptionsAlwaysOnTop(void)
{
HMENU hMenu;
......@@ -51,7 +49,7 @@ void TaskManager_OnOptionsAlwaysOnTop(void)
* Check or uncheck the always on top menu item
* and update main window.
*/
if (GetMenuState(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND) & MF_CHECKED)
if ((GetWindowLong(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0)
{
CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.AlwaysOnTop = FALSE;
......
......@@ -144,6 +144,9 @@ TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
case ID_OPTIONS_SHOW16BITTASKS:
TaskManager_OnOptionsShow16BitTasks();
break;
case ID_RESTORE:
TaskManager_OnRestoreMainWindow();
break;
case ID_VIEW_LARGE:
ApplicationPage_OnViewLargeIcons();
break;
......@@ -249,6 +252,48 @@ TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
}
break;
case WM_ONTRAYICON:
switch(lParam)
{
case WM_RBUTTONDOWN:
{
POINT pt;
BOOL OnTop;
HMENU hMenu, hPopupMenu;
GetCursorPos(&pt);
OnTop = ((GetWindowLong(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0);
hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TRAY_POPUP));
hPopupMenu = GetSubMenu(hMenu, 0);
if(IsWindowVisible(hMainWnd))
{
DeleteMenu(hPopupMenu, ID_RESTORE, MF_BYCOMMAND);
}
else
{
SetMenuDefaultItem(hPopupMenu, ID_RESTORE, FALSE);
}
if(OnTop)
{
CheckMenuItem(hPopupMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND | MF_CHECKED);
}
SetForegroundWindow(hMainWnd);
TrackPopupMenuEx(hPopupMenu, 0, pt.x, pt.y, hMainWnd, NULL);
DestroyMenu(hMenu);
break;
}
case WM_LBUTTONDBLCLK:
TaskManager_OnRestoreMainWindow();
break;
}
break;
case WM_NOTIFY:
idctrl = (int)wParam;
pnmh = (LPNMHDR)lParam;
......@@ -613,7 +658,13 @@ void OnSize( UINT nType, int cx, int cy )
RECT rc;
if (nType == SIZE_MINIMIZED)
{
if(TaskManagerSettings.HideWhenMinimized)
{
ShowWindow(hMainWnd, SW_HIDE);
}
return;
}
nXDifference = cx - nOldWidth;
nYDifference = cy - nOldHeight;
......@@ -778,6 +829,20 @@ void SaveSettings(void)
RegCloseKey(hKey);
}
void TaskManager_OnRestoreMainWindow(void)
{
HMENU hMenu, hOptionsMenu;
BOOL OnTop;
hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
OnTop = ((GetWindowLong(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0);
OpenIcon(hMainWnd);
SetForegroundWindow(hMainWnd);
SetWindowPos(hMainWnd, (OnTop ? HWND_TOPMOST : HWND_TOP), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
}
void TaskManager_OnEnterMenuLoop(HWND hWnd)
{
int nParts;
......
......@@ -153,6 +153,7 @@ void Draw3dRect2(HDC hDC, LPRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottom
void Font_DrawText(HDC hDC, LPCTSTR lpszText, int x, int y);
void LoadSettings(void);
void SaveSettings(void);
void TaskManager_OnRestoreMainWindow(void);
void TaskManager_OnEnterMenuLoop(HWND hWnd);
void TaskManager_OnExitMenuLoop(HWND hWnd);
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu);
......@@ -162,6 +163,9 @@ void TaskManager_OnViewUpdateSpeedLow(void);
void TaskManager_OnViewUpdateSpeedPaused(void);
void TaskManager_OnViewRefresh(void);
void TaskManager_OnTabWndSelChange(void);
#define OPTIONS_MENU_INDEX 1
void TaskManager_OnOptionsAlwaysOnTop(void);
void TaskManager_OnOptionsMinimizeOnUse(void);
void TaskManager_OnOptionsHideWhenMinimized(void);
......@@ -186,6 +190,8 @@ void ProcessPage_OnSetPriorityBelowNormal(void);
void ProcessPage_OnSetPriorityLow(void);
void ProcessPage_OnDebugChannels(void);
#define WM_ONTRAYICON WM_USER + 5
HICON TrayIcon_GetProcessorUsageIcon(void);
BOOL TrayIcon_ShellAddTrayIcon(void);
BOOL TrayIcon_ShellRemoveTrayIcon(void);
......
......@@ -155,7 +155,7 @@ BOOL TrayIcon_ShellAddTrayIcon(void)
nid.hWnd = hMainWnd;
nid.uID = 0;
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
/* nid.uCallbackMessage = ??; */
nid.uCallbackMessage = WM_ONTRAYICON;
nid.hIcon = hIcon;
wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage());
......@@ -178,7 +178,7 @@ BOOL TrayIcon_ShellRemoveTrayIcon(void)
nid.hWnd = hMainWnd;
nid.uID = 0;
nid.uFlags = 0;
/* nid.uCallbackMessage = ??; */
nid.uCallbackMessage = WM_ONTRAYICON;
bRetVal = Shell_NotifyIcon(NIM_DELETE, &nid);
......@@ -199,7 +199,7 @@ BOOL TrayIcon_ShellUpdateTrayIcon(void)
nid.hWnd = hMainWnd;
nid.uID = 0;
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
/* nid.uCallbackMessage = ??; */
nid.uCallbackMessage = WM_ONTRAYICON;
nid.hIcon = hIcon;
wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment