[MSCONFIG_NEW]

Enable Win7-like theming when applicable.

svn path=/trunk/; revision=69723
This commit is contained in:
Hermès Bélusca-Maïto 2015-10-27 21:22:17 +00:00
parent 28c1e663f3
commit 62bd2d4195
6 changed files with 138 additions and 58 deletions

View file

@ -11,6 +11,7 @@ include_directories(
list(APPEND C_SOURCE
comctl32ex/listviewfuncs.c
comctl32ex/uxthemesupp.c
fileextractdialog.c
fileutils.c
freeldrpage.c

View file

@ -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);
}

View file

@ -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_

View 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)
{

View file

@ -10,10 +10,11 @@
#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.

View 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.