From 94119478207034b767c1d0a4fa5d8950f7b07b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 4 Aug 2022 18:18:37 +0200 Subject: Use C++ casts, nullptr. --- c/win.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'c/win.cpp') diff --git a/c/win.cpp b/c/win.cpp index a120f96..19cfaab 100644 --- a/c/win.cpp +++ b/c/win.cpp @@ -22,11 +22,11 @@ const char* Win32Error::what() const noexcept if (!m_szMsg) FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (char*)&m_szMsg, - 0, NULL); + 0, nullptr); return m_szMsg; } @@ -35,11 +35,11 @@ const wchar_t* Win32Error::What() const noexcept if (!m_wszMsg) FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, code, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (wchar_t*)&m_wszMsg, - 0, NULL); + 0, nullptr); return m_wszMsg; } @@ -75,14 +75,14 @@ int EBMessageBox(const wchar_t* const wszText, const wchar_t* const wszCaption, if (!g_hWnd || nCode < 0 || nCode != HCBT_ACTIVATE) return CallNextHookEx(0, nCode, wParam, lParam); - HWND hWnd = (HWND)wParam; + HWND hWnd = reinterpret_cast(wParam); long lStyle = GetWindowLong(hWnd, GWL_STYLE); if (!(lStyle & WS_POPUP)) return 0; RECT rcMain, rcMsg; GetWindowRect(g_hWnd, &rcMain); GetWindowRect(hWnd, &rcMsg); - SetWindowPos(hWnd, NULL, + SetWindowPos(hWnd, nullptr, rcMain.left+(rcMain.right-rcMain.left)/2-(rcMsg.right-rcMsg.left)/2, rcMain.top+(rcMain.bottom-rcMain.top)/2-(rcMsg.bottom-rcMsg.top)/2, -1, -1, @@ -91,7 +91,7 @@ int EBMessageBox(const wchar_t* const wszText, const wchar_t* const wszCaption, return 0; }; - HHOOK hHook = Require(SetWindowsHookEx(WH_CBT, proc, (HINSTANCE)NULL, GetCurrentThreadId())); + HHOOK hHook = Require(SetWindowsHookEx(WH_CBT, proc, nullptr, GetCurrentThreadId())); int r = MessageBox(g_hWnd, wszText, wszCaption, uType); Require(UnhookWindowsHookEx(hHook)); return r; @@ -102,7 +102,7 @@ int GetRelativeCursorPos(HWND hWnd, POINT* pt) RECT rc; if (!GetClientRect(hWnd, &rc)) return 0; SetLastError(ERROR_SUCCESS); - if (!MapWindowPoints(hWnd, NULL, (POINT*)&rc, 2)) return 0; + if (!MapWindowPoints(hWnd, nullptr, (POINT*)&rc, 2)) return 0; POINT ptMouse; if (!GetCursorPos(&ptMouse)) return 0; -- cgit v1.2.3