[EXPLORER][EXPLORER_NEW]
[reactos.git] / reactos / base / applications / taskmgr / taskmgr.c
index ad91758..cf94146 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <precomp.h>
+#include "precomp.h"
+
+#include "perfpage.h"
+#include "about.h"
+#include "affinity.h"
+#include "debug.h"
+#include "priority.h"
 
 #define STATUS_WINDOW   2001
 
@@ -42,6 +48,60 @@ BOOL bInMenuLoop = FALSE;        /* Tells us if we are in the menu loop */
 
 TASKMANAGER_SETTINGS TaskManagerSettings;
 
+////////////////////////////////////////////////////////////////////////////////
+// Taken from WinSpy++ 1.7
+// http://www.catch22.net/software/winspy
+// Copyright (c) 2002 by J Brown
+//
+//
+//     Copied from uxtheme.h
+//  If you have this new header, then delete these and
+//  #include <uxtheme.h> instead!
+//
+#define ETDT_DISABLE        0x00000001
+#define ETDT_ENABLE         0x00000002
+#define ETDT_USETABTEXTURE  0x00000004
+#define ETDT_ENABLETAB      (ETDT_ENABLE  | ETDT_USETABTEXTURE)
+
+// 
+typedef HRESULT (WINAPI * ETDTProc) (HWND, DWORD);
+
+//
+//     Try to call EnableThemeDialogTexture, if uxtheme.dll is present
+//
+BOOL EnableDialogTheme(HWND hwnd)
+{
+    HMODULE hUXTheme;
+    ETDTProc fnEnableThemeDialogTexture;
+
+    hUXTheme = LoadLibraryA("uxtheme.dll");
+
+    if(hUXTheme)
+    {
+        fnEnableThemeDialogTexture = 
+            (ETDTProc)GetProcAddress(hUXTheme, "EnableThemeDialogTexture");
+
+        if(fnEnableThemeDialogTexture)
+        {
+            fnEnableThemeDialogTexture(hwnd, ETDT_ENABLETAB);
+
+            FreeLibrary(hUXTheme);
+            return TRUE;
+        }
+        else
+        {
+            // Failed to locate API!
+            FreeLibrary(hUXTheme);
+            return FALSE;
+        }
+    }
+    else
+    {
+        // Not running under XP? Just fail gracefully
+        return FALSE;
+    }
+}
 
 int APIENTRY wWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
@@ -70,6 +130,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
             SendMessage(hTaskMgr, WM_SYSCOMMAND, SC_RESTORE, 0);
             SetForegroundWindow(hTaskMgr);
         }
+
+        CloseHandle(hMutex);
         return 0;
     }
     else if (!hMutex)
@@ -110,11 +172,18 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
         return -1;
     }
 
+    /*
+     * Set our shutdown parameters: we want to shutdown the very last,
+     * without displaying any end task dialog if needed.
+     */
+    SetProcessShutdownParameters(1, SHUTDOWN_NORETRY);
+
     DialogBoxW(hInst, (LPCWSTR)IDD_TASKMGR_DIALOG, NULL, TaskManagerWndProc);
 
     /* Save our settings to the registry */
     SaveSettings();
     PerfDataUninitialize();
+    CloseHandle(hMutex);
     return 0;
 }
 
@@ -128,7 +197,6 @@ TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
     RECT             rc;
 #endif
     LPRECT           pRC;
-    int              idctrl;
     LPNMHDR          pnmh;
     WINDOWPLACEMENT  wp;
 
@@ -304,7 +372,6 @@ TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
         break;
 
     case WM_NOTIFY:
-        idctrl = (int)wParam;
         pnmh = (LPNMHDR)lParam;
         if ((pnmh->hwndFrom == hTabWnd) &&
             (pnmh->idFrom == IDC_TAB) &&
@@ -492,13 +559,13 @@ BOOL OnCreate(HWND hWnd)
     /* Create tab pages */
     hTabWnd = GetDlgItem(hWnd, IDC_TAB);
 #if 1
-    hApplicationPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_APPLICATION_PAGE), hWnd, ApplicationPageWndProc);
-    hProcessPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PROCESS_PAGE), hWnd, ProcessPageWndProc);
-    hPerformancePage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PERFORMANCE_PAGE), hWnd, PerformancePageWndProc);
+    hApplicationPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_APPLICATION_PAGE), hWnd, ApplicationPageWndProc); EnableDialogTheme(hApplicationPage);
+    hProcessPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PROCESS_PAGE), hWnd, ProcessPageWndProc); EnableDialogTheme(hProcessPage);
+    hPerformancePage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PERFORMANCE_PAGE), hWnd, PerformancePageWndProc); EnableDialogTheme(hPerformancePage);
 #else
-    hApplicationPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_APPLICATION_PAGE), hTabWnd, ApplicationPageWndProc);
-    hProcessPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PROCESS_PAGE), hTabWnd, ProcessPageWndProc);
-    hPerformancePage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PERFORMANCE_PAGE), hTabWnd, PerformancePageWndProc);
+    hApplicationPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_APPLICATION_PAGE), hTabWnd, ApplicationPageWndProc); EnableDialogTheme(hApplicationPage);
+    hProcessPage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PROCESS_PAGE), hTabWnd, ProcessPageWndProc); EnableDialogTheme(hProcessPage);
+    hPerformancePage = CreateDialogW(hInst, MAKEINTRESOURCEW(IDD_PERFORMANCE_PAGE), hTabWnd, PerformancePageWndProc); EnableDialogTheme(hPerformancePage);
 #endif
 
     /* Insert tabs */
@@ -772,11 +839,11 @@ void SaveSettings(void)
 
 void TaskManager_OnRestoreMainWindow(void)
 {
-    HMENU hMenu, hOptionsMenu;
+    //HMENU hMenu, hOptionsMenu;
     BOOL OnTop;
 
-    hMenu = GetMenu(hMainWnd);
-    hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
+    //hMenu = GetMenu(hMainWnd);
+    //hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
     OnTop = ((GetWindowLongPtrW(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0);
 
     OpenIcon(hMainWnd);