[Analyzers][CPP] turn on Warning 4100 (#21449)

* Analyzers CPP

Changing the warning level from 3 to 4.
change some project files to make them use the warning config in cpp props file.

* Analyzers C++ turn on warning 4706

Change Cpp.Build.props file to enable 4706
fix BugReportTool code to get rid of 4706

* Turn on warning 4100 and fix the code

* Follow c++ core guidelines

* Adapting to PR comments
This commit is contained in:
sosssego 2022-11-09 14:41:14 +00:00 committed by GitHub
parent cca10d2455
commit 78f5b4c3a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 128 additions and 127 deletions

View File

@ -40,9 +40,9 @@
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup> <ItemDefinitionGroup>
<ClCompile> <ClCompile>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<DisableSpecificWarnings>26800;28251;4100;4127;4189;4239;4244;4245;4389;4456;4457;4701;6387;4458;4505;4515;4459;4702;6031;6248;26451;28182;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>26800;28251;4127;4189;4239;4244;4245;4389;4456;4457;4701;6387;4458;4505;4515;4459;4702;6031;6248;26451;28182;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableAnalyzeExternal >true</DisableAnalyzeExternal> <DisableAnalyzeExternal >true</DisableAnalyzeExternal>
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel> <ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
<ConformanceMode>false</ConformanceMode> <ConformanceMode>false</ConformanceMode>

View File

@ -19,7 +19,7 @@ MonitorInfo::MonitorInfo(HMONITOR h) :
GetMonitorInfoW(handle, &info); GetMonitorInfoW(handle, &info);
} }
static BOOL CALLBACK GetDisplaysEnumCb(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) static BOOL CALLBACK GetDisplaysEnumCb(HMONITOR monitor, HDC /*hdc*/, LPRECT /*rect*/, LPARAM data)
{ {
auto* monitors = reinterpret_cast<std::vector<MonitorInfo>*>(data); auto* monitors = reinterpret_cast<std::vector<MonitorInfo>*>(data);
monitors->emplace_back(monitor); monitors->emplace_back(monitor);

View File

@ -24,7 +24,7 @@ HotkeyManager::~HotkeyManager()
} }
// When all Shortcut keys are pressed, fire the HotkeyCallback event. // When all Shortcut keys are pressed, fire the HotkeyCallback event.
void HotkeyManager::KeyboardEventProc(KeyboardEvent ^ ev) void HotkeyManager::KeyboardEventProc(KeyboardEvent ^ /*ev*/)
{ {
// pressedKeys always stores the latest keyboard state // pressedKeys always stores the latest keyboard state
auto pressedKeysHandle = GetHotkeyHandle(pressedKeys); auto pressedKeysHandle = GetHotkeyHandle(pressedKeys);

View File

@ -90,7 +90,7 @@ public:
} }
virtual HRESULT STDMETHODCALLTYPE Activate( virtual HRESULT STDMETHODCALLTYPE Activate(
LPCWSTR appUserModelId, LPCWSTR /*appUserModelId*/,
LPCWSTR invokedArgs, LPCWSTR invokedArgs,
const NOTIFICATION_USER_INPUT_DATA*, const NOTIFICATION_USER_INPUT_DATA*,
ULONG) override ULONG) override

View File

@ -14,7 +14,7 @@
extern "C" IMAGE_DOS_HEADER __ImageBase; extern "C" IMAGE_DOS_HEADER __ImageBase;
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@ -141,7 +141,7 @@ public:
return powertoys_gpo::getConfiguredHostsFileEditorEnabledValue(); return powertoys_gpo::getConfiguredHostsFileEditorEnabledValue();
} }
virtual bool get_config(wchar_t* buffer, int* buffer_size) override virtual bool get_config(wchar_t* /*buffer*/, int* /*buffer_size*/) override
{ {
return false; return false;
} }
@ -173,7 +173,7 @@ public:
} }
} }
virtual void set_config(const wchar_t* config) override virtual void set_config(const wchar_t* /*config*/) override
{ {
} }

View File

@ -9,11 +9,8 @@
extern "C" IMAGE_DOS_HEADER __ImageBase; extern "C" IMAGE_DOS_HEADER __ImageBase;
HMODULE m_hModule; BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{ {
m_hModule = hModule;
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
@ -245,7 +242,7 @@ public:
return m_enabled; return m_enabled;
} }
virtual bool on_hotkey(size_t hotkeyId) override virtual bool on_hotkey(size_t /*hotkeyId*/) override
{ {
if (m_enabled) if (m_enabled)
{ {

View File

@ -13,9 +13,9 @@
#include <common/utils/logger_helper.h> #include <common/utils/logger_helper.h>
#include <common/utils/winapi_error.h> #include <common/utils/winapi_error.h>
BOOL APIENTRY DllMain(HMODULE hModule, BOOL APIENTRY DllMain(HMODULE /*hModule*/,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID lpReserved) LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@ -30,6 +30,7 @@ BOOL APIENTRY DllMain(HMODULE hModule,
Trace::UnregisterProvider(); Trace::UnregisterProvider();
break; break;
} }
return TRUE; return TRUE;
} }
@ -127,7 +128,7 @@ private:
} }
else else
{ {
Logger::error( L"TextExtractor failed to start. {}", get_last_error_or_default(GetLastError())); Logger::error(L"TextExtractor failed to start. {}", get_last_error_or_default(GetLastError()));
} }
m_hProcess = sei.hProcess; m_hProcess = sei.hProcess;
@ -207,7 +208,7 @@ public:
return settings.serialize_to_buffer(buffer, buffer_size); return settings.serialize_to_buffer(buffer, buffer_size);
} }
virtual void call_custom_action(const wchar_t* action) override virtual void call_custom_action(const wchar_t* /*action*/) override
{ {
} }
@ -254,7 +255,7 @@ public:
Trace::EnablePowerOCR(false); Trace::EnablePowerOCR(false);
} }
virtual bool on_hotkey(size_t hotkeyId) override virtual bool on_hotkey(size_t /*hotkeyId*/) override
{ {
if (m_enabled) if (m_enabled)
{ {
@ -268,7 +269,7 @@ public:
return true; return true;
} }
return false; return false;
} }
virtual size_t get_hotkeys(Hotkey* hotkeys, size_t buffer_size) override virtual size_t get_hotkeys(Hotkey* hotkeys, size_t buffer_size) override
@ -292,7 +293,6 @@ public:
{ {
return m_enabled; return m_enabled;
} }
}; };
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create() extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()

View File

@ -12,12 +12,12 @@
#include "shortcut_guide.h" #include "shortcut_guide.h"
#include "target_state.h" #include "target_state.h"
#include "ShortcutGuideConstants.h" #include "ShortcutGuideConstants.h"
#include "trace.h" #include "trace.h"
const std::wstring instanceMutexName = L"Local\\PowerToys_ShortcutGuide_InstanceMutex"; const std::wstring instanceMutexName = L"Local\\PowerToys_ShortcutGuide_InstanceMutex";
// set current path to the executable path // set current path to the executable path
bool SetCurrentPath() bool SetCurrentPath()
{ {
TCHAR buffer[MAX_PATH] = { 0 }; TCHAR buffer[MAX_PATH] = { 0 };
if (!GetModuleFileName(NULL, buffer, MAX_PATH)) if (!GetModuleFileName(NULL, buffer, MAX_PATH))
@ -43,7 +43,7 @@ bool SetCurrentPath()
return true; return true;
} }
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ PWSTR lpCmdLine, _In_ int nCmdShow) int WINAPI wWinMain(_In_ HINSTANCE /*hInstance*/, _In_opt_ HINSTANCE /*hPrevInstance*/, _In_ PWSTR lpCmdLine, _In_ int /*nCmdShow*/)
{ {
winrt::init_apartment(); winrt::init_apartment();
LoggerHelpers::init_logger(ShortcutGuideConstants::ModuleKey, L"ShortcutGuide", LogSettings::shortcutGuideLoggerName); LoggerHelpers::init_logger(ShortcutGuideConstants::ModuleKey, L"ShortcutGuide", LogSettings::shortcutGuideLoggerName);

View File

@ -11,7 +11,7 @@
#include "Generated Files/resource.h" #include "Generated Files/resource.h"
#include <common/SettingsAPI/settings_objects.h> #include <common/SettingsAPI/settings_objects.h>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD /*ul_reason_for_call*/, LPVOID /*lpReserved*/)
{ {
return TRUE; return TRUE;
} }
@ -180,7 +180,7 @@ private:
std::wstring app_key; std::wstring app_key;
bool _enabled = false; bool _enabled = false;
HANDLE m_hProcess = nullptr; HANDLE m_hProcess = nullptr;
// Hotkey to invoke the module // Hotkey to invoke the module
HotkeyEx m_hotkey; HotkeyEx m_hotkey;
@ -226,7 +226,7 @@ private:
Logger::trace(L"Started SG process with pid={}", GetProcessId(sei.hProcess)); Logger::trace(L"Started SG process with pid={}", GetProcessId(sei.hProcess));
m_hProcess = sei.hProcess; m_hProcess = sei.hProcess;
return true; return true;
} }
void TerminateProcess() void TerminateProcess()
@ -271,7 +271,7 @@ private:
{ {
Logger::error("Failed to init settings. {}", ex.what()); Logger::error("Failed to init settings. {}", ex.what());
} }
catch(...) catch (...)
{ {
Logger::error("Failed to init settings"); Logger::error("Failed to init settings");
} }

View File

@ -30,7 +30,7 @@ namespace
const wchar_t JSON_KEY_VALUE[] = L"value"; const wchar_t JSON_KEY_VALUE[] = L"value";
} }
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@ -106,7 +106,7 @@ public:
} }
} }
virtual bool on_hotkey(size_t hotkeyId) override virtual bool on_hotkey(size_t /*hotkeyId*/) override
{ {
if (m_enabled) if (m_enabled)
{ {
@ -123,7 +123,7 @@ public:
return false; return false;
} }
virtual size_t get_hotkeys(Hotkey* hotkeys, size_t buffer_size) override virtual size_t get_hotkeys(Hotkey* hotkeys, size_t buffer_size) override
{ {
if (m_hotkey.key) if (m_hotkey.key)

View File

@ -17,7 +17,7 @@
#include <filesystem> #include <filesystem>
#include <set> #include <set>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {

View File

@ -13,9 +13,7 @@
#include <common/utils/logger_helper.h> #include <common/utils/logger_helper.h>
#include <common/utils/winapi_error.h> #include <common/utils/winapi_error.h>
BOOL APIENTRY DllMain(HMODULE hModule, BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
DWORD ul_reason_for_call,
LPVOID lpReserved)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@ -127,7 +125,7 @@ private:
} }
else else
{ {
Logger::error( L"ColorPicker failed to start. {}", get_last_error_or_default(GetLastError())); Logger::error(L"ColorPicker failed to start. {}", get_last_error_or_default(GetLastError()));
} }
m_hProcess = sei.hProcess; m_hProcess = sei.hProcess;
@ -208,7 +206,7 @@ public:
return settings.serialize_to_buffer(buffer, buffer_size); return settings.serialize_to_buffer(buffer, buffer_size);
} }
virtual void call_custom_action(const wchar_t* action) override virtual void call_custom_action(const wchar_t* /*action*/) override
{ {
} }
@ -255,7 +253,7 @@ public:
m_enabled = false; m_enabled = false;
} }
virtual bool on_hotkey(size_t hotkeyId) override virtual bool on_hotkey(size_t /*hotkeyId*/) override
{ {
if (m_enabled) if (m_enabled)
{ {
@ -269,7 +267,7 @@ public:
return true; return true;
} }
return false; return false;
} }
virtual size_t get_hotkeys(Hotkey* hotkeys, size_t buffer_size) override virtual size_t get_hotkeys(Hotkey* hotkeys, size_t buffer_size) override

View File

