ReactOS 0.4.15-dev-7918-g2a2556c
themehooks.c File Reference
#include "uxthemep.h"
Include dependency graph for themehooks.c:

Go to the source code of this file.

Typedefs

typedef BOOL(WINAPIPREGISTER_UAH_WINXP) (HINSTANCE hInstance, USERAPIHOOKPROC CallbackFunc)
 
typedef BOOL(WINAPIPREGISTER_UUAH_WIN2003) (PUSERAPIHOOKINFO puah)
 

Functions

PWND_DATA ThemeGetWndData (HWND hWnd)
 
void ThemeDestroyWndData (HWND hWnd)
 
HTHEME GetNCCaptionTheme (HWND hWnd, DWORD style)
 
HTHEME GetNCScrollbarTheme (HWND hWnd, DWORD style)
 
static BOOL CALLBACK ThemeCleanupChildWndContext (HWND hWnd, LPARAM msg)
 
static BOOL CALLBACK ThemeCleanupWndContext (HWND hWnd, LPARAM msg)
 
void SetThemeRegion (HWND hWnd)
 
int OnPostWinPosChanged (HWND hWnd, WINDOWPOS *pWinPos)
 
static LRESULT CALLBACK ThemeDefWindowProcW (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK ThemeDefWindowProcA (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK ThemePreWindowProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret, PDWORD unknown)
 
static LRESULT CALLBACK ThemePostWindowProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret, PDWORD unknown)
 
HRESULT GetDiaogTextureBrush (HTHEME theme, HWND hwnd, HDC hdc, HBRUSH *result, BOOL changeOrigin)
 
void HackFillStaticBg (HWND hwnd, HDC hdc, HBRUSH *result)
 
static LRESULT CALLBACK ThemeDlgPreWindowProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret, PDWORD unknown)
 
static LRESULT CALLBACK ThemeDlgPostWindowProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret, PDWORD unknown)
 
int WINAPI ThemeSetWindowRgn (HWND hWnd, HRGN hRgn, BOOL bRedraw)
 
