#include "alfpriv.h" #include DWORD _alf_compatBits = 0; typedef struct { LONG lock; SIZE currentBitmapSize; SIZE maxBitmapSize; HDC hdcBuffer; HBITMAP hbmBuffer; HBITMAP hbmOld; HDC hdcTarget; RECT rcTarget; } ALFCompatBufferedPaintPriv; ALFCompatBufferedPaintPriv *_alf_compatBufferedPaintPriv = NULL; static DWORD ALF_DllGetVersion(const char *dll) { HMODULE hDll = GetModuleHandleA(dll); if (hDll) { DLLGETVERSIONPROC pDllGetVersion; pDllGetVersion = (DLLGETVERSIONPROC)(void*)GetProcAddress(hDll, "DllGetVersion"); if (pDllGetVersion) { DLLVERSIONINFO dvi; HRESULT hr; ZeroMemory(&dvi, sizeof(dvi)); dvi.cbSize = sizeof(dvi); hr = (*pDllGetVersion)(&dvi); if (SUCCEEDED(hr)) { return (DWORD)MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion); } } } return 0; } static int WINAPI ALF_Compat_fallbackGetSystemMetricsForDpi(int nIndex, UINT dpi) { (void)dpi; if (!ALF_Compat_Is40()) { // old NT does not support several properties, so we fake them switch (nIndex) { case SM_CXEDGE: case SM_CYEDGE: return 2; } } return GetSystemMetrics(nIndex); } static BOOL WINAPI ALF_Compat_fallbackIsAppThemed(void) { return FALSE; } static UINT WINAPI ALF_Compat_fallbackGetDpiForWindow(HWND win) { (void)win; UINT dpi = 0; HDC hdcScreen = GetDC(NULL); if (hdcScreen) { dpi = (UINT)GetDeviceCaps(hdcScreen, LOGPIXELSY); ReleaseDC(NULL, hdcScreen); } if (!dpi) { dpi = 96; // FIXME! fallback to default DPI } return dpi; } static BOOL WINAPI ALF_Compat_fallbackSystemParametersInfoForDpi(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni, UINT dpi) { (void)dpi; // NOTE: we only use SystemParametersInfoForDpi for SPI_GETNONCLIENTMETRICS, // therefore we only provide a fallback for that. // SystemParametersInfoForDpi only accepts the Vista+ version of NONCLIENTMETRICSW. if (uiAction == SPI_GETNONCLIENTMETRICS && uiParam == sizeof(ALF_NONCLIENTMETRICSW_VISTA)) { ALF_NONCLIENTMETRICSW_VISTA *ncmw = (ALF_NONCLIENTMETRICSW_VISTA*)pvParam; // SystemParametersInfoForDpi is Unicode-only, but // we need to provide a fallback even on ANSI systems #ifdef UNICODE SIZE_T s = sizeof(*ncmw); if (!ALF_Compat_IsVista()) { // pre-vista OS doesn't contain last member s -= sizeof(ncmw->iPaddedBorderWidth); ncmw->iPaddedBorderWidth = 0; } ncmw->cbSize = (UINT)s; return SystemParametersInfo(SPI_GETNONCLIENTMETRICS, (UINT)s, ncmw, fWinIni); #else ALF_NONCLIENTMETRICSA_VISTA ncma; ZeroMemory(&ncma, sizeof(ncma)); SIZE_T s = sizeof(ncma); if (!ALF_Compat_IsVista()) { // pre-vista OS doesn't contain last member s -= sizeof(ncma.iPaddedBorderWidth); ncma.iPaddedBorderWidth = 0; } ncma.cbSize = s; if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, s, &ncma, fWinIni)) { ncmw->iBorderWidth = ncma.iBorderWidth; ncmw->iScrollWidth = ncma.iScrollWidth; ncmw->iScrollHeight = ncma.iScrollHeight; ncmw->iCaptionWidth = ncma.iCaptionWidth; ncmw->iCaptionHeight = ncma.iCaptionHeight; ALF_Compat_LogFontAtoW(&ncma.lfCaptionFont, &ncmw->lfCaptionFont); ncmw->iSmCaptionWidth = ncma.iSmCaptionWidth; ncmw->iSmCaptionHeight = ncma.iSmCaptionHeight; ALF_Compat_LogFontAtoW(&ncma.lfSmCaptionFont, &ncmw->lfSmCaptionFont); ncmw->iMenuWidth = ncma.iMenuWidth; ncmw->iMenuHeight = ncma.iMenuHeight; ALF_Compat_LogFontAtoW(&ncma.lfMenuFont, &ncmw->lfMenuFont); ALF_Compat_LogFontAtoW(&ncma.lfStatusFont, &ncmw->lfStatusFont); ALF_Compat_LogFontAtoW(&ncma.lfMessageFont, &ncmw->lfMessageFont); ncmw->iPaddedBorderWidth = ncma.iPaddedBorderWidth; return TRUE; } return FALSE; #endif } return FALSE; } static BOOL WINAPI ALF_Compat_fallbackAdjustWindowRectExForDpi(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, UINT dpi) { (void)dpi; return AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle); } long ALF_GetAveCharWidth(HDC hdc) { // see: HOWTO: Calculate Dialog Units When Not Using the System Font SIZE s; GetTextExtentPoint32A(hdc, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &s); return (s.cx / 26 + 1) / 2; } static HTHEME WINAPI ALF_Compat_fallbackOpenThemeData(HWND window, LPCWSTR classNames) { (void)window; (void)classNames; return NULL; } static HRESULT WINAPI ALF_Compat_fallbackCloseThemeData(HTHEME hTheme) { (void)hTheme; return S_OK; } static BOOL WINAPI ALF_Compat_fallbackIsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, int iStateId) { (void)hTheme; (void)iPartId; (void)iStateId; return TRUE; } static HRESULT WINAPI ALF_Compat_fallbackDrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc) { HWND parent = GetParent(hwnd); if (!parent) return E_NOTIMPL; RECT rc; if (prc) { rc = *prc; } else { GetClientRect(hwnd, &rc); } MapWindowRect(hwnd, parent, &rc); RECT childr; GetClientRect(hwnd, &childr); MapWindowRect(hwnd, parent, &childr); POINT o; OffsetViewportOrgEx(hdc, -childr.left, -childr.top, &o); HRGN oldClipRgn = CreateRectRgn(0, 0, 0, 0); if (!GetClipRgn(hdc, oldClipRgn)) { DeleteObject(oldClipRgn); oldClipRgn = NULL; } IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom); SendMessage(parent, WM_ERASEBKGND, (WPARAM)hdc, 0); SendMessage(parent, WM_PRINTCLIENT, (WPARAM)hdc, (LPARAM)PRF_CLIENT); SelectClipRgn(hdc, oldClipRgn); if (oldClipRgn) { DeleteObject(oldClipRgn); } SetViewportOrgEx(hdc, o.x, o.y, NULL); return S_OK; } static HRESULT WINAPI ALF_Compat_fallbackDrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect) { (void)hTheme; (void)hdc; (void)iPartId; (void)iStateId; (void)pRect; (void)pClipRect; return E_NOTIMPL; } static HRESULT WINAPI ALF_Compat_fallbackGetThemeBackgroundContentRect(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect) { (void)hTheme; (void)hdc; (void)iPartId; (void)iStateId; (void)pBoundingRect; (void)pContentRect; return E_NOTIMPL; } static HRESULT WINAPI ALF_Compat_fallbackGetThemeTextExtent(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, const RECT *pBoundingRect, RECT *pExtentRect) { (void)hTheme; (void)hdc; (void)iPartId; (void)iStateId; (void)pszText; (void)iCharCount; (void)dwTextFlags; (void)pBoundingRect; (void)pExtentRect; return E_NOTIMPL; } static HRESULT WINAPI ALF_Compat_fallbackDrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect) { (void)hTheme; (void)hdc; (void)iPartId; (void)iStateId; (void)pszText; (void)iCharCount; (void)dwTextFlags; (void)dwTextFlags2; (void)pRect; return E_NOTIMPL; } static BOOL WINAPI ALF_Compat_fallbackTrackMouseEvent(LPTRACKMOUSEEVENT tme) { (void)tme; return FALSE; } static HRESULT WINAPI ALF_Compat_fallbackBufferedPaintInit(void) { return E_NOTIMPL; } static HRESULT WINAPI ALF_Compat_fallbackBufferedPaintUnInit(void) { return E_NOTIMPL; } static ALF_Compat_HPAINTBUFFER WINAPI ALF_Compat_fallbackBeginBufferedPaint(HDC hdc, const RECT *prcTarget, DWORD dwFormat, ALF_Compat_BP_PAINTPARAMS *pPaintParams, HDC *phdcTarget) { if (dwFormat != 0 || pPaintParams != 0 || !_alf_compatBufferedPaintPriv || prcTarget->right - prcTarget->left > _alf_compatBufferedPaintPriv->maxBitmapSize.cx || prcTarget->bottom - prcTarget->top > _alf_compatBufferedPaintPriv->maxBitmapSize.cy || InterlockedExchange(&_alf_compatBufferedPaintPriv->lock, 1)) { SetLastError(ERROR_NOT_SUPPORTED); return NULL; } // we have locked the buffer! now allocate the bitmap if necessary if (!_alf_compatBufferedPaintPriv->hdcBuffer) { _alf_compatBufferedPaintPriv->hdcBuffer = CreateCompatibleDC(NULL); if (!_alf_compatBufferedPaintPriv->hdcBuffer) { InterlockedExchange(&_alf_compatBufferedPaintPriv->lock, 0); return NULL; } } if (!_alf_compatBufferedPaintPriv->hbmBuffer || prcTarget->right - prcTarget->left > _alf_compatBufferedPaintPriv->currentBitmapSize.cx || prcTarget->bottom - prcTarget->top > _alf_compatBufferedPaintPriv->currentBitmapSize.cy) { DeleteBitmap(_alf_compatBufferedPaintPriv->hbmBuffer); int neww = _alf_compatBufferedPaintPriv->currentBitmapSize.cx; int newh = _alf_compatBufferedPaintPriv->currentBitmapSize.cy; if (neww < 1) neww = 32; if (newh < 1) newh = 16; while (neww < prcTarget->right - prcTarget->left) { neww *= 2; } while (newh < prcTarget->bottom - prcTarget->top) { newh *= 2; } HDC hdcScreen = GetDC(NULL); _alf_compatBufferedPaintPriv->hbmBuffer = CreateCompatibleBitmap(hdcScreen, neww, newh); ReleaseDC(NULL, hdcScreen); if (!_alf_compatBufferedPaintPriv->hbmBuffer) { InterlockedExchange(&_alf_compatBufferedPaintPriv->lock, 0); return NULL; } _alf_compatBufferedPaintPriv->currentBitmapSize.cx = neww; _alf_compatBufferedPaintPriv->currentBitmapSize.cy = newh; } _alf_compatBufferedPaintPriv->hbmOld = SelectBitmap(_alf_compatBufferedPaintPriv->hdcBuffer, _alf_compatBufferedPaintPriv->hbmBuffer); _alf_compatBufferedPaintPriv->hdcTarget = hdc; _alf_compatBufferedPaintPriv->rcTarget = *prcTarget; *phdcTarget = _alf_compatBufferedPaintPriv->hdcBuffer; return _alf_compatBufferedPaintPriv; } static ALF_Compat_HANIMATIONBUFFER WINAPI ALF_Compat_fallbackBeginBufferedAnimation(HWND hwnd, HDC hdcTarget, const RECT *prcTarget, DWORD dwFormat, ALF_Compat_BP_PAINTPARAMS *pPaintParams, ALF_Compat_BP_ANIMATIONPARAMS *pAnimationParams, HDC *phdcFrom, HDC *phdcTo) { (void)hwnd; if (pAnimationParams != NULL && pAnimationParams->dwDuration == 0) { *phdcFrom = NULL; return ALF_Compat_fallbackBeginBufferedPaint(hdcTarget, prcTarget, dwFormat, pPaintParams, phdcTo); } else { SetLastError(ERROR_NOT_SUPPORTED); return NULL; } } extern HRESULT WINAPI ALF_Compat_fallbackEndBufferedPaint(ALF_Compat_HPAINTBUFFER hpbBuffer, BOOL fUpdateTarget) { if (hpbBuffer != _alf_compatBufferedPaintPriv) return E_INVALIDARG; if (fUpdateTarget) BitBlt(_alf_compatBufferedPaintPriv->hdcTarget, _alf_compatBufferedPaintPriv->rcTarget.left, _alf_compatBufferedPaintPriv->rcTarget.top, _alf_compatBufferedPaintPriv->rcTarget.right - _alf_compatBufferedPaintPriv->rcTarget.left, _alf_compatBufferedPaintPriv->rcTarget.bottom - _alf_compatBufferedPaintPriv->rcTarget.top, _alf_compatBufferedPaintPriv->hdcBuffer, 0, 0, SRCCOPY); SelectBitmap(_alf_compatBufferedPaintPriv->hdcBuffer, _alf_compatBufferedPaintPriv->hbmOld); _alf_compatBufferedPaintPriv->hdcTarget = NULL; InterlockedExchange(&_alf_compatBufferedPaintPriv->lock, 0); return S_OK; } static HRESULT WINAPI ALF_Compat_fallbackEndBufferedAnimation(ALF_Compat_HANIMATIONBUFFER hbpAnimation, BOOL fUpdateTarget) { return ALF_Compat_fallbackEndBufferedPaint(hbpAnimation, fUpdateTarget); } static BOOL WINAPI ALF_Compat_fallbackBufferedPaintRenderAnimation(HWND hwnd, HDC hdc) { (void)hwnd; (void)hdc; return FALSE; } static HRESULT WINAPI ALF_Compat_fallbackGetThemeTransitionDuration(HTHEME hTheme, int iPartId, int iStateIdFrom, int iStateIdTo, int iPropId, DWORD *pdwDuration) { (void)hTheme; (void)iPartId; (void)iStateIdFrom; (void)iStateIdTo; (void)iPropId; (void)pdwDuration; return E_NOTIMPL; } static HRESULT WINAPI ALF_Compat_fallbackGetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz) { (void)hTheme; (void)hdc; (void)iPartId; (void)iStateId; (void)prc; (void)eSize; (void)psz; return E_NOTIMPL; } static HRESULT WINAPI ALF_Compat_fallbackGetThemeColor(HTHEME hTheme, int iPartId, int iStateId, int iPropId, COLORREF *pColor) { (void)hTheme; (void)iPartId; (void)iStateId; (void)iPropId; (void)pColor; return E_NOTIMPL; } static HRESULT WINAPI ALF_Compat_fallbackGetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, LPCRECT prc, MARGINS *pMargins) { (void)hTheme; (void)hdc; (void)iPartId; (void)iStateId; (void)iPropId; (void)prc; (void)pMargins; return E_NOTIMPL; } static HRESULT WINAPI ALF_Compat_fallbackLoadIconWithScaleDown(HINSTANCE hinst, PCWSTR pszName, int cx, int cy, HICON *phico) { (void)hinst; (void)pszName; (void)cx; (void)cy; (void)phico; return E_NOTIMPL; } static BOOL WINAPI ALF_Compat_fallbackGetMonitorInfoA(HMONITOR monitor, MONITORINFO *lpmi) { if (monitor != (HMONITOR)0x12340042 || !lpmi || lpmi->cbSize != sizeof(MONITORINFO)) return FALSE; lpmi->rcMonitor.left = 0; lpmi->rcMonitor.top = 0; lpmi->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN); lpmi->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN); SystemParametersInfoA(SPI_GETWORKAREA, 0, &lpmi->rcWork, 0); lpmi->dwFlags = MONITORINFOF_PRIMARY; return TRUE; } static HMONITOR WINAPI ALF_Compat_fallbackMonitorFromPoint(POINT pt, DWORD flags) { (void)pt; (void)flags; return (HMONITOR)0x12340042; // like multimon.h } static HMONITOR WINAPI ALF_Compat_fallbackMonitorFromWindow(HWND window, DWORD flags) { (void)window; (void)flags; return (HMONITOR)0x12340042; // like multimon.h } static BOOL CALLBACK ALF_Compat_DrawDisabledText_DrawStateProc(HDC hdc, LPARAM lData, WPARAM wData, int cx, int cy) { RECT rc = { 0, 0, cx, cy }; DrawText(hdc, (const TCHAR *)lData, -1, &rc, (UINT)wData); return TRUE; } static int ALF_Compat_DrawDisabledTextEmbossed(HDC hdc, LPCTSTR lpchText, int cchText, LPRECT lprc, UINT format) { (void)cchText; return DrawState(hdc, NULL, ALF_Compat_DrawDisabledText_DrawStateProc, (LPARAM)lpchText, (WPARAM)format, lprc->left, lprc->top, lprc->right - lprc->left, lprc->bottom - lprc->top, DST_COMPLEX | DSS_DISABLED); } static int ALF_Compat_DrawDisabledTextSolid(HDC hdc, LPCTSTR lpchText, int cchText, LPRECT lprc, UINT format) { COLORREF oldcolor = SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); int r = DrawText(hdc, lpchText, cchText, lprc, format); SetTextColor(hdc, oldcolor); return r; } // FIXME! This is how NT 3.x does it, need to figure out how to get the real 16bit look static int ALF_Compat_DrawDisabledText31(HDC hdc, LPCTSTR lpchText, int cchText, LPRECT lprc, UINT format) { COLORREF oldcolor = SetTextColor(hdc, GetSysColor(COLOR_BTNSHADOW)); int r = DrawText(hdc, lpchText, cchText, lprc, format); SetTextColor(hdc, oldcolor); return r; } #define LOAD_FUNC(dll, name) do { \ if (_alf_dll_##dll) \ *((FARPROC*)&ALF_Compat_##name) = GetProcAddress(_alf_dll_##dll, #name); \ else \ ALF_Compat_##name = NULL; \ \ if (!ALF_Compat_##name) \ ALF_Compat_##name = ALF_Compat_fallback##name; \ } while (0) #define UNLOAD_FUNC(name) do { ALF_Compat_##name = NULL; } while (0) static HMODULE _alf_dll_uxtheme = NULL; static HMODULE _alf_dll_user32 = NULL; static HMODULE _alf_dll_comctl32 = NULL; void ALF_LoadCompatFunctions(void) { // setup compat bits DWORD v = GetVersion(); DWORD vMajor = LOBYTE(LOWORD(v)); DWORD vMinor = HIBYTE(LOWORD(v)); if (v < 0x80000000) _alf_compatBits |= ALF_COMPAT_ISNT; if (vMajor >= 4) _alf_compatBits |= ALF_COMPAT_IS40; if (vMajor >= 5) _alf_compatBits |= ALF_COMPAT_ISW2K; if (vMajor > 5 || (vMajor == 5 && vMinor >= 1)) _alf_compatBits |= ALF_COMPAT_ISXP; if (vMajor >= 6) _alf_compatBits |= ALF_COMPAT_ISVISTA; // load compat functions if (ALF_Compat_IsXP()) // don't even attempt to load uxtheme.dll on non-XP _alf_dll_uxtheme = LoadLibraryA("uxtheme.dll"); _alf_dll_user32 = LoadLibraryA("user32.dll"); _alf_dll_comctl32 = LoadLibraryA("comctl32.dll"); if (ALF_DllGetVersion("comctl32.dll") >= 0x60000) { _alf_compatBits |= ALF_COMPAT_ISCOMCTLV6; LOAD_FUNC(uxtheme, IsAppThemed); } else { ALF_Compat_IsAppThemed = ALF_Compat_fallbackIsAppThemed; } LOAD_FUNC(user32, GetDpiForWindow); LOAD_FUNC(user32, AdjustWindowRectExForDpi); LOAD_FUNC(user32, GetSystemMetricsForDpi); LOAD_FUNC(user32, SystemParametersInfoForDpi); LOAD_FUNC(user32, GetMonitorInfoA); LOAD_FUNC(user32, MonitorFromPoint); LOAD_FUNC(user32, MonitorFromWindow); *((FARPROC*)&ALF_Compat_TrackMouseEvent) = GetProcAddress(_alf_dll_comctl32, "_TrackMouseEvent"); if (!ALF_Compat_TrackMouseEvent) ALF_Compat_TrackMouseEvent = ALF_Compat_fallbackTrackMouseEvent; LOAD_FUNC(uxtheme, OpenThemeData); LOAD_FUNC(uxtheme, CloseThemeData); LOAD_FUNC(uxtheme, IsThemeBackgroundPartiallyTransparent); LOAD_FUNC(uxtheme, DrawThemeParentBackground); LOAD_FUNC(uxtheme, DrawThemeBackground); LOAD_FUNC(uxtheme, GetThemeBackgroundContentRect); LOAD_FUNC(uxtheme, GetThemeTextExtent); LOAD_FUNC(uxtheme, DrawThemeText); LOAD_FUNC(uxtheme, BufferedPaintInit); LOAD_FUNC(uxtheme, BufferedPaintUnInit); LOAD_FUNC(uxtheme, BeginBufferedAnimation); LOAD_FUNC(uxtheme, BeginBufferedPaint); LOAD_FUNC(uxtheme, EndBufferedAnimation); LOAD_FUNC(uxtheme, EndBufferedPaint); LOAD_FUNC(uxtheme, BufferedPaintRenderAnimation); LOAD_FUNC(uxtheme, GetThemeTransitionDuration); LOAD_FUNC(uxtheme, GetThemePartSize); LOAD_FUNC(uxtheme, GetThemeColor); LOAD_FUNC(uxtheme, GetThemeMargins); LOAD_FUNC(comctl32, LoadIconWithScaleDown); // initialize helper function for disabled text if (ALF_Compat_Is40()) { if (GetSystemMetrics(SM_SLOWMACHINE)) { ALF_Compat_DrawDisabledText = ALF_Compat_DrawDisabledTextSolid; } else { ALF_Compat_DrawDisabledText = ALF_Compat_DrawDisabledTextEmbossed; } } else { ALF_Compat_DrawDisabledText = ALF_Compat_DrawDisabledText31; } // initialize double buffering wrapper if (ALF_Compat_BufferedPaintInit == ALF_Compat_fallbackBufferedPaintInit) { // set max size based on available RAM, so that at most 1‰ of it is spent on us int maxx = 0; int maxy = 0; MEMORYSTATUS ms; ZeroMemory(&ms, sizeof(ms)); GlobalMemoryStatus(&ms); if (ms.dwTotalPhys >= 16777216u) { maxx = 128; maxy = 32; } if (ms.dwTotalPhys >= 33554432u) { maxy = 64; } if (ms.dwTotalPhys >= 67108864u) { maxx = 256; } if (ms.dwTotalPhys >= 134217728u) { maxy = 128; } if (ms.dwTotalPhys >= 268435456u) { maxx = 512; } if (ms.dwTotalPhys >= 536870912u) { maxx = 1024; } if (ms.dwTotalPhys >= 1073741824u) { maxy = 256; } if (ms.dwTotalPhys >= 2147483648u) { maxy = 512; } if (ms.dwTotalPhys == (SIZE_T)-1) { maxy = 1024; } if (maxx > 0 && maxy > 0) { _alf_compatBufferedPaintPriv = ALF_New(ALFCompatBufferedPaintPriv, 1); _alf_compatBufferedPaintPriv->maxBitmapSize.cx = maxx; _alf_compatBufferedPaintPriv->maxBitmapSize.cy = maxy; } } } void ALF_UnloadCompatFunctions(void) { if (_alf_compatBufferedPaintPriv) { DeleteDC(_alf_compatBufferedPaintPriv->hdcBuffer); DeleteBitmap(_alf_compatBufferedPaintPriv->hbmBuffer); ALF_Free(_alf_compatBufferedPaintPriv); _alf_compatBufferedPaintPriv = NULL; } UNLOAD_FUNC(IsAppThemed); UNLOAD_FUNC(GetDpiForWindow); UNLOAD_FUNC(AdjustWindowRectExForDpi); UNLOAD_FUNC(GetSystemMetricsForDpi); UNLOAD_FUNC(SystemParametersInfoForDpi); UNLOAD_FUNC(TrackMouseEvent); UNLOAD_FUNC(OpenThemeData); UNLOAD_FUNC(CloseThemeData); UNLOAD_FUNC(IsThemeBackgroundPartiallyTransparent); UNLOAD_FUNC(DrawThemeParentBackground); UNLOAD_FUNC(DrawThemeBackground); UNLOAD_FUNC(GetThemeBackgroundContentRect); UNLOAD_FUNC(GetThemeTextExtent); UNLOAD_FUNC(DrawThemeText); UNLOAD_FUNC(BufferedPaintInit); UNLOAD_FUNC(BufferedPaintUnInit); UNLOAD_FUNC(BeginBufferedAnimation); UNLOAD_FUNC(BeginBufferedPaint); UNLOAD_FUNC(EndBufferedAnimation); UNLOAD_FUNC(EndBufferedPaint); UNLOAD_FUNC(BufferedPaintRenderAnimation); UNLOAD_FUNC(GetThemeTransitionDuration); UNLOAD_FUNC(GetThemePartSize); UNLOAD_FUNC(GetThemeColor); UNLOAD_FUNC(GetThemeMargins); UNLOAD_FUNC(LoadIconWithScaleDown); FreeLibrary(_alf_dll_uxtheme); FreeLibrary(_alf_dll_user32); FreeLibrary(_alf_dll_comctl32); } #undef LOAD_FUNC #undef UNLOAD_FUNC int (*ALF_Compat_DrawDisabledText)(HDC,LPCTSTR,int,LPRECT,UINT) = NULL; BOOL (WINAPI *ALF_Compat_IsAppThemed)(void) = NULL; UINT (WINAPI *ALF_Compat_GetDpiForWindow)(HWND /*window*/) = NULL; BOOL (WINAPI *ALF_Compat_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT) = NULL; int (WINAPI *ALF_Compat_GetSystemMetricsForDpi)(int, UINT) = NULL; BOOL (WINAPI *ALF_Compat_SystemParametersInfoForDpi)(UINT,UINT,PVOID,UINT,UINT) = NULL; HTHEME (WINAPI *ALF_Compat_OpenThemeData)(HWND, LPCWSTR) = NULL; HRESULT (WINAPI *ALF_Compat_CloseThemeData)(HTHEME) = NULL; BOOL (WINAPI *ALF_Compat_IsThemeBackgroundPartiallyTransparent)(HTHEME,int,int) = NULL; HRESULT (WINAPI *ALF_Compat_DrawThemeParentBackground)(HWND,HDC,RECT *) = NULL; HRESULT (WINAPI *ALF_Compat_DrawThemeBackground)(HTHEME, HDC, int, int, const RECT *, const RECT *) = NULL; HRESULT (WINAPI *ALF_Compat_GetThemeBackgroundContentRect)(HTHEME,HDC,int,int,const RECT *,RECT *) = NULL; HRESULT (WINAPI *ALF_Compat_GetThemeTextExtent)(HTHEME,HDC,int,int,LPCWSTR,int,DWORD,const RECT *, RECT *) = NULL; HRESULT (WINAPI *ALF_Compat_DrawThemeText)(HTHEME,HDC,int,int,LPCWSTR,int,DWORD,DWORD,const RECT *) = NULL; BOOL (WINAPI *ALF_Compat_TrackMouseEvent)(LPTRACKMOUSEEVENT tme) = NULL; HRESULT (WINAPI *ALF_Compat_GetThemePartSize)(HTHEME,HDC,int,int,RECT *,THEMESIZE,SIZE *) = NULL; HRESULT (WINAPI *ALF_Compat_BufferedPaintInit)(void) = NULL; HRESULT (WINAPI *ALF_Compat_BufferedPaintUnInit)(void) = NULL; ALF_Compat_HANIMATIONBUFFER (WINAPI *ALF_Compat_BeginBufferedAnimation)(HWND,HDC,const RECT *,DWORD,ALF_Compat_BP_PAINTPARAMS *,ALF_Compat_BP_ANIMATIONPARAMS *,HDC *,HDC *) = NULL; ALF_Compat_HPAINTBUFFER (WINAPI *ALF_Compat_BeginBufferedPaint)(HDC,const RECT *,DWORD,ALF_Compat_BP_PAINTPARAMS *,HDC *) = NULL; HRESULT (WINAPI *ALF_Compat_EndBufferedAnimation)(ALF_Compat_HANIMATIONBUFFER,BOOL) = NULL; HRESULT (WINAPI *ALF_Compat_EndBufferedPaint)(ALF_Compat_HPAINTBUFFER,BOOL) = NULL; BOOL (WINAPI *ALF_Compat_BufferedPaintRenderAnimation)(HWND,HDC) = NULL; HRESULT (WINAPI *ALF_Compat_GetThemeTransitionDuration)(HTHEME,int,int,int,int,DWORD*) = NULL; HRESULT (WINAPI *ALF_Compat_GetThemeColor)(HTHEME,int,int,int,COLORREF*) = NULL; HRESULT (WINAPI *ALF_Compat_GetThemeMargins)(HTHEME,HDC,int,int,int,const RECT *,MARGINS *) = NULL; HRESULT (WINAPI *ALF_Compat_LoadIconWithScaleDown)(HINSTANCE,PCWSTR,int,int,HICON *) = NULL; BOOL (WINAPI *ALF_Compat_GetMonitorInfoA)(HMONITOR,MONITORINFO *) = NULL; HMONITOR (WINAPI *ALF_Compat_MonitorFromPoint)(POINT,DWORD) = NULL; HMONITOR (WINAPI *ALF_Compat_MonitorFromWindow)(HWND,DWORD) = NULL;