From 00d39b65bff668f04df476e28f8d12453aee80ab Mon Sep 17 00:00:00 2001 From: wj32 Date: Sun, 4 Jul 2010 11:30:26 +0000 Subject: [PATCH] implemented icon notifications git-svn-id: svn://svn.code.sf.net/p/processhacker/code@3265 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- 2.x/trunk/ProcessHacker/ProcessHacker.rc | 13 +- 2.x/trunk/ProcessHacker/include/phapp.h | 18 + 2.x/trunk/ProcessHacker/mainwnd.c | 428 ++++++++++++++++------- 2.x/trunk/ProcessHacker/notifico.c | 57 ++- 2.x/trunk/ProcessHacker/procprp.c | 66 ++-- 2.x/trunk/ProcessHacker/resource.h | 10 +- 2.x/trunk/ProcessHacker/settings.c | 1 + 7 files changed, 420 insertions(+), 173 deletions(-) diff --git a/2.x/trunk/ProcessHacker/ProcessHacker.rc b/2.x/trunk/ProcessHacker/ProcessHacker.rc index 87664e74f..124072242 100644 --- a/2.x/trunk/ProcessHacker/ProcessHacker.rc +++ b/2.x/trunk/ProcessHacker/ProcessHacker.rc @@ -341,7 +341,18 @@ BEGIN BEGIN MENUITEM "Show/Hide Process Hacker", ID_ICON_SHOWHIDEPROCESSHACKER MENUITEM "System Information", ID_ICON_SYSTEMINFORMATION - MENUITEM "Notifications", ID_ICON_NOTIFICATIONS + POPUP "Notifications" + BEGIN + MENUITEM "Enable All", ID_NOTIFICATIONS_ENABLEALL + MENUITEM "Disable All", ID_NOTIFICATIONS_DISABLEALL + MENUITEM SEPARATOR + MENUITEM "New Processes", ID_NOTIFICATIONS_NEWPROCESSES + MENUITEM "Terminated Processes", ID_NOTIFICATIONS_TERMINATEDPROCESSES + MENUITEM "New Services", ID_NOTIFICATIONS_NEWSERVICES + MENUITEM "Started Services", ID_NOTIFICATIONS_STARTEDSERVICES + MENUITEM "Stopped Services", ID_NOTIFICATIONS_STOPPEDSERVICES + MENUITEM "Deleted Services", ID_NOTIFICATIONS_DELETEDSERVICES + END POPUP "Processes" BEGIN MENUITEM "Dummy", ID_PROCESSES_DUMMY diff --git a/2.x/trunk/ProcessHacker/include/phapp.h b/2.x/trunk/ProcessHacker/include/phapp.h index 06aef6293..f1f588280 100644 --- a/2.x/trunk/ProcessHacker/include/phapp.h +++ b/2.x/trunk/ProcessHacker/include/phapp.h @@ -322,6 +322,16 @@ extern BOOLEAN PhMainWndExiting; #define ProcessHacker_CancelEarlyShutdown(hWnd) \ SendMessage(hWnd, WM_PH_CANCEL_EARLY_SHUTDOWN, 0, 0) +#define PH_NOTIFY_MINIMUM 0x1 +#define PH_NOTIFY_PROCESS_CREATE 0x1 +#define PH_NOTIFY_PROCESS_DELETE 0x2 +#define PH_NOTIFY_SERVICE_CREATE 0x4 +#define PH_NOTIFY_SERVICE_DELETE 0x8 +#define PH_NOTIFY_SERVICE_START 0x10 +#define PH_NOTIFY_SERVICE_STOP 0x20 +#define PH_NOTIFY_MAXIMUM 0x40 +#define PH_NOTIFY_VALID_MASK 0x3f + BOOLEAN PhMainWndInitialization( __in INT ShowCommand ); @@ -430,6 +440,14 @@ VOID PhModifyNotifyIcon( __in_opt HICON Icon ); +VOID PhShowBalloonTipNotifyIcon( + __in ULONG Id, + __in PWSTR Title, + __in PWSTR Text, + __in ULONG Timeout, + __in ULONG Flags + ); + HICON PhBitmapToIcon( __in HBITMAP Bitmap ); diff --git a/2.x/trunk/ProcessHacker/mainwnd.c b/2.x/trunk/ProcessHacker/mainwnd.c index 64acf5537..d761b9d32 100644 --- a/2.x/trunk/ProcessHacker/mainwnd.c +++ b/2.x/trunk/ProcessHacker/mainwnd.c @@ -95,6 +95,16 @@ VOID PhpAddIconProcesses( __out_ecount(NumberOfProcesses) HBITMAP *Bitmaps ); +VOID PhpShowIconContextMenu( + __in POINT Location + ); + +VOID PhpShowIconNotification( + __in PWSTR Title, + __in PWSTR Text, + __in ULONG Flags + ); + PPH_PROCESS_ITEM PhpGetSelectedProcess(); VOID PhpGetSelectedProcesses( @@ -173,6 +183,7 @@ static BOOLEAN NeedsMaximize = FALSE; static BOOLEAN DelayedLoadCompleted = FALSE; static ULONG NotifyIconMask; +static ULONG NotifyIconNotifyMask; static HBITMAP *IconProcessBitmaps; static HWND TabControlHandle; @@ -599,21 +610,21 @@ LRESULT CALLBACK PhMainWndProc( switch (LOWORD(wParam)) { - case ID_TRAYICONS_CPUHISTORY: - i = PH_ICON_CPU_HISTORY; - break; - case ID_TRAYICONS_CPUUSAGE: - i = PH_ICON_CPU_USAGE; - break; - case ID_TRAYICONS_IOHISTORY: - i = PH_ICON_IO_HISTORY; - break; - case ID_TRAYICONS_COMMITHISTORY: - i = PH_ICON_COMMIT_HISTORY; - break; - case ID_TRAYICONS_PHYSICALMEMORYHISTORY: - i = PH_ICON_PHYSICAL_HISTORY; - break; + case ID_TRAYICONS_CPUHISTORY: + i = PH_ICON_CPU_HISTORY; + break; + case ID_TRAYICONS_CPUUSAGE: + i = PH_ICON_CPU_USAGE; + break; + case ID_TRAYICONS_IOHISTORY: + i = PH_ICON_IO_HISTORY; + break; + case ID_TRAYICONS_COMMITHISTORY: + i = PH_ICON_COMMIT_HISTORY; + break; + case ID_TRAYICONS_PHYSICALMEMORYHISTORY: + i = PH_ICON_PHYSICAL_HISTORY; + break; } enable = !(GetMenuState(PhMainWndMenuHandle, LOWORD(wParam), 0) & MF_CHECKED); @@ -1066,24 +1077,24 @@ LRESULT CALLBACK PhMainWndProc( switch (id) { - case ID_PRIORITY_REALTIME: - priorityClassWin32 = REALTIME_PRIORITY_CLASS; - break; - case ID_PRIORITY_HIGH: - priorityClassWin32 = HIGH_PRIORITY_CLASS; - break; - case ID_PRIORITY_ABOVENORMAL: - priorityClassWin32 = ABOVE_NORMAL_PRIORITY_CLASS; - break; - case ID_PRIORITY_NORMAL: - priorityClassWin32 = NORMAL_PRIORITY_CLASS; - break; - case ID_PRIORITY_BELOWNORMAL: - priorityClassWin32 = BELOW_NORMAL_PRIORITY_CLASS; - break; - case ID_PRIORITY_IDLE: - priorityClassWin32 = IDLE_PRIORITY_CLASS; - break; + case ID_PRIORITY_REALTIME: + priorityClassWin32 = REALTIME_PRIORITY_CLASS; + break; + case ID_PRIORITY_HIGH: + priorityClassWin32 = HIGH_PRIORITY_CLASS; + break; + case ID_PRIORITY_ABOVENORMAL: + priorityClassWin32 = ABOVE_NORMAL_PRIORITY_CLASS; + break; + case ID_PRIORITY_NORMAL: + priorityClassWin32 = NORMAL_PRIORITY_CLASS; + break; + case ID_PRIORITY_BELOWNORMAL: + priorityClassWin32 = BELOW_NORMAL_PRIORITY_CLASS; + break; + case ID_PRIORITY_IDLE: + priorityClassWin32 = IDLE_PRIORITY_CLASS; + break; } PhReferenceObject(processItem); @@ -1505,93 +1516,10 @@ LRESULT CALLBACK PhMainWndProc( break; case WM_RBUTTONUP: { -#define PROCESSES_MENU_INDEX 3 - POINT point; - HMENU iconMenu; - HMENU menu; - ULONG numberOfProcesses; - ULONG id; - ULONG i; + POINT location; - iconMenu = LoadMenu(PhInstanceHandle, MAKEINTRESOURCE(IDR_ICON)); - menu = GetSubMenu(iconMenu, 0); - - // Add processes to the menu. - numberOfProcesses = PhGetIntegerSetting(L"IconProcesses"); - IconProcessBitmaps = PhAllocate(sizeof(HBITMAP) * numberOfProcesses); - memset(IconProcessBitmaps, 0, sizeof(HBITMAP) * numberOfProcesses); - PhpAddIconProcesses(GetSubMenu(menu, PROCESSES_MENU_INDEX), numberOfProcesses, IconProcessBitmaps); - - GetCursorPos(&point); - SetForegroundWindow(hWnd); // window must be foregrounded so menu will disappear properly - id = (ULONG)TrackPopupMenu( - menu, - TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, - point.x, - point.y, - 0, - hWnd, - NULL - ); - DestroyMenu(iconMenu); - - // Destroy the bitmaps. - for (i = 0; i < numberOfProcesses; i++) - { - if (IconProcessBitmaps[i]) - DeleteObject(IconProcessBitmaps[i]); - } - - PhFree(IconProcessBitmaps); - - if (!PhpProcessComputerCommand(id)) - { - switch (id) - { - case ID_ICON_SHOWHIDEPROCESSHACKER: - SendMessage(hWnd, WM_PH_TOGGLE_VISIBLE, 0, 0); - break; - case ID_ICON_SYSTEMINFORMATION: - SendMessage(hWnd, WM_COMMAND, ID_VIEW_SYSTEMINFORMATION, 0); - break; - case ID_ICONPROCESS_TERMINATE: - case ID_ICONPROCESS_SUSPEND: - case ID_ICONPROCESS_RESUME: - case ID_ICONPROCESS_PROPERTIES: - { - PPH_PROCESS_ITEM processItem; - - if (processItem = PhReferenceProcessItem(SelectedIconProcessId)) - { - switch (id) - { - case ID_ICONPROCESS_TERMINATE: - PhUiTerminateProcesses(hWnd, &processItem, 1); - break; - case ID_ICONPROCESS_SUSPEND: - PhUiSuspendProcesses(hWnd, &processItem, 1); - break; - case ID_ICONPROCESS_RESUME: - PhUiResumeProcesses(hWnd, &processItem, 1); - break; - case ID_ICONPROCESS_PROPERTIES: - ProcessHacker_ShowProcessProperties(hWnd, processItem); - break; - } - - PhDereferenceObject(processItem); - } - else - { - PhShowError(hWnd, L"The process does not exist."); - } - } - break; - case ID_ICON_EXIT: - SendMessage(hWnd, WM_COMMAND, ID_HACKER_EXIT, 0); - break; - } - } + GetCursorPos(&location); + PhpShowIconContextMenu(location); } break; } @@ -1808,6 +1736,8 @@ VOID PhpInitialLoadSettings() CheckMenuItem(PhMainWndMenuHandle, id, MF_CHECKED); } } + + NotifyIconNotifyMask = PhGetIntegerSetting(L"IconNotifyMask"); } static NTSTATUS PhpDelayedLoadFunction( @@ -1849,6 +1779,7 @@ VOID PhpSaveAllSettings() PH_RECTANGLE windowRectangle; PhSetIntegerSetting(L"IconMask", NotifyIconMask); + PhSetIntegerSetting(L"IconNotifyMask", NotifyIconNotifyMask); GetWindowPlacement(PhMainWndHandle, &placement); windowRectangle = PhRectToRectangle(placement.rcNormalPosition); @@ -2162,6 +2093,188 @@ VOID PhpAddIconProcesses( PhFree(processItems); } +VOID PhpShowIconContextMenu( + __in POINT Location + ) +{ +#define PROCESSES_MENU_INDEX 3 + + HMENU iconMenu; + HMENU menu; + ULONG numberOfProcesses; + ULONG id; + ULONG i; + + iconMenu = LoadMenu(PhInstanceHandle, MAKEINTRESOURCE(IDR_ICON)); + menu = GetSubMenu(iconMenu, 0); + + // Check the Notifications menu items. + for (i = PH_NOTIFY_MINIMUM; i != PH_NOTIFY_MAXIMUM; i <<= 1) + { + if (NotifyIconNotifyMask & i) + { + switch (i) + { + case PH_NOTIFY_PROCESS_CREATE: + id = ID_NOTIFICATIONS_NEWPROCESSES; + break; + case PH_NOTIFY_PROCESS_DELETE: + id = ID_NOTIFICATIONS_TERMINATEDPROCESSES; + break; + case PH_NOTIFY_SERVICE_CREATE: + id = ID_NOTIFICATIONS_NEWSERVICES; + break; + case PH_NOTIFY_SERVICE_DELETE: + id = ID_NOTIFICATIONS_DELETEDSERVICES; + break; + case PH_NOTIFY_SERVICE_START: + id = ID_NOTIFICATIONS_STARTEDSERVICES; + break; + case PH_NOTIFY_SERVICE_STOP: + id = ID_NOTIFICATIONS_STOPPEDSERVICES; + break; + } + + CheckMenuItem(menu, id, MF_CHECKED); + } + } + + // Add processes to the menu. + numberOfProcesses = PhGetIntegerSetting(L"IconProcesses"); + IconProcessBitmaps = PhAllocate(sizeof(HBITMAP) * numberOfProcesses); + memset(IconProcessBitmaps, 0, sizeof(HBITMAP) * numberOfProcesses); + PhpAddIconProcesses(GetSubMenu(menu, PROCESSES_MENU_INDEX), numberOfProcesses, IconProcessBitmaps); + + SetForegroundWindow(PhMainWndHandle); // window must be foregrounded so menu will disappear properly + id = (ULONG)TrackPopupMenu( + menu, + TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, + Location.x, + Location.y, + 0, + PhMainWndHandle, + NULL + ); + DestroyMenu(iconMenu); + + // Destroy the bitmaps. + for (i = 0; i < numberOfProcesses; i++) + { + if (IconProcessBitmaps[i]) + DeleteObject(IconProcessBitmaps[i]); + } + + PhFree(IconProcessBitmaps); + + if (!PhpProcessComputerCommand(id)) + { + switch (id) + { + case ID_ICON_SHOWHIDEPROCESSHACKER: + SendMessage(PhMainWndHandle, WM_PH_TOGGLE_VISIBLE, 0, 0); + break; + case ID_ICON_SYSTEMINFORMATION: + SendMessage(PhMainWndHandle, WM_COMMAND, ID_VIEW_SYSTEMINFORMATION, 0); + break; + case ID_NOTIFICATIONS_ENABLEALL: + NotifyIconNotifyMask |= PH_NOTIFY_VALID_MASK; + break; + case ID_NOTIFICATIONS_DISABLEALL: + NotifyIconNotifyMask &= ~PH_NOTIFY_VALID_MASK; + break; + case ID_NOTIFICATIONS_NEWPROCESSES: + case ID_NOTIFICATIONS_TERMINATEDPROCESSES: + case ID_NOTIFICATIONS_NEWSERVICES: + case ID_NOTIFICATIONS_STARTEDSERVICES: + case ID_NOTIFICATIONS_STOPPEDSERVICES: + case ID_NOTIFICATIONS_DELETEDSERVICES: + { + ULONG bit; + + switch (id) + { + case ID_NOTIFICATIONS_NEWPROCESSES: + bit = PH_NOTIFY_PROCESS_CREATE; + break; + case ID_NOTIFICATIONS_TERMINATEDPROCESSES: + bit = PH_NOTIFY_PROCESS_DELETE; + break; + case ID_NOTIFICATIONS_NEWSERVICES: + bit = PH_NOTIFY_SERVICE_CREATE; + break; + case ID_NOTIFICATIONS_STARTEDSERVICES: + bit = PH_NOTIFY_SERVICE_START; + break; + case ID_NOTIFICATIONS_STOPPEDSERVICES: + bit = PH_NOTIFY_SERVICE_STOP; + break; + case ID_NOTIFICATIONS_DELETEDSERVICES: + bit = PH_NOTIFY_SERVICE_DELETE; + break; + } + + NotifyIconNotifyMask ^= bit; + } + break; + case ID_ICONPROCESS_TERMINATE: + case ID_ICONPROCESS_SUSPEND: + case ID_ICONPROCESS_RESUME: + case ID_ICONPROCESS_PROPERTIES: + { + PPH_PROCESS_ITEM processItem; + + if (processItem = PhReferenceProcessItem(SelectedIconProcessId)) + { + switch (id) + { + case ID_ICONPROCESS_TERMINATE: + PhUiTerminateProcesses(PhMainWndHandle, &processItem, 1); + break; + case ID_ICONPROCESS_SUSPEND: + PhUiSuspendProcesses(PhMainWndHandle, &processItem, 1); + break; + case ID_ICONPROCESS_RESUME: + PhUiResumeProcesses(PhMainWndHandle, &processItem, 1); + break; + case ID_ICONPROCESS_PROPERTIES: + ProcessHacker_ShowProcessProperties(PhMainWndHandle, processItem); + break; + } + + PhDereferenceObject(processItem); + } + else + { + PhShowError(PhMainWndHandle, L"The process does not exist."); + } + } + break; + case ID_ICON_EXIT: + SendMessage(PhMainWndHandle, WM_COMMAND, ID_HACKER_EXIT, 0); + break; + } + } +} + +VOID PhpShowIconNotification( + __in PWSTR Title, + __in PWSTR Text, + __in ULONG Flags + ) +{ + ULONG i; + + // Find a visible icon to display the balloon tip on. + for (i = PH_ICON_MINIMUM; i != PH_ICON_MAXIMUM; i <<= 1) + { + if (NotifyIconMask & i) + { + PhShowBalloonTipNotifyIcon(i, Title, Text, 10, Flags); + break; + } + } +} + PPH_PROCESS_ITEM PhpGetSelectedProcess() { return PhGetSelectedProcessItem(); @@ -3182,6 +3295,29 @@ VOID PhMainWndOnProcessAdded( } PhCreateProcessNode(ProcessItem, RunId); + + if (RunId != 1 && (NotifyIconNotifyMask & PH_NOTIFY_PROCESS_CREATE)) + { + PPH_PROCESS_ITEM parentProcess; + PPH_STRING parentName = NULL; + + if (parentProcess = PhReferenceProcessItem(ProcessItem->ParentProcessId)) + { + parentName = parentProcess->ProcessName; + PhReferenceObject(parentName); + PhDereferenceObject(parentProcess); + } + + PhpShowIconNotification(L"Process Created", PhaFormatString( + L"The process %s (%u) was created by %s (%u)", + ProcessItem->ProcessName->Buffer, + (ULONG)ProcessItem->ProcessId, + PhGetStringOrDefault(parentName, L"Unknown Process"), + (ULONG)ProcessItem->ParentProcessId + )->Buffer, NIIF_INFO); + if (parentName) PhDereferenceObject(parentName); + } + // PhCreateProcessNode has its own reference. PhDereferenceObject(ProcessItem); } @@ -3203,6 +3339,15 @@ VOID PhMainWndOnProcessRemoved( ProcessesNeedsRedraw = TRUE; } + if (NotifyIconNotifyMask & PH_NOTIFY_PROCESS_DELETE) + { + PhpShowIconNotification(L"Process Terminated", PhaFormatString( + L"The process %s (%u) was terminated.", + ProcessItem->ProcessName->Buffer, + (ULONG)ProcessItem->ProcessId + )->Buffer, NIIF_INFO); + } + PhRemoveProcessNode(PhFindProcessNode(ProcessItem->ProcessId)); } @@ -3267,6 +3412,15 @@ VOID PhMainWndOnServiceAdded( PhpSetServiceItemImageIndex(lvItemIndex, ServiceItem); ServicesNeedsSort = TRUE; + + if (RunId != 1 && (NotifyIconNotifyMask & PH_NOTIFY_SERVICE_CREATE)) + { + PhpShowIconNotification(L"Service Created", PhaFormatString( + L"The service %s (%s) has been created.", + ServiceItem->Name->Buffer, + ServiceItem->DisplayName->Buffer + )->Buffer, NIIF_INFO); + } } VOID PhMainWndOnServiceModified( @@ -3291,6 +3445,32 @@ VOID PhMainWndOnServiceModified( PhpSetServiceItemImageIndex(lvItemIndex, ServiceModifiedData->Service); ServicesNeedsSort = TRUE; + + if (NotifyIconNotifyMask & (PH_NOTIFY_SERVICE_START | PH_NOTIFY_SERVICE_STOP)) + { + PH_SERVICE_CHANGE serviceChange; + PPH_SERVICE_ITEM serviceItem; + + serviceChange = PhGetServiceChange(ServiceModifiedData); + serviceItem = ServiceModifiedData->Service; + + if (serviceChange == ServiceStarted && (NotifyIconNotifyMask & PH_NOTIFY_SERVICE_START)) + { + PhpShowIconNotification(L"Service Started", PhaFormatString( + L"The service %s (%s) has been started.", + serviceItem->Name->Buffer, + serviceItem->DisplayName->Buffer + )->Buffer, NIIF_INFO); + } + else if (serviceChange == ServiceStopped && (NotifyIconNotifyMask & PH_NOTIFY_SERVICE_STOP)) + { + PhpShowIconNotification(L"Service Stopped", PhaFormatString( + L"The service %s (%s) has been stopped.", + serviceItem->Name->Buffer, + serviceItem->DisplayName->Buffer + )->Buffer, NIIF_INFO); + } + } } VOID PhMainWndOnServiceRemoved( @@ -3307,6 +3487,16 @@ VOID PhMainWndOnServiceRemoved( ServiceListViewHandle, PhFindListViewItemByParam(ServiceListViewHandle, -1, ServiceItem) ); + + if (NotifyIconNotifyMask & PH_NOTIFY_SERVICE_CREATE) + { + PhpShowIconNotification(L"Service Deleted", PhaFormatString( + L"The service %s (%s) has been deleted.", + ServiceItem->Name->Buffer, + ServiceItem->DisplayName->Buffer + )->Buffer, NIIF_INFO); + } + // Remove the reference we added in PhMainWndOnServiceAdded. PhDereferenceObject(ServiceItem); } diff --git a/2.x/trunk/ProcessHacker/notifico.c b/2.x/trunk/ProcessHacker/notifico.c index 5af9b418b..8337cea85 100644 --- a/2.x/trunk/ProcessHacker/notifico.c +++ b/2.x/trunk/ProcessHacker/notifico.c @@ -69,6 +69,32 @@ VOID PhModifyNotifyIcon( notifyIcon.hIcon = Icon; + if (!Shell_NotifyIcon(NIM_MODIFY, ¬ifyIcon)) + { + // Explorer probably died and we lost our icon. Try to add the icon, and try again. + PhAddNotifyIcon(Id); + Shell_NotifyIcon(NIM_MODIFY, ¬ifyIcon); + } +} + +VOID PhShowBalloonTipNotifyIcon( + __in ULONG Id, + __in PWSTR Title, + __in PWSTR Text, + __in ULONG Timeout, + __in ULONG Flags + ) +{ + NOTIFYICONDATA notifyIcon = { NOTIFYICONDATA_V3_SIZE }; + + notifyIcon.hWnd = PhMainWndHandle; + notifyIcon.uID = Id; + notifyIcon.uFlags = NIF_INFO; + wcscpy_s(notifyIcon.szInfoTitle, sizeof(notifyIcon.szInfoTitle) / sizeof(WCHAR), Title); + wcscpy_s(notifyIcon.szInfo, sizeof(notifyIcon.szInfo) / sizeof(WCHAR), Text); + notifyIcon.uTimeout = Timeout; + notifyIcon.dwInfoFlags = Flags; + Shell_NotifyIcon(NIM_MODIFY, ¬ifyIcon); } @@ -97,14 +123,19 @@ static VOID PhpBeginBitmap( __out HBITMAP *OldBitmap ) { - HDC screenHdc; - HDC hdc; - HBITMAP bitmap; + static BOOLEAN initialized = FALSE; + static HDC hdc; + static HBITMAP bitmap; - screenHdc = GetDC(NULL); - hdc = CreateCompatibleDC(screenHdc); - bitmap = CreateCompatibleBitmap(screenHdc, Width, Height); - ReleaseDC(NULL, screenHdc); + if (!initialized) + { + HDC screenHdc; + + screenHdc = GetDC(NULL); + hdc = CreateCompatibleDC(screenHdc); + bitmap = CreateCompatibleBitmap(screenHdc, Width, Height); + ReleaseDC(NULL, screenHdc); + } *Bitmap = bitmap; *Hdc = hdc; @@ -159,10 +190,7 @@ VOID PhUpdateIconCpuHistory() PhDrawGraph(hdc, &drawInfo); SelectObject(hdc, oldBitmap); - DeleteDC(hdc); - icon = PhBitmapToIcon(bitmap); - DeleteObject(bitmap); // Text @@ -257,10 +285,7 @@ VOID PhUpdateIconIoHistory() PhDrawGraph(hdc, &drawInfo); SelectObject(hdc, oldBitmap); - DeleteDC(hdc); - icon = PhBitmapToIcon(bitmap); - DeleteObject(bitmap); // Text @@ -343,10 +368,7 @@ VOID PhUpdateIconCommitHistory() PhDrawGraph(hdc, &drawInfo); SelectObject(hdc, oldBitmap); - DeleteDC(hdc); - icon = PhBitmapToIcon(bitmap); - DeleteObject(bitmap); // Text @@ -409,10 +431,7 @@ VOID PhUpdateIconPhysicalHistory() PhDrawGraph(hdc, &drawInfo); SelectObject(hdc, oldBitmap); - DeleteDC(hdc); - icon = PhBitmapToIcon(bitmap); - DeleteObject(bitmap); // Text diff --git a/2.x/trunk/ProcessHacker/procprp.c b/2.x/trunk/ProcessHacker/procprp.c index 0a58c41b9..3c8bbfd32 100644 --- a/2.x/trunk/ProcessHacker/procprp.c +++ b/2.x/trunk/ProcessHacker/procprp.c @@ -2455,27 +2455,27 @@ INT_PTR CALLBACK PhpProcessThreadsDlgProc( switch (id) { - case ID_PRIORITY_TIMECRITICAL: - threadPriorityWin32 = THREAD_PRIORITY_TIME_CRITICAL; - break; - case ID_PRIORITY_HIGHEST: - threadPriorityWin32 = THREAD_PRIORITY_HIGHEST; - break; - case ID_PRIORITY_ABOVENORMAL: - threadPriorityWin32 = THREAD_PRIORITY_ABOVE_NORMAL; - break; - case ID_PRIORITY_NORMAL: - threadPriorityWin32 = THREAD_PRIORITY_NORMAL; - break; - case ID_PRIORITY_BELOWNORMAL: - threadPriorityWin32 = THREAD_PRIORITY_BELOW_NORMAL; - break; - case ID_PRIORITY_LOWEST: - threadPriorityWin32 = THREAD_PRIORITY_LOWEST; - break; - case ID_PRIORITY_IDLE: - threadPriorityWin32 = THREAD_PRIORITY_IDLE; - break; + case ID_PRIORITY_TIMECRITICAL: + threadPriorityWin32 = THREAD_PRIORITY_TIME_CRITICAL; + break; + case ID_PRIORITY_HIGHEST: + threadPriorityWin32 = THREAD_PRIORITY_HIGHEST; + break; + case ID_PRIORITY_ABOVENORMAL: + threadPriorityWin32 = THREAD_PRIORITY_ABOVE_NORMAL; + break; + case ID_PRIORITY_NORMAL: + threadPriorityWin32 = THREAD_PRIORITY_NORMAL; + break; + case ID_PRIORITY_BELOWNORMAL: + threadPriorityWin32 = THREAD_PRIORITY_BELOW_NORMAL; + break; + case ID_PRIORITY_LOWEST: + threadPriorityWin32 = THREAD_PRIORITY_LOWEST; + break; + case ID_PRIORITY_IDLE: + threadPriorityWin32 = THREAD_PRIORITY_IDLE; + break; } PhReferenceObject(threadItem); @@ -2497,18 +2497,18 @@ INT_PTR CALLBACK PhpProcessThreadsDlgProc( switch (id) { - case ID_I_0: - ioPriority = 0; - break; - case ID_I_1: - ioPriority = 1; - break; - case ID_I_2: - ioPriority = 2; - break; - case ID_I_3: - ioPriority = 3; - break; + case ID_I_0: + ioPriority = 0; + break; + case ID_I_1: + ioPriority = 1; + break; + case ID_I_2: + ioPriority = 2; + break; + case ID_I_3: + ioPriority = 3; + break; } PhReferenceObject(threadItem); diff --git a/2.x/trunk/ProcessHacker/resource.h b/2.x/trunk/ProcessHacker/resource.h index 2dd6f2dab..6e2866d97 100644 --- a/2.x/trunk/ProcessHacker/resource.h +++ b/2.x/trunk/ProcessHacker/resource.h @@ -493,6 +493,14 @@ #define ID_ICON_SHUTDOWN 40175 #define ID_ICON_COMPUTER 40176 #define ID_PROCESSES_DUMMY 40177 +#define ID_NOTIFICATIONS_ENABLEALL 40178 +#define ID_NOTIFICATIONS_DISABLEALL 40179 +#define ID_NOTIFICATIONS_NEWPROCESSES 40180 +#define ID_NOTIFICATIONS_TERMINATEDPROCESSES 40181 +#define ID_NOTIFICATIONS_NEWSERVICES 40182 +#define ID_NOTIFICATIONS_STARTEDSERVICES 40183 +#define ID_NOTIFICATIONS_STOPPEDSERVICES 40184 +#define ID_NOTIFICATIONS_DELETEDSERVICES 40185 #define IDDYNAMIC 50000 // Next default values for new objects @@ -500,7 +508,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 175 -#define _APS_NEXT_COMMAND_VALUE 40178 +#define _APS_NEXT_COMMAND_VALUE 40186 #define _APS_NEXT_CONTROL_VALUE 1205 #define _APS_NEXT_SYMED_VALUE 119 #endif diff --git a/2.x/trunk/ProcessHacker/settings.c b/2.x/trunk/ProcessHacker/settings.c index 94b07ae88..0670c7e3b 100644 --- a/2.x/trunk/ProcessHacker/settings.c +++ b/2.x/trunk/ProcessHacker/settings.c @@ -50,6 +50,7 @@ VOID PhSettingsInitialization() PhpAddIntegerSetting(L"HideOnMinimize", L"0"); PhpAddIntegerSetting(L"HideUnnamedHandles", L"1"); PhpAddIntegerSetting(L"IconMask", L"1"); // PH_ICON_CPU_HISTORY + PhpAddIntegerSetting(L"IconNotifyMask", L"c"); // PH_NOTIFY_SERVICE_CREATE | PH_NOTIFY_SERVICE_DELETE PhpAddIntegerSetting(L"IconProcesses", L"a"); // 10 PhpAddIntegerSetting(L"MainWindowAlwaysOnTop", L"0"); PhpAddIntegerSetting(L"MainWindowOpacity", L"0"); // means 100%