From cf8707bf2ede99d8543d806355eee088bdc1376b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 6 Aug 2022 01:21:08 +0200 Subject: Use typedefs when interacting with Win32 API. It's not like they're ever going to change the definition of WORD (knock on wood) -- but I guess it's proper to use them as if their definitions might change. --- c/win.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'c/win.h') diff --git a/c/win.h b/c/win.h index d36cbdf..ff38ce0 100644 --- a/c/win.h +++ b/c/win.h @@ -5,9 +5,11 @@ #include /* Display message box centered in main window. */ -int EBMessageBox(const wchar_t* wszText, const wchar_t* wszCaption, unsigned uType); +int EBMessageBox(const wchar_t* wszText, const wchar_t* wszCaption, UINT uType); /* Retrieve mouse position relative to given window's client area. */ int GetRelativeCursorPos(HWND hWnd, POINT* pt); +/* Cached values from GetSystemMetrics. */ +template auto Metric = GetSystemMetrics(I); /* Exception for Windows API errors. */ struct Win32Error : public std::exception @@ -45,10 +47,6 @@ T* Library::GetProcAddress(const char* const szProc) noexcept return (T*)(void*)::GetProcAddress(m_hModule, szProc); } -/* Variable template for caching values from GetSystemMetrics. */ -template -auto Metric = GetSystemMetrics(I); - /* Check result of Windows API call, throwing error on null. */ template inline T Require(const T x) @@ -97,7 +95,7 @@ inline BOOL SetWindowRect(const HWND hWnd, const RECT r) } /* The following functions call uxtheme.dll functions, if uxtheme.dll - * exists, and otherwise do nothing.. */ + * exists, and otherwise do nothing. */ inline BOOL EBIsThemeActive() { @@ -105,9 +103,10 @@ inline BOOL EBIsThemeActive() return IsThemeActive? IsThemeActive(): 0; } -inline BOOL EBSetWindowTheme(HWND hWnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList) +inline BOOL EBSetWindowTheme(const HWND hWnd, const wchar_t* const pszSubAppName, + const wchar_t* const pszSubIdList) { - extern BOOL (*SetWindowTheme)(HWND, LPCWSTR, LPCWSTR); + extern BOOL (*SetWindowTheme)(HWND, const wchar_t*, const wchar_t*); return SetWindowTheme? SetWindowTheme(hWnd, pszSubAppName, pszSubIdList): 0; } -- cgit v1.2.3