BOOL WINAPI ThemeGetScrollInfo (HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
 
INT WINAPI ThemeSetScrollInfo (HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
 
BOOL CALLBACK ThemeInitApiHook (UAPIHK State, PUSERAPIHOOK puah)
 
BOOL WINAPI ThemeHooksInstall ()
 
BOOL WINAPI ThemeHooksRemove ()
 
INT WINAPI ClassicSystemParametersInfoW (UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
 
INT WINAPI ClassicSystemParametersInfoA (UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
 
INT WINAPI ClassicGetSystemMetrics (int nIndex)
 
BOOL WINAPI ClassicAdjustWindowRectEx (LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)
 

Variables

USERAPIHOOK g_user32ApiHook
 
BYTE gabDWPmessages [UAHOWP_MAX_SIZE]
 
BYTE gabMSGPmessages [UAHOWP_MAX_SIZE]
 
BYTE gabDLGPmessages [UAHOWP_MAX_SIZE]
 
BOOL g_bThemeHooksActive = FALSE
 

Typedef Documentation

◆ PREGISTER_UAH_WINXP

typedef BOOL(WINAPI * PREGISTER_UAH_WINXP) (HINSTANCE hInstance, USERAPIHOOKPROC CallbackFunc)

Definition at line 689 of file themehooks.c.

◆ PREGISTER_UUAH_WIN2003

typedef BOOL(WINAPI * PREGISTER_UUAH_WIN2003) (PUSERAPIHOOKINFO puah)

Definition at line 690 of file themehooks.c.

Function Documentation

◆ ClassicAdjustWindowRectEx()

BOOL WINAPI ClassicAdjustWindowRectEx ( LPRECT  lpRect,
DWORD  dwStyle,
BOOL  bMenu,
DWORD  dwExStyle 
)

Definition at line 776 of file themehooks.c.

777{
779 {
780 return g_user32ApiHook.AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
781 }
782
783 return AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
784}
ADJUSTWINDOWRECTEX AdjustWindowRectEx
Definition: undocuser.h:345
USERAPIHOOK g_user32ApiHook
Definition: themehooks.c:11
BOOL g_bThemeHooksActive
Definition: themehooks.c:15
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)

◆ ClassicGetSystemMetrics()

INT WINAPI ClassicGetSystemMetrics ( int  nIndex)

Definition at line 766 of file themehooks.c.

767{
769 {
770 return g_user32ApiHook.GetSystemMetrics(nIndex);
771 }
772
773 return GetSystemMetrics(nIndex);
774}
GETSYSTEMMETRICS GetSystemMetrics
Definition: undocuser.h:353
int WINAPI GetSystemMetrics(_In_ int)

◆ ClassicSystemParametersInfoA()

INT WINAPI ClassicSystemParametersInfoA ( UINT  uiAction,
UINT  uiParam,
PVOID  pvParam,
UINT  fWinIni 
)

Definition at line 756 of file themehooks.c.

757{
759 {
760 return g_user32ApiHook.SystemParametersInfoA(uiAction, uiParam, pvParam, fWinIni);
761 }
762
763 return SystemParametersInfoA(uiAction, uiParam, pvParam, fWinIni);
764}
SYSTEMPARAMETERSINFOA SystemParametersInfoA
Definition: undocuser.h:354
BOOL WINAPI SystemParametersInfoA(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)

◆ ClassicSystemParametersInfoW()

INT WINAPI ClassicSystemParametersInfoW ( UINT  uiAction,
UINT  uiParam,
PVOID  pvParam,
UINT  fWinIni 
)

Definition at line 746 of file themehooks.c.

747{
749 {
750 return g_user32ApiHook.SystemParametersInfoW(uiAction, uiParam, pvParam, fWinIni);
751 }
752
753 return SystemParametersInfoW(uiAction, uiParam, pvParam, fWinIni);
754}
SYSTEMPARAMETERSINFOW SystemParametersInfoW
Definition: undocuser.h:355
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)

◆ GetDiaogTextureBrush()

HRESULT GetDiaogTextureBrush ( HTHEME  theme,
HWND  hwnd,
HDC  hdc,
HBRUSH *  result,
BOOL  changeOrigin 
)

Definition at line 402 of file themehooks.c.

403{
404 PWND_DATA pwndData;
405
406 pwndData = ThemeGetWndData(hwnd);
407 if (pwndData == NULL)
408 return E_FAIL;
409
410 if (pwndData->hTabBackgroundBrush == NULL)
411 {
413 RECT dummy, bmpRect;
414 BOOL hasImageAlpha;
415 HRESULT hr;
416
417 hr = UXTHEME_LoadImage(theme, 0, TABP_BODY, 0, &dummy, FALSE, &hbmp, &bmpRect, &hasImageAlpha);
418 if (FAILED(hr))
419 return hr;
420
421 if (changeOrigin)
422 {
423 /* Unfortunately SetBrushOrgEx doesn't work at all */
424 RECT rcWindow, rcParent;
425 UINT y;
426 HDC hdcPattern, hdcHackPattern;
427 HBITMAP hbmpOld1, hbmpold2, hbmpHack;
428
429 GetWindowRect(hwnd, &rcWindow);
430 GetWindowRect(GetParent(hwnd), &rcParent);
431 y = (rcWindow.top - rcParent.top) % bmpRect.bottom;
432
433 hdcPattern = CreateCompatibleDC(hdc);
434 hbmpOld1 = (HBITMAP)SelectObject(hdcPattern, hbmp);
435
436 hdcHackPattern = CreateCompatibleDC(hdc);
437 hbmpHack = CreateCompatibleBitmap(hdc, bmpRect.right, bmpRect.bottom);
438 hbmpold2 = (HBITMAP)SelectObject(hdcHackPattern, hbmpHack);
439
440 BitBlt(hdcHackPattern, 0, 0, bmpRect.right, bmpRect.bottom - y, hdcPattern, 0, y, SRCCOPY);
441 BitBlt(hdcHackPattern, 0, bmpRect.bottom - y, bmpRect.right, y, hdcPattern, 0, 0, SRCCOPY);
442
443 hbmpold2 = (HBITMAP)SelectObject(hdcHackPattern, hbmpold2);
444 hbmpOld1 = (HBITMAP)SelectObject(hdcPattern, hbmpOld1);
445
446 DeleteDC(hdcPattern);
447 DeleteDC(hdcHackPattern);
448
449 /* Keep the handle of the bitmap we created so that it can be used later */
450 pwndData->hTabBackgroundBmp = hbmpHack;
451 hbmp = hbmpHack;
452 }
453
454 /* hbmp is cached so there is no need to free it */
456 }
457
458 if (!pwndData->hTabBackgroundBrush)
459 return E_FAIL;
460
461 *result = pwndData->hTabBackgroundBrush;
462 return S_OK;
463}
HBITMAP hbmp
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
HRESULT UXTHEME_LoadImage(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, BOOL glyph, HBITMAP *hBmp, RECT *bmpRect, BOOL *hasImageAlpha)
Definition: draw.c:230
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
unsigned int BOOL
Definition: ntddk_ex.h:94
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint64EXT * result
Definition: glext.h:11304
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
unsigned int UINT
Definition: ndis.h:50
HRESULT hr
Definition: shlfolder.c:183
HBRUSH hTabBackgroundBrush
Definition: uxthemep.h:176
HBITMAP hTabBackgroundBmp
Definition: uxthemep.h:177
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
PWND_DATA ThemeGetWndData(HWND hWnd)
Definition: themehooks.c:17
@ TABP_BODY
Definition: vsstyle.h:1227
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
BOOL WINAPI DeleteDC(_In_ HDC)
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)

Referenced by ThemeDlgPostWindowProc().

◆ GetNCCaptionTheme()

HTHEME GetNCCaptionTheme ( HWND  hWnd,
DWORD  style 
)

Definition at line 88 of file themehooks.c.

89{
90 PWND_DATA pwndData;
91
92 /* We only get the theme for the window class if the window has a caption */
93 if((style & WS_CAPTION) != WS_CAPTION)
94 return NULL;
95
96 /* Get theme data for this window */
97 pwndData = ThemeGetWndData(hWnd);
98 if (pwndData == NULL)
99 return NULL;
100
101 if (!(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
102 {
103 if (pwndData->hthemeWindow)
104 {
105 CloseThemeData(pwndData->hthemeWindow);
106 pwndData->hthemeWindow = NULL;
107 }
108 return NULL;
109 }
110
111 /* If the theme data was not cached, open it now */
112 if (!pwndData->hthemeWindow)
113 pwndData->hthemeWindow = OpenThemeDataEx(hWnd, L"WINDOW", OTD_NONCLIENT);
114
115 return pwndData->hthemeWindow;
116}
Arabic default style
Definition: afstyles.h:94
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetThemeAppProperties(void)
Definition: system.c:933
HTHEME WINAPI OpenThemeDataEx(HWND hwnd, LPCWSTR pszClassList, DWORD flags)
Definition: system.c:819
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950
#define L(x)
Definition: ntvdm.h:50
#define WS_CAPTION
Definition: pedump.c:624
HTHEME hthemeWindow
Definition: uxthemep.h:167

Referenced by SetThemeRegion(), ThemeCalculateCaptionButtonsPosEx(), and ThemeInitDrawContext().

◆ GetNCScrollbarTheme()

HTHEME GetNCScrollbarTheme ( HWND  hWnd,
DWORD  style 
)

Definition at line 118 of file themehooks.c.

119{
120 PWND_DATA pwndData;
121
122 /* We only get the theme for the scrollbar class if the window has a scrollbar */
123 if((style & (WS_HSCROLL|WS_VSCROLL)) == 0)
124 return NULL;
125
126 /* Get theme data for this window */
127 pwndData = ThemeGetWndData(hWnd);
128 if (pwndData == NULL)
129 return NULL;
130
131 if (!(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
132 {
133 if (pwndData->hthemeScrollbar)
134 {
136 pwndData->hthemeScrollbar = NULL;
137 }
138 return NULL;
139 }
140
141 /* If the theme data was not cached, open it now */
142 if (!pwndData->hthemeScrollbar)
143 pwndData->hthemeScrollbar = OpenThemeDataEx(hWnd, L"SCROLLBAR", OTD_NONCLIENT);
144
145 return pwndData->hthemeScrollbar;
146}
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
HTHEME hthemeScrollbar
Definition: uxthemep.h:168

Referenced by ThemeInitDrawContext().

◆ HackFillStaticBg()

void HackFillStaticBg ( HWND  hwnd,
HDC  hdc,
HBRUSH *  result 
)

Definition at line 465 of file themehooks.c.

466{
467 RECT rcStatic;
468
469 GetClientRect(hwnd, &rcStatic);
470 FillRect(hdc, &rcStatic, *result);
471
474}
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define TRANSPARENT
Definition: wingdi.h:950
#define NULL_BRUSH
Definition: wingdi.h:901
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by ThemeDlgPostWindowProc().

◆ OnPostWinPosChanged()

int OnPostWinPosChanged ( HWND  hWnd,
WINDOWPOS pWinPos 
)

Definition at line 218 of file themehooks.c.

219{
220 PWND_DATA pwndData;
221 DWORD style;
222
223 /* We only proceed to change the window shape if it has a caption */
226 return 0;
227
228 /* Get theme data for this window */
229 pwndData = ThemeGetWndData(hWnd);
230 if (pwndData == NULL)
231 return 0;
232
233 /* Do not change the region of the window if its size wasn't changed */
234 if ((pWinPos->flags & SWP_NOSIZE) != 0 && pwndData->DirtyThemeRegion == FALSE)
235 return 0;
236
237 /* We don't touch the shape of the window if the application sets it on its own */
238 if (pwndData->HasAppDefinedRgn != FALSE)
239 return 0;
240
241 /* Calling SetWindowRgn will call SetWindowPos again so we need to avoid this recursion */
242 if (pwndData->UpdatingRgn != FALSE)
243 return 0;
244
245 if(!IsAppThemed() || !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
246 {
247 if(pwndData->HasThemeRgn)
248 {
249 pwndData->HasThemeRgn = FALSE;
251 }
252 return 0;
253 }
254
255 pwndData->DirtyThemeRegion = FALSE;
256 pwndData->HasThemeRgn = TRUE;
257 pwndData->UpdatingRgn = TRUE;
259 pwndData->UpdatingRgn = FALSE;
260
261 return 0;
262 }
#define TRUE
Definition: types.h:120
BOOL WINAPI IsAppThemed(void)
Definition: system.c:596
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT flags
Definition: winuser.h:3594
BOOL DirtyThemeRegion
Definition: uxthemep.h:175
BOOL UpdatingRgn
Definition: uxthemep.h:174
BOOL HasThemeRgn
Definition: uxthemep.h:173
BOOL HasAppDefinedRgn
Definition: uxthemep.h:172
SETWINDOWRGN SetWindowRgn
Definition: undocuser.h:346
void SetThemeRegion(HWND hWnd)
Definition: themehooks.c:169
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define SWP_NOSIZE
Definition: winuser.h:1245
#define GWL_STYLE
Definition: winuser.h:852

Referenced by ThemePostWindowProc().

◆ SetThemeRegion()

void SetThemeRegion ( HWND  hWnd)

Definition at line 169 of file themehooks.c.

170{
171 HTHEME hTheme;
172 RECT rcWindow;
173 HRGN hrgn, hrgn1;
174 int CaptionHeight, iPart;
175 WINDOWINFO wi;
176
177 TRACE("SetThemeRegion %d\n", hWnd);
178
179 wi.cbSize = sizeof(wi);
180 GetWindowInfo(hWnd, &wi);
181
182 /* Get the caption part id */
183 if (wi.dwStyle & WS_MINIMIZE)
184 iPart = WP_MINCAPTION;
185 else if (wi.dwExStyle & WS_EX_TOOLWINDOW)
186 iPart = WP_SMALLCAPTION;
187 else if (wi.dwStyle & WS_MAXIMIZE)
188 iPart = WP_MAXCAPTION;
189 else
190 iPart = WP_CAPTION;
191
192 CaptionHeight = wi.cyWindowBorders;
194
195 GetWindowRect(hWnd, &rcWindow);
196 rcWindow.right -= rcWindow.left;
197 rcWindow.bottom = CaptionHeight;
198 rcWindow.top = 0;
199 rcWindow.left = 0;
200
201 hTheme = GetNCCaptionTheme(hWnd, wi.dwStyle);
202 GetThemeBackgroundRegion(hTheme, 0, iPart, FS_ACTIVE, &rcWindow, &hrgn);
203
204 GetWindowRect(hWnd, &rcWindow);
205 rcWindow.right -= rcWindow.left;
206 rcWindow.bottom -= rcWindow.top;
207 rcWindow.top = CaptionHeight;
208 rcWindow.left = 0;
209 hrgn1 = CreateRectRgnIndirect(&rcWindow);
210
211 CombineRgn(hrgn, hrgn, hrgn1, RGN_OR );
212
213 DeleteObject(hrgn1);
214
216}
static HRGN hrgn
HRESULT WINAPI GetThemeBackgroundRegion(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, HRGN *pRegion)
Definition: draw.c:1724
pKey DeleteObject()
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define WS_MAXIMIZE
Definition: pedump.c:623
#define WS_MINIMIZE
Definition: pedump.c:622
#define TRACE(s)
Definition: solgame.cpp:4
LONG left
Definition: windef.h:306
DWORD cbSize
Definition: winuser.h:3766
DWORD dwExStyle
Definition: winuser.h:3770
DWORD dwStyle
Definition: winuser.h:3769
UINT cyWindowBorders
Definition: winuser.h:3773
HTHEME GetNCCaptionTheme(HWND hWnd, DWORD style)
Definition: themehooks.c:88
@ WP_CAPTION
Definition: vsstyle.h:1611
@ WP_MAXCAPTION
Definition: vsstyle.h:1615
@ WP_MINCAPTION
Definition: vsstyle.h:1613
@ WP_SMALLCAPTION
Definition: vsstyle.h:1612
@ FS_ACTIVE
Definition: vsstyle.h:1654
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define RGN_OR
Definition: wingdi.h:359
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
BOOL WINAPI GetWindowInfo(_In_ HWND, _Inout_ PWINDOWINFO)
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define SM_CYSMCAPTION
Definition: winuser.h:1014
#define SM_CYCAPTION
Definition: winuser.h:963

Referenced by OnPostWinPosChanged().

◆ ThemeCleanupChildWndContext()

static BOOL CALLBACK ThemeCleanupChildWndContext ( HWND  hWnd,
LPARAM  msg 
)
static

Definition at line 148 of file themehooks.c.

149{
151 return TRUE;
152}
void ThemeDestroyWndData(HWND hWnd)
Definition: themehooks.c:38

Referenced by ThemeCleanupWndContext().

◆ ThemeCleanupWndContext()

static BOOL CALLBACK ThemeCleanupWndContext ( HWND  hWnd,
LPARAM  msg 
)
static

Definition at line 154 of file themehooks.c.

155{
156 if (hWnd == NULL)
157 {
159 }
160 else
161 {
164 }
165
166 return TRUE;
167}
static BOOL CALLBACK ThemeCleanupChildWndContext(HWND hWnd, LPARAM msg)
Definition: themehooks.c:148
static BOOL CALLBACK ThemeCleanupWndContext(HWND hWnd, LPARAM msg)
Definition: themehooks.c:154
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)

Referenced by ThemeCleanupWndContext(), and ThemeInitApiHook().

◆ ThemeDefWindowProcA()

static LRESULT CALLBACK ThemeDefWindowProcA ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 293 of file themehooks.c.

294{
295 PWND_DATA pwndData;
296
298
299 if(!IsAppThemed() ||
300 !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT) ||
301 (pwndData && pwndData->HasAppDefinedRgn))
302 {
304 Msg,
305 wParam,
306 lParam);
307 }
308
309 return ThemeWndProc(hWnd,
310 Msg,
311 wParam,
312 lParam,
314}
struct @1632 Msg[]
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
LRESULT CALLBACK ThemeWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, WNDPROC DefWndProc)
Definition: nonclient.c:1015
ATOM atWndContext
Definition: system.c:52
WNDPROC DefWindowProcA
Definition: undocuser.h:339
struct _WND_DATA * PWND_DATA
#define MAKEINTATOM(i)
Definition: winbase.h:1463
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by ThemeInitApiHook().

◆ ThemeDefWindowProcW()

static LRESULT CALLBACK ThemeDefWindowProcW ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 269 of file themehooks.c.

270{
271 PWND_DATA pwndData;
272
274
275 if(!IsAppThemed() ||
276 !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT) ||
277 (pwndData && pwndData->HasAppDefinedRgn))
278 {
280 Msg,
281 wParam,
282 lParam);
283 }
284
285 return ThemeWndProc(hWnd,
286 Msg,
287 wParam,
288 lParam,
290}
WNDPROC DefWindowProcW
Definition: undocuser.h:340

Referenced by ThemeInitApiHook().

◆ ThemeDestroyWndData()

void ThemeDestroyWndData ( HWND  hWnd)

Definition at line 38 of file themehooks.c.

39{
40 PWND_DATA pwndData;
42
43 /*Do not destroy WND_DATA of a window that belong to another process */
46 {
47 return;
48 }
49
51 if(pwndData == NULL)
52 {
53 return;
54 }
55
56 if(pwndData->HasThemeRgn)
57 {
59 }
60
61 if (pwndData->hTabBackgroundBrush != NULL)
62 {
64
66 }
67
68 if (pwndData->hTabBackgroundBmp != NULL)
69 {
71 }
72
73 if (pwndData->hthemeWindow)
74 {
76 }
77
78 if (pwndData->hthemeScrollbar)
79 {
81 }
82
83 HeapFree(GetProcessHeap(), 0, pwndData);
84
86}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2711
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)

Referenced by ThemeCleanupChildWndContext(), ThemeCleanupWndContext(), and ThemePostWindowProc().

◆ ThemeDlgPostWindowProc()

static LRESULT CALLBACK ThemeDlgPostWindowProc ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
ULONG_PTR  ret,
PDWORD  unknown 
)
static

Definition at line 483 of file themehooks.c.

484{
485 switch(Msg)
486 {
487 case WM_CTLCOLORDLG:
488 case WM_CTLCOLORBTN:
490 {
491 HWND hwndTarget = (HWND)lParam;
492 HDC hdc = (HDC)wParam;
493 HBRUSH* phbrush = (HBRUSH*)ret;
494 HTHEME hTheme;
495
496 if(!IsAppThemed() || !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
497 break;
498
500 break;
501
502 hTheme = GetWindowTheme(hWnd);
503 if (!hTheme)
504 hTheme = OpenThemeData(hWnd, L"TAB");
505
506 if (!hTheme)
507 break;
508
509 GetDiaogTextureBrush(hTheme, hwndTarget, hdc, phbrush, Msg != WM_CTLCOLORDLG);
510
511#if 1
512 {
513 WCHAR controlClass[32];
514 GetClassNameW (hwndTarget, controlClass, sizeof(controlClass) / sizeof(controlClass[0]));
515
516 /* This is a hack for the static class. Windows have a v6 static class just for this. */
517 if (lstrcmpiW (controlClass, WC_STATICW) == 0)
518 HackFillStaticBg(hwndTarget, hdc, phbrush);
519 }
520#endif
522 break;
523 }
524 }
525
526 return 0;
527}
HANDLE HWND
Definition: compat.h:19
BOOL WINAPI IsThemeDialogTextureEnabled(HWND hwnd)
Definition: draw.c:56
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
Definition: system.c:835
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define WC_STATICW
Definition: commctrl.h:4680
HRESULT GetDiaogTextureBrush(HTHEME theme, HWND hwnd, HDC hdc, HBRUSH *result, BOOL changeOrigin)
Definition: themehooks.c:402
void HackFillStaticBg(HWND hwnd, HDC hdc, HBRUSH *result)
Definition: themehooks.c:465
int ret
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1772
#define WM_CTLCOLORBTN
Definition: winuser.h:1769
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
#define WM_CTLCOLORDLG
Definition: winuser.h:1770
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ThemeInitApiHook().

◆ ThemeDlgPreWindowProc()

static LRESULT CALLBACK ThemeDlgPreWindowProc ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
ULONG_PTR  ret,
PDWORD  unknown 
)
static

Definition at line 477 of file themehooks.c.

478{
479 return 0;
480}

Referenced by ThemeInitApiHook().

◆ ThemeGetScrollInfo()

BOOL WINAPI ThemeGetScrollInfo ( HWND  hwnd,
int  fnBar,
LPSCROLLINFO  lpsi 
)

Definition at line 541 of file themehooks.c.

542{
543 PWND_DATA pwndData;
544 DWORD style;
545 BOOL ret;
546
547 /* Avoid creating a window context if it is not needed */
548 if(!IsAppThemed() || !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
549 goto dodefault;
550
552 if((style & (WS_HSCROLL|WS_VSCROLL))==0)
553 goto dodefault;
554
555 pwndData = ThemeGetWndData(hwnd);
556 if (pwndData == NULL)
557 goto dodefault;
558
559 /*
560 * Uxtheme needs to handle the tracking of the scrollbar itself
561 * This means than if an application needs to get the track position
562 * with GetScrollInfo, it will get wrong data. So uxtheme needs to
563 * hook it and set the correct tracking position itself
564 */
565 ret = g_user32ApiHook.GetScrollInfo(hwnd, fnBar, lpsi);
566 if ( lpsi &&
567 (lpsi->fMask & SIF_TRACKPOS) &&
568 pwndData->SCROLL_TrackingWin == hwnd &&
569 pwndData->SCROLL_TrackingBar == fnBar)
570 {
571 lpsi->nTrackPos = pwndData->SCROLL_TrackingVal;
572 }
573 return ret;
574
575dodefault:
576 return g_user32ApiHook.GetScrollInfo(hwnd, fnBar, lpsi);
577}
INT SCROLL_TrackingBar
Definition: uxthemep.h:183
INT SCROLL_TrackingVal
Definition: uxthemep.h:185
HWND SCROLL_TrackingWin
Definition: uxthemep.h:182
GETSCROLLINFO GetScrollInfo
Definition: undocuser.h:342
#define SIF_TRACKPOS
Definition: winuser.h:1237

Referenced by ThemeInitApiHook().

◆ ThemeGetWndData()

◆ ThemeHooksInstall()

BOOL WINAPI ThemeHooksInstall ( )

Definition at line 693 of file themehooks.c.

694{
695 PVOID lpFunc;
697 BOOL ret;
698
699 lpFunc = GetProcAddress(GetModuleHandle("user32.dll"), "RegisterUserApiHook");
700
701 ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
704
705 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
706 {
707 PREGISTER_UAH_WINXP lpfuncxp = (PREGISTER_UAH_WINXP)lpFunc;
708 ret = lpfuncxp(hDllInst, ThemeInitApiHook);
709 }
710 else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
711 {
713 USERAPIHOOKINFO uah;
714
715 uah.m_size = sizeof(uah);
716 uah.m_dllname1 = L"uxtheme.dll";
717 uah.m_funname1 = L"ThemeInitApiHook";
718 uah.m_dllname2 = NULL;
719 uah.m_funname2 = NULL;
720
721 ret = lpfunc2003(&uah);
722 }
723 else
724 {
726 ret = FALSE;
727 }
728
730
731 return ret;
732}
#define UNIMPLEMENTED
Definition: debug.h:115
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE hDllInst
Definition: system.c:45
BOOL CALLBACK UXTHEME_broadcast_theme_changed(HWND hWnd, LPARAM enable)
Definition: system.c:68
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:237
ULONG dwMajorVersion
Definition: rtltypes.h:238
ULONG dwMinorVersion
Definition: rtltypes.h:239
LPCWSTR m_funname2
Definition: undocuser.h:378
LPCWSTR m_dllname2
Definition: undocuser.h:377
LPCWSTR m_funname1
Definition: undocuser.h:376
LPCWSTR m_dllname1
Definition: undocuser.h:375
BOOL(WINAPI * PREGISTER_UAH_WINXP)(HINSTANCE hInstance, USERAPIHOOKPROC CallbackFunc)
Definition: themehooks.c:689
BOOL CALLBACK ThemeInitApiHook(UAPIHK State, PUSERAPIHOOK puah)
Definition: themehooks.c:607
BOOL(WINAPI * PREGISTER_UUAH_WIN2003)(PUSERAPIHOOKINFO puah)
Definition: themehooks.c:690
OSVERSIONINFO osvi
Definition: ver.c:28
#define ZeroMemory
Definition: winbase.h:1712
#define GetModuleHandle
Definition: winbase.h:3827
#define GetVersionEx
Definition: winbase.h:3852
OSVERSIONINFOA OSVERSIONINFO
Definition: rtltypes.h:293

Referenced by ThemeStartCallback().

◆ ThemeHooksRemove()

BOOL WINAPI ThemeHooksRemove ( )

Definition at line 735 of file themehooks.c.

736{
737 BOOL ret;
738
740
742
743 return ret;
744}
BOOL WINAPI UnregisterUserApiHook(VOID)
Definition: usrapihk.c:394

Referenced by ThemeServiceDiedCallback(), and ThemeStopCallback().

◆ ThemeInitApiHook()

BOOL CALLBACK ThemeInitApiHook ( UAPIHK  State,
PUSERAPIHOOK  puah 
)

Definition at line 607 of file themehooks.c.

608{
609 if (!puah || State != uahLoadInit)
610 {
614 return TRUE;
615 }
616
618
619 /* Store the original functions from user32 */
620 g_user32ApiHook = *puah;
621
634
638
650 UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_STYLECHANGED);
651 UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_SETICON);
657
664 UAH_HOOK_MESSAGE(puah->WndProcArray, WM_STYLECHANGING);
665 UAH_HOOK_MESSAGE(puah->WndProcArray, WM_STYLECHANGED);
671 UAH_HOOK_MESSAGE(puah->WndProcArray, WM_THEMECHANGED);
673
676
683
685
686 return TRUE;
687}
void UXTHEME_LoadTheme(BOOL bLoad)
Definition: system.c:183
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_PRINTCLIENT
Definition: richedit.h:70
BYTE * MsgBitArray
Definition: undocuser.h:328
DWORD Size
Definition: undocuser.h:329
WNDPROC_OWP PostWndProc
Definition: undocuser.h:348
WNDPROC_OWP PreWndProc
Definition: undocuser.h:347
UAHOWP WndProcArray
Definition: undocuser.h:349
UAHOWP DlgProcArray
Definition: undocuser.h:352
UAHOWP DefWndProcArray
Definition: undocuser.h:341
WNDPROC_OWP PreDefDlgProc
Definition: undocuser.h:350
WNDPROC_OWP PostDefDlgProc
Definition: undocuser.h:351
SETSCROLLINFO SetScrollInfo
Definition: undocuser.h:343
static LRESULT CALLBACK ThemeDefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: themehooks.c:293
BYTE gabMSGPmessages[UAHOWP_MAX_SIZE]
Definition: themehooks.c:13
BOOL WINAPI ThemeGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
Definition: themehooks.c:541
INT WINAPI ThemeSetScrollInfo(HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
Definition: themehooks.c:579
static LRESULT CALLBACK ThemePreWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret, PDWORD unknown)
Definition: themehooks.c:317
static LRESULT CALLBACK ThemeDlgPostWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret, PDWORD unknown)
Definition: themehooks.c:483
static LRESULT CALLBACK ThemeDlgPreWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret, PDWORD unknown)
Definition: themehooks.c:477
BYTE gabDWPmessages[UAHOWP_MAX_SIZE]
Definition: themehooks.c:12
static LRESULT CALLBACK ThemePostWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret, PDWORD unknown)
Definition: themehooks.c:384
BYTE gabDLGPmessages[UAHOWP_MAX_SIZE]
Definition: themehooks.c:14
int WINAPI ThemeSetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
Definition: themehooks.c:529
static LRESULT CALLBACK ThemeDefWindowProcW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: themehooks.c:269
#define WM_UAHINIT
Definition: undocuser.h:62
#define WM_NCUAHDRAWCAPTION
Definition: undocuser.h:46
#define UAHOWP_MAX_SIZE
Definition: undocuser.h:334
@ uahLoadInit
Definition: undocuser.h:365
#define UAH_HOOK_MESSAGE(uahowp, msg)
Definition: undocuser.h:332
#define WM_NCUAHDRAWFRAME
Definition: undocuser.h:47
#define WM_MDISETMENU
Definition: winuser.h:1822
#define WM_SYSCOMMAND
Definition: winuser.h:1741
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1661
#define WM_CREATE
Definition: winuser.h:1608
#define WM_NCHITTEST
Definition: winuser.h:1686
#define WM_INITDIALOG
Definition: winuser.h:1739
#define WM_CTLCOLORMSGBOX
Definition: winuser.h:1766
#define WM_DRAWITEM
Definition: winuser.h:1645
#define WM_NCCREATE
Definition: winuser.h:1683
#define WM_SETTINGCHANGE
Definition: winuser.h:1629
#define WM_SETTEXT
Definition: winuser.h:1617
#define WM_NCMOUSEMOVE
Definition: winuser.h:1691
#define WM_NCACTIVATE
Definition: winuser.h:1688
#define WM_MENUCHAR
Definition: winuser.h:1748
#define WM_MEASUREITEM
Definition: winuser.h:1646
#define WM_NCDESTROY
Definition: winuser.h:1684
#define WM_NCMOUSELEAVE
Definition: winuser.h:1842
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1662
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1692
#define WM_NCPAINT
Definition: winuser.h:1687

Referenced by ThemeHooksInstall().

◆ ThemePostWindowProc()

static LRESULT CALLBACK ThemePostWindowProc ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
ULONG_PTR  ret,
PDWORD  unknown 
)
static

Definition at line 384 of file themehooks.c.

385{
386 switch(Msg)
387 {
389 {
391 }
392 case WM_NCDESTROY:
393 {
395 return 0;
396 }
397 }
398
399 return 0;
400}
int OnPostWinPosChanged(HWND hWnd, WINDOWPOS *pWinPos)
Definition: themehooks.c:218

Referenced by ThemeInitApiHook().

◆ ThemePreWindowProc()

static LRESULT CALLBACK ThemePreWindowProc ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
ULONG_PTR  ret,
PDWORD  unknown 
)
static

Definition at line 317 of file themehooks.c.

318{
319 switch(Msg)
320 {
321 case WM_CREATE:
322 case WM_STYLECHANGED:
323 case WM_SIZE:
325 {
326 if(IsAppThemed() && (GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
328 break;
329 }
330 case WM_THEMECHANGED:
331 {
332 PWND_DATA pwndData = ThemeGetWndData(hWnd);
333
336
337 if (pwndData == NULL)
338 return 0;
339
340 if (pwndData->hTabBackgroundBrush != NULL)
341 {
343 pwndData->hTabBackgroundBrush = NULL;
344 }
345
346 if (pwndData->hTabBackgroundBmp != NULL)
347 {
349 pwndData->hTabBackgroundBmp = NULL;
350 }
351
352 if (pwndData->hthemeWindow)
353 {
354 CloseThemeData(pwndData->hthemeWindow);
355 pwndData->hthemeWindow = NULL;
356 }
357
358 if (pwndData->hthemeScrollbar)
359 {
361 pwndData->hthemeScrollbar = NULL;
362 }
363
364 if(IsAppThemed() && (GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
366
367 pwndData->DirtyThemeRegion = TRUE;
368 break;
369 }
370 case WM_NCCREATE:
371 {
372 PWND_DATA pwndData = ThemeGetWndData(hWnd);
373 if (pwndData == NULL)
374 return 0;
375 pwndData->DirtyThemeRegion = TRUE;
376 }
377 }
378
379 return 0;
380}
void ThemeCalculateCaptionButtonsPos(HWND hWnd, HTHEME htheme)
Definition: nonclient.c:270
#define WM_SIZE
Definition: winuser.h:1611
#define GA_PARENT
Definition: winuser.h:2788
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)

Referenced by ThemeInitApiHook().

◆ ThemeSetScrollInfo()

INT WINAPI ThemeSetScrollInfo ( HWND  hWnd,
int  fnBar,
LPCSCROLLINFO  lpsi,
BOOL  bRedraw 
)

Definition at line 579 of file themehooks.c.

580{
581 PWND_DATA pwndData;
582 SCROLLINFO siout;
583 LPSCROLLINFO lpsiout = &siout;
584 BOOL IsThemed = FALSE;
585
586 pwndData = ThemeGetWndData(hWnd);
587
588 if (!pwndData)
589 goto dodefault;
590
591 if (pwndData->hthemeScrollbar)
592 IsThemed = TRUE;
593
594 memcpy(&siout, lpsi, sizeof(SCROLLINFO));
595 if (IsThemed)
596 siout.fMask |= SIF_THEMED;
597
598dodefault:
599 return g_user32ApiHook.SetScrollInfo(hWnd, fnBar, lpsiout, bRedraw);
600}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define SIF_THEMED
Definition: winuser.h:1238

Referenced by ThemeInitApiHook().

◆ ThemeSetWindowRgn()

int WINAPI ThemeSetWindowRgn ( HWND  hWnd,
HRGN  hRgn,
BOOL  bRedraw 
)

Definition at line 529 of file themehooks.c.

530{
531 PWND_DATA pwndData = ThemeGetWndData(hWnd);
532 if(pwndData)
533 {
534 pwndData->HasAppDefinedRgn = TRUE;
535 pwndData->HasThemeRgn = FALSE;
536 }
537
538 return g_user32ApiHook.SetWindowRgn(hWnd, hRgn, bRedraw);
539}
static HRGN hRgn
Definition: mapping.c:33

Referenced by ThemeInitApiHook().

Variable Documentation

◆ g_bThemeHooksActive

◆ g_user32ApiHook

◆ gabDLGPmessages

BYTE gabDLGPmessages[UAHOWP_MAX_SIZE]

Definition at line 14 of file themehooks.c.

Referenced by ThemeInitApiHook().

◆ gabDWPmessages

BYTE gabDWPmessages[UAHOWP_MAX_SIZE]

Definition at line 12 of file themehooks.c.

Referenced by ThemeInitApiHook().

◆ gabMSGPmessages

BYTE gabMSGPmessages[UAHOWP_MAX_SIZE]

Definition at line 13 of file themehooks.c.

Referenced by ThemeInitApiHook().