[Analyzers][CPP]Changes to fix warning 26493 on src/common (#23467)

* Changes to fix warning 26493 on src/common

It will be multi PR change. This does not turn on the rule but fix the code under src/commom

* int cast
This commit is contained in:
sosssego 2023-02-08 11:00:19 +00:00 committed by GitHub
parent 956eb98125
commit a743e496c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 66 additions and 69 deletions

View File

@ -6,110 +6,110 @@ namespace winrt::PowerToys::GPOWrapper::implementation
{
GpoRuleConfigured GPOWrapper::GetConfiguredAlwaysOnTopEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredAlwaysOnTopEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredAlwaysOnTopEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredAwakeEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredAwakeEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredAwakeEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredColorPickerEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredColorPickerEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredColorPickerEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredFancyZonesEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredFancyZonesEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredFancyZonesEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredFileLocksmithEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredFileLocksmithEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredFileLocksmithEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredSvgPreviewEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredSvgPreviewEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredSvgPreviewEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredMarkdownPreviewEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredMarkdownPreviewEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredMarkdownPreviewEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredMonacoPreviewEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredMonacoPreviewEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredMonacoPreviewEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredPdfPreviewEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredPdfPreviewEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredPdfPreviewEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredGcodePreviewEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredGcodePreviewEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredGcodePreviewEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredSvgThumbnailsEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredSvgThumbnailsEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredSvgThumbnailsEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredPdfThumbnailsEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredPdfThumbnailsEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredPdfThumbnailsEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredGcodeThumbnailsEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredGcodeThumbnailsEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredGcodeThumbnailsEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredStlThumbnailsEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredStlThumbnailsEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredStlThumbnailsEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredHostsFileEditorEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredHostsFileEditorEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredHostsFileEditorEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredImageResizerEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredImageResizerEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredImageResizerEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredKeyboardManagerEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredKeyboardManagerEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredKeyboardManagerEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredFindMyMouseEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredFindMyMouseEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredFindMyMouseEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredMouseHighlighterEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredMouseHighlighterEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredMouseHighlighterEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredMousePointerCrosshairsEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredMousePointerCrosshairsEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredMousePointerCrosshairsEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredPowerRenameEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredPowerRenameEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredPowerRenameEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredPowerLauncherEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredPowerLauncherEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredPowerLauncherEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredQuickAccentEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredQuickAccentEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredQuickAccentEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredScreenRulerEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredScreenRulerEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredScreenRulerEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredShortcutGuideEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredShortcutGuideEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredShortcutGuideEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredTextExtractorEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredTextExtractorEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredTextExtractorEnabledValue());
}
GpoRuleConfigured GPOWrapper::GetConfiguredVideoConferenceMuteEnabledValue()
{
return (GpoRuleConfigured)powertoys_gpo::getConfiguredVideoConferenceMuteEnabledValue();
return static_cast<GpoRuleConfigured>(powertoys_gpo::getConfiguredVideoConferenceMuteEnabledValue());
}
}

View File

