diff options
| author | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-05-29 23:43:00 +0200 |
|---|---|---|
| committer | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-05-29 23:43:00 +0200 |
| commit | c9ebff8e7de093e7705aab6208593fae048ad98d (patch) | |
| tree | 06f641c182e4013e95c7fa1f255e4adbd32a67f2 /alf/alfcompat.cpp | |
| parent | 46326d57e0c912f265595ffed375d211bbe23f44 (diff) | |
controls: subclass generic "ALFControl" window
The idea is that the compiler can strip unused controls when linking
statically, but the window class initialization functions blocked that.
Diffstat (limited to 'alf/alfcompat.cpp')
| -rw-r--r-- | alf/alfcompat.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/alf/alfcompat.cpp b/alf/alfcompat.cpp index ec14b00..12a79f4 100644 --- a/alf/alfcompat.cpp +++ b/alf/alfcompat.cpp @@ -356,6 +356,58 @@ ALF_Compat_fallbackGetThemeColor(HTHEME hTheme, return E_NOTIMPL; } +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 { \ @@ -413,6 +465,17 @@ void ALF_LoadCompatFunctions(void) LOAD_FUNC(uxtheme, GetThemeTransitionDuration); LOAD_FUNC(uxtheme, GetThemePartSize); LOAD_FUNC(uxtheme, GetThemeColor); + + // initialize helper function for disabled text + if (ALF_Compat_IsMinWindowsVersion(4, 0)) { + if (GetSystemMetrics(SM_SLOWMACHINE)) { + ALF_Compat_DrawDisabledText = ALF_Compat_DrawDisabledTextSolid; + } else { + ALF_Compat_DrawDisabledText = ALF_Compat_DrawDisabledTextEmbossed; + } + } else { + ALF_Compat_DrawDisabledText = ALF_Compat_DrawDisabledText31; + } } void ALF_UnloadCompatFunctions(void) @@ -448,6 +511,8 @@ void ALF_UnloadCompatFunctions(void) #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; |