@ -138,7 +138,7 @@ namespace FancyZonesDataTypes
GUID virtualDesktopId{}; GUID virtualDesktopId{};
std::wstring toString() const noexcept; std::wstring toString() const noexcept;
}; };
struct AppZoneHistoryData struct AppZoneHistoryData
{ {
@ -194,7 +194,7 @@ namespace FancyZonesDataTypes
{ {
return lhs.monitor == rhs.monitor; return lhs.monitor == rhs.monitor;
} }
if (!lhs.serialNumber.empty() && !rhs.serialNumber.empty()) if (!lhs.serialNumber.empty() && !rhs.serialNumber.empty())
{ {
bool serialNumbersEqual = lhs.serialNumber == rhs.serialNumber; bool serialNumbersEqual = lhs.serialNumber == rhs.serialNumber;
@ -232,7 +232,7 @@ namespace FancyZonesDataTypes
lhs.virtualDesktopId.Data2 < rhs.virtualDesktopId.Data2 || lhs.virtualDesktopId.Data2 < rhs.virtualDesktopId.Data2 ||
lhs.virtualDesktopId.Data3 < rhs.virtualDesktopId.Data3; lhs.virtualDesktopId.Data3 < rhs.virtualDesktopId.Data3;
} }
if (!lhs.monitorId.serialNumber.empty() || rhs.monitorId.serialNumber.empty()) if (!lhs.monitorId.serialNumber.empty() || rhs.monitorId.serialNumber.empty())
{ {
return lhs.monitorId.serialNumber < rhs.monitorId.serialNumber; return lhs.monitorId.serialNumber < rhs.monitorId.serialNumber;
@ -247,7 +247,7 @@ namespace std
template<> template<>
struct hash<FancyZonesDataTypes::WorkAreaId> struct hash<FancyZonesDataTypes::WorkAreaId>
{ {
size_t operator()(const FancyZonesDataTypes::WorkAreaId& Value) const size_t operator()(const FancyZonesDataTypes::WorkAreaId& /*Value*/) const
{ {
return 0; return 0;
} }

View File

@ -110,7 +110,7 @@ namespace std
template<> template<>
struct hash<BackwardsCompatibility::DeviceIdData> struct hash<BackwardsCompatibility::DeviceIdData>
{ {
size_t operator()(const BackwardsCompatibility::DeviceIdData& Value) const size_t operator()(const BackwardsCompatibility::DeviceIdData& /*Value*/) const
{ {
return 0; return 0;
} }

View File

@ -19,7 +19,7 @@ public:
FancyZonesSettings::instance().RemoveObserver(*this); FancyZonesSettings::instance().RemoveObserver(*this);
} }
virtual void SettingsUpdate(SettingId type) {} virtual void SettingsUpdate(SettingId /*type*/) {}
bool WantsToBeNotified(SettingId type) const noexcept bool WantsToBeNotified(SettingId type) const noexcept
{ {

View File

@ -59,7 +59,7 @@ WindowMoveHandler::WindowMoveHandler(const std::function<void()>& keyUpdateCallb
{ {
} }
void WindowMoveHandler::MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, std::shared_ptr<WorkArea>>& workAreaMap) noexcept void WindowMoveHandler::MoveSizeStart(HWND window, HMONITOR monitor, POINT const& /*ptScreen*/, const std::unordered_map<HMONITOR, std::shared_ptr<WorkArea>>& workAreaMap) noexcept
{ {
if (!FancyZonesWindowProcessing::IsProcessable(window)) if (!FancyZonesWindowProcessing::IsProcessable(window))
{ {
@ -272,7 +272,7 @@ void WindowMoveHandler::MoveSizeEnd(HWND window, const std::unordered_map<HMONIT
} }
} }
} }
FancyZonesWindowProperties::RemoveZoneIndexProperty(window); FancyZonesWindowProperties::RemoveZoneIndexProperty(window);
} }
@ -373,7 +373,7 @@ void WindowMoveHandler::SetWindowTransparency(HWND window) noexcept
if (FancyZonesSettings::settings().makeDraggedWindowTransparent) if (FancyZonesSettings::settings().makeDraggedWindowTransparent)
{ {
m_windowTransparencyProperties.draggedWindowExstyle = GetWindowLong(window, GWL_EXSTYLE); m_windowTransparencyProperties.draggedWindowExstyle = GetWindowLong(window, GWL_EXSTYLE);
SetWindowLong(window, SetWindowLong(window,
GWL_EXSTYLE, GWL_EXSTYLE,
m_windowTransparencyProperties.draggedWindowExstyle | WS_EX_LAYERED); m_windowTransparencyProperties.draggedWindowExstyle | WS_EX_LAYERED);
@ -401,7 +401,7 @@ void WindowMoveHandler::ResetWindowTransparency() noexcept
{ {
Logger::error(L"Window transparency: SetLayeredWindowAttributes failed"); Logger::error(L"Window transparency: SetLayeredWindowAttributes failed");
} }
if (SetWindowLong(m_windowTransparencyProperties.draggedWindow, GWL_EXSTYLE, m_windowTransparencyProperties.draggedWindowExstyle) == 0) if (SetWindowLong(m_windowTransparencyProperties.draggedWindow, GWL_EXSTYLE, m_windowTransparencyProperties.draggedWindowExstyle) == 0)
{ {
Logger::error(L"Window transparency: SetWindowLong failed, {}", get_last_error_or_default(GetLastError())); Logger::error(L"Window transparency: SetWindowLong failed, {}", get_last_error_or_default(GetLastError()));

View File

@ -37,8 +37,8 @@ enum DWM_WINDOW_CORNER_PREFERENCE
}; };
namespace namespace
{ {
BOOL CALLBACK saveDisplayToVector(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) BOOL CALLBACK saveDisplayToVector(HMONITOR monitor, HDC /*hdc*/, LPRECT /*rect*/, LPARAM data)
{ {
reinterpret_cast<std::vector<HMONITOR>*>(data)->emplace_back(monitor); reinterpret_cast<std::vector<HMONITOR>*>(data)->emplace_back(monitor);
return true; return true;
@ -121,7 +121,6 @@ namespace
} }
} }
bool FancyZonesWindowUtils::IsSplashScreen(HWND window) bool FancyZonesWindowUtils::IsSplashScreen(HWND window)
{ {
wchar_t className[MAX_PATH]; wchar_t className[MAX_PATH];
@ -200,9 +199,7 @@ bool FancyZonesWindowUtils::IsPopupWindow(HWND window) noexcept
bool FancyZonesWindowUtils::HasThickFrameAndMinimizeMaximizeButtons(HWND window) noexcept bool FancyZonesWindowUtils::HasThickFrameAndMinimizeMaximizeButtons(HWND window) noexcept
{ {
auto style = GetWindowLong(window, GWL_STYLE); auto style = GetWindowLong(window, GWL_STYLE);
return ((style & WS_THICKFRAME) == WS_THICKFRAME return ((style & WS_THICKFRAME) == WS_THICKFRAME && (style & WS_MINIMIZEBOX) == WS_MINIMIZEBOX && (style & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX);
&& (style & WS_MINIMIZEBOX) == WS_MINIMIZEBOX
&& (style & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX);
} }
bool FancyZonesWindowUtils::IsCandidateForZoning(HWND window) bool FancyZonesWindowUtils::IsCandidateForZoning(HWND window)
@ -212,7 +209,7 @@ bool FancyZonesWindowUtils::IsCandidateForZoning(HWND window)
{ {
return false; return false;
} }
// popup could be the window we don't want to snap: start menu, notification popup, tray window, etc. // popup could be the window we don't want to snap: start menu, notification popup, tray window, etc.
// also, popup could be the windows we want to snap disregarding the "allowSnapPopupWindows" setting, e.g. Telegram // also, popup could be the windows we want to snap disregarding the "allowSnapPopupWindows" setting, e.g. Telegram
bool isPopup = IsPopupWindow(window); bool isPopup = IsPopupWindow(window);
@ -220,8 +217,8 @@ bool FancyZonesWindowUtils::IsCandidateForZoning(HWND window)
{ {
return false; return false;
} }
// allow child windows // allow child windows
auto hasOwner = HasVisibleOwner(window); auto hasOwner = HasVisibleOwner(window);
if (hasOwner && !FancyZonesSettings::settings().allowSnapChildWindows) if (hasOwner && !FancyZonesSettings::settings().allowSnapChildWindows)
{ {
@ -283,7 +280,7 @@ bool FancyZonesWindowUtils::IsExcludedByDefault(const std::wstring& processPath)
{ {
return true; return true;
} }
static std::vector<std::wstring> defaultExcludedApps = { NonLocalizable::PowerToysAppFZEditor, NonLocalizable::CoreWindow, NonLocalizable::SearchUI }; static std::vector<std::wstring> defaultExcludedApps = { NonLocalizable::PowerToysAppFZEditor, NonLocalizable::CoreWindow, NonLocalizable::SearchUI };
return (find_app_name_in_path(processPath, defaultExcludedApps)); return (find_app_name_in_path(processPath, defaultExcludedApps));
} }
@ -346,7 +343,7 @@ void FancyZonesWindowUtils::SizeWindowToRect(HWND window, RECT rect) noexcept
{ {
Logger::error(L"SetWindowPlacement failed, {}", get_last_error_or_default(GetLastError())); Logger::error(L"SetWindowPlacement failed, {}", get_last_error_or_default(GetLastError()));
} }
// Do it again, allowing Windows to resize the window and set correct scaling // Do it again, allowing Windows to resize the window and set correct scaling
// This fixes Issue #365 // This fixes Issue #365
result = ::SetWindowPlacement(window, &placement); result = ::SetWindowPlacement(window, &placement);

View File

@ -14,7 +14,7 @@ public:
~WorkArea(); ~WorkArea();
public: public:
inline bool Init(HINSTANCE hinstance, const FancyZonesDataTypes::WorkAreaId& parentUniqueId) inline bool Init([[maybe_unused]] HINSTANCE hinstance, const FancyZonesDataTypes::WorkAreaId& parentUniqueId)
{ {
#ifndef UNIT_TESTS #ifndef UNIT_TESTS
if (!InitWindow(hinstance)) if (!InitWindow(hinstance))
@ -22,7 +22,6 @@ public:
return false; return false;
} }
#endif #endif
InitLayout(parentUniqueId); InitLayout(parentUniqueId);
return true; return true;
} }
@ -60,7 +59,7 @@ public:
const std::unique_ptr<LayoutAssignedWindows>& GetLayoutWindows() const noexcept { return m_layoutWindows; } const std::unique_ptr<LayoutAssignedWindows>& GetLayoutWindows() const noexcept { return m_layoutWindows; }
ZoneIndexSet GetWindowZoneIndexes(HWND window) const noexcept; ZoneIndexSet GetWindowZoneIndexes(HWND window) const noexcept;
HRESULT MoveSizeEnter(HWND window) noexcept; HRESULT MoveSizeEnter(HWND window) noexcept;
HRESULT MoveSizeUpdate(POINT const& ptScreen, bool dragEnabled, bool selectManyZones) noexcept; HRESULT MoveSizeUpdate(POINT const& ptScreen, bool dragEnabled, bool selectManyZones) noexcept;
HRESULT MoveSizeEnd(HWND window) noexcept; HRESULT MoveSizeEnd(HWND window) noexcept;
@ -70,7 +69,7 @@ public:
bool MoveWindowIntoZoneByDirectionAndPosition(HWND window, DWORD vkCode, bool cycle) noexcept; bool MoveWindowIntoZoneByDirectionAndPosition(HWND window, DWORD vkCode, bool cycle) noexcept;
bool ExtendWindowByDirectionAndPosition(HWND window, DWORD vkCode) noexcept; bool ExtendWindowByDirectionAndPosition(HWND window, DWORD vkCode) noexcept;
void SaveWindowProcessToZoneIndex(HWND window) noexcept; void SaveWindowProcessToZoneIndex(HWND window) noexcept;
void UpdateActiveZoneSet() noexcept; void UpdateActiveZoneSet() noexcept;
void ShowZonesOverlay() noexcept; void ShowZonesOverlay() noexcept;
@ -115,7 +114,7 @@ inline std::shared_ptr<WorkArea> MakeWorkArea(HINSTANCE hinstance, HMONITOR moni
self->LogInitializationError(); self->LogInitializationError();
return nullptr; return nullptr;
} }
if (!self->Init(hinstance, parentUniqueId)) if (!self->Init(hinstance, parentUniqueId))
{ {
return nullptr; return nullptr;
@ -123,4 +122,3 @@ inline std::shared_ptr<WorkArea> MakeWorkArea(HINSTANCE hinstance, HMONITOR moni
return self; return self;
} }

View File

@ -43,7 +43,7 @@ namespace FancyZonesUtils
quad->rgbBlue = GetBValue(color) * alpha / 255; quad->rgbBlue = GetBValue(color) * alpha / 255;
} }
inline void FillRectARGB(wil::unique_hdc& hdc, RECT const* prcFill, BYTE alpha, COLORREF color, bool blendAlpha) inline void FillRectARGB(wil::unique_hdc& hdc, RECT const* prcFill, BYTE alpha, COLORREF color, bool /*blendAlpha*/)
{ {
BITMAPINFO bi; BITMAPINFO bi;
ZeroMemory(&bi, sizeof(bi)); ZeroMemory(&bi, sizeof(bi));
@ -104,7 +104,7 @@ namespace FancyZonesUtils
using result_t = std::vector<std::pair<HMONITOR, RECT>>; using result_t = std::vector<std::pair<HMONITOR, RECT>>;
result_t result; result_t result;
auto enumMonitors = [](HMONITOR monitor, HDC hdc, LPRECT pRect, LPARAM param) -> BOOL { auto enumMonitors = [](HMONITOR monitor, HDC /*hdc*/, LPRECT /*pRect*/, LPARAM param) -> BOOL {
MONITORINFOEX mi; MONITORINFOEX mi;
mi.cbSize = sizeof(mi); mi.cbSize = sizeof(mi);
result_t& result = *reinterpret_cast<result_t*>(param); result_t& result = *reinterpret_cast<result_t*>(param);
@ -126,7 +126,7 @@ namespace FancyZonesUtils
using result_t = std::vector<std::pair<HMONITOR, MONITORINFOEX>>; using result_t = std::vector<std::pair<HMONITOR, MONITORINFOEX>>;
result_t result; result_t result;
auto enumMonitors = [](HMONITOR monitor, HDC hdc, LPRECT pRect, LPARAM param) -> BOOL { auto enumMonitors = [](HMONITOR monitor, HDC /*hdc*/, LPRECT /*pRect*/, LPARAM param) -> BOOL {
MONITORINFOEX mi; MONITORINFOEX mi;
mi.cbSize = sizeof(mi); mi.cbSize = sizeof(mi);
result_t& result = *reinterpret_cast<result_t*>(param); result_t& result = *reinterpret_cast<result_t*>(param);
@ -176,5 +176,5 @@ namespace FancyZonesUtils
std::optional<std::wstring> GuidToString(const GUID& guid) noexcept; std::optional<std::wstring> GuidToString(const GUID& guid) noexcept;
RECT PrepareRectForCycling(RECT windowRect, RECT workAreaRect, DWORD vkCode) noexcept; RECT PrepareRectForCycling(RECT windowRect, RECT workAreaRect, DWORD vkCode) noexcept;
size_t ChooseNextZoneByPosition(DWORD vkCode, RECT windowRect, const std::vector<RECT>& zoneRects) noexcept; size_t ChooseNextZoneByPosition(DWORD vkCode, RECT windowRect, const std::vector<RECT>& zoneRects) noexcept;
} }

View File

@ -17,7 +17,7 @@
// Non-localizable // Non-localizable
const std::wstring fancyZonesPath = L"modules\\FancyZones\\PowerToys.FancyZones.exe"; const std::wstring fancyZonesPath = L"modules\\FancyZones\\PowerToys.FancyZones.exe";
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@ -59,20 +59,20 @@ public:
// Return JSON with the configuration options. // Return JSON with the configuration options.
// These are the settings shown on the settings page along with their current values. // These are the settings shown on the settings page along with their current values.
virtual bool get_config(_Out_ PWSTR buffer, _Out_ int* buffer_size) override virtual bool get_config(_Out_ PWSTR /*buffer*/, _Out_ int* /*buffer_size*/) override
{ {
return false; return false;
} }
// Passes JSON with the configuration settings for the powertoy. // Passes JSON with the configuration settings for the powertoy.
// This is called when the user hits Save on the settings page. // This is called when the user hits Save on the settings page.
virtual void set_config(PCWSTR config) override virtual void set_config(PCWSTR /*config*/) override
{ {
} }
// Signal from the Settings editor to call a custom action. // Signal from the Settings editor to call a custom action.
// This can be used to spawn more complex editors. // This can be used to spawn more complex editors.
virtual void call_custom_action(const wchar_t* action) override virtual void call_custom_action(const wchar_t* /*action*/) override
{ {
SetEvent(m_toggleEditorEvent); SetEvent(m_toggleEditorEvent);
} }
@ -124,7 +124,7 @@ public:
{ {
app_name = GET_RESOURCE_STRING(IDS_FANCYZONES); app_name = GET_RESOURCE_STRING(IDS_FANCYZONES);
app_key = NonLocalizable::ModuleKey; app_key = NonLocalizable::ModuleKey;
m_toggleEditorEvent = CreateDefaultEvent(CommonSharedConstants::FANCY_ZONES_EDITOR_TOGGLE_EVENT); m_toggleEditorEvent = CreateDefaultEvent(CommonSharedConstants::FANCY_ZONES_EDITOR_TOGGLE_EVENT);
if (!m_toggleEditorEvent) if (!m_toggleEditorEvent)
{ {

View File

@ -38,7 +38,7 @@ void CContextMenuHandler::Uninitialize()
} }
} }
HRESULT CContextMenuHandler::Initialize(_In_opt_ PCIDLIST_ABSOLUTE pidlFolder, _In_opt_ IDataObject* pdtobj, _In_opt_ HKEY hkeyProgID) HRESULT CContextMenuHandler::Initialize(_In_opt_ PCIDLIST_ABSOLUTE pidlFolder, _In_opt_ IDataObject* pdtobj, _In_opt_ HKEY /*hkeyProgID*/)
{ {
Uninitialize(); Uninitialize();
@ -61,7 +61,7 @@ HRESULT CContextMenuHandler::Initialize(_In_opt_ PCIDLIST_ABSOLUTE pidlFolder, _
return S_OK; return S_OK;
} }
HRESULT CContextMenuHandler::QueryContextMenu(_In_ HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) HRESULT CContextMenuHandler::QueryContextMenu(_In_ HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT uFlags)
{ {
if (uFlags & CMF_DEFAULTONLY) if (uFlags & CMF_DEFAULTONLY)
return S_OK; return S_OK;
@ -167,7 +167,7 @@ HRESULT CContextMenuHandler::QueryContextMenu(_In_ HMENU hmenu, UINT indexMenu,
return S_OK; return S_OK;
} }
HRESULT CContextMenuHandler::GetCommandString(UINT_PTR idCmd, UINT uType, _In_ UINT* pReserved, LPSTR pszName, UINT cchMax) HRESULT CContextMenuHandler::GetCommandString(UINT_PTR idCmd, UINT uType, _In_ UINT* /*pReserved*/, LPSTR pszName, UINT cchMax)
{ {
if (idCmd == ID_RESIZE_PICTURES) if (idCmd == ID_RESIZE_PICTURES)
{ {
@ -360,7 +360,7 @@ HRESULT __stdcall CContextMenuHandler::GetCanonicalName(GUID* pguidCommandName)
return S_OK; return S_OK;
} }
HRESULT __stdcall CContextMenuHandler::GetState(IShellItemArray* psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE* pCmdState) HRESULT __stdcall CContextMenuHandler::GetState(IShellItemArray* psiItemArray, BOOL /*fOkToBeSlow*/, EXPCMDSTATE* pCmdState)
{ {
if (!CSettingsInstance().GetEnabled()) if (!CSettingsInstance().GetEnabled())
{ {

View File

@ -92,10 +92,10 @@ public:
// Signal from the Settings editor to call a custom action. // Signal from the Settings editor to call a custom action.
// This can be used to spawn more complex editors. // This can be used to spawn more complex editors.
virtual void call_custom_action(const wchar_t* action) override {} virtual void call_custom_action(const wchar_t* /*action*/) override {}
// Called by the runner to pass the updated settings values as a serialized JSON. // Called by the runner to pass the updated settings values as a serialized JSON.
virtual void set_config(const wchar_t* config) override {} virtual void set_config(const wchar_t* /*config*/) override {}
// Enable the powertoy // Enable the powertoy
virtual void enable() virtual void enable()
@ -114,7 +114,6 @@ public:
} }
} }
Trace::EnableImageResizer(m_enabled); Trace::EnableImageResizer(m_enabled);
} }

View File

@ -68,7 +68,7 @@ public:
/* Sets the configuration values. */ /* Sets the configuration values. */
virtual void set_config(const wchar_t* config) = 0; virtual void set_config(const wchar_t* config) = 0;
/* Call custom action from settings screen. */ /* Call custom action from settings screen. */
virtual void call_custom_action(const wchar_t* action){}; virtual void call_custom_action(const wchar_t* /*action*/){};
/* Enables the PowerToy. */ /* Enables the PowerToy. */
virtual void enable() = 0; virtual void enable() = 0;
/* Disables the PowerToy, should free as much memory as possible. */ /* Disables the PowerToy, should free as much memory as possible. */
@ -83,7 +83,10 @@ public:
* Modules do not need to override this method, it will return zero by default. * Modules do not need to override this method, it will return zero by default.
* This method is called even when the module is disabled. * This method is called even when the module is disabled.
*/ */
virtual size_t get_hotkeys(Hotkey* buffer, size_t buffer_size) { return 0; } virtual size_t get_hotkeys(Hotkey* /*buffer*/, size_t /*buffer_size*/)
{
return 0;
}
virtual std::optional<HotkeyEx> GetHotkeyEx() virtual std::optional<HotkeyEx> GetHotkeyEx()
{ {
@ -97,7 +100,10 @@ public:
/* Called when one of the registered hotkeys is pressed. Should return true /* Called when one of the registered hotkeys is pressed. Should return true
* if the key press is to be swallowed. * if the key press is to be swallowed.
*/ */
virtual bool on_hotkey(size_t hotkeyId) { return false; } virtual bool on_hotkey(size_t /*hotkeyId*/)
{
return false;
}
/* These are for enabling the legacy behavior of showing the shortcut guide after pressing the win key. /* These are for enabling the legacy behavior of showing the shortcut guide after pressing the win key.
* keep_track_of_pressed_win_key returns true if the module wants to keep track of the win key being pressed. * keep_track_of_pressed_win_key returns true if the module wants to keep track of the win key being pressed.
@ -114,7 +120,8 @@ public:
virtual bool is_enabled_by_default() const { return true; } virtual bool is_enabled_by_default() const { return true; }
/* Provides the GPO configuration value for the module. This should be overriden by the module interface to get the proper gpo policy setting. */ /* Provides the GPO configuration value for the module. This should be overriden by the module interface to get the proper gpo policy setting. */
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() { virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration()
{
return powertoys_gpo::gpo_rule_configured_not_configured; return powertoys_gpo::gpo_rule_configured_not_configured;
} }

View File

@ -22,12 +22,10 @@ std::unique_ptr<KeyboardManagerEditor> editor = nullptr;
const std::wstring instanceMutexName = L"Local\\PowerToys_KBMEditor_InstanceMutex"; const std::wstring instanceMutexName = L"Local\\PowerToys_KBMEditor_InstanceMutex";
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance, _In_opt_ HINSTANCE /*hPrevInstance*/,
_In_ LPWSTR lpCmdLine, _In_ LPWSTR /*lpCmdLine*/,
_In_ int nCmdShow) _In_ int /*nCmdShow*/)
{ {
UNREFERENCED_PARAMETER(hPrevInstance);
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Editor", LogSettings::keyboardManagerLoggerName); LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Editor", LogSettings::keyboardManagerLoggerName);
if (powertoys_gpo::getConfiguredKeyboardManagerEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled) if (powertoys_gpo::getConfiguredKeyboardManagerEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled)
@ -78,7 +76,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
{ {
type = static_cast<KeyboardManagerEditorType>(_wtoi(cmdArgs[1])); type = static_cast<KeyboardManagerEditorType>(_wtoi(cmdArgs[1]));
} }
if (numArgs == 3) if (numArgs == 3)
{ {
std::wstring pid = std::wstring(cmdArgs[2]); std::wstring pid = std::wstring(cmdArgs[2]);
@ -106,12 +104,12 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
auto errorMessage = get_last_error_message(errorCode); auto errorMessage = get_last_error_message(errorCode);
Logger::error(L"Unable to start keyboard hook: {}", errorMessage.has_value() ? errorMessage.value() : L""); Logger::error(L"Unable to start keyboard hook: {}", errorMessage.has_value() ? errorMessage.value() : L"");
Trace::Error(errorCode, errorMessage.has_value() ? errorMessage.value() : L"", L"start_lowlevel_keyboard_hook.SetWindowsHookEx"); Trace::Error(errorCode, errorMessage.has_value() ? errorMessage.value() : L"", L"start_lowlevel_keyboard_hook.SetWindowsHookEx");
return -1; return -1;
} }
editor->OpenEditorWindow(type); editor->OpenEditorWindow(type);
editor = nullptr; editor = nullptr;
Trace::UnregisterProvider(); Trace::UnregisterProvider();

View File

@ -11,7 +11,10 @@
const std::wstring instanceMutexName = L"Local\\PowerToys_KBMEngine_InstanceMutex"; const std::wstring instanceMutexName = L"Local\\PowerToys_KBMEngine_InstanceMutex";
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ PWSTR lpCmdLine, _In_ int nCmdShow) int WINAPI wWinMain(_In_ HINSTANCE /*hInstance*/,
_In_opt_ HINSTANCE /*hPrevInstance*/,
_In_ PWSTR lpCmdLine,
_In_ int /*nCmdShow*/)
{ {
winrt::init_apartment(); winrt::init_apartment();
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Engine", LogSettings::keyboardManagerLoggerName); LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Engine", LogSettings::keyboardManagerLoggerName);
@ -59,11 +62,11 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
auto kbm = KeyboardManager(); auto kbm = KeyboardManager();
kbm.StartLowlevelKeyboardHook(); kbm.StartLowlevelKeyboardHook();
run_message_loop(); run_message_loop();
kbm.StopLowlevelKeyboardHook(); kbm.StopLowlevelKeyboardHook();
Trace::UnregisterProvider(); Trace::UnregisterProvider();
return 0; return 0;
} }

View File

@ -10,7 +10,7 @@ void MockedInput::SetHookProc(std::function<intptr_t(LowlevelKeyboardEvent*)> ho
} }
// Function to simulate keyboard input - arguments and return value based on SendInput function (https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendinput) // Function to simulate keyboard input - arguments and return value based on SendInput function (https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendinput)
UINT MockedInput::SendVirtualInput(UINT cInputs, LPINPUT pInputs, int cbSize) UINT MockedInput::SendVirtualInput(UINT cInputs, LPINPUT pInputs, int /*cbSize*/)
{ {
// Iterate over inputs // Iterate over inputs
for (UINT i = 0; i < cInputs; i++) for (UINT i = 0; i < cInputs; i++)

View File

@ -9,7 +9,7 @@
#include <shellapi.h> #include <shellapi.h>
#include <common/utils/logger_helper.h> #include <common/utils/logger_helper.h>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@ -23,6 +23,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
Trace::UnregisterProvider(); Trace::UnregisterProvider();
break; break;
} }
return TRUE; return TRUE;
} }
@ -40,12 +41,13 @@ private:
std::wstring app_key = KeyboardManagerConstants::ModuleName; std::wstring app_key = KeyboardManagerConstants::ModuleName;
HANDLE m_hProcess = nullptr; HANDLE m_hProcess = nullptr;
public: public:
// Constructor // Constructor
KeyboardManager() KeyboardManager()
{ {
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"ModuleInterface", LogSettings::keyboardManagerLoggerName); LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"ModuleInterface", LogSettings::keyboardManagerLoggerName);
std::filesystem::path oldLogPath(PTSettingsHelper::get_module_save_folder_location(app_key)); std::filesystem::path oldLogPath(PTSettingsHelper::get_module_save_folder_location(app_key));
oldLogPath.append("Logs"); oldLogPath.append("Logs");
LoggerHelpers::delete_old_log_folder(oldLogPath); LoggerHelpers::delete_old_log_folder(oldLogPath);
@ -89,7 +91,7 @@ public:
} }
// Signal from the Settings editor to call a custom action. // Signal from the Settings editor to call a custom action.
virtual void call_custom_action(const wchar_t* action) override virtual void call_custom_action(const wchar_t* /*action*/) override
{ {
} }
@ -118,7 +120,7 @@ public:
m_enabled = true; m_enabled = true;
// Log telemetry // Log telemetry
Trace::EnableKeyboardManager(true); Trace::EnableKeyboardManager(true);
unsigned long powertoys_pid = GetCurrentProcessId(); unsigned long powertoys_pid = GetCurrentProcessId();
std::wstring executable_args = L""; std::wstring executable_args = L"";
executable_args.append(std::to_wstring(powertoys_pid)); executable_args.append(std::to_wstring(powertoys_pid));

View File

@ -29,7 +29,7 @@ namespace
const wchar_t JSON_KEY_USE_CENTRALIZED_KEYBOARD_HOOK[] = L"use_centralized_keyboard_hook"; const wchar_t JSON_KEY_USE_CENTRALIZED_KEYBOARD_HOOK[] = L"use_centralized_keyboard_hook";
} }
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@ -43,6 +43,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
Trace::UnregisterProvider(); Trace::UnregisterProvider();
break; break;
} }
return TRUE; return TRUE;
} }
@ -318,7 +319,7 @@ public:
} }
// Process the hotkey event // Process the hotkey event
virtual bool on_hotkey(size_t hotkeyId) override virtual bool on_hotkey(size_t /*hotkeyId*/) override
{ {
// For now, hotkeyId will always be zero // For now, hotkeyId will always be zero
if (m_enabled) if (m_enabled)

View File

@ -18,7 +18,7 @@
#include <filesystem> #include <filesystem>
#include <set> #include <set>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@ -32,6 +32,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
Trace::UnregisterProvider(); Trace::UnregisterProvider();
break; break;
} }
return TRUE; return TRUE;
} }

