summaryrefslogtreecommitdiff
path: root/alf/alfcompat.h
diff options
context:
space:
mode:
authorJonas Kümmerlin <jonas@kuemmerlin.eu>2019-05-01 16:27:25 +0200
committerJonas Kümmerlin <jonas@kuemmerlin.eu>2019-05-01 16:27:25 +0200
commitae25d8012939de481633fa3572e7cd598d8a5a5f (patch)
tree87d8222d6c27a8e5f041eeb86d85a846510eec43 /alf/alfcompat.h
parentf6dad4900a82c58a6666cdcdd46150b28bc2aa23 (diff)
redo compat function architecture
way less code at the expense of explicit initialization
Diffstat (limited to 'alf/alfcompat.h')
-rw-r--r--alf/alfcompat.h85
1 files changed, 58 insertions, 27 deletions
diff --git a/alf/alfcompat.h b/alf/alfcompat.h
index 0d5a7d4..6926de5 100644
--- a/alf/alfcompat.h
+++ b/alf/alfcompat.h
@@ -8,39 +8,51 @@
#define WM_DPICHANGED 0x02E0
#endif
+#ifdef __cplusplus
extern "C" IMAGE_DOS_HEADER __ImageBase;
+#else
+extern IMAGE_DOS_HEADER __ImageBase;
+#endif
#define ALF_HINSTANCE ((HINSTANCE)&__ImageBase)
typedef LRESULT (CALLBACK *ALF_COMPAT_SUBCLASSPROC)(HWND,UINT,WPARAM,LPARAM,UINT_PTR,DWORD_PTR);
typedef struct {
- UINT cbSize;
- int iBorderWidth;
- int iScrollWidth;
- int iScrollHeight;
- int iCaptionWidth;
- int iCaptionHeight;
- LOGFONT lfCaptionFont;
- int iSmCaptionWidth;
- int iSmCaptionHeight;
- LOGFONT lfSmCaptionFont;
- int iMenuWidth;
- int iMenuHeight;
- LOGFONT lfMenuFont;
- LOGFONT lfStatusFont;
- LOGFONT lfMessageFont;
- int iPaddedBorderWidth; // new in Vista
-} ALF_NONCLIENTMETRICS_VISTA;
-
-static inline SIZE_T
-ALF_SizeOf_NONCLIENTMETRICS(void)
-{
- if (LOBYTE(LOWORD(GetVersion())) >= 6) {
- return sizeof(ALF_NONCLIENTMETRICS_VISTA);
- } else {
- return sizeof(ALF_NONCLIENTMETRICS_VISTA) - sizeof(int);
- }
-}
+ UINT cbSize;
+ int iBorderWidth;
+ int iScrollWidth;
+ int iScrollHeight;
+ int iCaptionWidth;
+ int iCaptionHeight;
+ LOGFONTW lfCaptionFont;
+ int iSmCaptionWidth;
+ int iSmCaptionHeight;
+ LOGFONTW lfSmCaptionFont;
+ int iMenuWidth;
+ int iMenuHeight;
+ LOGFONTW lfMenuFont;
+ LOGFONTW lfStatusFont;
+ LOGFONTW lfMessageFont;
+ int iPaddedBorderWidth; // new in Vista
+} ALF_NONCLIENTMETRICSW_VISTA;
+typedef struct {
+ UINT cbSize;
+ int iBorderWidth;
+ int iScrollWidth;
+ int iScrollHeight;
+ int iCaptionWidth;
+ int iCaptionHeight;
+ LOGFONTA lfCaptionFont;
+ int iSmCaptionWidth;
+ int iSmCaptionHeight;
+ LOGFONTA lfSmCaptionFont;
+ int iMenuWidth;
+ int iMenuHeight;
+ LOGFONTA lfMenuFont;
+ LOGFONTA lfStatusFont;
+ LOGFONTA lfMessageFont;
+ int iPaddedBorderWidth; // new in Vista
+} ALF_NONCLIENTMETRICSA_VISTA;
long
ALF_GetAveCharWidth(HDC hdc);
@@ -75,6 +87,25 @@ typedef struct {
#define TMT_TRANSITIONDURATION 6000
#endif
+void ALF_LoadCompatFunctions(void);
+void ALF_UnloadCompatFunctions(void);
+
+inline static void
+ALF_Compat_LogFontWtoA(const LOGFONTW *w, LOGFONTA *a)
+{
+ CopyMemory(a, w, sizeof(LOGFONTA) - LF_FACESIZE);
+ WideCharToMultiByte(CP_ACP, 0, w->lfFaceName, -1, a->lfFaceName, LF_FACESIZE, NULL, NULL);
+ a->lfFaceName[LF_FACESIZE - 1] = '\0';
+}
+
+inline static void
+ALF_Compat_LogFontAtoW(const LOGFONTA *a, LOGFONTW *w)
+{
+ CopyMemory(w, a, sizeof(LOGFONTA) - LF_FACESIZE);
+ MultiByteToWideChar(CP_ACP, 0, a->lfFaceName, -1, w->lfFaceName, LF_FACESIZE);
+ w->lfFaceName[LF_FACESIZE - 1] = 0;
+}
+
extern BOOL (WINAPI *ALF_Compat_IsAppThemed)(void);
extern UINT (WINAPI *ALF_Compat_GetDpiForWindow)(HWND);
extern BOOL (WINAPI *ALF_Compat_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);