From dccea47e9bc322d654902a1db4fc52cbf6dd0cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Tue, 26 Jul 2022 18:51:15 +0200 Subject: Improve Win32Error, library handling code. --- c/main.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'c/main.cpp') diff --git a/c/main.cpp b/c/main.cpp index 057bf32..2037578 100644 --- a/c/main.cpp +++ b/c/main.cpp @@ -167,22 +167,21 @@ static LRESULT CALLBACK CBTProc(const int nCode, const WPARAM wParam, const LPAR g_hWnd = (HWND)wParam; /* Look up constants. */ - if (auto opLib = maybe_make(TEXT("User32.dll"))) - if (auto GetDpiForWindow = opLib->GetProcAddress("GetDpiForWindow")) - g_iDPI = GetDpiForWindow(g_hWnd); - - if (auto opLib = maybe_make(TEXT("uxtheme.dll"))) - if (opLib->GetProcAddress("SetWindowTheme")) - g_bThemes = 1; - - if (auto opLib = maybe_make(TEXT("User32.dll"))) { - if (opLib->GetProcAddress("SystemParametersInfo" WA)) { - NONCLIENTMETRICS m; - m.cbSize = sizeof(NONCLIENTMETRICS); - require(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, - sizeof(NONCLIENTMETRICS), &m, 0)); - g_hfNormal = require(CreateFontIndirect(&m.lfMessageFont)); - } + if (auto opLib = maybe_make(TEXT("User32.dll")); + auto GetDpiForWindow = opLib->GetProcAddress("GetDpiForWindow")) + g_iDPI = GetDpiForWindow(g_hWnd); + + if (auto opLib = maybe_make(TEXT("uxtheme.dll")); + opLib->GetProcAddress("SetWindowTheme")) + g_bThemes = 1; + + if (auto opLib = maybe_make(TEXT("User32.dll")); + opLib->GetProcAddress("SystemParametersInfo" WA)) { + NONCLIENTMETRICS m; + m.cbSize = sizeof(NONCLIENTMETRICS); + require(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, + sizeof(NONCLIENTMETRICS), &m, 0)); + g_hfNormal = require(CreateFontIndirect(&m.lfMessageFont)); } else g_hfNormal = static_cast(require(GetStockObject(DEFAULT_GUI_FONT))); -- cgit v1.2.3