2011-05-14 18:31:47 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS uxtheme.dll
|
|
|
|
* FILE: dll/win32/uxtheme/themehooks.c
|
|
|
|
* PURPOSE: uxtheme user api hook functions
|
|
|
|
* PROGRAMMER: Giannis Adamopoulos
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <undocuser.h>
|
|
|
|
|
|
|
|
#include "vfwmsgs.h"
|
|
|
|
#include "uxtheme.h"
|
2011-07-12 19:45:49 +00:00
|
|
|
#include "uxthemedll.h"
|
2011-05-14 18:31:47 +00:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern HINSTANCE hDllInst;
|
|
|
|
|
2011-05-14 18:47:23 +00:00
|
|
|
LRESULT CALLBACK ThemeWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, WNDPROC DefWndProc);
|
2011-05-14 18:31:47 +00:00
|
|
|
|
|
|
|
USERAPIHOOK user32ApiHook;
|
|
|
|
BYTE gabDWPmessages[UAHOWP_MAX_SIZE];
|
2011-05-14 18:47:23 +00:00
|
|
|
BYTE gabMSGPmessages[UAHOWP_MAX_SIZE];
|
2011-05-14 18:31:47 +00:00
|
|
|
|
|
|
|
static LRESULT CALLBACK
|
|
|
|
ThemeDefWindowProcW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2011-08-02 13:38:58 +00:00
|
|
|
if(!IsThemeActive())
|
|
|
|
{
|
|
|
|
return user32ApiHook.DefWindowProcW(hWnd,
|
|
|
|
Msg,
|
|
|
|
wParam,
|
|
|
|
lParam);
|
|
|
|
}
|
|
|
|
|
2011-05-14 18:47:23 +00:00
|
|
|
return ThemeWndProc(hWnd,
|
|
|
|
Msg,
|
|
|
|
wParam,
|
|
|
|
lParam,
|
|
|
|
user32ApiHook.DefWindowProcW);
|
2011-05-14 18:31:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CALLBACK
|
|
|
|
ThemeDefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2011-08-02 13:38:58 +00:00
|
|
|
if(!IsThemeActive())
|
|
|
|
{
|
|
|
|
return user32ApiHook.DefWindowProcA(hWnd,
|
|
|
|
Msg,
|
|
|
|
wParam,
|
|
|
|
lParam);
|
|
|
|
}
|
|
|
|
|
2011-05-14 18:47:23 +00:00
|
|
|
return ThemeWndProc(hWnd,
|
|
|
|
Msg,
|
|
|
|
wParam,
|
|
|
|
lParam,
|
|
|
|
user32ApiHook.DefWindowProcA);
|
2011-05-14 18:31:47 +00:00
|
|
|
}
|
|
|
|
|
2011-08-02 13:38:58 +00:00
|
|
|
static LRESULT CALLBACK
|
|
|
|
ThemePreWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, ULONG_PTR ret,PDWORD unknown)
|
|
|
|
{
|
|
|
|
switch(Msg)
|
|
|
|
{
|
|
|
|
case WM_THEMECHANGED:
|
|
|
|
UXTHEME_LoadTheme();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-14 18:31:47 +00:00
|
|
|
BOOL CALLBACK
|
|
|
|
ThemeInitApiHook(UAPIHK State, PUSERAPIHOOK puah)
|
|
|
|
{
|
|
|
|
/* Sanity checks for the caller */
|
|
|
|
if (!puah || State != uahLoadInit)
|
2011-05-14 18:45:37 +00:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store the original functions from user32 */
|
|
|
|
user32ApiHook = *puah;
|
2011-05-14 18:31:47 +00:00
|
|
|
|
2011-05-14 18:45:37 +00:00
|
|
|
puah->DefWindowProcA = ThemeDefWindowProcA;
|
|
|
|
puah->DefWindowProcW = ThemeDefWindowProcW;
|
2011-08-02 13:38:58 +00:00
|
|
|
puah->PreWndProc = ThemePreWindowProc;
|
2011-05-14 18:31:47 +00:00
|
|
|
puah->DefWndProcArray.MsgBitArray = gabDWPmessages;
|
|
|
|
puah->DefWndProcArray.Size = UAHOWP_MAX_SIZE;
|
2011-05-14 18:47:23 +00:00
|
|
|
puah->WndProcArray.MsgBitArray = gabMSGPmessages;
|
|
|
|
puah->WndProcArray.Size = UAHOWP_MAX_SIZE;
|
2011-05-14 18:31:47 +00:00
|
|
|
|
2011-05-14 18:45:37 +00:00
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCPAINT);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCACTIVATE);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCMOUSEMOVE);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCMOUSELEAVE);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCHITTEST);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCLBUTTONDOWN);
|
2011-05-14 18:47:23 +00:00
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCUAHDRAWCAPTION);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCUAHDRAWFRAME);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_SETTEXT);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_WINDOWPOSCHANGED);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_CONTEXTMENU);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_STYLECHANGED);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_SETICON);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_NCDESTROY);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_SYSCOMMAND);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_CTLCOLORMSGBOX);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_CTLCOLORBTN);
|
|
|
|
UAH_HOOK_MESSAGE(puah->DefWndProcArray, WM_CTLCOLORSTATIC);
|
|
|
|
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_CREATE);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_SETTINGCHANGE);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_DRAWITEM);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_MEASUREITEM);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_WINDOWPOSCHANGING);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_WINDOWPOSCHANGED);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_STYLECHANGING);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_STYLECHANGED);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_NCCREATE);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_NCDESTROY);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_NCPAINT);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_MENUCHAR);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_MDISETMENU);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_THEMECHANGED);
|
|
|
|
UAH_HOOK_MESSAGE(puah->WndProcArray, WM_UAHINIT);
|
|
|
|
|
2011-08-07 20:50:01 +00:00
|
|
|
UXTHEME_LoadTheme();
|
|
|
|
|
2011-05-14 18:31:47 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef BOOL (WINAPI * PREGISTER_UAH_WINXP)(HINSTANCE hInstance, USERAPIHOOKPROC CallbackFunc);
|
|
|
|
typedef BOOL (WINAPI * PREGISTER_UUAH_WIN2003)(PUSERAPIHOOKINFO puah);
|
|
|
|
|
|
|
|
BOOL WINAPI
|
|
|
|
ThemeHooksInstall()
|
|
|
|
{
|
2011-05-14 18:45:37 +00:00
|
|
|
PVOID lpFunc;
|
|
|
|
OSVERSIONINFO osvi;
|
2011-08-07 20:42:22 +00:00
|
|
|
BOOL ret;
|
2011-05-14 18:45:37 +00:00
|
|
|
|
|
|
|
lpFunc = GetProcAddress(GetModuleHandle("user32.dll"), "RegisterUserApiHook");
|
|
|
|
|
2011-05-14 18:31:47 +00:00
|
|
|
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
|
|
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
2011-05-14 18:45:37 +00:00
|
|
|
GetVersionEx(&osvi);
|
|
|
|
|
|
|
|
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1)
|
|
|
|
{
|
|
|
|
PREGISTER_UAH_WINXP lpfuncxp = (PREGISTER_UAH_WINXP)lpFunc;
|
2011-08-07 20:42:22 +00:00
|
|
|
ret = lpfuncxp(hDllInst, ThemeInitApiHook);
|
2011-05-14 18:45:37 +00:00
|
|
|
}
|
|
|
|
else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2)
|
|
|
|
{
|
|
|
|
PREGISTER_UUAH_WIN2003 lpfunc2003 = (PREGISTER_UUAH_WIN2003)lpFunc;
|
|
|
|
USERAPIHOOKINFO uah;
|
|
|
|
|
|
|
|
uah.m_size = sizeof(uah);
|
|
|
|
uah.m_dllname1 = L"uxtheme.dll";
|
|
|
|
uah.m_funname1 = L"ThemeInitApiHook";
|
|
|
|
uah.m_dllname2 = NULL;
|
|
|
|
uah.m_funname2 = NULL;
|
|
|
|
|
2011-08-07 20:42:22 +00:00
|
|
|
ret = lpfunc2003(&uah);
|
2011-05-14 18:45:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
2011-08-07 20:42:22 +00:00
|
|
|
ret = FALSE;
|
2011-05-14 18:45:37 +00:00
|
|
|
}
|
2011-08-07 20:42:22 +00:00
|
|
|
|
|
|
|
UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED);
|
|
|
|
|
|
|
|
return ret;
|
2011-05-14 18:31:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI
|
|
|
|
ThemeHooksRemove()
|
|
|
|
{
|
2011-08-12 10:21:10 +00:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
ret = UnregisterUserApiHook();
|
|
|
|
|
|
|
|
if(IsThemeActive())
|
|
|
|
UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|