ReactOS 0.4.17-dev-1321-g5c122a9
themehooks.c File Reference
#include "uxthemep.h"
Include dependency graph for themehooks.c:

Go to the source code of this file.

Typedefs

typedef BOOL(WINAPI * PREGISTER_UAH_WINXP) (HINSTANCE hInstance, USERAPIHOOKPROC CallbackFunc)
 
typedef BOOL(WINAPI * PREGISTER_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 702 of file themehooks.c.

◆ PREGISTER_UUAH_WIN2003

typedef BOOL(WINAPI * PREGISTER_UUAH_WIN2003) (PUSERAPIHOOKINFO puah)

Definition at line 703 of file themehooks.c.

Function Documentation

◆ ClassicAdjustWindowRectEx()

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

Definition at line 789 of file themehooks.c.

790{
792 {
793 return g_user32ApiHook.AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
794 }
795
796 return AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle);
797}
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
ADJUSTWINDOWRECTEX AdjustWindowRectEx
Definition: undocuser.h:366
USERAPIHOOK g_user32ApiHook
Definition: themehooks.c:11
BOOL g_bThemeHooksActive
Definition: themehooks.c:15

◆ ClassicGetSystemMetrics()

INT WINAPI ClassicGetSystemMetrics ( int  nIndex)

Definition at line 779 of file themehooks.c.

780{
782 {
783 return g_user32ApiHook.GetSystemMetrics(nIndex);
784 }
785
786 return GetSystemMetrics(nIndex);
787}
int WINAPI GetSystemMetrics(_In_ int)
GETSYSTEMMETRICS GetSystemMetrics
Definition: undocuser.h:374

◆ ClassicSystemParametersInfoA()

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

Definition at line 769 of file themehooks.c.

770{
772 {
773 return g_user32ApiHook.SystemParametersInfoA(uiAction, uiParam, pvParam, fWinIni);
774 }
775
776 return SystemParametersInfoA(uiAction, uiParam, pvParam, fWinIni);
777}
BOOL WINAPI SystemParametersInfoA(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
SYSTEMPARAMETERSINFOA SystemParametersInfoA
Definition: undocuser.h:375

◆ ClassicSystemParametersInfoW()

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

Definition at line 759 of file themehooks.c.

760{
762 {
763 return g_user32ApiHook.SystemParametersInfoW(uiAction, uiParam, pvParam, fWinIni);
764 }
765
766 return SystemParametersInfoW(uiAction, uiParam, pvParam, fWinIni);
767}
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
SYSTEMPARAMETERSINFOW SystemParametersInfoW
Definition: undocuser.h:376

◆ GetDiaogTextureBrush()

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

Definition at line 415 of file themehooks.c.

416{
417 PWND_DATA pwndData;
418
419 pwndData = ThemeGetWndData(hwnd);
420 if (pwndData == NULL)
421 return E_FAIL;
422
423 if (pwndData->hTabBackgroundBrush == NULL)
424 {
426 RECT dummy, bmpRect;
427 BOOL hasImageAlpha;
428 HRESULT hr;
429
430 hr = UXTHEME_LoadImage(theme, 0, TABP_BODY, 0, &dummy, FALSE, &hbmp, &bmpRect, &hasImageAlpha);
431 if (FAILED(hr))
432 return hr;
433
434 if (changeOrigin)
435 {
436 /* Unfortunately SetBrushOrgEx doesn't work at all */
437 RECT rcWindow, rcParent;
438 UINT y;
439 HDC hdcPattern, hdcHackPattern;
440 HBITMAP hbmpOld1, hbmpold2, hbmpHack;
441
442 GetWindowRect(hwnd, &rcWindow);
443 GetWindowRect(GetParent(hwnd), &rcParent);
444 y = (rcWindow.top - rcParent.top) % bmpRect.bottom;
445
446 hdcPattern = CreateCompatibleDC(hdc);
447 hbmpOld1 = (HBITMAP)SelectObject(hdcPattern, hbmp);
448
449 hdcHackPattern = CreateCompatibleDC(hdc);
450 hbmpHack = CreateCompatibleBitmap(hdc, bmpRect.right, bmpRect.bottom);
451 hbmpold2 = (HBITMAP)SelectObject(hdcHackPattern, hbmpHack);
452
453 BitBlt(hdcHackPattern, 0, 0, bmpRect.right, bmpRect.bottom - y, hdcPattern, 0, y, SRCCOPY);
454 BitBlt(hdcHackPattern, 0, bmpRect.bottom - y, bmpRect.right, y, hdcPattern, 0, 0, SRCCOPY);
455
456 hbmpold2 = (HBITMAP)SelectObject(hdcHackPattern, hbmpold2);
457 hbmpOld1 = (HBITMAP)SelectObject(hdcPattern, hbmpOld1);
458
459 DeleteDC(hdcPattern);
460 DeleteDC(hdcHackPattern);
461
462 /* Keep the handle of the bitmap we created so that it can be used later */
463 pwndData->hTabBackgroundBmp = hbmpHack;
464 hbmp = hbmpHack;
465 }
466
467 /* hbmp is cached so there is no need to free it */
469 }
470
471 if (!pwndData->hTabBackgroundBrush)
472 return E_FAIL;
473
474 *result = pwndData->hTabBackgroundBrush;
475 return S_OK;
476}
HBITMAP hbmp
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
#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_(Height *Stride) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Stride)
Definition: common.c:42
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
unsigned int UINT
Definition: sysinfo.c:13
#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:88
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
HBRUSH hTabBackgroundBrush
Definition: uxthemep.h:186
HBITMAP hTabBackgroundBmp
Definition: uxthemep.h:187
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:1546
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)

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}
HWND hWnd
Definition: settings.c:17
DWORD WINAPI GetThemeAppProperties(void)
Definition: system.c:1019
HTHEME WINAPI OpenThemeDataEx(HWND hwnd, LPCWSTR pszClassList, DWORD flags)
Definition: system.c:874
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:1036
#define L(x)
Definition: resources.c:13
#define WS_CAPTION
Definition: pedump.c:624
HTHEME hthemeWindow
Definition: uxthemep.h:177
Definition: style.c:91

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:178

Referenced by ThemeInitDrawContext().

◆ HackFillStaticBg()

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

Definition at line 478 of file themehooks.c.

479{
480 RECT rcStatic;
481
482 GetClientRect(hwnd, &rcStatic);
483 FillRect(hdc, &rcStatic, *result);
484
487}
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
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

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 {
227 /* Drop the theme region once the caption is gone, e.g. when going fullscreen */
229 if (pwndData && pwndData->HasThemeRgn && !pwndData->UpdatingRgn)
230 {
231 pwndData->HasThemeRgn = FALSE;
232 /* Rebuild it once the caption returns, even without a size change */
233 pwndData->DirtyThemeRegion = TRUE;
234 pwndData->UpdatingRgn = TRUE;
236 pwndData->UpdatingRgn = FALSE;
237 }
238 return 0;
239 }
240
241 /* Get theme data for this window */
242 pwndData = ThemeGetWndData(hWnd);
243 if (pwndData == NULL)
244 return 0;
245
246 /* Do not change the region of the window if its size wasn't changed */
247 if ((pWinPos->flags & SWP_NOSIZE) != 0 && pwndData->DirtyThemeRegion == FALSE)
248 return 0;
249
250 /* We don't touch the shape of the window if the application sets it on its own */
251 if (pwndData->HasAppDefinedRgn != FALSE)
252 return 0;
253
254 /* Calling SetWindowRgn will call SetWindowPos again so we need to avoid this recursion */
255 if (pwndData->UpdatingRgn != FALSE)
256 return 0;
257
258 if(!IsAppThemed() || !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
259 {
260 if(pwndData->HasThemeRgn)
261 {
262 pwndData->HasThemeRgn = FALSE;
264 }
265 return 0;
266 }
267
268 pwndData->DirtyThemeRegion = FALSE;
269 pwndData->HasThemeRgn = TRUE;
270 pwndData->UpdatingRgn = TRUE;
272 pwndData->UpdatingRgn = FALSE;
273
274 return 0;
275 }
#define TRUE
Definition: types.h:120
ATOM atWndContext
Definition: system.c:54
BOOL WINAPI IsAppThemed(void)
Definition: system.c:620
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define SWP_NOSIZE
Definition: winuser.h:1256
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
#define GWL_STYLE
Definition: winuser.h:863
UINT flags
Definition: winuser.h:3702
BOOL DirtyThemeRegion
Definition: uxthemep.h:185
BOOL UpdatingRgn
Definition: uxthemep.h:184
BOOL HasThemeRgn
Definition: uxthemep.h:183
BOOL HasAppDefinedRgn
Definition: uxthemep.h:182
SETWINDOWRGN SetWindowRgn
Definition: undocuser.h:367
void SetThemeRegion(HWND hWnd)
Definition: themehooks.c:169
const uint16_t * LPCWSTR
Definition: typedefs.h:57
struct _WND_DATA * PWND_DATA
#define MAKEINTATOM(i)
Definition: winbase.h:1196

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:1768
pKey DeleteObject()
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define WS_MAXIMIZE
Definition: pedump.c:623
#define WS_MINIMIZE
Definition: pedump.c:622
BOOL WINAPI GetWindowInfo(_In_ HWND, _Inout_ PWINDOWINFO)
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define SM_CYSMCAPTION
Definition: winuser.h:1025
#define SM_CYCAPTION
Definition: winuser.h:974
#define TRACE(s)
Definition: solgame.cpp:4
long left
Definition: dcommon.idl:29
DWORD cbSize
Definition: winuser.h:3874
DWORD dwExStyle
Definition: winuser.h:3878
DWORD dwStyle
Definition: winuser.h:3877
UINT cyWindowBorders
Definition: winuser.h:3881
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)

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}
BOOL WINAPI EnumChildWindows(_In_opt_ HWND, _In_ WNDENUMPROC, _In_ LPARAM)
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC lpEnumFunc, _In_ LPARAM lParam)
static BOOL CALLBACK ThemeCleanupChildWndContext(HWND hWnd, LPARAM msg)
Definition: themehooks.c:148
static BOOL CALLBACK ThemeCleanupWndContext(HWND hWnd, LPARAM msg)
Definition: themehooks.c:154

Referenced by ThemeCleanupWndContext(), and ThemeInitApiHook().

◆ ThemeDefWindowProcA()

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

Definition at line 306 of file themehooks.c.

307{
308 PWND_DATA pwndData;
309
311
312 if(!IsAppThemed() ||
313 !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT) ||
314 (pwndData && pwndData->HasAppDefinedRgn))
315 {
317 Msg,
318 wParam,
319 lParam);
320 }
321
322 return ThemeWndProc(hWnd,
323 Msg,
324 wParam,
325 lParam,
327}
struct @1907 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
WNDPROC DefWindowProcA
Definition: undocuser.h:360

Referenced by ThemeInitApiHook().

◆ ThemeDefWindowProcW()

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

Definition at line 282 of file themehooks.c.

283{
284 PWND_DATA pwndData;
285
287
288 if(!IsAppThemed() ||
289 !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT) ||
290 (pwndData && pwndData->HasAppDefinedRgn))
291 {
293 Msg,
294 wParam,
295 lParam);
296 }
297
298 return ThemeWndProc(hWnd,
299 Msg,
300 wParam,
301 lParam,
303}
WNDPROC DefWindowProcW
Definition: undocuser.h:361

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:920
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2712
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1207
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)

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 496 of file themehooks.c.

497{
498 switch(Msg)
499 {
500 case WM_CTLCOLORDLG:
501 case WM_CTLCOLORBTN:
503 {
504 HWND hwndTarget = (HWND)lParam;
505 HDC hdc = (HDC)wParam;
506 HBRUSH* phbrush = (HBRUSH*)ret;
507 HTHEME hTheme;
508
509 if(!IsAppThemed() || !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
510 break;
511
513 break;
514
515 hTheme = GetWindowTheme(hWnd);
516 if (!hTheme)
517 hTheme = OpenThemeData(hWnd, L"TAB");
518
519 if (!hTheme)
520 break;
521
522 GetDiaogTextureBrush(hTheme, hwndTarget, hdc, phbrush, Msg != WM_CTLCOLORDLG);
523
524#if 1
525 {
526 WCHAR controlClass[32];
527 GetClassNameW (hwndTarget, controlClass, sizeof(controlClass) / sizeof(controlClass[0]));
528
529 /* This is a hack for the static class. Windows have a v6 static class just for this. */
530 if (lstrcmpiW (controlClass, WC_STATICW) == 0)
531 HackFillStaticBg(hwndTarget, hdc, phbrush);
532 }
533#endif
535 break;
536 }
537 }
538
539 return 0;
540}
HANDLE HWND
Definition: compat.h:19
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
BOOL WINAPI IsThemeDialogTextureEnabled(HWND hwnd)
Definition: draw.c:56
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR pszClassList)
Definition: system.c:890
return ret
Definition: mutex.c:147
short WCHAR
Definition: pedump.c:58
#define WC_STATICW
Definition: commctrl.h:4685
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1800
#define WM_CTLCOLORBTN
Definition: winuser.h:1797
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
#define WM_CTLCOLORDLG
Definition: winuser.h:1798
HRESULT GetDiaogTextureBrush(HTHEME theme, HWND hwnd, HDC hdc, HBRUSH *result, BOOL changeOrigin)
Definition: themehooks.c:415
void HackFillStaticBg(HWND hwnd, HDC hdc, HBRUSH *result)
Definition: themehooks.c:478

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 490 of file themehooks.c.

