[MSCONFIG_NEW]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 27 Oct 2015 21:22:17 +0000 (21:22 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 27 Oct 2015 21:22:17 +0000 (21:22 +0000)
Enable Win7-like theming when applicable.

svn path=/trunk/; revision=69723

reactos/base/applications/msconfig_new/CMakeLists.txt
reactos/base/applications/msconfig_new/comctl32ex/uxthemesupp.c [new file with mode: 0644]
reactos/base/applications/msconfig_new/comctl32ex/uxthemesupp.h [new file with mode: 0644]
reactos/base/applications/msconfig_new/msconfig.c
reactos/base/applications/msconfig_new/srvpage.cpp
reactos/base/applications/msconfig_new/toolspage.cpp

index 6a11f88..a799820 100644 (file)
@@ -11,6 +11,7 @@ include_directories(
 
 list(APPEND C_SOURCE
     comctl32ex/listviewfuncs.c
+    comctl32ex/uxthemesupp.c
     fileextractdialog.c
     fileutils.c
     freeldrpage.c
diff --git a/reactos/base/applications/msconfig_new/comctl32ex/uxthemesupp.c b/reactos/base/applications/msconfig_new/comctl32ex/uxthemesupp.c
new file mode 100644 (file)
index 0000000..b820732
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * PROJECT:     ReactOS Applications
+ * LICENSE:     LGPL - See COPYING in the top level directory
+ * FILE:        base/applications/msconfig_new/comctl32ex/uxthemesupp.c
+ * PURPOSE:     UX Theming helpers.
+ * COPYRIGHT:   Copyright 2015 Hermes BELUSCA - MAITO <hermes.belusca@sfr.fr>
+ */
+
+#include "precomp.h"
+#include "uxthemesupp.h"
+
+static HMODULE hUxTheme = NULL;
+
+static BOOL
+InitUxTheme(VOID)
+{
+    static BOOL Initialized = FALSE;
+
+    if (Initialized) return TRUE;
+
+    hUxTheme = LoadLibraryW(L"uxtheme.dll");
+    if (hUxTheme == NULL) return FALSE;
+
+    Initialized = TRUE;
+    return TRUE;
+}
+
+static VOID
+CleanupUxTheme(VOID)
+{
+    FreeLibrary(hUxTheme);
+    hUxTheme = NULL;
+    // Initialized = FALSE;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Taken from WinSpy++ 1.7
+// http://www.catch22.net/software/winspy
+// Copyright (c) 2002 by J Brown
+//
+
+typedef HRESULT (WINAPI* ETDTProc)(HWND, DWORD);
+
+HRESULT
+WINAPI
+EnableThemeDialogTexture(_In_ HWND  hwnd,
+                         _In_ DWORD dwFlags)
+{
+    ETDTProc fnEnableThemeDialogTexture;
+
+    if (!InitUxTheme())
+        return HRESULT_FROM_WIN32(GetLastError());
+
+    fnEnableThemeDialogTexture =
+        (ETDTProc)GetProcAddress(hUxTheme, "EnableThemeDialogTexture");
+    if (!fnEnableThemeDialogTexture)
+        return HRESULT_FROM_WIN32(GetLastError());
+
+    return fnEnableThemeDialogTexture(hwnd, dwFlags);
+}
+
+
+typedef HRESULT (WINAPI* SWTProc)(HWND, LPCWSTR, LPCWSTR);
+
+HRESULT
+WINAPI
+SetWindowTheme(_In_ HWND    hwnd,
+               _In_ LPCWSTR pszSubAppName,
+               _In_ LPCWSTR pszSubIdList)
+{
+    SWTProc fnSetWindowTheme;
+
+    if (!InitUxTheme())
+        return HRESULT_FROM_WIN32(GetLastError());
+
+    fnSetWindowTheme =
+        (SWTProc)GetProcAddress(hUxTheme, "SetWindowTheme");
+    if (!fnSetWindowTheme)
+        return HRESULT_FROM_WIN32(GetLastError());
+
+    return fnSetWindowTheme(hwnd, pszSubAppName, pszSubIdList);
+}
diff --git a/reactos/base/applications/msconfig_new/comctl32ex/uxthemesupp.h b/reactos/base/applications/msconfig_new/comctl32ex/uxthemesupp.h
new file mode 100644 (file)
index 0000000..e372e85
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * PROJECT:     ReactOS Applications
+ * LICENSE:     LGPL - See COPYING in the top level directory
+ * FILE:        base/applications/msconfig_new/comctl32ex/uxthemesupp.c
+ * PURPOSE:     UX Theming helpers.
+ * COPYRIGHT:   Copyright 2015 Hermes BELUSCA - MAITO <hermes.belusca@sfr.fr>
+ */
+
+#ifndef _UXTHEMESUPP_H_
+#define _UXTHEMESUPP_H_
+
+#pragma once
+
+#if defined(_UXTHEME_H) || defined(_UXTHEME_H_) // First one is our headers from Wine/MinGW, second one is MS PSDK
+#warning "PSDK header uxtheme.h is already included, you might think about using it instead!"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//
+//  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)
+
+HRESULT
+WINAPI
+EnableThemeDialogTexture(_In_ HWND  hwnd,
+                         _In_ DWORD dwFlags);
+
+HRESULT
+WINAPI
+SetWindowTheme(_In_ HWND    hwnd,
+               _In_ LPCWSTR pszSubAppName,
+               _In_ LPCWSTR pszSubIdList);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _UXTHEMESUPP_H_
index 83acfbf..3b159ad 100644 (file)
@@ -46,61 +46,6 @@ HICON   hIcon          = NULL;
 WNDPROC wpOrigEditProc = NULL;
 
 
-////////////////////////////////////////////////////////////////////////////////
-// 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 = LoadLibrary(_T("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;
-    }
-}
-
 /* About Box dialog */
 INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 {
index 9fa77b2..a88c8b2 100644 (file)
 
 #include "precomp.h"
 #include "utils.h"
-#include "listviewfuncs.h"
 #include "regutils.h"
 #include "stringutils.h"
 // #include "CmdLineParser.h"
+#include "listviewfuncs.h"
+#include "uxthemesupp.h"
 
 #include <winsvc.h>
 
@@ -666,7 +667,7 @@ ServicesPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
             //
             DWORD dwStyle = ListView_GetExtendedListViewStyle(hServicesListCtrl);
             ListView_SetExtendedListViewStyle(hServicesListCtrl, dwStyle | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
-            /** SetWindowTheme(hServicesListCtrl, _T("Explorer"), NULL); // TODO: activate this only if Windows >= XP **/
+            SetWindowTheme(hServicesListCtrl, L"Explorer", NULL);
 
             //
             // Initialize the application page's controls.
index 4cd5715..746be91 100644 (file)
@@ -11,6 +11,7 @@
 #include "xmldomparser.hpp"
 #include "utils.h"
 #include "listviewfuncs.h"
+#include "uxthemesupp.h"
 
 static HWND hToolsPage     = NULL;
 static HWND hToolsListCtrl = NULL;
@@ -330,7 +331,7 @@ ToolsPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
             //
             DWORD dwStyle = ListView_GetExtendedListViewStyle(hToolsListCtrl);
             ListView_SetExtendedListViewStyle(hToolsListCtrl, dwStyle | LVS_EX_FULLROWSELECT);
-            /** SetWindowTheme(hToolsListCtrl, _T("Explorer"), NULL); // TODO: activate this only if Windows >= XP **/
+            SetWindowTheme(hToolsListCtrl, L"Explorer", NULL);
 
             //
             // Initialize the application page's controls.