diff --git a/src/modules/FileLocksmith/FileLocksmithExt/ExplorerCommand.cpp b/src/modules/FileLocksmith/FileLocksmithExt/ExplorerCommand.cpp index 6db892d2fb..e61d50da9e 100644 --- a/src/modules/FileLocksmith/FileLocksmithExt/ExplorerCommand.cpp +++ b/src/modules/FileLocksmith/FileLocksmithExt/ExplorerCommand.cpp @@ -247,7 +247,7 @@ inline std::wstring get_module_folderpath(HMODULE mod = nullptr, const bool remo { PathRemoveFileSpecW(buffer); } - return { buffer, (UINT)lstrlenW(buffer) }; + return { buffer, static_cast(lstrlenW(buffer)) }; } HRESULT ExplorerCommand::LaunchUI(CMINVOKECOMMANDINFO* pici, ipc::Writer* writer) diff --git a/src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp b/src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp index 9f9db964f5..b61b75ea8d 100644 --- a/src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp +++ b/src/modules/alwaysontop/AlwaysOnTop/AlwaysOnTop.cpp @@ -23,7 +23,7 @@ namespace NonLocalizable bool isExcluded(HWND window) { auto processPath = get_process_path(window); - CharUpperBuffW(processPath.data(), (DWORD)processPath.length()); + CharUpperBuffW(processPath.data(), static_cast(processPath.length())); return find_app_name_in_path(processPath, AlwaysOnTopSettings::settings().excludedApps); } @@ -381,7 +381,7 @@ bool AlwaysOnTop::IsPinned(HWND window) const noexcept bool AlwaysOnTop::PinTopmostWindow(HWND window) const noexcept { - if (!SetProp(window, NonLocalizable::WINDOW_IS_PINNED_PROP, (HANDLE)1)) + if (!SetProp(window, NonLocalizable::WINDOW_IS_PINNED_PROP, reinterpret_cast(1))) { Logger::error(L"SetProp failed, {}", get_last_error_or_default(GetLastError())); } diff --git a/src/modules/alwaysontop/AlwaysOnTop/FrameDrawer.cpp b/src/modules/alwaysontop/AlwaysOnTop/FrameDrawer.cpp index 9613769f2f..3978f3d105 100644 --- a/src/modules/alwaysontop/AlwaysOnTop/FrameDrawer.cpp +++ b/src/modules/alwaysontop/AlwaysOnTop/FrameDrawer.cpp @@ -188,10 +188,10 @@ D2D1_ROUNDED_RECT FrameDrawer::ConvertRect(RECT rect, int thickness, float radiu float halfThickness = thickness / 2.0f; // 1 is needed to eliminate the gap between border and window - auto d2d1Rect = D2D1::RectF((float)rect.left + halfThickness + 1, - (float)rect.top + halfThickness + 1, - (float)rect.right - halfThickness - 1, - (float)rect.bottom - halfThickness - 1); + auto d2d1Rect = D2D1::RectF(static_cast(rect.left) + halfThickness + 1, + static_cast(rect.top) + halfThickness + 1, + static_cast(rect.right) - halfThickness - 1, + static_cast(rect.bottom) - halfThickness - 1); return D2D1::RoundedRect(d2d1Rect, radius, radius); } @@ -200,10 +200,10 @@ D2D1_RECT_F FrameDrawer::ConvertRect(RECT rect, int thickness) float halfThickness = thickness / 2.0f; // 1 is needed to eliminate the gap between border and window - return D2D1::RectF((float)rect.left + halfThickness + 1, - (float)rect.top + halfThickness + 1, - (float)rect.right - halfThickness - 1, - (float)rect.bottom - halfThickness - 1); + return D2D1::RectF(static_cast(rect.left) + halfThickness + 1, + static_cast(rect.top) + halfThickness + 1, + static_cast(rect.right) - halfThickness - 1, + static_cast(rect.bottom) - halfThickness - 1); } void FrameDrawer::Render() diff --git a/src/modules/alwaysontop/AlwaysOnTop/Settings.cpp b/src/modules/alwaysontop/AlwaysOnTop/Settings.cpp index f91ce253a8..251fa1f6ba 100644 --- a/src/modules/alwaysontop/AlwaysOnTop/Settings.cpp +++ b/src/modules/alwaysontop/AlwaysOnTop/Settings.cpp @@ -169,7 +169,7 @@ void AlwaysOnTopSettings::LoadSettings() std::wstring apps = std::move(*jsonVal); std::vector excludedApps; auto excludedUppercase = apps; - CharUpperBuffW(excludedUppercase.data(), (DWORD)excludedUppercase.length()); + CharUpperBuffW(excludedUppercase.data(), static_cast(excludedUppercase.length())); std::wstring_view view(excludedUppercase); view = left_trim(trim(view)); diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZonesData/CustomLayouts.cpp b/src/modules/fancyzones/FancyZonesLib/FancyZonesData/CustomLayouts.cpp index a64e2f4991..4040273cc7 100644 --- a/src/modules/fancyzones/FancyZonesLib/FancyZonesData/CustomLayouts.cpp +++ b/src/modules/fancyzones/FancyZonesLib/FancyZonesData/CustomLayouts.cpp @@ -242,7 +242,7 @@ std::optional CustomLayouts::GetLayout(const GUID& id) const noexcep { auto layoutInfo = std::get(customLayout.info); layout.sensitivityRadius = layoutInfo.sensitivityRadius; - layout.zoneCount = (int)layoutInfo.zones.size(); + layout.zoneCount = static_cast(layoutInfo.zones.size()); } return layout; diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZonesWindowProperties.cpp b/src/modules/fancyzones/FancyZonesLib/FancyZonesWindowProperties.cpp index 2cec6f78f4..dd3298cd8a 100644 --- a/src/modules/fancyzones/FancyZonesLib/FancyZonesWindowProperties.cpp +++ b/src/modules/fancyzones/FancyZonesLib/FancyZonesWindowProperties.cpp @@ -85,7 +85,7 @@ ZoneIndexSet FancyZonesWindowProperties::RetrieveZoneIndexProperty(HWND window) void FancyZonesWindowProperties::StampMovedOnOpeningProperty(HWND window) { - ::SetPropW(window, ZonedWindowProperties::PropertyMovedOnOpening, (HANDLE)1); + ::SetPropW(window, ZonedWindowProperties::PropertyMovedOnOpening, reinterpret_cast(1)); } bool FancyZonesWindowProperties::RetrieveMovedOnOpeningProperty(HWND window) diff --git a/src/modules/fancyzones/FancyZonesLib/GenericKeyHook.h b/src/modules/fancyzones/FancyZonesLib/GenericKeyHook.h index 76716ca407..a826e2280f 100644 --- a/src/modules/fancyzones/FancyZonesLib/GenericKeyHook.h +++ b/src/modules/fancyzones/FancyZonesLib/GenericKeyHook.h @@ -48,7 +48,7 @@ private: { if (wParam == WM_KEYDOWN || wParam == WM_KEYUP) { - PKBDLLHOOKSTRUCT kbdHookStruct = (PKBDLLHOOKSTRUCT)lParam; + PKBDLLHOOKSTRUCT kbdHookStruct = reinterpret_cast(lParam); if (((kbdHookStruct->vkCode == keys) || ...)) { callback(wParam == WM_KEYDOWN); diff --git a/src/modules/fancyzones/FancyZonesLib/LayoutConfigurator.cpp b/src/modules/fancyzones/FancyZonesLib/LayoutConfigurator.cpp index 1f1402ff15..9585e358c9 100644 --- a/src/modules/fancyzones/FancyZonesLib/LayoutConfigurator.cpp +++ b/src/modules/fancyzones/FancyZonesLib/LayoutConfigurator.cpp @@ -197,8 +197,8 @@ ZonesMap LayoutConfigurator::Focus(FancyZonesUtils::Rect workArea, int zoneCount long left{ 100 }; long top{ 100 }; - long right{ left + long(workArea.width() * 0.4) }; - long bottom{ top + long(workArea.height() * 0.4) }; + long right{ left + static_cast(workArea.width() * 0.4) }; + long bottom{ top + static_cast(workArea.height() * 0.4) }; RECT focusZoneRect{ left, top, right, bottom }; diff --git a/src/modules/fancyzones/FancyZonesLib/MonitorUtils.cpp b/src/modules/fancyzones/FancyZonesLib/MonitorUtils.cpp index 4926c287d3..6e46babd2a 100644 --- a/src/modules/fancyzones/FancyZonesLib/MonitorUtils.cpp +++ b/src/modules/fancyzones/FancyZonesLib/MonitorUtils.cpp @@ -88,7 +88,7 @@ namespace MonitorUtils // on a particular host computer. IWbemLocator* pLocator = 0; - hres = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID*)&pLocator); + hres = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, reinterpret_cast(&pLocator)); if (FAILED(hres)) { Logger::error(L"Failed to create IWbemLocator object. {}", get_last_error_or_default(hres)); diff --git a/src/modules/fancyzones/FancyZonesLib/Settings.cpp b/src/modules/fancyzones/FancyZonesLib/Settings.cpp index 844b4dbc06..4f7e9cf463 100644 --- a/src/modules/fancyzones/FancyZonesLib/Settings.cpp +++ b/src/modules/fancyzones/FancyZonesLib/Settings.cpp @@ -212,7 +212,7 @@ void FancyZonesSettings::LoadSettings() std::wstring apps = std::move(*val); std::vector excludedApps; auto excludedUppercase = apps; - CharUpperBuffW(excludedUppercase.data(), (DWORD)excludedUppercase.length()); + CharUpperBuffW(excludedUppercase.data(), static_cast(excludedUppercase.length())); std::wstring_view view(excludedUppercase); view = left_trim(trim(view)); @@ -236,7 +236,7 @@ void FancyZonesSettings::LoadSettings() if (auto val = values.get_int_value(NonLocalizable::OverlappingZonesAlgorithmID)) { // Avoid undefined behavior - if (*val >= 0 || *val < (int)OverlappingZonesAlgorithm::EnumElements) + if (*val >= 0 || *val < static_cast(OverlappingZonesAlgorithm::EnumElements)) { auto algorithm = (OverlappingZonesAlgorithm)*val; if (m_settings.overlappingZonesAlgorithm != algorithm) diff --git a/src/modules/fancyzones/FancyZonesLib/WindowUtils.cpp b/src/modules/fancyzones/FancyZonesLib/WindowUtils.cpp index 41f079f6b6..c9252ba5df 100644 --- a/src/modules/fancyzones/FancyZonesLib/WindowUtils.cpp +++ b/src/modules/fancyzones/FancyZonesLib/WindowUtils.cpp @@ -226,7 +226,7 @@ bool FancyZonesWindowUtils::IsCandidateForZoning(HWND window) } std::wstring processPath = get_process_path_waiting_uwp(window); - CharUpperBuffW(const_cast(processPath).data(), (DWORD)processPath.length()); + CharUpperBuffW(const_cast(processPath).data(), static_cast(processPath.length())); if (IsExcludedByUser(processPath)) { return false; diff --git a/src/modules/fancyzones/FancyZonesLib/ZonesOverlay.cpp b/src/modules/fancyzones/FancyZonesLib/ZonesOverlay.cpp index b5908eade7..ada45b5d5c 100644 --- a/src/modules/fancyzones/FancyZonesLib/ZonesOverlay.cpp +++ b/src/modules/fancyzones/FancyZonesLib/ZonesOverlay.cpp @@ -70,7 +70,7 @@ D2D1_COLOR_F ZonesOverlay::ConvertColor(COLORREF color) D2D1_RECT_F ZonesOverlay::ConvertRect(RECT rect) { - return D2D1::RectF((float)rect.left + 0.5f, (float)rect.top + 0.5f, (float)rect.right - 0.5f, (float)rect.bottom - 0.5f); + return D2D1::RectF(rect.left + 0.5f, rect.top + 0.5f, rect.right - 0.5f, rect.bottom - 0.5f); } ZonesOverlay::ZonesOverlay(HWND window) @@ -174,7 +174,7 @@ ZonesOverlay::RenderResult ZonesOverlay::Render() { textFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); textFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); - m_renderTarget->DrawTextW(idStr.c_str(), (UINT32)idStr.size(), textFormat, drawableRect.rect, textBrush); + m_renderTarget->DrawTextW(idStr.c_str(), static_cast(idStr.size()), textFormat, drawableRect.rect, textBrush); } if (textBrush) diff --git a/src/modules/fancyzones/FancyZonesTests/UnitTests/AppZoneHistoryTests.Spec.cpp b/src/modules/fancyzones/FancyZonesTests/UnitTests/AppZoneHistoryTests.Spec.cpp index 0071514185..f1365f2079 100644 --- a/src/modules/fancyzones/FancyZonesTests/UnitTests/AppZoneHistoryTests.Spec.cpp +++ b/src/modules/fancyzones/FancyZonesTests/UnitTests/AppZoneHistoryTests.Spec.cpp @@ -16,7 +16,7 @@ namespace FancyZonesUnitTests TEST_METHOD_INITIALIZE(Init) { - m_hInst = (HINSTANCE)GetModuleHandleW(nullptr); + m_hInst = static_cast(GetModuleHandleW(nullptr)); AppZoneHistory::instance().LoadData(); } diff --git a/src/modules/fancyzones/FancyZonesTests/UnitTests/Util.cpp b/src/modules/fancyzones/FancyZonesTests/UnitTests/Util.cpp index f85597c0c6..6f638085e7 100644 --- a/src/modules/fancyzones/FancyZonesTests/UnitTests/Util.cpp +++ b/src/modules/fancyzones/FancyZonesTests/UnitTests/Util.cpp @@ -70,7 +70,7 @@ BOOL RegisterDLLWindowClass(LPCWSTR szClassName, Mocks::HwndCreator* creator) wc.lpszMenuName = NULL; wc.cbClsExtra = 0; wc.cbWndExtra = 0; - wc.hbrBackground = (HBRUSH)COLOR_BACKGROUND; + wc.hbrBackground = reinterpret_cast(COLOR_BACKGROUND); auto regRes = RegisterClassEx(&wc); return regRes; @@ -83,9 +83,9 @@ DWORD WINAPI ThreadProc(LPVOID lpParam) if (!creator) return static_cast(-1); - if (RegisterDLLWindowClass((LPCWSTR)creator->getWindowClassName().c_str(), creator) != 0) + if (RegisterDLLWindowClass(creator->getWindowClassName().c_str(), creator) != 0) { - auto hWnd = CreateWindowEx(0, (LPCWSTR)creator->getWindowClassName().c_str(), (LPCWSTR)creator->getTitle().c_str(), WS_EX_APPWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 10, 10, nullptr, nullptr, creator->getHInstance(), NULL); + auto hWnd = CreateWindowEx(0, creator->getWindowClassName().c_str(), creator->getTitle().c_str(), WS_EX_APPWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 10, 10, nullptr, nullptr, creator->getHInstance(), NULL); SetWindowPos(hWnd, HWND_TOPMOST, 10, 10, 100, 100, SWP_SHOWWINDOW); creator->setHwnd(hWnd); creator->setCondition(true); @@ -130,7 +130,7 @@ namespace Mocks m_conditionFlag = false; std::unique_lock lock(m_mutex); - m_thread = CreateThread(0, NULL, ThreadProc, (LPVOID)this, NULL, NULL); + m_thread = CreateThread(0, NULL, ThreadProc, reinterpret_cast(this), NULL, NULL); m_conditionVar.wait(lock, [this] { return m_conditionFlag; }); return m_hWnd; diff --git a/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp b/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp index bbfd3cb159..f37f6c8614 100644 --- a/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp +++ b/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp @@ -382,7 +382,7 @@ namespace FancyZonesUnitTests Assert::AreEqual((size_t)1, actualAppZoneHistory.size()); const auto& layoutWindows = workArea->GetLayoutWindows(); - Assert::IsTrue(ZoneIndexSet{ static_cast(workArea->GetLayout()->Zones().size()) - 1 } == layoutWindows->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(ZoneIndexSet{ static_cast(workArea->GetLayout()->Zones().size() - 1) } == layoutWindows->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveAppliedWindowByIndexNoCycle) diff --git a/src/modules/fancyzones/FancyZonesTests/UnitTests/Zone.Spec.cpp b/src/modules/fancyzones/FancyZonesTests/UnitTests/Zone.Spec.cpp index f0ee4ffd01..987371875f 100644 --- a/src/modules/fancyzones/FancyZonesTests/UnitTests/Zone.Spec.cpp +++ b/src/modules/fancyzones/FancyZonesTests/UnitTests/Zone.Spec.cpp @@ -16,7 +16,7 @@ namespace FancyZonesUnitTests TEST_METHOD_INITIALIZE(Init) { - m_hInst = (HINSTANCE)GetModuleHandleW(nullptr); + m_hInst = static_cast(GetModuleHandleW(nullptr)); } public: