2005-07-27 12:54:49 +02:00
|
|
|
/*
|
|
|
|
* Theming - Initialization
|
|
|
|
*
|
|
|
|
* Copyright (c) 2005 by Frank Richter
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-07-27 12:54:49 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "comctl32.h"
|
2005-10-19 21:08:31 +02:00
|
|
|
#include "uxtheme.h"
|
2005-07-27 12:54:49 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(theming);
|
|
|
|
|
|
|
|
typedef LRESULT (CALLBACK* THEMING_SUBCLASSPROC)(HWND, UINT, WPARAM, LPARAM,
|
|
|
|
ULONG_PTR);
|
|
|
|
|
2005-08-19 12:05:34 +02:00
|
|
|
extern LRESULT CALLBACK THEMING_DialogSubclassProc (HWND, UINT, WPARAM, LPARAM,
|
2011-05-13 16:34:26 +02:00
|
|
|
ULONG_PTR) DECLSPEC_HIDDEN;
|
2015-02-15 17:10:10 +01:00
|
|
|
extern LRESULT CALLBACK THEMING_ScrollbarSubclassProc (HWND, UINT, WPARAM, LPARAM,
|
|
|
|
ULONG_PTR) DECLSPEC_HIDDEN;
|
2005-08-18 13:45:43 +02:00
|
|
|
|
2020-11-16 15:26:34 +01:00
|
|
|
static const WCHAR dialogClass[] = L"#32770";
|
2005-08-15 12:24:22 +02:00
|
|
|
|
2005-07-27 12:54:49 +02:00
|
|
|
static const struct ThemingSubclass
|
|
|
|
{
|
|
|
|
const WCHAR* className;
|
|
|
|
THEMING_SUBCLASSPROC subclassProc;
|
|
|
|
} subclasses[] = {
|
|
|
|
/* Note: list must be sorted by class name */
|
2005-08-19 12:05:34 +02:00
|
|
|
{dialogClass, THEMING_DialogSubclassProc},
|
2015-02-15 17:10:10 +01:00
|
|
|
{WC_SCROLLBARW, THEMING_ScrollbarSubclassProc}
|
2005-07-27 12:54:49 +02:00
|
|
|
};
|
|
|
|
|
2018-02-26 23:29:13 +01:00
|
|
|
#define NUM_SUBCLASSES (ARRAY_SIZE(subclasses))
|
2005-07-27 12:54:49 +02:00
|
|
|
|
|
|
|
static WNDPROC originalProcs[NUM_SUBCLASSES];
|
|
|
|
static ATOM atRefDataProp;
|
|
|
|
static ATOM atSubclassProp;
|
|
|
|
|
2005-08-12 17:52:56 +02:00
|
|
|
/* Generate a number of subclass window procs.
|
|
|
|
* With a single proc alone, we can't really reliably find out the superclass,
|
2005-08-19 15:57:49 +02:00
|
|
|
* so have one for each subclass. The subclass number is also stored in a prop
|
2007-10-23 15:30:30 +02:00
|
|
|
* since it's needed by THEMING_CallOriginalClass(). Then, the subclass
|
2005-08-19 15:57:49 +02:00
|
|
|
* proc and ref data are fetched and the proc called.
|
2005-08-12 17:52:56 +02:00
|
|
|
*/
|
2005-08-19 15:57:49 +02:00
|
|
|
#define MAKE_SUBCLASS_PROC(N) \
|
|
|
|
static LRESULT CALLBACK subclass_proc ## N (HWND wnd, UINT msg, \
|
2005-08-12 17:52:56 +02:00
|
|
|
WPARAM wParam, LPARAM lParam) \
|
|
|
|
{ \
|
2005-08-19 15:57:49 +02:00
|
|
|
LRESULT result; \
|
|
|
|
ULONG_PTR refData; \
|
2006-11-08 01:19:02 +01:00
|
|
|
SetPropW (wnd, (LPCWSTR)MAKEINTATOM(atSubclassProp), (HANDLE)N); \
|
|
|
|
refData = (ULONG_PTR)GetPropW (wnd, (LPCWSTR)MAKEINTATOM(atRefDataProp)); \
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE ("%d; (%p, %x, %lx, %lx, %lx)\n", N, wnd, msg, wParam, lParam, \
|
2005-08-19 15:57:49 +02:00
|
|
|
refData); \
|
|
|
|
result = subclasses[N].subclassProc (wnd, msg, wParam, lParam, refData);\
|
|
|
|
TRACE ("result = %lx\n", result); \
|
|
|
|
return result; \
|
2005-08-12 17:52:56 +02:00
|
|
|
}
|
|
|
|
|
2005-08-19 15:57:49 +02:00
|
|
|
MAKE_SUBCLASS_PROC(0)
|
|
|
|
MAKE_SUBCLASS_PROC(1)
|
|
|
|
|
2005-10-06 13:38:45 +02:00
|
|
|
static const WNDPROC subclassProcs[NUM_SUBCLASSES] = {
|
2005-08-19 15:57:49 +02:00
|
|
|
subclass_proc0,
|
|
|
|
subclass_proc1,
|
2005-08-12 17:52:56 +02:00
|
|
|
};
|
|
|
|
|
2005-07-27 12:54:49 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* THEMING_Initialize
|
|
|
|
*
|
|
|
|
* Register classes for standard controls that will shadow the system
|
|
|
|
* classes.
|
|
|
|
*/
|
|
|
|
void THEMING_Initialize (void)
|
|
|
|
{
|
2008-09-20 23:29:32 +02:00
|
|
|
unsigned int i;
|
2005-07-27 12:54:49 +02:00
|
|
|
|
2005-10-19 21:08:31 +02:00
|
|
|
if (!IsThemeActive()) return;
|
|
|
|
|
2020-11-16 15:26:34 +01:00
|
|
|
atSubclassProp = GlobalAddAtomW (L"CC32ThemingSubCl");
|
|
|
|
atRefDataProp = GlobalAddAtomW (L"CC32ThemingData");
|
2005-07-27 12:54:49 +02:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_SUBCLASSES; i++)
|
|
|
|
{
|
|
|
|
WNDCLASSEXW class;
|
|
|
|
|
|
|
|
class.cbSize = sizeof(class);
|
2011-12-15 15:41:10 +01:00
|
|
|
if (!GetClassInfoExW (NULL, subclasses[i].className, &class))
|
|
|
|
{
|
|
|
|
ERR("Could not retrieve information for class %s\n",
|
|
|
|
debugstr_w (subclasses[i].className));
|
|
|
|
continue;
|
|
|
|
}
|
2005-07-27 12:54:49 +02:00
|
|
|
originalProcs[i] = class.lpfnWndProc;
|
2005-08-19 15:57:49 +02:00
|
|
|
class.lpfnWndProc = subclassProcs[i];
|
2005-08-12 17:52:56 +02:00
|
|
|
|
|
|
|
if (!class.lpfnWndProc)
|
|
|
|
{
|
2005-08-19 15:57:49 +02:00
|
|
|
ERR("Missing proc for class %s\n",
|
2005-08-12 17:52:56 +02:00
|
|
|
debugstr_w (subclasses[i].className));
|
|
|
|
continue;
|
|
|
|
}
|
2005-07-27 12:54:49 +02:00
|
|
|
|
|
|
|
if (!RegisterClassExW (&class))
|
|
|
|
{
|
2006-10-13 15:34:21 +02:00
|
|
|
ERR("Could not re-register class %s: %x\n",
|
2005-07-27 12:54:49 +02:00
|
|
|
debugstr_w (subclasses[i].className), GetLastError ());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Re-registered class %s\n",
|
|
|
|
debugstr_w (subclasses[i].className));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-12 13:10:58 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* THEMING_Uninitialize
|
|
|
|
*
|
|
|
|
* Unregister shadow classes for standard controls.
|
|
|
|
*/
|
|
|
|
void THEMING_Uninitialize (void)
|
|
|
|
{
|
2008-09-20 23:29:32 +02:00
|
|
|
unsigned int i;
|
2005-10-19 21:08:31 +02:00
|
|
|
|
|
|
|
if (!atSubclassProp) return; /* not initialized */
|
|
|
|
|
2005-09-12 13:10:58 +02:00
|
|
|
for (i = 0; i < NUM_SUBCLASSES; i++)
|
|
|
|
{
|
|
|
|
UnregisterClassW (subclasses[i].className, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-27 12:54:49 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* THEMING_CallOriginalClass
|
|
|
|
*
|
|
|
|
* Determines the original window proc and calls it.
|
|
|
|
*/
|
|
|
|
LRESULT THEMING_CallOriginalClass (HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2006-11-08 01:19:02 +01:00
|
|
|
INT_PTR subclass = (INT_PTR)GetPropW (wnd, (LPCWSTR)MAKEINTATOM(atSubclassProp));
|
2005-07-27 12:54:49 +02:00
|
|
|
WNDPROC oldProc = originalProcs[subclass];
|
|
|
|
return CallWindowProcW (oldProc, wnd, msg, wParam, lParam);
|
|
|
|
}
|