summaryrefslogtreecommitdiff
path: root/alf/alf.cpp
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/alf.cpp
parentf6dad4900a82c58a6666cdcdd46150b28bc2aa23 (diff)
redo compat function architecture
way less code at the expense of explicit initialization
Diffstat (limited to 'alf/alf.cpp')
-rw-r--r--alf/alf.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/alf/alf.cpp b/alf/alf.cpp
index 92ba1bf..06b0099 100644
--- a/alf/alf.cpp
+++ b/alf/alf.cpp
@@ -62,14 +62,17 @@ ALF_UpdateFontsPriv(HWND win, ALFWindowPriv *priv)
priv->fonts.hMessageFont = (HFONT)GetStockObject(SYSTEM_FONT);
GetObject(priv->fonts.hMessageFont, sizeof(priv->fonts.lfMessageFont), &priv->fonts.lfMessageFont);
} else {
- // XXX: SystemParametersInfoForDpi needs the Vista+ NONCLIENTMETRICS,
- // but we want to be able to build with WINVER = 0x0500 and PSDK2003
- ALF_NONCLIENTMETRICS_VISTA ncm;
+ // XXX: SystemParametersInfoForDpi is Unicode-only and needs Vista+ NONCLIENTMETRICS,
+ ALF_NONCLIENTMETRICSW_VISTA ncm;
ZeroMemory(&ncm, sizeof(ncm));
- ncm.cbSize = ALF_SizeOf_NONCLIENTMETRICS();
+ ncm.cbSize = sizeof(ncm);
if (ALF_Compat_SystemParametersInfoForDpi(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0, priv->fonts.dpi)) {
+#ifdef UNICODE
priv->fonts.lfMessageFont = ncm.lfMessageFont;
+#else
+ ALF_Compat_LogFontWtoA(&ncm.lfMessageFont, &priv->fonts.lfMessageFont);
+#endif
} else {
// FIXME! fallback to default font, 8pt MS Shell Dlg
ZeroMemory(&priv->fonts.lfMessageFont, sizeof(priv->fonts.lfMessageFont));
@@ -356,6 +359,8 @@ ALF_Initialize(void)
if (!_alf_initCounter++) {
InitCommonControls();
+ ALF_LoadCompatFunctions();
+
ALF_RegisterComboClass();
ALF_RegisterPanelClass();
ALF_RegisterSpacerClass();
@@ -382,6 +387,8 @@ ALF_UnInitialize(void)
UnregisterClass(_alf_comboClass, ALF_HINSTANCE);
UnregisterClass(_alf_panelClass, ALF_HINSTANCE);
UnregisterClass(_alf_spacerClass, ALF_HINSTANCE);
+
+ ALF_UnloadCompatFunctions();
}
// release init lock
@@ -636,7 +643,7 @@ ALF_SetWidgetText(HWND parent, WORD id, const TCHAR *text)
TCHAR * // free with ALF_Free
ALF_Text(HWND hwnd)
{
- int len = GetWindowTextLengthA(hwnd);
+ int len = GetWindowTextLength(hwnd);
if (len > 0) {
TCHAR *buf = ALF_New(TCHAR, len+1);
if (GetWindowText(hwnd, buf, len)) {