491{
492 return 0;
493}

Referenced by ThemeInitApiHook().

◆ ThemeGetScrollInfo()

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

Definition at line 554 of file themehooks.c.

555{
556 PWND_DATA pwndData;
557 DWORD style;
558 BOOL ret;
559
560 /* Avoid creating a window context if it is not needed */
561 if(!IsAppThemed() || !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
562 goto dodefault;
563
565 if((style & (WS_HSCROLL|WS_VSCROLL))==0)
566 goto dodefault;
567
568 pwndData = ThemeGetWndData(hwnd);
569 if (pwndData == NULL)
570 goto dodefault;
571
572 /*
573 * Uxtheme needs to handle the tracking of the scrollbar itself
574 * This means than if an application needs to get the track position
575 * with GetScrollInfo, it will get wrong data. So uxtheme needs to
576 * hook it and set the correct tracking position itself
577 */
578 ret = g_user32ApiHook.GetScrollInfo(hwnd, fnBar, lpsi);
579 if ( lpsi &&
580 (lpsi->fMask & SIF_TRACKPOS) &&
581 pwndData->SCROLL_TrackingWin == hwnd &&
582 pwndData->SCROLL_TrackingBar == fnBar)
583 {
584 lpsi->nTrackPos = pwndData->SCROLL_TrackingVal;
585 }
586 return ret;
587
588dodefault:
589 return g_user32ApiHook.GetScrollInfo(hwnd, fnBar, lpsi);
590}
#define SIF_TRACKPOS
Definition: winuser.h:1248
INT SCROLL_TrackingBar
Definition: uxthemep.h:193
INT SCROLL_TrackingVal
Definition: uxthemep.h:195
HWND SCROLL_TrackingWin
Definition: uxthemep.h:192
GETSCROLLINFO GetScrollInfo
Definition: undocuser.h:363

Referenced by ThemeInitApiHook().

◆ ThemeGetWndData()

◆ ThemeHooksInstall()

BOOL WINAPI ThemeHooksInstall ( )

Definition at line 706 of file themehooks.c.

707{
708 PVOID lpFunc;
710 BOOL ret;
711
712 lpFunc = GetProcAddress(GetModuleHandle("user32.dll"), "RegisterUserApiHook");
713
714 ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
717
718 if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
719 {
720 PREGISTER_UAH_WINXP lpfuncxp = (PREGISTER_UAH_WINXP)lpFunc;
721 ret = lpfuncxp(hDllInst, ThemeInitApiHook);
722 }
723 else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
724 {
726 USERAPIHOOKINFO uah;
727
728 uah.m_size = sizeof(uah);
729 uah.m_dllname1 = L"uxtheme.dll";
730 uah.m_funname1 = L"ThemeInitApiHook";
731 uah.m_dllname2 = NULL;
732 uah.m_funname2 = NULL;
733
734 ret = lpfunc2003(&uah);
735 }
736 else
737 {
739 ret = FALSE;
740 }
741
743
744 return ret;
745}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE hDllInst
Definition: system.c:47
BOOL CALLBACK UXTHEME_broadcast_theme_changed(HWND hWnd, LPARAM enable)
Definition: system.c:70
#define ZeroMemory
Definition: minwinbase.h:31
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:237
ULONG dwMajorVersion
Definition: rtltypes.h:238
ULONG dwMinorVersion
Definition: rtltypes.h:239
LPCWSTR m_funname2
Definition: undocuser.h:399
LPCWSTR m_dllname2
Definition: undocuser.h:398
LPCWSTR m_funname1
Definition: undocuser.h:397
LPCWSTR m_dllname1
Definition: undocuser.h:396
BOOL(WINAPI * PREGISTER_UAH_WINXP)(HINSTANCE hInstance, USERAPIHOOKPROC CallbackFunc)
Definition: themehooks.c:702
BOOL CALLBACK ThemeInitApiHook(UAPIHK State, PUSERAPIHOOK puah)
Definition: themehooks.c:620
BOOL(WINAPI * PREGISTER_UUAH_WIN2003)(PUSERAPIHOOKINFO puah)
Definition: themehooks.c:703
OSVERSIONINFO osvi
Definition: ver.c:28
#define GetModuleHandle
Definition: winbase.h:3550
#define GetVersionEx
Definition: winbase.h:3575
OSVERSIONINFOA OSVERSIONINFO
Definition: rtltypes.h:306

Referenced by ThemeStartCallback().

◆ ThemeHooksRemove()

BOOL WINAPI ThemeHooksRemove ( )

Definition at line 748 of file themehooks.c.

749{
750 BOOL ret;
751
753
755
756 return ret;
757}
BOOL WINAPI UnregisterUserApiHook(VOID)
Definition: usrapihk.c:394

Referenced by ThemeServiceDiedCallback(), and ThemeStopCallback().

◆ ThemeInitApiHook()

BOOL CALLBACK ThemeInitApiHook ( UAPIHK  State,
PUSERAPIHOOK  puah 
)

Definition at line 620 of file themehooks.c.

621{
622 if (!puah || State != uahLoadInit)
623 {
627 return TRUE;
628 }
629
631
632 /* Store the original functions from user32 */
633 g_user32ApiHook = *puah;
634
647
651
663 UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_STYLECHANGED);
664 UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_SETICON);
670
677 UAH_HOOK_MESSAGE(puah->WndProcArray, WM_STYLECHANGING);
678 UAH_HOOK_MESSAGE(puah->WndProcArray, WM_STYLECHANGED);
684 UAH_HOOK_MESSAGE(puah->WndProcArray, WM_THEMECHANGED);
686
689
696
698
699 return TRUE;
700}
void UXTHEME_LoadTheme(BOOL bLoad)
Definition: system.c:185
#define WM_MDISETMENU
Definition: winuser.h:1850
#define WM_SYSCOMMAND
Definition: winuser.h:1769
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1689
#define WM_CREATE
Definition: winuser.h:1636
#define WM_NCHITTEST
Definition: winuser.h:1714
#define WM_INITDIALOG
Definition: winuser.h:1767
#define WM_CTLCOLORMSGBOX
Definition: winuser.h:1794
#define WM_DRAWITEM
Definition: winuser.h:1673
#define WM_NCCREATE
Definition: winuser.h:1711
#define WM_SETTINGCHANGE
Definition: winuser.h:1657
#define WM_SETTEXT
Definition: winuser.h:1645
#define WM_NCMOUSEMOVE
Definition: winuser.h:1719
#define WM_NCACTIVATE
Definition: winuser.h:1716
#define WM_MENUCHAR
Definition: winuser.h:1776
#define WM_MEASUREITEM
Definition: winuser.h:1674
#define WM_NCDESTROY
Definition: winuser.h:1712
#define WM_NCMOUSELEAVE
Definition: winuser.h:1870
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1690
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1720
#define WM_NCPAINT
Definition: winuser.h:1715
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_PRINTCLIENT
Definition: richedit.h:70
BYTE * MsgBitArray
Definition: undocuser.h:349
DWORD Size
Definition: undocuser.h:350
WNDPROC_OWP PostWndProc
Definition: undocuser.h:369
WNDPROC_OWP PreWndProc
Definition: undocuser.h:368
UAHOWP WndProcArray
Definition: undocuser.h:370
UAHOWP DlgProcArray
Definition: undocuser.h:373
UAHOWP DefWndProcArray
Definition: undocuser.h:362
WNDPROC_OWP PreDefDlgProc
Definition: undocuser.h:371
WNDPROC_OWP PostDefDlgProc
Definition: undocuser.h:372
SETSCROLLINFO SetScrollInfo
Definition: undocuser.h:364
static LRESULT CALLBACK ThemeDefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: themehooks.c:306
BYTE gabMSGPmessages[UAHOWP_MAX_SIZE]
Definition: themehooks.c:13
BOOL WINAPI ThemeGetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi)
Definition: themehooks.c:554
INT WINAPI ThemeSetScrollInfo(HWND hWnd, int fnBar, LPCSCROLLINFO lpsi, BOOL bRedraw)
Definition: themehooks.c:592
static LRESULT CALLBACK ThemePreWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret, PDWORD unknown)
Definition: themehooks.c:330
static LRESULT CALLBACK ThemeDlgPostWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret, PDWORD unknown)
Definition: themehooks.c:496
static LRESULT CALLBACK ThemeDlgPreWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret, PDWORD unknown)
Definition: themehooks.c:490
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:397
BYTE gabDLGPmessages[UAHOWP_MAX_SIZE]
Definition: themehooks.c:14
int WINAPI ThemeSetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
Definition: themehooks.c:542
static LRESULT CALLBACK ThemeDefWindowProcW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: themehooks.c:282
#define WM_UAHINIT
Definition: undocuser.h:63
#define WM_NCUAHDRAWCAPTION
Definition: undocuser.h:48
#define UAHOWP_MAX_SIZE
Definition: undocuser.h:355
@ uahLoadInit
Definition: undocuser.h:386
#define UAH_HOOK_MESSAGE(uahowp, msg)
Definition: undocuser.h:353
#define WM_NCUAHDRAWFRAME
Definition: undocuser.h:49

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 397 of file themehooks.c.

