2005-07-27 10:54:49 +00: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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-07-27 10:54:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "comctl32.h"
|
2005-10-19 19:08:31 +00:00
|
|
|
#include "uxtheme.h"
|
2005-07-27 10:54:49 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(theming);
|
|
|
|
|
|
|
|
typedef LRESULT (CALLBACK* THEMING_SUBCLASSPROC)(HWND, UINT, WPARAM, LPARAM,
|
|
|
|
ULONG_PTR);
|
|
|
|
|
2005-08-16 19:30:06 +00:00
|
|
|
extern LRESULT CALLBACK THEMING_ComboSubclassProc (HWND, UINT, WPARAM, LPARAM,
|
|
|
|
ULONG_PTR);
|
2005-08-19 10:05:34 +00:00
|
|
|
extern LRESULT CALLBACK THEMING_DialogSubclassProc (HWND, UINT, WPARAM, LPARAM,
|
|
|
|
ULONG_PTR);
|
2005-08-15 10:24:22 +00:00
|
|
|
extern LRESULT CALLBACK THEMING_EditSubclassProc (HWND, UINT, WPARAM, LPARAM,
|
2005-08-16 19:30:06 +00:00
|
|
|
ULONG_PTR);
|
2005-08-18 11:45:43 +00:00
|
|
|
extern LRESULT CALLBACK THEMING_ListBoxSubclassProc (HWND, UINT, WPARAM, LPARAM,
|
|
|
|
ULONG_PTR);
|
|
|
|
|
2005-08-19 10:05:34 +00:00
|
|
|
static const WCHAR dialogClass[] = {'#','3','2','7','7','0',0};
|
2005-08-18 11:45:43 +00:00
|
|
|
static const WCHAR comboLboxClass[] = {'C','o','m','b','o','L','b','o','x',0};
|
2005-08-15 10:24:22 +00:00
|
|
|
|
2005-07-27 10:54:49 +00:00
|
|
|
static const struct ThemingSubclass
|
|
|
|
{
|
|
|
|
const WCHAR* className;
|
|
|
|
THEMING_SUBCLASSPROC subclassProc;
|
|
|
|
} subclasses[] = {
|
|
|
|
/* Note: list must be sorted by class name */
|
2005-08-19 10:05:34 +00:00
|
|
|
{dialogClass, THEMING_DialogSubclassProc},
|
2005-08-16 19:30:06 +00:00
|
|
|
{WC_COMBOBOXW, THEMING_ComboSubclassProc},
|
2005-08-18 11:45:43 +00:00
|
|
|
{comboLboxClass, THEMING_ListBoxSubclassProc},
|
|
|
|
{WC_EDITW, THEMING_EditSubclassProc},
|
|
|
|
{WC_LISTBOXW, THEMING_ListBoxSubclassProc}
|
2005-07-27 10:54:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define NUM_SUBCLASSES (sizeof(subclasses)/sizeof(subclasses[0]))
|
|
|
|
|
|
|
|
static WNDPROC originalProcs[NUM_SUBCLASSES];
|
|
|
|
static ATOM atRefDataProp;
|
|
|
|
static ATOM atSubclassProp;
|
|
|
|
|
2005-08-12 15:52:56 +00: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 13:57:49 +00:00
|
|
|
* so have one for each subclass. The subclass number is also stored in a prop
|
2007-10-23 13:30:30 +00:00
|
|
|
* since it's needed by THEMING_CallOriginalClass(). Then, the subclass
|
2005-08-19 13:57:49 +00:00
|
|
|
* proc and ref data are fetched and the proc called.
|
2005-08-12 15:52:56 +00:00
|
|
|
*/
|
2005-08-19 13:57:49 +00:00
|
|
|
#define MAKE_SUBCLASS_PROC(N) \
|
|
|
|
static LRESULT CALLBACK subclass_proc ## N (HWND wnd, UINT msg, \
|
2005-08-12 15:52:56 +00:00
|
|
|
WPARAM wParam, LPARAM lParam) \
|
|
|
|
{ \
|
2005-08-19 13:57:49 +00:00
|
|
|
LRESULT result; \
|
|
|
|
ULONG_PTR refData; \
|
2006-11-08 00:19:02 +00:00
|
|
|
SetPropW (wnd, (LPCWSTR)MAKEINTATOM(atSubclassProp), (HANDLE)N); \
|
|
|
|
refData = (ULONG_PTR)GetPropW (wnd, (LPCWSTR)MAKEINTATOM(atRefDataProp)); \
|
2007-05-24 14:41:17 +00:00
|
|
|
TRACE ("%d; (%p, %x, %lx, %lx, %lx)\n", N, wnd, msg, wParam, lParam, \
|
2005-08-19 13:57:49 +00:00
|
|
|
refData); \
|
|
|
|
result = subclasses[N].subclassProc (wnd, msg, wParam, lParam, refData);\
|
|
|
|
TRACE ("result = %lx\n", result); \
|
|
|
|
return result; \
|
2005-08-12 15:52:56 +00:00
|
|
|
}
|
|
|
|
|
2005-08-19 13:57:49 +00:00
|
|
|
MAKE_SUBCLASS_PROC(0)
|
|
|
|
MAKE_SUBCLASS_PROC(1)
|
|
|
|
MAKE_SUBCLASS_PROC(2)
|
|
|
|
MAKE_SUBCLASS_PROC(3)
|
|
|
|
MAKE_SUBCLASS_PROC(4)
|
|
|
|
|
2005-10-06 11:38:45 +00:00
|
|
|
static const WNDPROC subclassProcs[NUM_SUBCLASSES] = {
|
2005-08-19 13:57:49 +00:00
|
|
|
subclass_proc0,
|
|
|
|
subclass_proc1,
|
|
|
|
subclass_proc2,
|
|
|
|
subclass_proc3,
|
|
|
|
subclass_proc4
|
2005-08-12 15:52:56 +00:00
|
|
|
};
|
|
|
|
|
2005-07-27 10:54:49 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* THEMING_Initialize
|
|
|
|
*
|
|
|
|
* Register classes for standard controls that will shadow the system
|
|
|
|
* classes.
|
|
|
|
*/
|
|
|
|
void THEMING_Initialize (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
static const WCHAR subclassPropName[] =
|
|
|
|
{ 'C','C','3','2','T','h','e','m','i','n','g','S','u','b','C','l',0 };
|
|
|
|
static const WCHAR refDataPropName[] =
|
|
|
|
{ 'C','C','3','2','T','h','e','m','i','n','g','D','a','t','a',0 };
|
|
|
|
|
2005-10-19 19:08:31 +00:00
|
|
|
if (!IsThemeActive()) return;
|
|
|
|
|
2005-07-27 10:54:49 +00:00
|
|
|
atSubclassProp = GlobalAddAtomW (subclassPropName);
|
|
|
|
atRefDataProp = GlobalAddAtomW (refDataPropName);
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_SUBCLASSES; i++)
|
|
|
|
{
|
|
|
|
WNDCLASSEXW class;
|
|
|
|
|
|
|
|
class.cbSize = sizeof(class);
|
|
|
|
class.style |= CS_GLOBALCLASS;
|
|
|
|
GetClassInfoExW (NULL, subclasses[i].className, &class);
|
|
|
|
originalProcs[i] = class.lpfnWndProc;
|
2005-08-19 13:57:49 +00:00
|
|
|
class.lpfnWndProc = subclassProcs[i];
|
2005-08-12 15:52:56 +00:00
|
|
|
|
|
|
|
if (!class.lpfnWndProc)
|
|
|
|
{
|
2005-08-19 13:57:49 +00:00
|
|
|
ERR("Missing proc for class %s\n",
|
2005-08-12 15:52:56 +00:00
|
|
|
debugstr_w (subclasses[i].className));
|
|
|
|
continue;
|
|
|
|
}
|
2005-07-27 10:54:49 +00:00
|
|
|
|
|
|
|
if (!RegisterClassExW (&class))
|
|
|
|
{
|
2006-10-13 13:34:21 +00:00
|
|
|
ERR("Could not re-register class %s: %x\n",
|
2005-07-27 10:54:49 +00:00
|
|
|
debugstr_w (subclasses[i].className), GetLastError ());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Re-registered class %s\n",
|
|
|
|
debugstr_w (subclasses[i].className));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-12 11:10:58 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* THEMING_Uninitialize
|
|
|
|
*
|
|
|
|
* Unregister shadow classes for standard controls.
|
|
|
|
*/
|
|
|
|
void THEMING_Uninitialize (void)
|
|
|
|
{
|
|
|
|
int i;
|
2005-10-19 19:08:31 +00:00
|
|
|
|
|
|
|
if (!atSubclassProp) return; /* not initialized */
|
|
|
|
|
2005-09-12 11:10:58 +00:00
|
|
|
for (i = 0; i < NUM_SUBCLASSES; i++)
|
|
|
|
{
|
|
|
|
UnregisterClassW (subclasses[i].className, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-27 10:54:49 +00: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 00:19:02 +00:00
|
|
|
INT_PTR subclass = (INT_PTR)GetPropW (wnd, (LPCWSTR)MAKEINTATOM(atSubclassProp));
|
2005-07-27 10:54:49 +00:00
|
|
|
WNDPROC oldProc = originalProcs[subclass];
|
|
|
|
return CallWindowProcW (oldProc, wnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* THEMING_SetSubclassData
|
|
|
|
*
|
|
|
|
* Update the "refData" value of the subclassed window.
|
|
|
|
*/
|
|
|
|
void THEMING_SetSubclassData (HWND wnd, ULONG_PTR refData)
|
|
|
|
{
|
2006-11-08 00:19:02 +00:00
|
|
|
SetPropW (wnd, (LPCWSTR)MAKEINTATOM(atRefDataProp), (HANDLE)refData);
|
2005-07-27 10:54:49 +00:00
|
|
|
}
|