mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-19 06:53:26 +08:00
[Analyzers][CPP]Changes to fix warning 26493 on src/modules/ (P) (#23604)
* Changes to fix warning 26493 on src/modules/
This commit is contained in:
parent
17475ec705
commit
c7f761a589
@ -94,7 +94,7 @@ namespace winrt::PowerToys::PowerAccentKeyboardService::implementation
|
||||
{
|
||||
std::vector<std::wstring> excludedApps;
|
||||
auto excludedUppercase = std::wstring(excludedAppsView);
|
||||
CharUpperBuffW(excludedUppercase.data(), (DWORD)excludedUppercase.length());
|
||||
CharUpperBuffW(excludedUppercase.data(), static_cast<DWORD>(excludedUppercase.length()));
|
||||
std::wstring_view view(excludedUppercase);
|
||||
view = left_trim<wchar_t>(trim<wchar_t>(view));
|
||||
|
||||
@ -129,7 +129,7 @@ namespace winrt::PowerToys::PowerAccentKeyboardService::implementation
|
||||
return m_prevForegroundAppExcl.second;
|
||||
}
|
||||
auto processPath = get_process_path(foregroundApp);
|
||||
CharUpperBuffW(processPath.data(), (DWORD)processPath.length());
|
||||
CharUpperBuffW(processPath.data(), static_cast<DWORD>(processPath.length()));
|
||||
m_prevForegroundAppExcl = { foregroundApp,
|
||||
find_app_name_in_path(processPath, m_settings.excludedApps) };
|
||||
|
||||
|
@ -213,7 +213,7 @@ private:
|
||||
auto val = get_last_error_message(GetLastError());
|
||||
Logger::warn(L"UuidCreate can not create guid. {}", val.has_value() ? val.value() : L"");
|
||||
}
|
||||
else if (UuidToString(&temp_uuid, (RPC_WSTR*)&uuid_chars) != RPC_S_OK)
|
||||
else if (UuidToString(&temp_uuid, reinterpret_cast<RPC_WSTR*>(& uuid_chars)) != RPC_S_OK)
|
||||
{
|
||||
auto val = get_last_error_message(GetLastError());
|
||||
Logger::warn(L"UuidToString can not convert to string. {}", val.has_value() ? val.value() : L"");
|
||||
@ -222,7 +222,7 @@ private:
|
||||
if (uuid_chars != nullptr)
|
||||
{
|
||||
pipe_name += std::wstring(uuid_chars);
|
||||
RpcStringFree((RPC_WSTR*)&uuid_chars);
|
||||
RpcStringFree(reinterpret_cast<RPC_WSTR*>(&uuid_chars));
|
||||
uuid_chars = nullptr;
|
||||
}
|
||||
create_pipe_thread = std::thread(&PowerRenameContextMenuCommand::StartNamedPipeServerAndSendData, this, pipe_name);
|
||||
|
@ -87,8 +87,8 @@ namespace winrt::PowerRenameUI::implementation
|
||||
|
||||
winrt::Windows::Graphics::RectInt32 rect;
|
||||
// Scale window size
|
||||
rect.Width = (int32_t)(width * (float)window_dpi / x_dpi);
|
||||
rect.Height = (int32_t)(height * (float)window_dpi / x_dpi);
|
||||
rect.Width = static_cast<int32_t>(width * static_cast<float>(window_dpi) / x_dpi);
|
||||
rect.Height = static_cast<int32_t>(height * static_cast<float>(window_dpi) / x_dpi);
|
||||
// Center to screen
|
||||
rect.X = displayArea.WorkArea().X + displayArea.WorkArea().Width / 2 - width / 2;
|
||||
rect.Y = displayArea.WorkArea().Y + displayArea.WorkArea().Height / 2 - height / 2;
|
||||
@ -1070,7 +1070,7 @@ namespace winrt::PowerRenameUI::implementation
|
||||
if (closeUIWindowAfterRenaming)
|
||||
{
|
||||
// Close the window
|
||||
PostMessage(m_window, WM_CLOSE, (WPARAM)0, (LPARAM)0);
|
||||
PostMessage(m_window, WM_CLOSE, static_cast<WPARAM>(0), static_cast<LPARAM>(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -13,7 +13,13 @@
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include <winrt/Windows.System.h>
|
||||
|
||||
// disable warning 26493 - Don't use C-style casts
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 26493)
|
||||
#include <winrt/Microsoft.UI.Composition.h>
|
||||
#pragma warning(pop)
|
||||
|
||||
#include <winrt/Microsoft.UI.Xaml.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.Automation.Peers.h>
|
||||
#include <winrt/Microsoft.UI.Xaml.Controls.h>
|
||||
|
@ -88,7 +88,7 @@ HRESULT CPowerRenameMenu::QueryContextMenu(HMENU hMenu, UINT index, UINT uIDFirs
|
||||
|
||||
if (CSettingsInstance().GetShowIconOnMenu())
|
||||
{
|
||||
HICON hIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_RENAME), IMAGE_ICON, 16, 16, 0);
|
||||
HICON hIcon = static_cast<HICON>(LoadImage(g_hInst, MAKEINTRESOURCE(IDI_RENAME), IMAGE_ICON, 16, 16, 0));
|
||||
if (hIcon)
|
||||
{
|
||||
mii.fMask |= MIIM_BITMAP;
|
||||
@ -131,7 +131,7 @@ HRESULT CPowerRenameMenu::RunPowerRename(CMINVOKECOMMANDINFO* pici, IShellItemAr
|
||||
// Set the application path based on the location of the dll
|
||||
std::wstring path = get_module_folderpath(g_hInst);
|
||||
path = path + L"\\PowerToys.PowerRename.exe";
|
||||
LPTSTR lpApplicationName = (LPTSTR)path.c_str();
|
||||
LPTSTR lpApplicationName = path.data();
|
||||
// Create an anonymous pipe to stream filenames
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
HANDLE hReadPipe;
|
||||
|
@ -420,7 +420,7 @@ BOOL GetEnumeratedFileName(__out_ecount(cchMax) PWSTR pszUniqueName, UINT cchMax
|
||||
if (!pszRest)
|
||||
{
|
||||
pszRest = PathFindExtension(pszTemplate);
|
||||
cchStem = (int)(pszRest - pszTemplate);
|
||||
cchStem = static_cast<int>(pszRest - pszTemplate);
|
||||
|
||||
hr = StringCchCopy(szFormat, ARRAYSIZE(szFormat), L" (%lu)");
|
||||
}
|
||||
@ -428,7 +428,7 @@ BOOL GetEnumeratedFileName(__out_ecount(cchMax) PWSTR pszUniqueName, UINT cchMax
|
||||
{
|
||||
pszRest++;
|
||||
|
||||
cchStem = (int)(pszRest - pszTemplate);
|
||||
cchStem = static_cast<int>(pszRest - pszTemplate);
|
||||
|
||||
while (*pszRest && *pszRest >= L'0' && *pszRest <= L'9')
|
||||
{
|
||||
@ -581,7 +581,7 @@ HWND CreateMsgWindow(_In_ HINSTANCE hInst, _In_ WNDPROC pfnWndProc, _In_ void* p
|
||||
wc.lpfnWndProc = DefWindowProc;
|
||||
wc.cbWndExtra = sizeof(void*);
|
||||
wc.hInstance = hInst;
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_BTNFACE + 1);
|
||||
wc.lpszClassName = wndClassName;
|
||||
|
||||
RegisterClass(&wc);
|
||||
@ -590,10 +590,10 @@ HWND CreateMsgWindow(_In_ HINSTANCE hInst, _In_ WNDPROC pfnWndProc, _In_ void* p
|
||||
0, wndClassName, nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hInst, nullptr);
|
||||
if (hwnd)
|
||||
{
|
||||
SetWindowLongPtr(hwnd, 0, (LONG_PTR)p);
|
||||
SetWindowLongPtr(hwnd, 0, reinterpret_cast<LONG_PTR>(p));
|
||||
if (pfnWndProc)
|
||||
{
|
||||
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)pfnWndProc);
|
||||
SetWindowLongPtr(hwnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(pfnWndProc));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,12 +123,12 @@ void MRUListHandler::ParseJson()
|
||||
unsigned int oldSize{ size };
|
||||
if (json::has(jsonObject, c_maxMRUSize, json::JsonValueType::Number))
|
||||
{
|
||||
oldSize = (unsigned int)jsonObject.GetNamedNumber(c_maxMRUSize);
|
||||
oldSize = static_cast<unsigned int>(jsonObject.GetNamedNumber(c_maxMRUSize));
|
||||
}
|
||||
unsigned int oldPushIdx{ 0 };
|
||||
if (json::has(jsonObject, c_insertionIdx, json::JsonValueType::Number))
|
||||
{
|
||||
oldPushIdx = (unsigned int)jsonObject.GetNamedNumber(c_insertionIdx);
|
||||
oldPushIdx = static_cast<unsigned int>(jsonObject.GetNamedNumber(c_insertionIdx));
|
||||
if (oldPushIdx < 0 || oldPushIdx >= oldSize)
|
||||
{
|
||||
oldPushIdx = 0;
|
||||
@ -156,7 +156,7 @@ void MRUListHandler::ParseJson()
|
||||
if (size > oldSize)
|
||||
{
|
||||
std::reverse(std::begin(temp), std::end(temp));
|
||||
pushIdx = (unsigned int)temp.size();
|
||||
pushIdx = static_cast<unsigned int>(temp.size());
|
||||
temp.resize(size);
|
||||
}
|
||||
else
|
||||
|
@ -526,7 +526,7 @@ LRESULT CALLBACK CPowerRenameManager::s_msgWndProc(_In_ HWND hwnd, _In_ UINT uMs
|
||||
{
|
||||
LRESULT lRes = 0;
|
||||
|
||||
CPowerRenameManager* pThis = (CPowerRenameManager*)GetWindowLongPtr(hwnd, 0);
|
||||
CPowerRenameManager* pThis = reinterpret_cast<CPowerRenameManager*>(GetWindowLongPtr(hwnd, 0));
|
||||
if (pThis != nullptr)
|
||||
{
|
||||
lRes = pThis->_WndProc(hwnd, uMsg, wParam, lParam);
|
||||
|
@ -125,7 +125,7 @@ void CSettings::ParseJson()
|
||||
}
|
||||
if (json::has(jsonSettings, c_maxMRUSize, json::JsonValueType::Number))
|
||||
{
|
||||
settings.maxMRUSize = (unsigned int)jsonSettings.GetNamedNumber(c_maxMRUSize);
|
||||
settings.maxMRUSize = static_cast<unsigned int>(jsonSettings.GetNamedNumber(c_maxMRUSize));
|
||||
}
|
||||
if (json::has(jsonSettings, c_searchText, json::JsonValueType::String))
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ IFACEMETHODIMP GcodeThumbnailProvider::GetThumbnail(UINT cx, HBITMAP* phbmp, WTS
|
||||
std::wstring fileNameBmp = filePath + guid + L".bmp";
|
||||
if (std::filesystem::exists(fileNameBmp))
|
||||
{
|
||||
*phbmp = (HBITMAP)LoadImage(NULL, fileNameBmp.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
||||
*phbmp = static_cast<HBITMAP>(LoadImage(NULL, fileNameBmp.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE));
|
||||
*pdwAlpha = WTS_ALPHATYPE::WTSAT_ARGB;
|
||||
std::filesystem::remove(fileNameBmp);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ IFACEMETHODIMP PdfThumbnailProvider::GetThumbnail(UINT cx, HBITMAP* phbmp, WTS_A
|
||||
std::wstring fileNameBmp = filePath + guid + L".bmp";
|
||||
if (std::filesystem::exists(fileNameBmp))
|
||||
{
|
||||
*phbmp = (HBITMAP)LoadImage(NULL, fileNameBmp.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
||||
*phbmp = static_cast<HBITMAP>(LoadImage(NULL, fileNameBmp.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE));
|
||||
*pdwAlpha = WTS_ALPHATYPE::WTSAT_ARGB;
|
||||
std::filesystem::remove(fileNameBmp);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ IFACEMETHODIMP StlThumbnailProvider::GetThumbnail(UINT cx, HBITMAP* phbmp, WTS_A
|
||||
std::wstring fileNameBmp = filePath + guid + L".bmp";
|
||||
if (std::filesystem::exists(fileNameBmp))
|
||||
{
|
||||
*phbmp = (HBITMAP)LoadImage(NULL, fileNameBmp.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
||||
*phbmp = static_cast<HBITMAP>(LoadImage(NULL, fileNameBmp.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE));
|
||||
*pdwAlpha = WTS_ALPHATYPE::WTSAT_ARGB;
|
||||
std::filesystem::remove(fileNameBmp);
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ IFACEMETHODIMP SvgThumbnailProvider::GetThumbnail(UINT cx, HBITMAP* phbmp, WTS_A
|
||||
|
||||
if (std::filesystem::exists(fileNameBmp))
|
||||
{
|
||||
*phbmp = (HBITMAP)LoadImage(NULL, fileNameBmp.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
||||
*phbmp = static_cast<HBITMAP>(LoadImage(NULL, fileNameBmp.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE));
|
||||
*pdwAlpha = WTS_ALPHATYPE::WTSAT_ARGB;
|
||||
std::filesystem::remove(fileNameBmp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user