diff options
| author | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-04-14 17:12:52 +0200 |
|---|---|---|
| committer | Jonas Kümmerlin <jonas@kuemmerlin.eu> | 2020-04-14 17:12:52 +0200 |
| commit | 0f6698f3b9f95552b2ad4a9dcd271941303067cd (patch) | |
| tree | b5f68af0ecb6c1fe7d26cf6ea0992f9324f01b76 /alf | |
| parent | 0948993ec9e08e170d1d22f2c7176b00bd987103 (diff) | |
use Win95 fonts and colors even when running on Win32s/NT3.51
Diffstat (limited to 'alf')
| -rw-r--r-- | alf/alf.cpp | 49 | ||||
| -rw-r--r-- | alf/alfcombobox.cpp | 11 | ||||
| -rw-r--r-- | alf/alflabel.cpp | 15 | ||||
| -rw-r--r-- | alf/alfspacer.cpp | 7 |
4 files changed, 31 insertions, 51 deletions
diff --git a/alf/alf.cpp b/alf/alf.cpp index c59cdbb..b4d9052 100644 --- a/alf/alf.cpp +++ b/alf/alf.cpp @@ -57,35 +57,29 @@ ALF_UpdateFontsPriv(HWND win, ALFWindowPriv *priv) { priv->fonts.dpi = ALF_Compat_GetDpiForWindow(win); - if (LOBYTE(LOWORD(GetVersion())) < 4) { - // NT 3.x uses System font for everything, we copy that - priv->fonts.hMessageFont = (HFONT)GetStockObject(SYSTEM_FONT); - GetObject(priv->fonts.hMessageFont, sizeof(priv->fonts.lfMessageFont), &priv->fonts.lfMessageFont); - } else { - // XXX: SystemParametersInfoForDpi is Unicode-only and needs Vista+ NONCLIENTMETRICS, - ALF_NONCLIENTMETRICSW_VISTA ncm; - ZeroMemory(&ncm, sizeof(ncm)); - ncm.cbSize = sizeof(ncm); + // XXX: SystemParametersInfoForDpi is Unicode-only and needs Vista+ NONCLIENTMETRICS, + ALF_NONCLIENTMETRICSW_VISTA ncm; + ZeroMemory(&ncm, sizeof(ncm)); + ncm.cbSize = sizeof(ncm); - if (ALF_Compat_SystemParametersInfoForDpi(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0, priv->fonts.dpi)) { + if (ALF_Compat_SystemParametersInfoForDpi(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0, priv->fonts.dpi)) { #ifdef UNICODE - priv->fonts.lfMessageFont = ncm.lfMessageFont; + priv->fonts.lfMessageFont = ncm.lfMessageFont; #else - ALF_Compat_LogFontWtoA(&ncm.lfMessageFont, &priv->fonts.lfMessageFont); + 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)); + } else { + // FIXME! fallback to default font, 8pt MS Shell Dlg + ZeroMemory(&priv->fonts.lfMessageFont, sizeof(priv->fonts.lfMessageFont)); - priv->fonts.lfMessageFont.lfHeight = -MulDiv(8, priv->fonts.dpi, 72); - lstrcpy(priv->fonts.lfMessageFont.lfFaceName, TEXT("MS Shell Dlg")); - } + priv->fonts.lfMessageFont.lfHeight = -MulDiv(8, priv->fonts.dpi, 72); + lstrcpy(priv->fonts.lfMessageFont.lfFaceName, TEXT("MS Shell Dlg")); + } - if (priv->fonts.hMessageFont) { - DeleteObject(priv->fonts.hMessageFont); - } - priv->fonts.hMessageFont = CreateFontIndirect(&priv->fonts.lfMessageFont); + if (priv->fonts.hMessageFont) { + DeleteObject(priv->fonts.hMessageFont); } + priv->fonts.hMessageFont = CreateFontIndirect(&priv->fonts.lfMessageFont); ALF_ApplyFontsPriv(win, priv); } @@ -470,6 +464,8 @@ ALF_BuildUniqueName(TCHAR *buf, const TCHAR *prefix, ULONG_PTR uniquifier) uniquifier >>= 4; i--; } + + buf[prefixlen + numlen] = 0; } LPTSTR @@ -493,12 +489,7 @@ ALF_RegisterWindowClass(HINSTANCE hInstance, const ALFWindowClassParams *params) cls.style = params->classStyle; cls.hInstance = hInstance; cls.hCursor = LoadCursor(NULL, (LPTSTR)IDC_ARROW); - if (LOBYTE(LOWORD(GetVersion())) >= 4) { - cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); - } else { - // NT 3.x has white dialog backgrounds - cls.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - } + cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); cls.lpszClassName = classNamePtr; cls.cbWndExtra = sizeof(void*); cls.cbClsExtra = sizeof(void*); @@ -696,7 +687,7 @@ ALF_Text(HWND hwnd) } } - return NULL; + return ALF_New(TCHAR, 1); } TCHAR * // free with ALF_Free diff --git a/alf/alfcombobox.cpp b/alf/alfcombobox.cpp index efe3706..bf64cb9 100644 --- a/alf/alfcombobox.cpp +++ b/alf/alfcombobox.cpp @@ -112,9 +112,9 @@ ALF__ComboWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return SendMessage(hwndChild, CB_GETCURSEL, wParam, lParam); } if ((uMsg == ALF_CB_SETCURSEL || uMsg == CB_SETCURSEL) && hwndChild) { - LRESULT curSel = SendMessage(hwndChild, CB_GETCURSEL, wParam, lParam); + LRESULT curSel = SendMessage(hwndChild, CB_GETCURSEL, 0, 0); if ((WPARAM)curSel != wParam) { - LRESULT newSel = SendMessage(hwndChild, CB_SETCURSEL, wParam, lParam); + LRESULT newSel = SendMessage(hwndChild, CB_SETCURSEL, wParam, 0); SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(GetWindowLong(hwndChild, GWL_ID), CBN_SELCHANGE), (LPARAM)hwndChild); return newSel; } @@ -272,12 +272,7 @@ ALF_RegisterComboClass(void) cls.hInstance = ALF_HINSTANCE; cls.hCursor = LoadCursor(NULL, (LPTSTR)IDC_ARROW); - if (LOBYTE(LOWORD(GetVersion())) >= 4) { - cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); - } else { - // NT 3.x has white dialog backgrounds - cls.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - } + cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); cls.lpszClassName = classNameBuf; cls.cbWndExtra = sizeof(void*); cls.lpfnWndProc = ALF__ComboWindowProc; diff --git a/alf/alflabel.cpp b/alf/alflabel.cpp index 422a8dc..73216e1 100644 --- a/alf/alflabel.cpp +++ b/alf/alflabel.cpp @@ -131,7 +131,12 @@ ALF__LabelWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) TCHAR *text = ALF_Text(hwnd); if (!IsWindowEnabled(hwnd)) { - if (GetVersion() >= 0x80000000) { + if (!ALF_Compat_IsMinWindowsVersion(4, 0)) { + // Win32s/NT 3.51 uses gray text, but a different gray than Win9x + SetTextColor(hdc, GetSysColor(COLOR_BTNSHADOW)); + + DrawText(hdc, text, -1, &rc, format); + } if (GetVersion() >= 0x80000000) { // Win9x just uses gray text. DSS_DISABLED is broken there, too, // so we can't get the NT look even if we wanted to SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); @@ -209,7 +214,7 @@ ALF_AddLabel(HWND win, WORD id, UINT x, UINT y, const TCHAR *text) { HWND hwndLabel = CreateWindow(_alf_labelClass, text, - WS_CHILD | WS_VISIBLE | SS_OWNERDRAW, + WS_CHILD | WS_VISIBLE, 0, 0, 100, 100, win, (HMENU)(int)id, @@ -246,12 +251,6 @@ ALF_RegisterLabelClass(void) cls.hInstance = ALF_HINSTANCE; cls.hCursor = LoadCursor(NULL, (LPTSTR)IDC_ARROW); - if (LOBYTE(LOWORD(GetVersion())) >= 4) { - cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); - } else { - // NT 3.x has white dialog backgrounds - cls.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - } cls.lpszClassName = classNameBuf; cls.cbWndExtra = sizeof(void*); cls.lpfnWndProc = ALF__LabelWindowProc; diff --git a/alf/alfspacer.cpp b/alf/alfspacer.cpp index 1b9278d..7c0f776 100644 --- a/alf/alfspacer.cpp +++ b/alf/alfspacer.cpp @@ -13,12 +13,7 @@ ALF_RegisterSpacerClass(void) cls.hInstance = ALF_HINSTANCE; cls.hCursor = LoadCursor(NULL, (LPTSTR)IDC_ARROW); - if (LOBYTE(LOWORD(GetVersion())) >= 4) { - cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); - } else { - // NT 3.x has white dialog backgrounds - cls.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - } + cls.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); cls.lpszClassName = classNameBuf; cls.cbWndExtra = sizeof(void*); cls.lpfnWndProc = DefWindowProc; |