398{
399 switch(Msg)
400 {
402 {
404 }
405 case WM_NCDESTROY:
406 {
408 return 0;
409 }
410 }
411
412 return 0;
413}
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 330 of file themehooks.c.

331{
332 switch(Msg)
333 {
334 case WM_CREATE:
335 case WM_STYLECHANGED:
336 case WM_SIZE:
338 {
339 if(IsAppThemed() && (GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
341 break;
342 }
343 case WM_THEMECHANGED:
344 {
345 PWND_DATA pwndData = ThemeGetWndData(hWnd);
346
349
350 if (pwndData == NULL)
351 return 0;
352
353 if (pwndData->hTabBackgroundBrush != NULL)
354 {
356 pwndData->hTabBackgroundBrush = NULL;
357 }
358
359 if (pwndData->hTabBackgroundBmp != NULL)
360 {
362 pwndData->hTabBackgroundBmp = NULL;
363 }
364
365 if (pwndData->hthemeWindow)
366 {
367 CloseThemeData(pwndData->hthemeWindow);
368 pwndData->hthemeWindow = NULL;
369 }
370
371 if (pwndData->hthemeScrollbar)
372 {
374 pwndData->hthemeScrollbar = NULL;
375 }
376
377 if(IsAppThemed() && (GetThemeAppProperties() & STAP_ALLOW_NONCLIENT))
379
380 pwndData->DirtyThemeRegion = TRUE;
381 break;
382 }
383 case WM_NCCREATE:
384 {
385 PWND_DATA pwndData = ThemeGetWndData(hWnd);
386 if (pwndData == NULL)
387 return 0;
388 pwndData->DirtyThemeRegion = TRUE;
389 }
390 }
391
392 return 0;
393}
void ThemeCalculateCaptionButtonsPos(HWND hWnd, HTHEME htheme)
Definition: nonclient.c:270
#define WM_SIZE
Definition: winuser.h:1639
#define GA_PARENT
Definition: winuser.h:2892
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
HWND WINAPI GetAncestor(_In_ HWND, _In_ UINT)
Definition: window.c:929

Referenced by ThemeInitApiHook().

◆ ThemeSetScrollInfo()

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

Definition at line 592 of file themehooks.c.

593{
594 PWND_DATA pwndData;
595 SCROLLINFO siout;
596 LPSCROLLINFO lpsiout = &siout;
597 BOOL IsThemed = FALSE;
598
599 pwndData = ThemeGetWndData(hWnd);
600
601 if (!pwndData)
602 goto dodefault;
603
604 if (pwndData->hthemeScrollbar)
605 IsThemed = TRUE;
606
607 memcpy(&siout, lpsi, sizeof(SCROLLINFO));
608 if (IsThemed)
609 siout.fMask |= SIF_THEMED;
610
611dodefault:
612 return g_user32ApiHook.SetScrollInfo(hWnd, fnBar, lpsiout, bRedraw);
613}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define SIF_THEMED
Definition: winuser.h:1249

Referenced by ThemeInitApiHook().

◆ ThemeSetWindowRgn()

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

Definition at line 542 of file themehooks.c.

543{
544 PWND_DATA pwndData = ThemeGetWndData(hWnd);
545 if(pwndData)
546 {
547 pwndData->HasAppDefinedRgn = TRUE;
548 pwndData->HasThemeRgn = FALSE;
549 }
550
551 return g_user32ApiHook.SetWindowRgn(hWnd, hRgn, bRedraw);
552}
static HRGN hRgn
Definition: mapping.c:32

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().