winepulse: Set pulse master volume to 0 when session is muted.
[wine.git] / dlls / comctl32 / theming.c
blob8078e661b765bc9d12150ede7866f361d43819e0
1 /*
2 * Theming - Initialization
4 * Copyright (c) 2005 by Frank Richter
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <stdarg.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "winuser.h"
28 #include "comctl32.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(theming);
33 typedef LRESULT (CALLBACK* THEMING_SUBCLASSPROC)(HWND, UINT, WPARAM, LPARAM,
34 ULONG_PTR);
36 extern LRESULT CALLBACK THEMING_DialogSubclassProc (HWND, UINT, WPARAM, LPARAM,
37 ULONG_PTR) DECLSPEC_HIDDEN;
38 extern LRESULT CALLBACK THEMING_ScrollbarSubclassProc (HWND, UINT, WPARAM, LPARAM,
39 ULONG_PTR) DECLSPEC_HIDDEN;
41 static const WCHAR dialogClass[] = L"#32770";
43 static const struct ThemingSubclass
45 const WCHAR* className;
46 THEMING_SUBCLASSPROC subclassProc;
47 } subclasses[] = {
48 /* Note: list must be sorted by class name */
49 {dialogClass, THEMING_DialogSubclassProc},
50 {WC_SCROLLBARW, THEMING_ScrollbarSubclassProc}
53 #define NUM_SUBCLASSES (ARRAY_SIZE(subclasses))
55 static WNDPROC originalProcs[NUM_SUBCLASSES];
56 static ATOM atRefDataProp;
57 static ATOM atSubclassProp;
59 /* Generate a number of subclass window procs.
60 * With a single proc alone, we can't really reliably find out the superclass,
61 * so have one for each subclass. The subclass number is also stored in a prop
62 * since it's needed by THEMING_CallOriginalClass(). Then, the subclass
63 * proc and ref data are fetched and the proc called.
65 #define MAKE_SUBCLASS_PROC(N) \
66 static LRESULT CALLBACK subclass_proc ## N (HWND wnd, UINT msg, \
67 WPARAM wParam, LPARAM lParam) \
68 { \
69 LRESULT result; \
70 ULONG_PTR refData; \
71 SetPropW (wnd, (LPCWSTR)MAKEINTATOM(atSubclassProp), (HANDLE)N); \
72 refData = (ULONG_PTR)GetPropW (wnd, (LPCWSTR)MAKEINTATOM(atRefDataProp)); \
73 TRACE ("%d; (%p, %x, %lx, %lx, %lx)\n", N, wnd, msg, wParam, lParam, \
74 refData); \
75 result = subclasses[N].subclassProc (wnd, msg, wParam, lParam, refData);\
76 TRACE ("result = %lx\n", result); \
77 return result; \
80 MAKE_SUBCLASS_PROC(0)
81 MAKE_SUBCLASS_PROC(1)
83 static const WNDPROC subclassProcs[NUM_SUBCLASSES] = {
84 subclass_proc0,
85 subclass_proc1,
88 /***********************************************************************
89 * THEMING_Initialize
91 * Register classes for standard controls that will shadow the system
92 * classes.
94 void THEMING_Initialize (void)
96 unsigned int i;
98 atSubclassProp = GlobalAddAtomW (L"CC32ThemingSubCl");
99 atRefDataProp = GlobalAddAtomW (L"CC32ThemingData");
101 for (i = 0; i < NUM_SUBCLASSES; i++)
103 WNDCLASSEXW class;
105 class.cbSize = sizeof(class);
106 if (!GetClassInfoExW (NULL, subclasses[i].className, &class))
108 ERR("Could not retrieve information for class %s\n",
109 debugstr_w (subclasses[i].className));
110 continue;
112 originalProcs[i] = class.lpfnWndProc;
113 class.lpfnWndProc = subclassProcs[i];
115 if (!class.lpfnWndProc)
117 ERR("Missing proc for class %s\n",
118 debugstr_w (subclasses[i].className));
119 continue;
122 if (!RegisterClassExW (&class))
124 ERR("Could not re-register class %s: %x\n",
125 debugstr_w (subclasses[i].className), GetLastError ());
127 else
129 TRACE("Re-registered class %s\n",
130 debugstr_w (subclasses[i].className));
135 /***********************************************************************
136 * THEMING_Uninitialize
138 * Unregister shadow classes for standard controls.
140 void THEMING_Uninitialize (void)
142 unsigned int i;
144 if (!atSubclassProp) return; /* not initialized */
146 for (i = 0; i < NUM_SUBCLASSES; i++)
148 UnregisterClassW (subclasses[i].className, NULL);
152 /***********************************************************************
153 * THEMING_CallOriginalClass
155 * Determines the original window proc and calls it.
157 LRESULT THEMING_CallOriginalClass (HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
159 INT_PTR subclass = (INT_PTR)GetPropW (wnd, (LPCWSTR)MAKEINTATOM(atSubclassProp));
160 WNDPROC oldProc = originalProcs[subclass];
161 return CallWindowProcW (oldProc, wnd, msg, wParam, lParam);