@ -247,7 +247,7 @@ namespace PowerToysSettings
bool Settings::serialize_to_buffer(wchar_t* buffer, int* buffer_size)
{
auto result = m_json.Stringify();
const int result_len = (int)result.size() + 1;
const int result_len = static_cast<int>(result.size() + 1);
if (buffer == nullptr || *buffer_size < result_len)
{

View File

@ -220,7 +220,7 @@ namespace PowerToysSettings
std::array<BYTE, 256> key_states{}; // Zero-initialize
std::array<wchar_t, 256> output;
const UINT wFlags = 1 << 2; // If bit 2 is set, keyboard state is not changed (Windows 10, version 1607 and newer)
auto output_bytes = ToUnicodeEx(key_code, scan_code, key_states.data(), output.data(), (int)output.size() - 1, wFlags, layout);
auto output_bytes = ToUnicodeEx(key_code, scan_code, key_states.data(), output.data(), static_cast<int>(output.size()) - 1, wFlags, layout);
if (output_bytes <= 0)
{
// If ToUnicodeEx fails (e.g. for F1-F12 keys) use GetKeyNameTextW

View File

@ -14,7 +14,7 @@ HRESULT GetIconIndexFromPath(_In_ PCWSTR path, _Out_ int* index)
if (!PathIsRelative(path))
{
DWORD attrib = GetFileAttributes(path);
HIMAGELIST himl = (HIMAGELIST)SHGetFileInfo(path, attrib, &shFileInfo, sizeof(shFileInfo), (SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES));
auto himl =SHGetFileInfo(path, attrib, &shFileInfo, sizeof(shFileInfo), (SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_USEFILEATTRIBUTES));
if (himl)
{
*index = shFileInfo.iIcon;
@ -61,14 +61,14 @@ HBITMAP CreateBitmapFromIcon(_In_ HICON hIcon, _In_opt_ UINT width, _In_opt_ UIN
if (hBitmap != NULL)
{
// Select bitmap into DC
HBITMAP hBitmapOld = (HBITMAP)SelectObject(hDC, hBitmap);
HBITMAP hBitmapOld = static_cast<HBITMAP>(SelectObject(hDC, hBitmap));
if (hBitmapOld != NULL)
{
// Draw icon into DC
if (DrawIconEx(hDC, 0, 0, hIcon, rc.right, rc.bottom, 0, NULL, DI_NORMAL))
{
// Restore original bitmap in DC
hBitmapResult = (HBITMAP)SelectObject(hDC, hBitmapOld);
hBitmapResult = static_cast<HBITMAP>(SelectObject(hDC, hBitmapOld));
hBitmapOld = NULL;
hBitmap = NULL;
}

View File

@ -28,10 +28,7 @@ AppTheme ThemeHelpers::GetAppTheme()
}
// convert bytes written to our buffer to an int, assuming little-endian
auto i = int(buffer[3] << 24 |
buffer[2] << 16 |
buffer[1] << 8 |
buffer[0]);
auto i = static_cast<int>(buffer[3] << 24 | buffer[2] << 16 | buffer[1] << 8 | buffer[0]);
return AppTheme(i);
}

View File

@ -8,7 +8,7 @@
#pragma warning(disable : 4702)
DWORD WINAPI _checkTheme(LPVOID lpParam)
{
auto listener = (ThemeListener*)lpParam;
auto listener = static_cast<ThemeListener*>(lpParam);
listener->CheckTheme();
return 0;
}

View File

@ -11,7 +11,7 @@ DWORD WindowsColors::rgb_color(DWORD abgr_color)
}
DWORD WindowsColors::rgb_color(winrt::Windows::UI::Color color)
{
return ((DWORD)color.R << 16) | ((DWORD)color.G << 8) | ((DWORD)color.B);
return static_cast<DWORD>((color.R << 16) | (color.G << 8) | (color.B));
}
WindowsColors::Color WindowsColors::get_button_face_color()
{

View File

@ -56,7 +56,7 @@ bool mapKeycodeToUnicode(const int vCode, HKL layout, const BYTE* keyState, std:
const UINT scanCode = MapVirtualKeyExW(vCode, MAPVK_VK_TO_VSC, layout);
// Get the unicode representation from the virtual key code and scan code pair
const UINT wFlags = 1 << 2; // If bit 2 is set, keyboard state is not changed (Windows 10, version 1607 and newer)
const int result = ToUnicodeEx(vCode, scanCode, keyState, outBuffer.data(), (int)outBuffer.size(), wFlags, layout);
const int result = ToUnicodeEx(vCode, scanCode, keyState, outBuffer.data(), static_cast<int>(outBuffer.size()), wFlags, layout);
return result != 0;
}

View File

@ -184,9 +184,9 @@ BOOL TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::GetLogonSID(HANDLE hToken,
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
goto Cleanup;
ptg = (PTOKEN_GROUPS)HeapAlloc(GetProcessHeap(),
ptg = static_cast<PTOKEN_GROUPS>(HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
dwLength);
dwLength));
if (ptg == NULL)
goto Cleanup;
@ -213,14 +213,14 @@ BOOL TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::GetLogonSID(HANDLE hToken,
// Found the logon SID; make a copy of it.
dwLength = GetLengthSid(ptg->Groups[dwIndex].Sid);
*ppsid = (PSID)HeapAlloc(GetProcessHeap(),
*ppsid = static_cast<PSID>(HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
dwLength);
dwLength));
if (*ppsid == NULL)
goto Cleanup;
if (!CopySid(dwLength, *ppsid, ptg->Groups[dwIndex].Sid))
{
HeapFree(GetProcessHeap(), 0, (LPVOID)*ppsid);
HeapFree(GetProcessHeap(), 0, static_cast<LPVOID>(*ppsid));
goto Cleanup;
}
break;
@ -233,7 +233,7 @@ Cleanup:
// Free the buffer for the token groups.
if (ptg != NULL)
HeapFree(GetProcessHeap(), 0, (LPVOID)ptg);
HeapFree(GetProcessHeap(), 0, static_cast<LPVOID>(ptg));
return bSuccess;
}
@ -241,7 +241,7 @@ Cleanup:
VOID TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::FreeLogonSID(PSID* ppsid)
{
// From https://learn.microsoft.com/previous-versions/aa446670(v=vs.85)
HeapFree(GetProcessHeap(), 0, (LPVOID)*ppsid);
HeapFree(GetProcessHeap(), 0, static_cast<LPVOID>(*ppsid));
}
int TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::change_pipe_security_allow_restricted_token(HANDLE handle, HANDLE token)
@ -279,7 +279,7 @@ int TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::change_pipe_security_allow_r
ea.grfInheritance = NO_INHERITANCE;
ea.Trustee.TrusteeForm = TRUSTEE_IS_SID;
ea.Trustee.TrusteeType = TRUSTEE_IS_USER;
ea.Trustee.ptstrName = (LPTSTR)user_restricted;
ea.Trustee.ptstrName = static_cast<LPTSTR>(user_restricted);
if (SetEntriesInAcl(1, &ea, old_dacl, &new_dacl))
{
@ -302,9 +302,9 @@ int TwoWayPipeMessageIPC::TwoWayPipeMessageIPCImpl::change_pipe_security_allow_r
error = 0;
Lclean_dacl:
LocalFree((HLOCAL)new_dacl);
LocalFree(static_cast<HLOCAL>(new_dacl));
Lclean_sd:
LocalFree((HLOCAL)sd);
LocalFree(static_cast<HLOCAL>(sd));
Lclean_sid:
FreeLogonSID(&user_restricted);
Ldone:

View File

@ -19,7 +19,7 @@ public:
if (SUCCEEDED(pDataObject->GetData(&formatetc, &m_medium)))
{
_listCount = DragQueryFile((HDROP)m_medium.hGlobal, 0xFFFFFFFF, NULL, 0);
_listCount = DragQueryFile(static_cast<HDROP>(m_medium.hGlobal), 0xFFFFFFFF, NULL, 0);
}
else
{
@ -52,10 +52,10 @@ public:
LPTSTR CurrentItem() const
{
UINT cch = DragQueryFile((HDROP)m_medium.hGlobal, _current, NULL, 0) + 1;
LPTSTR pszPath = (LPTSTR)malloc(sizeof(TCHAR) * cch);
UINT cch = DragQueryFile(static_cast<HDROP>(m_medium.hGlobal), _current, NULL, 0) + 1;
LPTSTR pszPath = static_cast<LPTSTR>(malloc(sizeof(TCHAR) * cch));
DragQueryFile((HDROP)m_medium.hGlobal, _current, pszPath, cch);
DragQueryFile(static_cast<HDROP>(m_medium.hGlobal), _current, pszPath, cch);
return pszPath;
}

View File

@ -57,7 +57,7 @@ namespace http
totalBytesRead += buffer.Length();
if (progressUpdateCallback)
{
float percentage = (float)totalBytesRead / totalBytes;
float percentage = static_cast<float>(totalBytesRead) / totalBytes;
progressUpdateCallback(percentage);
}

View File

@ -93,7 +93,7 @@ inline std::wstring GetModuleName(HANDLE process, const STACKFRAME64& stack)
return std::wstring();
}
if (!GetModuleFileNameW((HINSTANCE)moduleBase, modulePath, MAX_PATH))
if (!GetModuleFileNameW(reinterpret_cast<HINSTANCE>(moduleBase), modulePath, MAX_PATH))
{
Logger::error(L"Failed to get a module path. {}", get_last_error_or_default(GetLastError()));
return std::wstring();
@ -105,7 +105,7 @@ inline std::wstring GetModuleName(HANDLE process, const STACKFRAME64& stack)
inline std::wstring GetName(HANDLE process, const STACKFRAME64& stack)
{
static IMAGEHLP_SYMBOL64* pSymbol = (IMAGEHLP_SYMBOL64*)malloc(sizeof(IMAGEHLP_SYMBOL64) + MAX_PATH * sizeof(TCHAR));
static IMAGEHLP_SYMBOL64* pSymbol = static_cast<IMAGEHLP_SYMBOL64*>(malloc(sizeof(IMAGEHLP_SYMBOL64) + MAX_PATH * sizeof(TCHAR)));
if (!pSymbol)
{
return std::wstring();

View File

@ -198,7 +198,7 @@ inline bool drop_elevated_privileges()
TOKEN_MANDATORY_LABEL label = { 0 };
label.Label.Attributes = SE_GROUP_INTEGRITY;
label.Label.Sid = medium_sid;
DWORD size = (DWORD)sizeof(TOKEN_MANDATORY_LABEL) + ::GetLengthSid(medium_sid);
DWORD size = static_cast<DWORD>(sizeof(TOKEN_MANDATORY_LABEL) + ::GetLengthSid(medium_sid));
BOOL result = SetTokenInformation(token, TokenIntegrityLevel, &label, size);
LocalFree(medium_sid);
@ -464,7 +464,7 @@ inline bool check_user_is_admin()
}
// Allocate the buffer.
pGroupInfo = (PTOKEN_GROUPS)GlobalAlloc(GPTR, dwSize);
pGroupInfo = static_cast<PTOKEN_GROUPS>(GlobalAlloc(GPTR, dwSize));
// Call GetTokenInformation again to get the group information.
if (!GetTokenInformation(hToken, TokenGroups, pGroupInfo, dwSize, &dwSize))

View File

@ -50,7 +50,7 @@ namespace powertoys_gpo {
inline gpo_rule_configured_t getConfiguredValue(const std::wstring& registry_value_name)
{
HKEY key{};
DWORD value = (DWORD) -2;
DWORD value = 0xFFFFFFFE;
DWORD valueSize = sizeof(value);
bool machine_key_found = true;
@ -62,7 +62,7 @@ namespace powertoys_gpo {
if(machine_key_found)
{
// If the path was found in the machine, we need to check if the value for the policy exists.
auto res = RegQueryValueExW(key, registry_value_name.c_str(), nullptr, nullptr, (LPBYTE)&value, &valueSize);
auto res = RegQueryValueExW(key, registry_value_name.c_str(), nullptr, nullptr, reinterpret_cast<LPBYTE>(&value), &valueSize);
RegCloseKey(key);
@ -82,7 +82,7 @@ namespace powertoys_gpo {
}
return gpo_rule_configured_unavailable;
}
auto res = RegQueryValueExW(key, registry_value_name.c_str(), nullptr, nullptr, (LPBYTE)&value, &valueSize);
auto res = RegQueryValueExW(key, registry_value_name.c_str(), nullptr, nullptr, reinterpret_cast<LPBYTE>(&value), &valueSize);
RegCloseKey(key);
if (res != ERROR_SUCCESS) {

View File

@ -15,7 +15,7 @@ inline std::wstring get_process_path(DWORD pid) noexcept
{
name.resize(MAX_PATH);
DWORD name_length = static_cast<DWORD>(name.length());
if (QueryFullProcessImageNameW(process, 0, (LPWSTR)name.data(), &name_length) == 0)
if (QueryFullProcessImageNameW(process, 0, name.data(), &name_length) == 0)
{
name_length = 0;
}
@ -118,5 +118,5 @@ inline std::wstring get_module_folderpath(HMODULE mod = nullptr, const bool remo
{
PathRemoveFileSpecW(buffer);
}
return { buffer, (UINT)lstrlenW(buffer) };
return { buffer, static_cast<uint64_t>(lstrlenW(buffer))};
}

View File

@ -241,7 +241,7 @@ namespace registry
switch (type)
{
case REG_DWORD:
return *(DWORD*)buffer;
return *reinterpret_cast<const DWORD*>(buffer);
case REG_SZ:
{
if (!valueSize)

View File

@ -60,7 +60,7 @@ namespace timeutil
inline int64_t in_days(const std::time_t to, const std::time_t from)
{
return static_cast<int64_t>(std::difftime(to, from) / (3600 * (int64_t)24));
return static_cast<int64_t>(std::difftime(to, from) / (3600 * 24LL));
}
}
}

View File

@ -35,7 +35,7 @@ inline void show_last_error_message(const wchar_t* functionName, DWORD dw, const
{
return;
}
LPWSTR lpDisplayBuf = (LPWSTR)LocalAlloc(LMEM_ZEROINIT, (system_message->size() + lstrlenW(functionName) + 40) * sizeof(WCHAR));
LPWSTR lpDisplayBuf = static_cast<LPWSTR>(LocalAlloc(LMEM_ZEROINIT, (system_message->size() + lstrlenW(functionName) + 40) * sizeof(WCHAR)));
if (lpDisplayBuf != NULL)
{
StringCchPrintfW(lpDisplayBuf,
@ -44,7 +44,7 @@ inline void show_last_error_message(const wchar_t* functionName, DWORD dw, const
functionName,
system_message->c_str(),
dw);
MessageBoxW(NULL, (LPCTSTR)lpDisplayBuf, errorTitle, MB_OK | MB_ICONERROR);
MessageBoxW(NULL, lpDisplayBuf, errorTitle, MB_OK | MB_ICONERROR);
LocalFree(lpDisplayBuf);
}
}

View File

@ -60,7 +60,7 @@ template<typename T>
inline T GetWindowCreateParam(LPARAM lparam)
{
static_assert(sizeof(T) <= sizeof(void*));
T data{ (T)(reinterpret_cast<CREATESTRUCT*>(lparam)->lpCreateParams) };
T data{ static_cast <T>(reinterpret_cast<CREATESTRUCT*>(lparam)->lpCreateParams) };
return data;
}
@ -74,5 +74,5 @@ inline void StoreWindowParam(HWND window, T data)
template<typename T>
inline T GetWindowParam(HWND window)
{
return (T)GetWindowLongPtrW(window, GWLP_USERDATA);
return reinterpret_cast <T>(GetWindowLongPtrW(window, GWLP_USERDATA));
}