2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS uxtheme.dll
4 * FILE: dll/win32/uxtheme/themehooks.c
5 * PURPOSE: uxtheme user api hook functions
6 * PROGRAMMER: Giannis Adamopoulos
11 USERAPIHOOK g_user32ApiHook
;
12 BYTE gabDWPmessages
[UAHOWP_MAX_SIZE
];
13 BYTE gabMSGPmessages
[UAHOWP_MAX_SIZE
];
14 BYTE gabDLGPmessages
[UAHOWP_MAX_SIZE
];
15 BOOL g_bThemeHooksActive
= FALSE
;
17 PWND_DATA
ThemeGetWndData(HWND hWnd
)
21 pwndData
= (PWND_DATA
)GetPropW(hWnd
, (LPCWSTR
)MAKEINTATOM(atWndContext
));
24 pwndData
= HeapAlloc(GetProcessHeap(),
32 SetPropW( hWnd
, (LPCWSTR
)MAKEINTATOM(atWndContext
), pwndData
);
38 void ThemeDestroyWndData(HWND hWnd
)
43 /*Do not destroy WND_DATA of a window that belong to another process */
44 GetWindowThreadProcessId(hWnd
, &ProcessId
);
45 if(ProcessId
!= GetCurrentProcessId())
50 pwndData
= (PWND_DATA
)GetPropW(hWnd
, (LPCWSTR
)MAKEINTATOM(atWndContext
));
56 if(pwndData
->HasThemeRgn
)
58 g_user32ApiHook
.SetWindowRgn(hWnd
, 0, TRUE
);
61 if (pwndData
->hTabBackgroundBrush
!= NULL
)
63 CloseThemeData(GetWindowTheme(hWnd
));
65 DeleteObject(pwndData
->hTabBackgroundBrush
);
68 if (pwndData
->hTabBackgroundBmp
!= NULL
)
70 DeleteObject(pwndData
->hTabBackgroundBmp
);
73 if (pwndData
->hthemeWindow
)
75 CloseThemeData(pwndData
->hthemeWindow
);
78 if (pwndData
->hthemeScrollbar
)
80 CloseThemeData(pwndData
->hthemeScrollbar
);
83 HeapFree(GetProcessHeap(), 0, pwndData
);
85 SetPropW( hWnd
, (LPCWSTR
)MAKEINTATOM(atWndContext
), NULL
);
88 HTHEME
GetNCCaptionTheme(HWND hWnd
, DWORD style
)
92 /* We only get the theme for the window class if the window has a caption */
93 if((style
& WS_CAPTION
) != WS_CAPTION
)
96 /* Get theme data for this window */
97 pwndData
= ThemeGetWndData(hWnd
);
101 if (!(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT
))
103 if (pwndData
->hthemeWindow
)
105 CloseThemeData(pwndData
->hthemeWindow
);
106 pwndData
->hthemeWindow
= NULL
;
111 /* If the theme data was not cached, open it now */
112 if (!pwndData
->hthemeWindow
)
113 pwndData
->hthemeWindow
= OpenThemeDataEx(hWnd
, L
"WINDOW", OTD_NONCLIENT
);
115 return pwndData
->hthemeWindow
;
118 HTHEME
GetNCScrollbarTheme(HWND hWnd
, DWORD style
)
122 /* We only get the theme for the scrollbar class if the window has a scrollbar */
123 if((style
& (WS_HSCROLL
|WS_VSCROLL
)) == 0)
126 /* Get theme data for this window */
127 pwndData
= ThemeGetWndData(hWnd
);
128 if (pwndData
== NULL
)
131 if (!(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT
))
133 if (pwndData
->hthemeScrollbar
)
135 CloseThemeData(pwndData
->hthemeScrollbar
);
136 pwndData
->hthemeScrollbar
= NULL
;
141 /* If the theme data was not cached, open it now */
142 if (!pwndData
->hthemeScrollbar
)
143 pwndData
->hthemeScrollbar
= OpenThemeDataEx(hWnd
, L
"SCROLLBAR", OTD_NONCLIENT
);
145 return pwndData
->hthemeScrollbar
;
148 static BOOL CALLBACK
ThemeCleanupChildWndContext (HWND hWnd
, LPARAM msg
)
150 ThemeDestroyWndData(hWnd
);
154 static BOOL CALLBACK
ThemeCleanupWndContext(HWND hWnd
, LPARAM msg
)
158 EnumWindows (ThemeCleanupWndContext
, 0);
162 ThemeDestroyWndData(hWnd
);
163 EnumChildWindows (hWnd
, ThemeCleanupChildWndContext
, 0);
169 void SetThemeRegion(HWND hWnd
)
174 int CaptionHeight
, iPart
;
177 TRACE("SetThemeRegion %d\n", hWnd
);
179 wi
.cbSize
= sizeof(wi
);
180 GetWindowInfo(hWnd
, &wi
);
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
;
192 CaptionHeight
= wi
.cyWindowBorders
;
193 CaptionHeight
+= GetSystemMetrics(wi
.dwExStyle
& WS_EX_TOOLWINDOW
? SM_CYSMCAPTION
: SM_CYCAPTION
);
195 GetWindowRect(hWnd
, &rcWindow
);
196 rcWindow
.right
-= rcWindow
.left
;
197 rcWindow
.bottom
= CaptionHeight
;
201 hTheme
= GetNCCaptionTheme(hWnd
, wi
.dwStyle
);
202 GetThemeBackgroundRegion(hTheme
, 0, iPart
, FS_ACTIVE
, &rcWindow
, &hrgn
);
204 GetWindowRect(hWnd
, &rcWindow
);
205 rcWindow
.right
-= rcWindow
.left
;
206 rcWindow
.bottom
-= rcWindow
.top
;
207 rcWindow
.top
= CaptionHeight
;
209 hrgn1
= CreateRectRgnIndirect(&rcWindow
);
211 CombineRgn(hrgn
, hrgn
, hrgn1
, RGN_OR
);
215 g_user32ApiHook
.SetWindowRgn(hWnd
, hrgn
, TRUE
);
218 int OnPostWinPosChanged(HWND hWnd
, WINDOWPOS
* pWinPos
)
223 /* We only proceed to change the window shape if it has a caption */
224 style
= GetWindowLongW(hWnd
, GWL_STYLE
);
225 if((style
& WS_CAPTION
)!=WS_CAPTION
)
228 /* Get theme data for this window */
229 pwndData
= ThemeGetWndData(hWnd
);
230 if (pwndData
== NULL
)
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
)
237 /* We don't touch the shape of the window if the application sets it on its own */
238 if (pwndData
->HasAppDefinedRgn
!= FALSE
)
241 /* Calling SetWindowRgn will call SetWindowPos again so we need to avoid this recursion */
242 if (pwndData
->UpdatingRgn
!= FALSE
)
245 if(!IsAppThemed() || !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT
))
247 if(pwndData
->HasThemeRgn
)
249 pwndData
->HasThemeRgn
= FALSE
;
250 g_user32ApiHook
.SetWindowRgn(hWnd
, 0, TRUE
);
255 pwndData
->DirtyThemeRegion
= FALSE
;
256 pwndData
->HasThemeRgn
= TRUE
;
257 pwndData
->UpdatingRgn
= TRUE
;
258 SetThemeRegion(hWnd
);
259 pwndData
->UpdatingRgn
= FALSE
;
264 /**********************************************************************
268 static LRESULT CALLBACK
269 ThemeDefWindowProcW(HWND hWnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
273 pwndData
= (PWND_DATA
)GetPropW(hWnd
, (LPCWSTR
)MAKEINTATOM(atWndContext
));
276 !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT
) ||
277 (pwndData
&& pwndData
->HasAppDefinedRgn
))
279 return g_user32ApiHook
.DefWindowProcW(hWnd
,
285 return ThemeWndProc(hWnd
,
289 g_user32ApiHook
.DefWindowProcW
);
292 static LRESULT CALLBACK
293 ThemeDefWindowProcA(HWND hWnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
)
297 pwndData
= (PWND_DATA
)GetPropW(hWnd
, (LPCWSTR
)MAKEINTATOM(atWndContext
));
300 !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT
) ||
301 (pwndData
&& pwndData
->HasAppDefinedRgn
))
303 return g_user32ApiHook
.DefWindowProcA(hWnd
,
309 return ThemeWndProc(hWnd
,
313 g_user32ApiHook
.DefWindowProcA
);
316 static LRESULT CALLBACK
317 ThemePreWindowProc(HWND hWnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
, ULONG_PTR ret
,PDWORD unknown
)
322 case WM_STYLECHANGED
:
324 case WM_WINDOWPOSCHANGED
:
326 if(IsAppThemed() && (GetThemeAppProperties() & STAP_ALLOW_NONCLIENT
))
327 ThemeCalculateCaptionButtonsPos(hWnd
, NULL
);
330 case WM_THEMECHANGED
:
332 PWND_DATA pwndData
= ThemeGetWndData(hWnd
);
334 if (GetAncestor(hWnd
, GA_PARENT
) == GetDesktopWindow())
335 UXTHEME_LoadTheme(TRUE
);
337 if (pwndData
== NULL
)
340 if (pwndData
->hTabBackgroundBrush
!= NULL
)
342 DeleteObject(pwndData
->hTabBackgroundBrush
);
343 pwndData
->hTabBackgroundBrush
= NULL
;
346 if (pwndData
->hTabBackgroundBmp
!= NULL
)
348 DeleteObject(pwndData
->hTabBackgroundBmp
);
349 pwndData
->hTabBackgroundBmp
= NULL
;
352 if (pwndData
->hthemeWindow
)
354 CloseThemeData(pwndData
->hthemeWindow
);
355 pwndData
->hthemeWindow
= NULL
;
358 if (pwndData
->hthemeScrollbar
)
360 CloseThemeData(pwndData
->hthemeScrollbar
);
361 pwndData
->hthemeScrollbar
= NULL
;
364 if(IsAppThemed() && (GetThemeAppProperties() & STAP_ALLOW_NONCLIENT
))
365 ThemeCalculateCaptionButtonsPos(hWnd
, NULL
);
367 pwndData
->DirtyThemeRegion
= TRUE
;
372 PWND_DATA pwndData
= ThemeGetWndData(hWnd
);
373 if (pwndData
== NULL
)
375 pwndData
->DirtyThemeRegion
= TRUE
;
383 static LRESULT CALLBACK
384 ThemePostWindowProc(HWND hWnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
, ULONG_PTR ret
,PDWORD unknown
)
388 case WM_WINDOWPOSCHANGED
:
390 return OnPostWinPosChanged(hWnd
, (WINDOWPOS
*)lParam
);
394 ThemeDestroyWndData(hWnd
);
402 HRESULT
GetDiaogTextureBrush(HTHEME theme
, HWND hwnd
, HDC hdc
, HBRUSH
* result
, BOOL changeOrigin
)
406 pwndData
= ThemeGetWndData(hwnd
);
407 if (pwndData
== NULL
)
410 if (pwndData
->hTabBackgroundBrush
== NULL
)
417 hr
= UXTHEME_LoadImage(theme
, 0, TABP_BODY
, 0, &dummy
, FALSE
, &hbmp
, &bmpRect
, &hasImageAlpha
);
423 /* Unfortunately SetBrushOrgEx doesn't work at all */
424 RECT rcWindow
, rcParent
;
426 HDC hdcPattern
, hdcHackPattern
;
427 HBITMAP hbmpOld1
, hbmpold2
, hbmpHack
;
429 GetWindowRect(hwnd
, &rcWindow
);
430 GetWindowRect(GetParent(hwnd
), &rcParent
);
431 y
= (rcWindow
.top
- rcParent
.top
) % bmpRect
.bottom
;
433 hdcPattern
= CreateCompatibleDC(hdc
);
434 hbmpOld1
= (HBITMAP
)SelectObject(hdcPattern
, hbmp
);
436 hdcHackPattern
= CreateCompatibleDC(hdc
);
437 hbmpHack
= CreateCompatibleBitmap(hdc
, bmpRect
.right
, bmpRect
.bottom
);
438 hbmpold2
= (HBITMAP
)SelectObject(hdcHackPattern
, hbmpHack
);
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
);
443 hbmpold2
= (HBITMAP
)SelectObject(hdcHackPattern
, hbmpold2
);
444 hbmpOld1
= (HBITMAP
)SelectObject(hdcPattern
, hbmpOld1
);
446 DeleteDC(hdcPattern
);
447 DeleteDC(hdcHackPattern
);
449 /* Keep the handle of the bitmap we created so that it can be used later */
450 pwndData
->hTabBackgroundBmp
= hbmpHack
;
454 /* hbmp is cached so there is no need to free it */
455 pwndData
->hTabBackgroundBrush
= CreatePatternBrush(hbmp
);
458 if (!pwndData
->hTabBackgroundBrush
)
461 *result
= pwndData
->hTabBackgroundBrush
;
465 void HackFillStaticBg(HWND hwnd
, HDC hdc
, HBRUSH
* result
)
469 GetClientRect(hwnd
, &rcStatic
);
470 FillRect(hdc
, &rcStatic
, *result
);
472 SetBkMode (hdc
, TRANSPARENT
);
473 *result
= GetStockObject (NULL_BRUSH
);
476 static LRESULT CALLBACK
477 ThemeDlgPreWindowProc(HWND hWnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
, ULONG_PTR ret
,PDWORD unknown
)
482 static LRESULT CALLBACK
483 ThemeDlgPostWindowProc(HWND hWnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
, ULONG_PTR ret
,PDWORD unknown
)
489 case WM_CTLCOLORSTATIC
:
491 HWND hwndTarget
= (HWND
)lParam
;
492 HDC hdc
= (HDC
)wParam
;
493 HBRUSH
* phbrush
= (HBRUSH
*)ret
;
496 if(!IsAppThemed() || !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT
))
499 if (!IsThemeDialogTextureEnabled (hWnd
))
502 hTheme
= GetWindowTheme(hWnd
);
504 hTheme
= OpenThemeData(hWnd
, L
"TAB");
509 GetDiaogTextureBrush(hTheme
, hwndTarget
, hdc
, phbrush
, Msg
!= WM_CTLCOLORDLG
);
513 WCHAR controlClass
[32];
514 GetClassNameW (hwndTarget
, controlClass
, sizeof(controlClass
) / sizeof(controlClass
[0]));
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
);
521 SetBkMode( hdc
, TRANSPARENT
);
529 int WINAPI
ThemeSetWindowRgn(HWND hWnd
, HRGN hRgn
, BOOL bRedraw
)
531 PWND_DATA pwndData
= ThemeGetWndData(hWnd
);
534 pwndData
->HasAppDefinedRgn
= TRUE
;
535 pwndData
->HasThemeRgn
= FALSE
;
538 return g_user32ApiHook
.SetWindowRgn(hWnd
, hRgn
, bRedraw
);
541 BOOL WINAPI
ThemeGetScrollInfo(HWND hwnd
, int fnBar
, LPSCROLLINFO lpsi
)
547 /* Avoid creating a window context if it is not needed */
548 if(!IsAppThemed() || !(GetThemeAppProperties() & STAP_ALLOW_NONCLIENT
))
551 style
= GetWindowLongW(hwnd
, GWL_STYLE
);
552 if((style
& (WS_HSCROLL
|WS_VSCROLL
))==0)
555 pwndData
= ThemeGetWndData(hwnd
);
556 if (pwndData
== NULL
)
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
565 ret
= g_user32ApiHook
.GetScrollInfo(hwnd
, fnBar
, lpsi
);
567 (lpsi
->fMask
& SIF_TRACKPOS
) &&
568 pwndData
->SCROLL_TrackingWin
== hwnd
&&
569 pwndData
->SCROLL_TrackingBar
== fnBar
)
571 lpsi
->nTrackPos
= pwndData
->SCROLL_TrackingVal
;
576 return g_user32ApiHook
.GetScrollInfo(hwnd
, fnBar
, lpsi
);
579 INT WINAPI
ThemeSetScrollInfo(HWND hWnd
, int fnBar
, LPCSCROLLINFO lpsi
, BOOL bRedraw
)
583 LPSCROLLINFO lpsiout
= &siout
;
584 BOOL IsThemed
= FALSE
;
586 pwndData
= ThemeGetWndData(hWnd
);
591 if (pwndData
->hthemeScrollbar
)
594 memcpy(&siout
, lpsi
, sizeof(SCROLLINFO
));
596 siout
.fMask
|= SIF_THEMED
;
599 return g_user32ApiHook
.SetScrollInfo(hWnd
, fnBar
, lpsiout
, bRedraw
);
602 /**********************************************************************
607 ThemeInitApiHook(UAPIHK State
, PUSERAPIHOOK puah
)
609 if (!puah
|| State
!= uahLoadInit
)
611 UXTHEME_LoadTheme(FALSE
);
612 ThemeCleanupWndContext(NULL
, 0);
613 g_bThemeHooksActive
= FALSE
;
617 g_bThemeHooksActive
= TRUE
;
619 /* Store the original functions from user32 */
620 g_user32ApiHook
= *puah
;
622 puah
->DefWindowProcA
= ThemeDefWindowProcA
;
623 puah
->DefWindowProcW
= ThemeDefWindowProcW
;
624 puah
->PreWndProc
= ThemePreWindowProc
;
625 puah
->PostWndProc
= ThemePostWindowProc
;
626 puah
->PreDefDlgProc
= ThemeDlgPreWindowProc
;
627 puah
->PostDefDlgProc
= ThemeDlgPostWindowProc
;
628 puah
->DefWndProcArray
.MsgBitArray
= gabDWPmessages
;
629 puah
->DefWndProcArray
.Size
= UAHOWP_MAX_SIZE
;
630 puah
->WndProcArray
.MsgBitArray
= gabMSGPmessages
;
631 puah
->WndProcArray
.Size
= UAHOWP_MAX_SIZE
;
632 puah
->DlgProcArray
.MsgBitArray
= gabDLGPmessages
;
633 puah
->DlgProcArray
.Size
= UAHOWP_MAX_SIZE
;
635 puah
->SetWindowRgn
= ThemeSetWindowRgn
;
636 puah
->GetScrollInfo
= ThemeGetScrollInfo
;
637 puah
->SetScrollInfo
= ThemeSetScrollInfo
;
639 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_NCPAINT
);
640 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_NCACTIVATE
);
641 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_NCMOUSEMOVE
);
642 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_NCMOUSELEAVE
);
643 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_NCHITTEST
);
644 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_NCLBUTTONDOWN
);
645 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_NCUAHDRAWCAPTION
);
646 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_NCUAHDRAWFRAME
);
647 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_SETTEXT
);
648 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_WINDOWPOSCHANGED
);
649 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_CONTEXTMENU
);
650 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_STYLECHANGED
);
651 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_SETICON
);
652 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_NCDESTROY
);
653 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_SYSCOMMAND
);
654 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_CTLCOLORMSGBOX
);
655 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_CTLCOLORBTN
);
656 UAH_HOOK_MESSAGE(puah
->DefWndProcArray
, WM_CTLCOLORSTATIC
);
658 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_CREATE
);
659 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_SETTINGCHANGE
);
660 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_DRAWITEM
);
661 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_MEASUREITEM
);
662 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_WINDOWPOSCHANGING
);
663 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_WINDOWPOSCHANGED
);
664 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_STYLECHANGING
);
665 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_STYLECHANGED
);
666 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_NCCREATE
);
667 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_NCDESTROY
);
668 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_NCPAINT
);
669 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_MENUCHAR
);
670 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_MDISETMENU
);
671 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_THEMECHANGED
);
672 UAH_HOOK_MESSAGE(puah
->WndProcArray
, WM_UAHINIT
);
674 puah
->DlgProcArray
.MsgBitArray
= gabDLGPmessages
;
675 puah
->DlgProcArray
.Size
= UAHOWP_MAX_SIZE
;
677 UAH_HOOK_MESSAGE(puah
->DlgProcArray
, WM_INITDIALOG
);
678 UAH_HOOK_MESSAGE(puah
->DlgProcArray
, WM_CTLCOLORMSGBOX
);
679 UAH_HOOK_MESSAGE(puah
->DlgProcArray
, WM_CTLCOLORBTN
);
680 UAH_HOOK_MESSAGE(puah
->DlgProcArray
, WM_CTLCOLORDLG
);
681 UAH_HOOK_MESSAGE(puah
->DlgProcArray
, WM_CTLCOLORSTATIC
);
682 UAH_HOOK_MESSAGE(puah
->DlgProcArray
, WM_PRINTCLIENT
);
684 UXTHEME_LoadTheme(TRUE
);
689 typedef BOOL (WINAPI
* PREGISTER_UAH_WINXP
)(HINSTANCE hInstance
, USERAPIHOOKPROC CallbackFunc
);
690 typedef BOOL (WINAPI
* PREGISTER_UUAH_WIN2003
)(PUSERAPIHOOKINFO puah
);
699 lpFunc
= GetProcAddress(GetModuleHandle("user32.dll"), "RegisterUserApiHook");
701 ZeroMemory(&osvi
, sizeof(OSVERSIONINFO
));
702 osvi
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
705 if ( osvi
.dwMajorVersion
== 5 && osvi
.dwMinorVersion
== 1)
707 PREGISTER_UAH_WINXP lpfuncxp
= (PREGISTER_UAH_WINXP
)lpFunc
;
708 ret
= lpfuncxp(hDllInst
, ThemeInitApiHook
);
710 else if ( osvi
.dwMajorVersion
== 5 && osvi
.dwMinorVersion
== 2)
712 PREGISTER_UUAH_WIN2003 lpfunc2003
= (PREGISTER_UUAH_WIN2003
)lpFunc
;
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
;
721 ret
= lpfunc2003(&uah
);
729 UXTHEME_broadcast_theme_changed (NULL
, TRUE
);
739 ret
= UnregisterUserApiHook();
741 UXTHEME_broadcast_theme_changed (NULL
, FALSE
);
746 INT WINAPI
ClassicSystemParametersInfoW(UINT uiAction
, UINT uiParam
, PVOID pvParam
, UINT fWinIni
)
748 if (g_bThemeHooksActive
)
750 return g_user32ApiHook
.SystemParametersInfoW(uiAction
, uiParam
, pvParam
, fWinIni
);
753 return SystemParametersInfoW(uiAction
, uiParam
, pvParam
, fWinIni
);
756 INT WINAPI
ClassicSystemParametersInfoA(UINT uiAction
, UINT uiParam
, PVOID pvParam
, UINT fWinIni
)
758 if (g_bThemeHooksActive
)
760 return g_user32ApiHook
.SystemParametersInfoA(uiAction
, uiParam
, pvParam
, fWinIni
);
763 return SystemParametersInfoA(uiAction
, uiParam
, pvParam
, fWinIni
);
766 INT WINAPI
ClassicGetSystemMetrics(int nIndex
)
768 if (g_bThemeHooksActive
)
770 return g_user32ApiHook
.GetSystemMetrics(nIndex
);
773 return GetSystemMetrics(nIndex
);
776 BOOL WINAPI
ClassicAdjustWindowRectEx(LPRECT lpRect
, DWORD dwStyle
, BOOL bMenu
, DWORD dwExStyle
)
778 if (g_bThemeHooksActive
)
780 return g_user32ApiHook
.AdjustWindowRectEx(lpRect
, dwStyle
, bMenu
, dwExStyle
);
783 return AdjustWindowRectEx(lpRect
, dwStyle
, bMenu
, dwExStyle
);