From bb9280267bfb78a8d69adea02f5ed7894833b19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Fri, 2 Sep 2022 01:21:58 +0200 Subject: Improve Windows XP compatibility. Various bug fixes. --- c/main.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'c/main.cpp') diff --git a/c/main.cpp b/c/main.cpp index 2af8030..203a24d 100644 --- a/c/main.cpp +++ b/c/main.cpp @@ -60,8 +60,8 @@ FileView g_fvElv(L"elvdata.dat", g_cfg.cEp+128u); FileView g_fvDlv(L"dlvdata.dat", g_cfg.cEp+128u); /* Optional Windows functions. */ -BOOL (*IsThemeActive)(); -BOOL (*SetWindowTheme)(HWND, const wchar_t*, const wchar_t*); +BOOL (__stdcall *IsThemeActive)(); +HRESULT (__stdcall *SetWindowTheme)(HWND, const wchar_t*, const wchar_t*); /* Initialize important global state on parent window creation. */ static void InitializeMainWindow(HWND); @@ -157,16 +157,21 @@ void InitializeMainWindow(const HWND hWnd) /* Load normal font. */ if (auto lib = Library::Maybe(L"User32.dll"); lib && lib->GetProcAddress("SystemParametersInfoW")) { - NONCLIENTMETRICS m = {sizeof(NONCLIENTMETRICS)}; - Require(SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &m, 0)); + NONCLIENTMETRICSW m = {sizeof(NONCLIENTMETRICSW)}; + +#if (WINVER >= 0x0600) + m.cbSize -= 4; +#endif + + Require(SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSW), &m, 0)); g_hfNormal = Require(CreateFontIndirectW(&m.lfMessageFont)); } else g_hfNormal = static_cast(Require(GetStockObject(DEFAULT_GUI_FONT))); /* Load bold font. */ { - LOGFONT lf; - Require(GetObjectW(g_hfNormal, sizeof(LOGFONT), &lf)); + LOGFONTW lf; + Require(GetObjectW(g_hfNormal, sizeof(LOGFONTW), &lf)); lf.lfWeight = FW_BOLD; g_hfBold = Require(CreateFontIndirectW(&lf)); } -- cgit v1.2.3