diff options
author | John Ankarström <john@ankarstrom.se> | 2022-08-06 01:21:08 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-08-06 01:21:08 +0200 |
commit | cf8707bf2ede99d8543d806355eee088bdc1376b (patch) | |
tree | 0f1ffc52906d9f66f75631bd97dfb0dcf91989ad /c/win.h | |
parent | c0024748e8ff2f46e5d37a054fa349f24ddc497f (diff) | |
download | EpisodeBrowser-cf8707bf2ede99d8543d806355eee088bdc1376b.tar.gz |
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.
Diffstat (limited to 'c/win.h')
-rw-r--r-- | c/win.h | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -5,9 +5,11 @@ #include <windows.h> /* 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 <int I> 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 <int I> -auto Metric = GetSystemMetrics(I); - /* Check result of Windows API call, throwing error on null. */ template <typename T> 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; } |