View File

@ -272,7 +272,7 @@ HRESULT __stdcall CPowerRenameMenu::GetCanonicalName(GUID* pguidCommandName)
return S_OK; return S_OK;
} }
HRESULT __stdcall CPowerRenameMenu::GetState(IShellItemArray* psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE* pCmdState) HRESULT __stdcall CPowerRenameMenu::GetState(IShellItemArray* /*psiItemArray*/, BOOL /*fOkToBeSlow*/, EXPCMDSTATE* pCmdState)
{ {
*pCmdState = CSettingsInstance().GetEnabled() ? ECS_ENABLED : ECS_HIDDEN; *pCmdState = CSettingsInstance().GetEnabled() ? ECS_ENABLED : ECS_HIDDEN;
return S_OK; return S_OK;

View File

@ -168,8 +168,6 @@ private:
std::wstring app_key; std::wstring app_key;
public: public:
// Return the localized display name of the powertoy // Return the localized display name of the powertoy
virtual PCWSTR get_name() override virtual PCWSTR get_name() override
{ {
@ -300,7 +298,7 @@ public:
// Signal from the Settings editor to call a custom action. // Signal from the Settings editor to call a custom action.
// This can be used to spawn more complex editors. // This can be used to spawn more complex editors.
virtual void call_custom_action(const wchar_t* action) override virtual void call_custom_action(const wchar_t* /*action*/) override
{ {
} }

View File

@ -28,9 +28,9 @@ DEFINE_GUID(BHID_DataObject, 0xb8c0bd9f, 0xed24, 0x455c, 0x83, 0xe6, 0xd5, 0x39,
int APIENTRY wWinMain( int APIENTRY wWinMain(
_In_ HINSTANCE hInstance, _In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance, _In_opt_ HINSTANCE /*hPrevInstance*/,
_In_ PWSTR lpCmdLine, _In_ PWSTR /*lpCmdLine*/,
_In_ int nCmdShow) _In_ int /*nCmdShow*/)
{ {
g_hostHInst = hInstance; g_hostHInst = hInstance;
HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
@ -81,5 +81,6 @@ int APIENTRY wWinMain(
} }
CoUninitialize(); CoUninitialize();
} }
return 0; return 0;
} }

View File

@ -53,19 +53,19 @@ IFACEMETHODIMP CMockPowerRenameManagerEvents::OnError(_In_ IPowerRenameItem* pIt
return S_OK; return S_OK;
} }
IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExStarted(_In_ DWORD threadId) IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExStarted(_In_ DWORD /*threadId*/)
{ {
m_regExStarted = true; m_regExStarted = true;
return S_OK; return S_OK;
} }
IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExCanceled(_In_ DWORD threadId) IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExCanceled(_In_ DWORD /*threadId*/)
{ {
m_regExCanceled = true; m_regExCanceled = true;
return S_OK; return S_OK;
} }
IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExCompleted(_In_ DWORD threadId) IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExCompleted(_In_ DWORD /*threadId*/)
{ {
m_regExCompleted = true; m_regExCompleted = true;
return S_OK; return S_OK;

View File

@ -31,7 +31,7 @@ HRESULT CALLBACK DllGetClassObject(REFCLSID clsid, REFIID riid, void** ppv)
return hr; return hr;
} }
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {

View File

@ -9,7 +9,7 @@ namespace CentralizedHotkeys
std::wstring moduleName; std::wstring moduleName;
std::function<void(WORD, WORD)> action; std::function<void(WORD, WORD)> action;
Action(std::wstring moduleName = L"", std::function<void(WORD, WORD)> action = ([](WORD modifiersMask, WORD vkCode) {})) Action(std::wstring moduleName = L"", std::function<void(WORD, WORD)> action = ([](WORD /*modifiersMask*/, WORD /*vkCode*/) {}))
{ {
this->moduleName = moduleName; this->moduleName = moduleName;
this->action = action; this->action = action;

View File

@ -58,9 +58,9 @@ namespace CentralizedKeyboardHook
// Handle the pressed key proc // Handle the pressed key proc
void PressedKeyTimerProc( void PressedKeyTimerProc(
HWND hwnd, HWND hwnd,
UINT message, UINT /*message*/,
UINT_PTR idTimer, UINT_PTR idTimer,
DWORD dwTime) DWORD /*dwTime*/)
{ {
std::multiset<PressedKeyDescriptor> copy; std::multiset<PressedKeyDescriptor> copy;
{ {

View File

@ -348,7 +348,7 @@ void cleanup_updates()
} }
} }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int /*nCmdShow*/)
{ {
Gdiplus::GdiplusStartupInput gpStartupInput; Gdiplus::GdiplusStartupInput gpStartupInput;
ULONG_PTR gpToken; ULONG_PTR gpToken;

View File

@ -78,7 +78,7 @@ void PowertoyModule::UpdateHotkeyEx()
{ {
auto hotkey = container.value(); auto hotkey = container.value();
auto modulePtr = pt_module.get(); auto modulePtr = pt_module.get();
auto action = [modulePtr](WORD modifiersMask, WORD vkCode) { auto action = [modulePtr](WORD /*modifiersMask*/, WORD /*vkCode*/) {
Logger::trace(L"{} hotkey Ex is invoked from Centralized keyboard hook", modulePtr->get_key()); Logger::trace(L"{} hotkey Ex is invoked from Centralized keyboard hook", modulePtr->get_key());
modulePtr->OnHotkeyEx(); modulePtr->OnHotkeyEx();
}; };

View File

@ -86,7 +86,7 @@ std::optional<std::wstring> dispatch_json_action_to_module(const json::JsonObjec
else if (action == L"restart_maintain_elevation") else if (action == L"restart_maintain_elevation")
{ {
// this was added to restart and maintain elevation, which is needed after settings are change from outside the normal process. // this was added to restart and maintain elevation, which is needed after settings are change from outside the normal process.
// since a normal PostQuitMessage(0) would usually cause this process to save it's in memory settings to disk, we need to // since a normal PostQuitMessage(0) would usually cause this process to save it's in memory settings to disk, we need to
// send a PostQuitMessage(1) and check for that on exit, and skip the settings-flush. // send a PostQuitMessage(1) and check for that on exit, and skip the settings-flush.
auto loaded = PTSettingsHelper::load_general_settings(); auto loaded = PTSettingsHelper::load_general_settings();
@ -462,7 +462,7 @@ LExit:
#define MAX_TITLE_LENGTH 100 #define MAX_TITLE_LENGTH 100
void bring_settings_to_front() void bring_settings_to_front()
{ {
auto callback = [](HWND hwnd, LPARAM data) -> BOOL { auto callback = [](HWND hwnd, LPARAM /*data*/) -> BOOL {
DWORD processId; DWORD processId;
if (GetWindowThreadProcessId(hwnd, &processId) && processId == g_settings_process_id) if (GetWindowThreadProcessId(hwnd, &processId) && processId == g_settings_process_id)
{ {

View File

@ -9,6 +9,7 @@
<ProjectName>BugReportTool</ProjectName> <ProjectName>BugReportTool</ProjectName>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<PropertyGroup Label="Configuration"> <PropertyGroup Label="Configuration">
<PlatformToolset>v143</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
</PropertyGroup> </PropertyGroup>
@ -23,7 +24,7 @@
<PropertyGroup Condition="'$(Configuration)'=='Release'"> <PropertyGroup Condition="'$(Configuration)'=='Release'">
<TargetName>PowerToys.$(ProjectName)</TargetName> <TargetName>PowerToys.$(ProjectName)</TargetName>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
</ImportGroup> </ImportGroup>
<ImportGroup Label="Shared"> <ImportGroup Label="Shared">
@ -45,7 +46,7 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\deps\cziplib\src\zip.c"> <ClCompile Include="..\..\..\deps\cziplib\src\zip.c">
<!-- Disabling warnings for external code --> <!-- Disabling warnings for external code -->
<DisableSpecificWarnings>26451;4706;4267;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4706;26451;4267;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<ClCompile Include="EventViewer.cpp" /> <ClCompile Include="EventViewer.cpp" />
<ClCompile Include="InstallationFolder.cpp" /> <ClCompile Include="InstallationFolder.cpp" />