From 34239277d7ee5847e0e5b318ce6134f89a4c0044 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexander=20Steinh=C3=B6fer?= Date: Fri, 25 Feb 2022 14:39:57 +0100 Subject: [PATCH] Remade project with small cleanups. No more MFC dependency --- .gitattributes | 1 + {Build => Dist}/tools/chocolateyinstall.ps1 | 0 ScreensaverNotify/ScreensaverNotify.cpp | 6 +- ScreensaverNotify/ScreensaverNotify.h | 7 +- ScreensaverNotify/ScreensaverNotify.vcxproj | 156 +++++----- .../ScreensaverNotify.vcxproj.filters | 2 +- .../ScreensaverNotify.vcxproj.user | 2 +- .../ScreensaverNotify32.vcxproj | 38 +-- .../ScreensaverNotifierProxy.cpp | 5 +- ScreensaverProxy32/ScreensaverNotifierProxy.h | 2 +- ScreensaverProxy32/ScreensaverProxy.cpp | 4 +- ScreensaverProxy32/ScreensaverProxy32.vcxproj | 32 +- .../ScreensaverProxy32.vcxproj.filters | 4 +- .../ScreensaverProxy32.vcxproj.user | 17 +- WinMute.sln | 85 +++--- WinMute/AboutDlg.cpp | 28 +- WinMute/Log.cpp | 12 +- WinMute/Log.h | 4 +- WinMute/MMNotificationClient.cpp | 6 +- WinMute/MMNotificationClient.h | 15 +- WinMute/QuietHoursDlg.cpp | 30 +- WinMute/ScreensaverNotifier.cpp | 60 ++-- WinMute/ScreensaverNotifier.h | 4 +- WinMute/Settings.cpp | 7 +- WinMute/Settings.h | 6 +- WinMute/TrayIcon.cpp | 31 +- WinMute/TrayIcon.h | 11 +- WinMute/Utility.cpp | 46 +-- WinMute/VersionHelper.h | 8 +- WinMute/VistaAudio.cpp | 82 +++--- WinMute/VistaAudioSessionEvents.cpp | 25 +- WinMute/VistaAudioSessionEvents.h | 34 +-- WinMute/WinAudio.h | 10 +- WinMute/WinMain.cpp | 58 ++-- WinMute/WinMute.cpp | 57 ++-- WinMute/WinMute.h | 6 +- WinMute/{res.rc => WinMute.rc} | 264 ++++++++++------- WinMute/WinMute.vcxproj | 275 +++++++----------- WinMute/WinMute.vcxproj.filters | 160 +++++----- WinMute/WinMute.vcxproj.user | 19 +- WinMute/{StdAfx.cpp => common.cpp} | 4 +- WinMute/{StdAfx.h => common.h} | 24 +- WinMute/{ => icons}/app.ico | Bin WinMute/{ => icons}/tray_bright.ico | Bin WinMute/{ => icons}/tray_dark.ico | Bin WinMute/resource.h | 82 +++--- 46 files changed, 848 insertions(+), 881 deletions(-) rename {Build => Dist}/tools/chocolateyinstall.ps1 (100%) rename WinMute/{res.rc => WinMute.rc} (57%) rename WinMute/{StdAfx.cpp => common.cpp} (95%) rename WinMute/{StdAfx.h => common.h} (71%) rename WinMute/{ => icons}/app.ico (100%) rename WinMute/{ => icons}/tray_bright.ico (100%) rename WinMute/{ => icons}/tray_dark.ico (100%) diff --git a/.gitattributes b/.gitattributes index 45205ba..46c1821 100644 --- a/.gitattributes +++ b/.gitattributes @@ -20,6 +20,7 @@ *.vcxproj.filters text eol=crlf *.vcxproj.users text eol=crlf *.rc text eol=crlf +resource.h text eol=crlf # Denote all files that are truly binary and should not be modified. *.png binary diff --git a/Build/tools/chocolateyinstall.ps1 b/Dist/tools/chocolateyinstall.ps1 similarity index 100% rename from Build/tools/chocolateyinstall.ps1 rename to Dist/tools/chocolateyinstall.ps1 diff --git a/ScreensaverNotify/ScreensaverNotify.cpp b/ScreensaverNotify/ScreensaverNotify.cpp index 9a1c91c..fd8c3ea 100644 --- a/ScreensaverNotify/ScreensaverNotify.cpp +++ b/ScreensaverNotify/ScreensaverNotify.cpp @@ -1,6 +1,6 @@ /* ScreensaverNotify DLL - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -56,7 +56,7 @@ static HINSTANCE hglobInstance_ = nullptr; static LRESULT CALLBACK MsgHookProc(UINT code, WPARAM wParam, LPARAM lParam) { - MSG const * const msg = reinterpret_cast(lParam); + MSG const* const msg = reinterpret_cast(lParam); if (msg->message == WM_SYSCOMMAND) { if (msg->wParam == SC_SCREENSAVE) { PostMessage(hNotifyWnd_, notifyWndMsgId_, wParam, lParam); @@ -85,7 +85,7 @@ extern "C" { 0); if (hook_ == nullptr) { MessageBoxW(NULL, _T("Failed to install hook"), _T("WinMute"), - MB_ICONERROR); + MB_ICONERROR); } return hook_ != nullptr; } diff --git a/ScreensaverNotify/ScreensaverNotify.h b/ScreensaverNotify/ScreensaverNotify.h index 474477e..de2c1fa 100644 --- a/ScreensaverNotify/ScreensaverNotify.h +++ b/ScreensaverNotify/ScreensaverNotify.h @@ -1,6 +1,6 @@ /* ScreensaverNotify DLL - Copyright (c) 2017, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -33,12 +33,13 @@ POSSIBILITY OF SUCH DAMAGE. #pragma once +#define WIN32_LEAND_AND_MEAN #include #ifdef WINMUTEDLL_EXPORTS - #define WINMUTEDLL_API __declspec(dllexport) +# define WINMUTEDLL_API __declspec(dllexport) #else - #define WINMUTEDLL_API __declspec(dllimport) +# define WINMUTEDLL_API __declspec(dllimport) #endif extern "C" { diff --git a/ScreensaverNotify/ScreensaverNotify.vcxproj b/ScreensaverNotify/ScreensaverNotify.vcxproj index e264a8e..a9de328 100644 --- a/ScreensaverNotify/ScreensaverNotify.vcxproj +++ b/ScreensaverNotify/ScreensaverNotify.vcxproj @@ -1,28 +1,28 @@ - - + + Debug Win32 - - Debug - x64 - Release Win32 + + Debug + x64 + Release x64 - {A48C241D-70F5-4919-BE06-8C5BE99CCC23} + 16.0 Win32Proj + {238ed265-3248-4042-be8a-2ede6c481cbc} ScreensaverNotify - ScreensaverNotify 10.0 @@ -33,18 +33,18 @@ Unicode Spectre - + DynamicLibrary - true + false v143 + true Unicode Spectre - + DynamicLibrary - false + true v143 - true Unicode Spectre @@ -59,152 +59,132 @@ + + - + - + - + true - $(SolutionDir)Bin\$(PlatformShortName)\ - $(ProjectName) - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - NativeRecommendedRules.ruleset - true - false - false - - - $(ProjectName) - true - $(SolutionDir)Bin\$(PlatformShortName)\ - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - NativeRecommendedRules.ruleset - true - false - false + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ false - $(SolutionDir)Bin\$(PlatformShortName)\ - $(ProjectName) - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - NativeRecommendedRules.ruleset - true - false - false + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ + + + true + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - $(ProjectName) false - $(SolutionDir)Bin\$(PlatformShortName)\ - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - NativeRecommendedRules.ruleset - true - false - false + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - NotUsing Level4 - Disabled - WINMUTEDLL_EXPORTS;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - false + WINMUTEDLL_EXPORTS;WIN32;_DEBUG;SCREENSAVERNOTIFY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + NotUsing + + + stdcpp20 true - true Caret - stdcpp17 Windows true + false - + - NotUsing Level4 - Disabled - WINMUTEDLL_EXPORTS;WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + true true - false + WINMUTEDLL_EXPORTS;WIN32;NDEBUG;SCREENSAVERNOTIFY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + NotUsing + + + stdcpp20 true - true + true Caret - stdcpp17 Windows + true + true true + false - + Level4 - NotUsing - MaxSpeed - true - true - WINMUTEDLL_EXPORTS;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - true - MultiThreadedDLL + WINMUTEDLL_EXPORTS;_DEBUG;SCREENSAVERNOTIFY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + NotUsing + + + stdcpp20 true - true Caret - stdcpp17 Windows true - true - true + false - - copy "$(TargetPath)" "$(SolutionDir)dist\bin\$(PlatformShortName)\$(TargetFileName)" - Level4 - NotUsing - MaxSpeed true true - WINMUTEDLL_EXPORTS;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true - true - MultiThreadedDLL + WINMUTEDLL_EXPORTS;NDEBUG;SCREENSAVERNOTIFY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + NotUsing + + + stdcpp20 true - true + true Caret - stdcpp20 Windows - true true true + true + false - - copy "$(TargetPath)" "$(SolutionDir)dist\bin\$(PlatformShortName)\$(TargetFileName)" - - + - + diff --git a/ScreensaverNotify/ScreensaverNotify.vcxproj.filters b/ScreensaverNotify/ScreensaverNotify.vcxproj.filters index 96422cc..6ed9222 100644 --- a/ScreensaverNotify/ScreensaverNotify.vcxproj.filters +++ b/ScreensaverNotify/ScreensaverNotify.vcxproj.filters @@ -3,7 +3,7 @@ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx diff --git a/ScreensaverNotify/ScreensaverNotify.vcxproj.user b/ScreensaverNotify/ScreensaverNotify.vcxproj.user index a375ae3..88a5509 100644 --- a/ScreensaverNotify/ScreensaverNotify.vcxproj.user +++ b/ScreensaverNotify/ScreensaverNotify.vcxproj.user @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/ScreensaverNotify32/ScreensaverNotify32.vcxproj b/ScreensaverNotify32/ScreensaverNotify32.vcxproj index 170e804..6e9ef6e 100644 --- a/ScreensaverNotify32/ScreensaverNotify32.vcxproj +++ b/ScreensaverNotify32/ScreensaverNotify32.vcxproj @@ -21,7 +21,7 @@ 16.0 Win32Proj - {2e31ff98-3cc4-4b3a-8bb1-2efde1331c9a} + {ab1f1ada-1d35-4052-867c-430d69d1ad4c} ScreensaverNotify32 10.0 @@ -76,23 +76,23 @@ true - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - $(SolutionDir)Bin\x64\ + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ false - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - $(SolutionDir)Bin\x64\ + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ true - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - $(SolutionDir)Bin\x64\ + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ false - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - $(SolutionDir)Bin\x64\ + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ @@ -100,8 +100,9 @@ true WINMUTEDLL_EXPORTS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpp20 + true Caret - stdcpp17 Console @@ -116,8 +117,10 @@ true WINMUTEDLL_EXPORTS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpp20 + true Caret - stdcpp17 + true Console @@ -125,9 +128,6 @@ true true - - copy "$(TargetPath)" "$(SolutionDir)dist\bin\$(PlatformShortName)\$(TargetFileName)" - @@ -135,8 +135,9 @@ true WINMUTEDLL_EXPORTS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true + stdcpp20 + true Caret - stdcpp17 Console @@ -151,8 +152,10 @@ true WINMUTEDLL_EXPORTS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - Caret stdcpp20 + true + Caret + true Console @@ -160,9 +163,6 @@ true true - - copy "$(TargetPath)" "$(SolutionDir)dist\bin\$(PlatformShortName)\$(TargetFileName)" - diff --git a/ScreensaverProxy32/ScreensaverNotifierProxy.cpp b/ScreensaverProxy32/ScreensaverNotifierProxy.cpp index 917aa5a..1b78155 100644 --- a/ScreensaverProxy32/ScreensaverNotifierProxy.cpp +++ b/ScreensaverProxy32/ScreensaverNotifierProxy.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -42,7 +42,8 @@ ScreensaverNotifierProxy::ScreensaverNotifierProxy() : notifyWndMsg_(0), regHook_(nullptr), unregHook_(nullptr) -{ } +{ +} ScreensaverNotifierProxy::~ScreensaverNotifierProxy() { diff --git a/ScreensaverProxy32/ScreensaverNotifierProxy.h b/ScreensaverProxy32/ScreensaverNotifierProxy.h index e862c3f..e4b21a5 100644 --- a/ScreensaverProxy32/ScreensaverNotifierProxy.h +++ b/ScreensaverProxy32/ScreensaverNotifierProxy.h @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without diff --git a/ScreensaverProxy32/ScreensaverProxy.cpp b/ScreensaverProxy32/ScreensaverProxy.cpp index 621bd4f..5af470f 100644 --- a/ScreensaverProxy32/ScreensaverProxy.cpp +++ b/ScreensaverProxy32/ScreensaverProxy.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -75,7 +75,7 @@ void PrintWindowsError(const char* lpszFunction, DWORD lastError) lastError, reinterpret_cast(lpMsgBuf)); MessageBox(nullptr, static_cast(lpDisplayBuf), - "WinMute - ScreensaverProxy", MB_OK | MB_ICONERROR); + "WinMute - ScreensaverProxy", MB_OK | MB_ICONERROR); LocalFree(lpDisplayBuf); } LocalFree(lpMsgBuf); diff --git a/ScreensaverProxy32/ScreensaverProxy32.vcxproj b/ScreensaverProxy32/ScreensaverProxy32.vcxproj index 446ea7f..c3bdb63 100644 --- a/ScreensaverProxy32/ScreensaverProxy32.vcxproj +++ b/ScreensaverProxy32/ScreensaverProxy32.vcxproj @@ -21,7 +21,7 @@ 16.0 Win32Proj - {b3023843-584d-4dbb-9041-19e1f8b6f13e} + {7214696d-b598-435d-8622-ad4ae3755d28} ScreensaverProxy32 10.0 @@ -76,23 +76,23 @@ true - $(SolutionDir)Bin\x64\ - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ false - $(SolutionDir)Bin\x64\ - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ true - $(SolutionDir)Bin\x64\ - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ false - $(SolutionDir)Bin\x64\ - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ @@ -100,7 +100,9 @@ true WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpp20 + true + Caret Windows @@ -115,7 +117,9 @@ true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpp20 + true + Caret Windows @@ -130,7 +134,9 @@ true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - stdcpp17 + stdcpp20 + true + Caret Windows @@ -146,6 +152,8 @@ NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp20 + true + Caret Windows diff --git a/ScreensaverProxy32/ScreensaverProxy32.vcxproj.filters b/ScreensaverProxy32/ScreensaverProxy32.vcxproj.filters index 3b59de4..26cf414 100644 --- a/ScreensaverProxy32/ScreensaverProxy32.vcxproj.filters +++ b/ScreensaverProxy32/ScreensaverProxy32.vcxproj.filters @@ -7,10 +7,10 @@ - + Source Files - + Source Files diff --git a/ScreensaverProxy32/ScreensaverProxy32.vcxproj.user b/ScreensaverProxy32/ScreensaverProxy32.vcxproj.user index 8376c54..88a5509 100644 --- a/ScreensaverProxy32/ScreensaverProxy32.vcxproj.user +++ b/ScreensaverProxy32/ScreensaverProxy32.vcxproj.user @@ -1,19 +1,4 @@  - - /msgId:1234 - WindowsLocalDebugger - - - /msgId:1234 - WindowsLocalDebugger - - - /msgId:1234 - WindowsLocalDebugger - - - /msgId:1234 - WindowsLocalDebugger - + \ No newline at end of file diff --git a/WinMute.sln b/WinMute.sln index 4bcb7d5..4bb0043 100644 --- a/WinMute.sln +++ b/WinMute.sln @@ -1,64 +1,61 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30011.22 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32210.238 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinMute", "WinMute\WinMute.vcxproj", "{488617F0-5DD3-42B5-81ED-A1E9B3117551}" - ProjectSection(ProjectDependencies) = postProject - {A48C241D-70F5-4919-BE06-8C5BE99CCC23} = {A48C241D-70F5-4919-BE06-8C5BE99CCC23} - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinMute", "WinMute\WinMute.vcxproj", "{479D2958-3FFC-43F8-8217-44D0FF9C11B1}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScreensaverNotify", "ScreensaverNotify\ScreensaverNotify.vcxproj", "{A48C241D-70F5-4919-BE06-8C5BE99CCC23}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScreensaverNotify", "ScreensaverNotify\ScreensaverNotify.vcxproj", "{238ED265-3248-4042-BE8A-2EDE6C481CBC}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScreensaverNotify32", "ScreensaverNotify32\ScreensaverNotify32.vcxproj", "{2E31FF98-3CC4-4B3A-8BB1-2EFDE1331C9A}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScreensaverNotify32", "ScreensaverNotify32\ScreensaverNotify32.vcxproj", "{AB1F1ADA-1D35-4052-867C-430D69D1AD4C}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScreensaverProxy32", "ScreensaverProxy32\ScreensaverProxy32.vcxproj", "{B3023843-584D-4DBB-9041-19E1F8B6F13E}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScreensaverProxy32", "ScreensaverProxy32\ScreensaverProxy32.vcxproj", "{7214696D-B598-435D-8622-AD4AE3755D28}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 + Debug|x86 = Debug|x86 Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {488617F0-5DD3-42B5-81ED-A1E9B3117551}.Debug|Win32.ActiveCfg = Debug|Win32 - {488617F0-5DD3-42B5-81ED-A1E9B3117551}.Debug|Win32.Build.0 = Debug|Win32 - {488617F0-5DD3-42B5-81ED-A1E9B3117551}.Debug|x64.ActiveCfg = Debug|x64 - {488617F0-5DD3-42B5-81ED-A1E9B3117551}.Debug|x64.Build.0 = Debug|x64 - {488617F0-5DD3-42B5-81ED-A1E9B3117551}.Release|Win32.ActiveCfg = Release|Win32 - {488617F0-5DD3-42B5-81ED-A1E9B3117551}.Release|Win32.Build.0 = Release|Win32 - {488617F0-5DD3-42B5-81ED-A1E9B3117551}.Release|x64.ActiveCfg = Release|x64 - {488617F0-5DD3-42B5-81ED-A1E9B3117551}.Release|x64.Build.0 = Release|x64 - {A48C241D-70F5-4919-BE06-8C5BE99CCC23}.Debug|Win32.ActiveCfg = Debug|Win32 - {A48C241D-70F5-4919-BE06-8C5BE99CCC23}.Debug|Win32.Build.0 = Debug|Win32 - {A48C241D-70F5-4919-BE06-8C5BE99CCC23}.Debug|x64.ActiveCfg = Debug|x64 - {A48C241D-70F5-4919-BE06-8C5BE99CCC23}.Debug|x64.Build.0 = Debug|x64 - {A48C241D-70F5-4919-BE06-8C5BE99CCC23}.Release|Win32.ActiveCfg = Release|Win32 - {A48C241D-70F5-4919-BE06-8C5BE99CCC23}.Release|Win32.Build.0 = Release|Win32 - {A48C241D-70F5-4919-BE06-8C5BE99CCC23}.Release|x64.ActiveCfg = Release|x64 - {A48C241D-70F5-4919-BE06-8C5BE99CCC23}.Release|x64.Build.0 = Release|x64 - {2E31FF98-3CC4-4B3A-8BB1-2EFDE1331C9A}.Debug|Win32.ActiveCfg = Debug|Win32 - {2E31FF98-3CC4-4B3A-8BB1-2EFDE1331C9A}.Debug|Win32.Build.0 = Debug|Win32 - {2E31FF98-3CC4-4B3A-8BB1-2EFDE1331C9A}.Debug|x64.ActiveCfg = Debug|Win32 - {2E31FF98-3CC4-4B3A-8BB1-2EFDE1331C9A}.Debug|x64.Build.0 = Debug|Win32 - {2E31FF98-3CC4-4B3A-8BB1-2EFDE1331C9A}.Release|Win32.ActiveCfg = Release|Win32 - {2E31FF98-3CC4-4B3A-8BB1-2EFDE1331C9A}.Release|Win32.Build.0 = Release|Win32 - {2E31FF98-3CC4-4B3A-8BB1-2EFDE1331C9A}.Release|x64.ActiveCfg = Release|Win32 - {2E31FF98-3CC4-4B3A-8BB1-2EFDE1331C9A}.Release|x64.Build.0 = Release|Win32 - {B3023843-584D-4DBB-9041-19E1F8B6F13E}.Debug|Win32.ActiveCfg = Debug|Win32 - {B3023843-584D-4DBB-9041-19E1F8B6F13E}.Debug|Win32.Build.0 = Debug|Win32 - {B3023843-584D-4DBB-9041-19E1F8B6F13E}.Debug|x64.ActiveCfg = Debug|Win32 - {B3023843-584D-4DBB-9041-19E1F8B6F13E}.Debug|x64.Build.0 = Debug|Win32 - {B3023843-584D-4DBB-9041-19E1F8B6F13E}.Release|Win32.ActiveCfg = Release|Win32 - {B3023843-584D-4DBB-9041-19E1F8B6F13E}.Release|Win32.Build.0 = Release|Win32 - {B3023843-584D-4DBB-9041-19E1F8B6F13E}.Release|x64.ActiveCfg = Release|Win32 - {B3023843-584D-4DBB-9041-19E1F8B6F13E}.Release|x64.Build.0 = Release|Win32 + {479D2958-3FFC-43F8-8217-44D0FF9C11B1}.Debug|x64.ActiveCfg = Debug|x64 + {479D2958-3FFC-43F8-8217-44D0FF9C11B1}.Debug|x64.Build.0 = Debug|x64 + {479D2958-3FFC-43F8-8217-44D0FF9C11B1}.Debug|x86.ActiveCfg = Debug|Win32 + {479D2958-3FFC-43F8-8217-44D0FF9C11B1}.Debug|x86.Build.0 = Debug|Win32 + {479D2958-3FFC-43F8-8217-44D0FF9C11B1}.Release|x64.ActiveCfg = Release|x64 + {479D2958-3FFC-43F8-8217-44D0FF9C11B1}.Release|x64.Build.0 = Release|x64 + {479D2958-3FFC-43F8-8217-44D0FF9C11B1}.Release|x86.ActiveCfg = Release|Win32 + {479D2958-3FFC-43F8-8217-44D0FF9C11B1}.Release|x86.Build.0 = Release|Win32 + {238ED265-3248-4042-BE8A-2EDE6C481CBC}.Debug|x64.ActiveCfg = Debug|x64 + {238ED265-3248-4042-BE8A-2EDE6C481CBC}.Debug|x64.Build.0 = Debug|x64 + {238ED265-3248-4042-BE8A-2EDE6C481CBC}.Debug|x86.ActiveCfg = Debug|Win32 + {238ED265-3248-4042-BE8A-2EDE6C481CBC}.Debug|x86.Build.0 = Debug|Win32 + {238ED265-3248-4042-BE8A-2EDE6C481CBC}.Release|x64.ActiveCfg = Release|x64 + {238ED265-3248-4042-BE8A-2EDE6C481CBC}.Release|x64.Build.0 = Release|x64 + {238ED265-3248-4042-BE8A-2EDE6C481CBC}.Release|x86.ActiveCfg = Release|Win32 + {238ED265-3248-4042-BE8A-2EDE6C481CBC}.Release|x86.Build.0 = Release|Win32 + {AB1F1ADA-1D35-4052-867C-430D69D1AD4C}.Debug|x64.ActiveCfg = Debug|Win32 + {AB1F1ADA-1D35-4052-867C-430D69D1AD4C}.Debug|x64.Build.0 = Debug|Win32 + {AB1F1ADA-1D35-4052-867C-430D69D1AD4C}.Debug|x86.ActiveCfg = Debug|Win32 + {AB1F1ADA-1D35-4052-867C-430D69D1AD4C}.Debug|x86.Build.0 = Debug|Win32 + {AB1F1ADA-1D35-4052-867C-430D69D1AD4C}.Release|x64.ActiveCfg = Release|x64 + {AB1F1ADA-1D35-4052-867C-430D69D1AD4C}.Release|x64.Build.0 = Release|x64 + {AB1F1ADA-1D35-4052-867C-430D69D1AD4C}.Release|x86.ActiveCfg = Release|Win32 + {AB1F1ADA-1D35-4052-867C-430D69D1AD4C}.Release|x86.Build.0 = Release|Win32 + {7214696D-B598-435D-8622-AD4AE3755D28}.Debug|x64.ActiveCfg = Debug|Win32 + {7214696D-B598-435D-8622-AD4AE3755D28}.Debug|x64.Build.0 = Debug|Win32 + {7214696D-B598-435D-8622-AD4AE3755D28}.Debug|x86.ActiveCfg = Debug|Win32 + {7214696D-B598-435D-8622-AD4AE3755D28}.Debug|x86.Build.0 = Debug|Win32 + {7214696D-B598-435D-8622-AD4AE3755D28}.Release|x64.ActiveCfg = Release|x64 + {7214696D-B598-435D-8622-AD4AE3755D28}.Release|x64.Build.0 = Release|x64 + {7214696D-B598-435D-8622-AD4AE3755D28}.Release|x86.ActiveCfg = Release|Win32 + {7214696D-B598-435D-8622-AD4AE3755D28}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {AE62E32B-8E8B-4236-9173-9671A647A778} + SolutionGuid = {302C5470-9998-4A12-A027-07D24C9FC8FA} EndGlobalSection EndGlobal diff --git a/WinMute/AboutDlg.cpp b/WinMute/AboutDlg.cpp index 2d5c53d..01ccd83 100644 --- a/WinMute/AboutDlg.cpp +++ b/WinMute/AboutDlg.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -43,20 +43,22 @@ INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) EndDialog(hDlg, 0); } return 0; - case WM_NOTIFY: { + case WM_NOTIFY: + { PNMLINK pNmLink = (PNMLINK)lParam; switch (pNmLink->hdr.code) { - case NM_CLICK: - case NM_RETURN: { - UINT_PTR ctrlId = pNmLink->hdr.idFrom; - LITEM item = pNmLink->item; - if ((ctrlId == IDC_LINK_HOMEPAGE || ctrlId == IDC_LINK_SUPPORT) - && item.iLink == 0) { - ShellExecute(nullptr, _T("open"), item.szUrl, nullptr, nullptr, - SW_SHOW); - } - break; + case NM_CLICK: + case NM_RETURN: + { + UINT_PTR ctrlId = pNmLink->hdr.idFrom; + LITEM item = pNmLink->item; + if ((ctrlId == IDC_LINK_HOMEPAGE || ctrlId == IDC_LINK_SUPPORT) + && item.iLink == 0) { + ShellExecute(nullptr, _T("open"), item.szUrl, nullptr, nullptr, + SW_SHOW); } + break; + } } return TRUE; } diff --git a/WinMute/Log.cpp b/WinMute/Log.cpp index 5dc5e18..ae44416 100644 --- a/WinMute/Log.cpp +++ b/WinMute/Log.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,15 +31,13 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#pragma once +#include "common.h" -#include "StdAfx.h" - -static bool OpenLogFile(std::ofstream &logFile) +static bool OpenLogFile(std::ofstream& logFile) { auto path = std::filesystem::temp_directory_path(); path /= "WinMute.log"; - logFile.open(path.string(), std::ios::out|std::ios::app|std::ios::binary); + logFile.open(path.string(), std::ios::out | std::ios::app | std::ios::binary); return logFile.is_open(); } @@ -49,7 +47,7 @@ Log& Log::GetInstance() return log; } -Log::Log(): +Log::Log() : initialized_(false) { if (OpenLogFile(logFile_)) { diff --git a/WinMute/Log.h b/WinMute/Log.h index 1fbc55b..406d737 100644 --- a/WinMute/Log.h +++ b/WinMute/Log.h @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #pragma once -#include "StdAfx.h" +#include "common.h" class Log { public: diff --git a/WinMute/MMNotificationClient.cpp b/WinMute/MMNotificationClient.cpp index bb59ac5..9de582a 100644 --- a/WinMute/MMNotificationClient.cpp +++ b/WinMute/MMNotificationClient.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" #include "WinAudio.h" #include "MMNotificationClient.h" @@ -62,7 +62,7 @@ ULONG STDMETHODCALLTYPE MMNotificationClient::Release() } HRESULT STDMETHODCALLTYPE MMNotificationClient::QueryInterface( - REFIID riid, VOID **ppvInterface) + REFIID riid, VOID** ppvInterface) { if (IID_IUnknown == riid) { AddRef(); diff --git a/WinMute/MMNotificationClient.h b/WinMute/MMNotificationClient.h index c502627..004f108 100644 --- a/WinMute/MMNotificationClient.h +++ b/WinMute/MMNotificationClient.h @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "Common.h" #include class WinAudio; @@ -43,19 +43,20 @@ public: ULONG STDMETHODCALLTYPE AddRef(); ULONG STDMETHODCALLTYPE Release(); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, VOID **ppvInterface); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, VOID** ppvInterface); HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(EDataFlow flow, ERole role, - LPCWSTR pwstrDeviceId); + LPCWSTR pwstrDeviceId); HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId); HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId); HRESULT STDMETHODCALLTYPE OnDeviceStateChanged(LPCWSTR pwstrDeviceId, - DWORD dwNewState); + DWORD dwNewState); HRESULT STDMETHODCALLTYPE OnPropertyValueChanged(LPCWSTR pwstrDeviceId, - const PROPERTYKEY key); + const PROPERTYKEY key); private: LONG ref_; - IMMDeviceEnumerator *pEnumerator_; + IMMDeviceEnumerator* pEnumerator_; WinAudio* notifyParent_; }; +#pragma once diff --git a/WinMute/QuietHoursDlg.cpp b/WinMute/QuietHoursDlg.cpp index 32284f2..7e0149f 100644 --- a/WinMute/QuietHoursDlg.cpp +++ b/WinMute/QuietHoursDlg.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" static bool IsValidTimeRange( const LPSYSTEMTIME start, @@ -39,15 +39,15 @@ static bool IsValidTimeRange( { bool isValid = true; if (start->wHour == end->wHour && - start->wMinute == end->wMinute && - start->wSecond == end->wSecond) { + start->wMinute == end->wMinute && + start->wSecond == end->wSecond) { isValid = false; } return isValid; } static bool SaveQuietHours( - Settings *settings, + Settings* settings, const int enabled, const int forceUnmute, const int showNotifications, @@ -71,13 +71,13 @@ static bool SaveQuietHours( } int setStart = start->wHour * 3600 + start->wMinute * 60 + start->wSecond; - int setEnd = end->wHour * 3600 + end->wMinute * 60 + end->wSecond; + int setEnd = end->wHour * 3600 + end->wMinute * 60 + end->wSecond; if (!settings->SetValue(SettingsKey::QUIETHOURS_ENABLE, enabled) || - !settings->SetValue(SettingsKey::QUIETHOURS_FORCEUNMUTE, forceUnmute) || - !settings->SetValue(SettingsKey::QUIETHOURS_NOTIFICATIONS, showNotifications) || - !settings->SetValue(SettingsKey::QUIETHOURS_START, setStart) || - !settings->SetValue(SettingsKey::QUIETHOURS_END, setEnd)) { + !settings->SetValue(SettingsKey::QUIETHOURS_FORCEUNMUTE, forceUnmute) || + !settings->SetValue(SettingsKey::QUIETHOURS_NOTIFICATIONS, showNotifications) || + !settings->SetValue(SettingsKey::QUIETHOURS_START, setStart) || + !settings->SetValue(SettingsKey::QUIETHOURS_END, setEnd)) { TaskDialog( nullptr, nullptr, @@ -97,13 +97,14 @@ INT_PTR CALLBACK QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP { UNREFERENCED_PARAMETER(lParam); switch (msg) { - case WM_INITDIALOG: { + case WM_INITDIALOG: + { HWND hEnable = GetDlgItem(hDlg, IDC_ENABLEQUIETHOURS); HWND hForce = GetDlgItem(hDlg, IDC_FORCEUNMUTE); HWND hNotify = GetDlgItem(hDlg, IDC_SHOWNOTIFICATIONS); HWND hStart = GetDlgItem(hDlg, IDC_QUIETHOURS_START); HWND hEnd = GetDlgItem(hDlg, IDC_QUIETHOURS_END); - Settings *settings = reinterpret_cast(lParam); + Settings* settings = reinterpret_cast(lParam); assert(settings != NULL); SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast(settings)); @@ -144,7 +145,8 @@ INT_PTR CALLBACK QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP return TRUE; } - case WM_COMMAND: { + case WM_COMMAND: + { HWND hEnable = GetDlgItem(hDlg, IDC_ENABLEQUIETHOURS); HWND hForce = GetDlgItem(hDlg, IDC_FORCEUNMUTE); HWND hNotify = GetDlgItem(hDlg, IDC_SHOWNOTIFICATIONS); @@ -153,7 +155,7 @@ INT_PTR CALLBACK QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP if (LOWORD(wParam) == IDOK) { SYSTEMTIME start; SYSTEMTIME end; - Settings *settings = reinterpret_cast(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + Settings* settings = reinterpret_cast(GetWindowLongPtr(hDlg, GWLP_USERDATA)); int qhEnabled = Button_GetCheck(hEnable) == BST_CHECKED; int qhForceUnmute = Button_GetCheck(hForce) == BST_CHECKED; int qhNotifications = Button_GetCheck(hNotify) == BST_CHECKED; diff --git a/WinMute/ScreensaverNotifier.cpp b/WinMute/ScreensaverNotifier.cpp index c41e59b..090e9ae 100644 --- a/WinMute/ScreensaverNotifier.cpp +++ b/WinMute/ScreensaverNotifier.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" #include "ScreensaverNotifier.h" /* ========================================================================== */ @@ -50,22 +50,23 @@ static LPCTSTR SCRSVER_NOTIFY_WND_CLASS = _T("LXS_WinMuteScreensaverNotifyClass" static LRESULT CALLBACK ScrsvrWndProc(HWND hWnd, UINT msg, WPARAM wParam, - LPARAM lParam) + LPARAM lParam) { auto sn = reinterpret_cast( - GetWindowLongPtr(hWnd, GWLP_USERDATA)); + GetWindowLongPtr(hWnd, GWLP_USERDATA)); switch (msg) { - case WM_NCCREATE: { + case WM_NCCREATE: + { LPCREATESTRUCTW cs = reinterpret_cast(lParam); SetWindowLongPtr(hWnd, GWLP_USERDATA, - reinterpret_cast(cs->lpCreateParams)); + reinterpret_cast(cs->lpCreateParams)); return TRUE; } default: break; } return (sn) ? sn->WindowProc(hWnd, msg, wParam, lParam) - : DefWindowProc(hWnd, msg, wParam, lParam); + : DefWindowProc(hWnd, msg, wParam, lParam); } /* ========================================================================== */ @@ -82,7 +83,8 @@ ScreensaverNotifier::ScreensaverNotifier() : hookWndMsg_(0), regHook_(nullptr), unregHook_(nullptr) -{ } +{ +} ScreensaverNotifier::~ScreensaverNotifier() { @@ -159,23 +161,23 @@ bool ScreensaverNotifier::InitHook32() if (hJob_ == nullptr) { PrintWindowsError(_T("CreateJobObject"), GetLastError()); } else if (SetInformationJobObject( - hJob_, - JobObjectExtendedLimitInformation, - &jobInfo, - sizeof(jobInfo)) == FALSE) { + hJob_, + JobObjectExtendedLimitInformation, + &jobInfo, + sizeof(jobInfo)) == FALSE) { PrintWindowsError(_T("SetInformationJobObject"), GetLastError()); CloseHandle(hJob_); } else if (CreateProcess( - _T(".\\ScreensaverProxy32.exe"), - commandLine, - NULL, - NULL, - FALSE, - NORMAL_PRIORITY_CLASS, - NULL, - NULL, - &startupInfo, - &procInfo) == FALSE) { + _T(".\\ScreensaverProxy32.exe"), + commandLine, + NULL, + NULL, + FALSE, + NORMAL_PRIORITY_CLASS, + NULL, + NULL, + &startupInfo, + &procInfo) == FALSE) { PrintWindowsError(_T("CreateProcess")); CloseHandle(hJob_); hJob_ = nullptr; @@ -288,10 +290,10 @@ bool ScreensaverNotifier::IsScreensaverRunning() { BOOL isRunning = FALSE; if (SystemParametersInfo( - SPI_GETSCREENSAVERRUNNING, - 0, - &isRunning, - FALSE) == FALSE) { + SPI_GETSCREENSAVERRUNNING, + 0, + &isRunning, + FALSE) == FALSE) { PrintWindowsError(_T("SystemParametersInfo")); return false; } @@ -310,10 +312,12 @@ LRESULT CALLBACK ScreensaverNotifier::WindowProc( { static UINT uTaskbarRestart = 0; switch (msg) { - case WM_CREATE: { + case WM_CREATE: + { return TRUE; } - case WM_TIMER: { + case WM_TIMER: + { if (wParam == SCRSV_TIMER_ID) { if (!IsScreensaverRunning()) { StartScreensaverPollTimer(false); diff --git a/WinMute/ScreensaverNotifier.h b/WinMute/ScreensaverNotifier.h index 7c9a359..ca8ec0e 100644 --- a/WinMute/ScreensaverNotifier.h +++ b/WinMute/ScreensaverNotifier.h @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #pragma once -#include "StdAfx.h" +#include "common.h" #define WM_SCRNSAVE_CHANGE (WM_APP + 100) diff --git a/WinMute/Settings.cpp b/WinMute/Settings.cpp index 314cc8d..19544b0 100644 --- a/WinMute/Settings.cpp +++ b/WinMute/Settings.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" #include "Settings.h" static const LPCWSTR LX_SYSTEMS_SUBKEY = _T("SOFTWARE\\lx-systems\\WinMute"); @@ -81,7 +81,8 @@ static LPCWSTR KeyToStr(SettingsKey key) Settings::Settings() : hRegSettingsKey_(nullptr) -{ } +{ +} Settings::~Settings() { diff --git a/WinMute/Settings.h b/WinMute/Settings.h index c27ee37..360c80d 100644 --- a/WinMute/Settings.h +++ b/WinMute/Settings.h @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -33,10 +33,10 @@ POSSIBILITY OF SUCH DAMAGE. #pragma once -#include "StdAfx.h" +#include "common.h" enum class SettingsKey { - MUTE_ON_LOCK + MUTE_ON_LOCK , MUTE_ON_SCREENSAVER , RESTORE_AUDIO , MUTE_ON_SUSPEND diff --git a/WinMute/TrayIcon.cpp b/WinMute/TrayIcon.cpp index 6f5b612..dfbaa78 100644 --- a/WinMute/TrayIcon.cpp +++ b/WinMute/TrayIcon.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,23 +31,22 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" TrayIcon::TrayIcon() : iconVisible_(false), trayID_(0), hIcon_(0), hWnd_(0) { - } TrayIcon::TrayIcon(HWND hWnd, UINT trayID, HICON hIcon, - const std::wstring& tooltip, bool show) : + const std::wstring& tooltip, bool show) : iconVisible_(false) { Init(hWnd, trayID, hIcon, tooltip, show); } void TrayIcon::Init(HWND hWnd, UINT trayID, HICON hIcon, - const std::wstring& tooltip, bool show) + const std::wstring& tooltip, bool show) { if (!hIcon) { hIcon_ = LoadIcon(0, IDI_APPLICATION); @@ -82,7 +81,7 @@ void TrayIcon::Hide() void TrayIcon::Show() { if (!iconVisible_) { - if(AddNotifyIcon()) { + if (AddNotifyIcon()) { iconVisible_ = true; } } @@ -125,8 +124,8 @@ void TrayIcon::ChangeText(const std::wstring& tooltip) } void TrayIcon::ShowPopup( - const std::wstring &title, - const std::wstring &text) + const std::wstring& title, + const std::wstring& text) { NOTIFYICONDATA tnid; tnid.cbSize = sizeof(NOTIFYICONDATA); @@ -134,10 +133,10 @@ void TrayIcon::ShowPopup( tnid.uID = trayID_; tnid.uFlags = NIF_INFO; tnid.dwInfoFlags = NIIF_INFO | NIIF_NOSOUND | NIIF_LARGE_ICON - | NIIF_RESPECT_QUIET_TIME; + | NIIF_RESPECT_QUIET_TIME; tnid.uTimeout = 10 * 1000; - wcscpy_s(tnid.szInfoTitle, sizeof(tnid.szInfoTitle)/sizeof(TCHAR), title.c_str()); - wcscpy_s(tnid.szInfo, sizeof(tnid.szInfo)/sizeof(TCHAR), text.c_str()); + wcscpy_s(tnid.szInfoTitle, sizeof(tnid.szInfoTitle) / sizeof(TCHAR), title.c_str()); + wcscpy_s(tnid.szInfo, sizeof(tnid.szInfo) / sizeof(TCHAR), text.c_str()); Shell_NotifyIcon(NIM_MODIFY, &tnid); } @@ -157,13 +156,13 @@ bool TrayIcon::AddNotifyIcon() tnid.cbSize = sizeof(NOTIFYICONDATA); tnid.hWnd = hWnd_; tnid.uID = trayID_; - tnid.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE; + tnid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; tnid.hIcon = hIcon_; tnid.uCallbackMessage = WM_TRAYICON; if (SUCCEEDED(StringCchCopy(tnid.szTip, - sizeof(tnid.szTip) / sizeof(TCHAR), - tooltip_.c_str()))) { + sizeof(tnid.szTip) / sizeof(TCHAR), + tooltip_.c_str()))) { return Shell_NotifyIcon(NIM_ADD, &tnid) != 0; } return false; @@ -190,8 +189,8 @@ bool TrayIcon::ChangeText() tnid.uFlags = NIF_TIP; if (SUCCEEDED(StringCchCopy(tnid.szTip, - sizeof(tnid.szTip) / sizeof(TCHAR), - tooltip_.c_str()))) { + sizeof(tnid.szTip) / sizeof(TCHAR), + tooltip_.c_str()))) { return Shell_NotifyIcon(NIM_MODIFY, &tnid) != 0; } return false; diff --git a/WinMute/TrayIcon.h b/WinMute/TrayIcon.h index bdb9a8c..f8db69c 100644 --- a/WinMute/TrayIcon.h +++ b/WinMute/TrayIcon.h @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -32,18 +32,19 @@ POSSIBILITY OF SUCH DAMAGE. */ #pragma once -#include "StdAfx.h" + +#include "common.h" #define WM_TRAYICON (WM_APP + 700) -class TrayIcon{ +class TrayIcon { public: TrayIcon(); TrayIcon(HWND hWnd, UINT trayID, HICON hIcon, const std::wstring& tooltip, - bool show); + bool show); ~TrayIcon(); void Init(HWND hWnd, UINT trayID, HICON hIcon, const std::wstring& tooltip, - bool show); + bool show); void Hide(); void Show(); bool IsShown() const { return iconVisible_; } diff --git a/WinMute/Utility.cpp b/WinMute/Utility.cpp index 18361ea..b8eeaa5 100644 --- a/WinMute/Utility.cpp +++ b/WinMute/Utility.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "Common.h" void PrintWindowsError(LPCWSTR lpszFunction, DWORD lastError) { @@ -42,33 +42,33 @@ void PrintWindowsError(LPCWSTR lpszFunction, DWORD lastError) LPVOID lpMsgBuf; if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - nullptr, lastError, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - reinterpret_cast(&lpMsgBuf), 0, nullptr) != 0) { - size_t displayBufSize = - ((size_t)lstrlen(static_cast(lpMsgBuf)) + - (size_t)lstrlen(static_cast(lpszFunction)) + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + nullptr, lastError, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + reinterpret_cast(&lpMsgBuf), 0, nullptr) != 0) { + size_t displayBufSize = + ((size_t)lstrlen(static_cast(lpMsgBuf)) + + (size_t)lstrlen(static_cast(lpszFunction)) + 40) * sizeof(TCHAR); // Display the error message and exit the process LPVOID lpDisplayBuf = reinterpret_cast( - LocalAlloc(LMEM_ZEROINIT, displayBufSize)); + LocalAlloc(LMEM_ZEROINIT, displayBufSize)); if (lpDisplayBuf) { StringCchPrintf((LPTSTR)lpDisplayBuf, - LocalSize(lpDisplayBuf), - _T("%s failed with error %u: %s"), - lpszFunction, - lastError, - reinterpret_cast(lpMsgBuf)); + LocalSize(lpDisplayBuf), + _T("%s failed with error %u: %s"), + lpszFunction, + lastError, + reinterpret_cast(lpMsgBuf)); TaskDialog(nullptr, - nullptr, - PROGRAM_NAME, - static_cast(lpDisplayBuf), - nullptr, - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - nullptr); + nullptr, + PROGRAM_NAME, + static_cast(lpDisplayBuf), + nullptr, + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + nullptr); LocalFree(lpDisplayBuf); } LocalFree(lpMsgBuf); diff --git a/WinMute/VersionHelper.h b/WinMute/VersionHelper.h index 416c919..dd810e3 100644 --- a/WinMute/VersionHelper.h +++ b/WinMute/VersionHelper.h @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #pragma once -#include "StdAfx.h" +#include "common.h" #ifndef _versionhelpers_H_INCLUDED_ // avoid conflict with MS versionhelpers @@ -44,9 +44,9 @@ inline bool IsWindowsVersionOrGreater(WORD wMajorVersion, OSVERSIONINFOEXW osvi = { sizeof(osvi), 0, 0, 0, 0, { 0 }, 0, 0 }; DWORDLONG const dwlConditionMask = VerSetConditionMask( VerSetConditionMask( - VerSetConditionMask( - 0, VER_MAJORVERSION, VER_GREATER_EQUAL), - VER_MINORVERSION, VER_GREATER_EQUAL), + VerSetConditionMask( + 0, VER_MAJORVERSION, VER_GREATER_EQUAL), + VER_MINORVERSION, VER_GREATER_EQUAL), VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); osvi.dwMajorVersion = wMajorVersion; diff --git a/WinMute/VistaAudio.cpp b/WinMute/VistaAudio.cpp index 7ca1907..c5beb06 100644 --- a/WinMute/VistaAudio.cpp +++ b/WinMute/VistaAudio.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" #include #pragma warning(disable : 4201) @@ -69,56 +69,56 @@ bool VistaAudio::Init(HWND hParent) hParent_ = hParent; reInit_ = false; - if(FAILED(CoCreateInstance(__uuidof(MMDeviceEnumerator), - nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&deviceEnumerator_)))) { - return false; + if (FAILED(CoCreateInstance(__uuidof(MMDeviceEnumerator), + nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&deviceEnumerator_)))) { + return false; } - IMMDevice *defaultDevice = nullptr; + IMMDevice* defaultDevice = nullptr; HRESULT hr = deviceEnumerator_->GetDefaultAudioEndpoint(eRender, eConsole, &defaultDevice); - if(FAILED(hr)) { + if (FAILED(hr)) { if (hr != E_NOTFOUND) { TaskDialog(nullptr, - nullptr, - PROGRAM_NAME, - _T("Failed to get default audio endpoint device"), - _T("WinMute is not able to recover from that condition.\n") - _T("Please try restarting the program"), - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - nullptr); + nullptr, + PROGRAM_NAME, + _T("Failed to get default audio endpoint device"), + _T("WinMute is not able to recover from that condition.\n") + _T("Please try restarting the program"), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + nullptr); } return false; } IAudioSessionManager2* sessionManager2 = nullptr; if (FAILED(defaultDevice->Activate(__uuidof(IAudioSessionManager2), - CLSCTX_INPROC_SERVER, nullptr, - reinterpret_cast(&sessionManager2)))) { + CLSCTX_INPROC_SERVER, nullptr, + reinterpret_cast(&sessionManager2)))) { TaskDialog(nullptr, - nullptr, - PROGRAM_NAME, - _T("Failed to retrieve audio session manager."), - _T("Please try restarting the program"), - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - nullptr); + nullptr, + PROGRAM_NAME, + _T("Failed to retrieve audio session manager."), + _T("Please try restarting the program"), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + nullptr); SafeRelease(&defaultDevice); return false; } if (FAILED(sessionManager2->GetAudioSessionControl(nullptr, 0, - &sessionControl_))) { + &sessionControl_))) { TaskDialog(nullptr, - nullptr, - PROGRAM_NAME, - _T("Failed to retrieve session control."), - _T("Please try restarting the program"), - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - nullptr); + nullptr, + PROGRAM_NAME, + _T("Failed to retrieve session control."), + _T("Please try restarting the program"), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + nullptr); SafeRelease(&sessionManager2); return false; } @@ -134,16 +134,16 @@ bool VistaAudio::Init(HWND hParent) } if (FAILED(defaultDevice->Activate(__uuidof(IAudioEndpointVolume), - CLSCTX_INPROC_SERVER, nullptr, - reinterpret_cast(&endpointVolume_)))) { + CLSCTX_INPROC_SERVER, nullptr, + reinterpret_cast(&endpointVolume_)))) { TaskDialog(nullptr, - nullptr, - PROGRAM_NAME, - _T("Failed to activate default audio device."), - _T("Please try restarting the program"), - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - nullptr); + nullptr, + PROGRAM_NAME, + _T("Failed to activate default audio device."), + _T("Please try restarting the program"), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + nullptr); SafeRelease(&defaultDevice); return false; } diff --git a/WinMute/VistaAudioSessionEvents.cpp b/WinMute/VistaAudioSessionEvents.cpp index 9772e51..ea1ec37 100644 --- a/WinMute/VistaAudioSessionEvents.cpp +++ b/WinMute/VistaAudioSessionEvents.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,11 +31,10 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" #include "WinAudio.h" #include "VistaAudioSessionEvents.h" - VistaAudioSessionEvents::VistaAudioSessionEvents(WinAudio* notifyParent) : ref_(1) { @@ -61,7 +60,7 @@ ULONG STDMETHODCALLTYPE VistaAudioSessionEvents::Release() } HRESULT STDMETHODCALLTYPE VistaAudioSessionEvents::QueryInterface( - REFIID riid, VOID **ppvInterface) + REFIID riid, VOID** ppvInterface) { if (riid == IID_IUnknown) { AddRef(); @@ -120,7 +119,7 @@ HRESULT STDMETHODCALLTYPE VistaAudioSessionEvents::OnSessionDisconnected( AudioSessionDisconnectReason disconnectReason) { - switch (disconnectReason) { + switch (disconnectReason) { case DisconnectReasonDeviceRemoval: case DisconnectReasonFormatChanged: case DisconnectReasonSessionDisconnected: @@ -128,14 +127,14 @@ HRESULT STDMETHODCALLTYPE VistaAudioSessionEvents::OnSessionDisconnected( break; case DisconnectReasonServerShutdown: TaskDialog(nullptr, - nullptr, - PROGRAM_NAME, - _T("The audio service has been shut down. "), - _T("WinMute is not able to recover from that condition.\n") - _T("Please try restarting the program"), - TDCBF_OK_BUTTON, - TD_WARNING_ICON, - nullptr); + nullptr, + PROGRAM_NAME, + _T("The audio service has been shut down. "), + _T("WinMute is not able to recover from that condition.\n") + _T("Please try restarting the program"), + TDCBF_OK_BUTTON, + TD_WARNING_ICON, + nullptr); break; case DisconnectReasonSessionLogoff: break; diff --git a/WinMute/VistaAudioSessionEvents.h b/WinMute/VistaAudioSessionEvents.h index 621316e..bcb3711 100644 --- a/WinMute/VistaAudioSessionEvents.h +++ b/WinMute/VistaAudioSessionEvents.h @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" #include class WinAudio; @@ -45,36 +45,36 @@ public: ULONG STDMETHODCALLTYPE AddRef(); ULONG STDMETHODCALLTYPE Release(); - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, VOID **ppvInterface); + HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, VOID** ppvInterface); // Notification methods for audio session events HRESULT STDMETHODCALLTYPE OnDisplayNameChanged( - LPCWSTR newDisplayName, - LPCGUID eventContext); + LPCWSTR newDisplayName, + LPCGUID eventContext); HRESULT STDMETHODCALLTYPE OnIconPathChanged( - LPCWSTR newIconPath, - LPCGUID eventContext); + LPCWSTR newIconPath, + LPCGUID eventContext); HRESULT STDMETHODCALLTYPE OnSimpleVolumeChanged( - float newVolume, - BOOL newMute, - LPCGUID eventContext); + float newVolume, + BOOL newMute, + LPCGUID eventContext); HRESULT STDMETHODCALLTYPE OnChannelVolumeChanged( - DWORD channelCount, - float newChannelVolumeArray[], - DWORD changedChannel, - LPCGUID eventContext); + DWORD channelCount, + float newChannelVolumeArray[], + DWORD changedChannel, + LPCGUID eventContext); HRESULT STDMETHODCALLTYPE OnGroupingParamChanged( - LPCGUID newGroupingParam, - LPCGUID eventContext); + LPCGUID newGroupingParam, + LPCGUID eventContext); HRESULT STDMETHODCALLTYPE OnStateChanged(AudioSessionState newState); HRESULT STDMETHODCALLTYPE OnSessionDisconnected( - AudioSessionDisconnectReason disconnectReason); + AudioSessionDisconnectReason disconnectReason); private: LONG ref_; diff --git a/WinMute/WinAudio.h b/WinMute/WinAudio.h index 5e83dc0..a965b56 100644 --- a/WinMute/WinAudio.h +++ b/WinMute/WinAudio.h @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #pragma once -#include "StdAfx.h" +#include "common.h" class WinAudio { public: @@ -42,7 +42,7 @@ public: virtual bool IsMuted() = 0; virtual void Mute() = 0; virtual void UnMute() = 0; - virtual ~WinAudio() noexcept { }; + virtual ~WinAudio() noexcept {}; }; // Forwards @@ -68,9 +68,9 @@ private: IAudioEndpointVolume* endpointVolume_; IAudioSessionControl* sessionControl_; - IMMDeviceEnumerator *deviceEnumerator_; + IMMDeviceEnumerator* deviceEnumerator_; VistaAudioSessionEvents* wasapiAudioEvents_; - MMNotificationClient* mmnAudioEvents_; + MMNotificationClient* mmnAudioEvents_; bool reInit_; float oldVolume_; diff --git a/WinMute/WinMain.cpp b/WinMute/WinMain.cpp index 0d04a90..c3024ec 100644 --- a/WinMute/WinMain.cpp +++ b/WinMute/WinMain.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,14 +31,14 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" HINSTANCE hglobInstance; int WINAPI wWinMain(_In_ HINSTANCE hInstance, - _In_opt_ HINSTANCE, - _In_ PWSTR, - _In_ int) + _In_opt_ HINSTANCE, + _In_ PWSTR, + _In_ int) { HANDLE hMutex = CreateMutex(nullptr, TRUE, _T("LxSystemsWinMute")); if (hMutex == nullptr) { @@ -47,14 +47,14 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, if (GetLastError() == ERROR_ALREADY_EXISTS) { ReleaseMutex(hMutex); TaskDialog(nullptr, - nullptr, - PROGRAM_NAME, - _T("WinMute is already running"), - _T("Please look for a white speaker icon in your Windows ") - _T(" taskbar notification area."), - TDCBF_OK_BUTTON, - TD_INFORMATION_ICON, - nullptr); + nullptr, + PROGRAM_NAME, + _T("WinMute is already running"), + _T("Please look for a white speaker icon in your Windows ") + _T(" taskbar notification area."), + TDCBF_OK_BUTTON, + TD_INFORMATION_ICON, + nullptr); return FALSE; } @@ -67,14 +67,14 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, initComCtrl.dwSize = sizeof(INITCOMMONCONTROLSEX); initComCtrl.dwICC = ICC_LINK_CLASS; if (InitCommonControlsEx(&initComCtrl) == FALSE) { - TaskDialog(nullptr, - nullptr, - PROGRAM_NAME, - _T("Failed to register extended window controls."), - _T("Please try to restart the program."), - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - nullptr); + TaskDialog(nullptr, + nullptr, + PROGRAM_NAME, + _T("Failed to register extended window controls."), + _T("Please try to restart the program."), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + nullptr); ReleaseMutex(hMutex); return FALSE; } @@ -83,18 +83,18 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, // if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK) { TaskDialog(nullptr, - nullptr, - PROGRAM_NAME, - _T("Failed to initialize COM library."), - _T("Please try to restart the program."), - TDCBF_OK_BUTTON, - TD_ERROR_ICON, - nullptr); + nullptr, + PROGRAM_NAME, + _T("Failed to initialize COM library."), + _T("Please try to restart the program."), + TDCBF_OK_BUTTON, + TD_ERROR_ICON, + nullptr); ReleaseMutex(hMutex); return FALSE; } - MSG msg = {0}; + MSG msg = { 0 }; WinMute program; if (program.Init()) { while (GetMessage(&msg, nullptr, 0, 0)) { diff --git a/WinMute/WinMute.cpp b/WinMute/WinMute.cpp index 6da378f..85a0fe8 100644 --- a/WinMute/WinMute.cpp +++ b/WinMute/WinMute.cpp @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" #include "WinMute.h" #include "WinAudio.h" @@ -42,21 +42,21 @@ extern INT_PTR CALLBACK QuietHoursDlgProc(HWND, UINT, WPARAM, LPARAM); static LPCTSTR WINMUTE_CLASS_NAME = _T("WinMute"); static LRESULT CALLBACK WinMuteWndProc(HWND hWnd, UINT msg, WPARAM wParam, - LPARAM lParam) + LPARAM lParam) { auto wm = reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); switch (msg) { case WM_NCCREATE: { LPCREATESTRUCTW cs = reinterpret_cast(lParam); SetWindowLongPtr(hWnd, GWLP_USERDATA, - reinterpret_cast(cs->lpCreateParams)); + reinterpret_cast(cs->lpCreateParams)); return TRUE; } default: break; } return (wm) ? wm->WindowProc(hWnd, msg, wParam, lParam) - : DefWindowProc(hWnd, msg, wParam, lParam); + : DefWindowProc(hWnd, msg, wParam, lParam); } static int IsDarkMode(bool& isDarkMode) @@ -130,7 +130,7 @@ WinMute::~WinMute() bool WinMute::RegisterWindowClass() { - WNDCLASS wc={0}; + WNDCLASS wc = { 0 }; wc.hIcon = LoadIcon(hglobInstance, MAKEINTRESOURCE(IDI_APP)); wc.hbrBackground = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); wc.hInstance = hglobInstance; @@ -160,11 +160,11 @@ bool WinMute::InitAudio() if (IsWindowsVistaOrGreater()) { audio_ = std::unique_ptr(new VistaAudio); } else if (IsWindowsXPOrGreater()) { - TaskDialog(nullptr, nullptr, PROGRAM_NAME, - _T("Only Windows Vista and newer is supported"), - _T("For Windows XP support, please download WinMute ") - _T(" version 1.4.2 or older"), - TDCBF_OK_BUTTON, TD_ERROR_ICON, nullptr); + TaskDialog(nullptr, nullptr, PROGRAM_NAME, + _T("Only Windows Vista and newer is supported"), + _T("For Windows XP support, please download WinMute ") + _T(" version 1.4.2 or older"), + TDCBF_OK_BUTTON, TD_ERROR_ICON, nullptr); return false; } @@ -203,13 +203,13 @@ bool WinMute::Init() hAppIcon_ = LoadIcon(hglobInstance, MAKEINTRESOURCE(IDI_APP)); if (!settings_.Init() || - !LoadDefaults()) { + !LoadDefaults()) { return false; } if (!RegisterWindowClass() || - !InitWindow() || - !InitTrayMenu()) { + !InitWindow() || + !InitTrayMenu()) { return false; } @@ -237,7 +237,7 @@ bool WinMute::Init() hTrayIcon_ = LoadIcon( hglobInstance, isDarkMode ? MAKEINTRESOURCE(IDI_TRAY_DARK) - : MAKEINTRESOURCE(IDI_TRAY_BRIGHT)); + : MAKEINTRESOURCE(IDI_TRAY_BRIGHT)); if (hTrayIcon_ == NULL) { PrintWindowsError(_T("LoadIcon")); return false; @@ -329,8 +329,7 @@ LRESULT CALLBACK WinMute::WindowProc( if (!state) { Log::GetInstance().Write("Mute: Off | Manual per Menu"); audio_->UnMute(); - } - else { + } else { Log::GetInstance().Write("Mute: On | Manual per Menu"); audio_->Mute(); } @@ -354,8 +353,7 @@ LRESULT CALLBACK WinMute::WindowProc( muteConfig_.withRestore.onScreensaver); if (muteConfig_.withRestore.onScreensaver) { scrnSaverNoti_.ActivateNotifications(hWnd_); - } - else { + } else { scrnSaverNoti_.ClearNotifications(); } break; @@ -380,7 +378,8 @@ LRESULT CALLBACK WinMute::WindowProc( } return 0; } - case WM_TRAYICON: { + case WM_TRAYICON: + { switch (lParam) { case WM_LBUTTONUP: case WM_RBUTTONUP: { @@ -413,10 +412,9 @@ LRESULT CALLBACK WinMute::WindowProc( } muteCounter_ += 1; } - } - else if (wParam == WTS_SESSION_UNLOCK) { + } else if (wParam == WTS_SESSION_UNLOCK) { if (muteConfig_.restoreAudio && - muteConfig_.withRestore.onLock) { + muteConfig_.withRestore.onLock) { if (--muteCounter_ == 0) { Log::GetInstance().Write("Mute: Off | Workstation Unlock"); audio_->UnMute(); @@ -439,8 +437,7 @@ LRESULT CALLBACK WinMute::WindowProc( Log::GetInstance().Write("Mute: On | Shutdown"); audio_->Mute(); } - } - else if ((lParam & ENDSESSION_LOGOFF)) { + } else if ((lParam & ENDSESSION_LOGOFF)) { if (muteConfig_.noRestore.onLogoff) { Log::GetInstance().Write("Mute: On | Logoff"); audio_->Mute(); @@ -462,7 +459,7 @@ LRESULT CALLBACK WinMute::WindowProc( case WM_WINMUTE_QUIETHOURS_END: muteCounter_ -= 1; if (muteCounter_ > 0 && muteConfig_.quietHours.forceUnmute || - muteCounter_ == 0) { + muteCounter_ == 0) { Log::GetInstance().Write("Mute: Off | Quiet Hours ended"); audio_->UnMute(); if (muteConfig_.quietHours.notifications) { @@ -530,7 +527,7 @@ LRESULT CALLBACK WinMute::WindowProc( } } else if (wParam == SCRNSAVE_STOP) { if (muteConfig_.restoreAudio && - muteConfig_.withRestore.onScreensaver) { + muteConfig_.withRestore.onScreensaver) { if (--muteCounter_ == 0) { Log::GetInstance().Write("Mute: Off | Screensaver start"); audio_->UnMute(); @@ -546,7 +543,7 @@ LRESULT CALLBACK WinMute::WindowProc( hTrayIcon_ = LoadIcon( hglobInstance, isDarkMode ? MAKEINTRESOURCE(IDI_TRAY_DARK) - : MAKEINTRESOURCE(IDI_TRAY_BRIGHT)); + : MAKEINTRESOURCE(IDI_TRAY_BRIGHT)); if (hTrayIcon_ == NULL) { PrintWindowsError(_T("LoadIcon")); } else { @@ -619,8 +616,8 @@ static int GetDiffMillseconds(const LPSYSTEMTIME t1, const LPSYSTEMTIME t2) VOID CALLBACK QuietHoursTimer(HWND hWnd, UINT msg, UINT_PTR id, DWORD msSinceSysStart) { - UNREFERENCED_PARAMETER( msg ); - UNREFERENCED_PARAMETER( msSinceSysStart ); + UNREFERENCED_PARAMETER(msg); + UNREFERENCED_PARAMETER(msSinceSysStart); if (id == QUIETHOURS_TIMER_START_ID) { KillTimer(hWnd, id); SendMessage(hWnd, WM_WINMUTE_QUIETHOURS_START, 0, 0); diff --git a/WinMute/WinMute.h b/WinMute/WinMute.h index 5994783..d40a31f 100644 --- a/WinMute/WinMute.h +++ b/WinMute/WinMute.h @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #pragma once -#include "StdAfx.h" +#include "common.h" class WinAudio; @@ -52,7 +52,7 @@ public: bool Init(); void Close(); - // for internal use + // for internal use LRESULT CALLBACK WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); private: struct MuteConfigItem { diff --git a/WinMute/res.rc b/WinMute/WinMute.rc similarity index 57% rename from WinMute/res.rc rename to WinMute/WinMute.rc index 2050bcb..88c8086 100644 --- a/WinMute/res.rc +++ b/WinMute/WinMute.rc @@ -7,7 +7,7 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxres.h" +#include "winres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -25,18 +25,18 @@ LANGUAGE LANG_GERMAN, SUBLANG_GERMAN // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN - "#include ""afxres.h""\r\n" + "#include ""winres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" @@ -45,73 +45,67 @@ END #endif // APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_TRAYMENU MENU -BEGIN - POPUP "TrayMenu" - BEGIN - MENUITEM "Info", ID_TRAYMENU_INFO - MENUITEM SEPARATOR - MENUITEM "Mute when ...", ID_TRAYMENU_MUTEON, INACTIVE - MENUITEM "... Workstation is locked", ID_TRAYMENU_MUTEONLOCK, CHECKED - MENUITEM "... Screensaver starts", ID_TRAYMENU_MUTEONSCREENSAVER, CHECKED - MENUITEM SEPARATOR - MENUITEM "... Restore volume when returning", ID_TRAYMENU_RESTOREAUDIO, CHECKED - MENUITEM SEPARATOR - MENUITEM "Configure Quiet Hours...", ID_TRAYMENU_CONFIGUREQUIETHOURS - MENUITEM SEPARATOR - MENUITEM "Mute on (no volume restore)...", ID_TRAYMENU_AFTERWARDS, INACTIVE - MENUITEM "... Shutdown", ID_TRAYMENU_MUTEONSHUTDOWN - MENUITEM "... Sleep", ID_TRAYMENU_MUTEONSUSPEND - MENUITEM "... Logout", ID_TRAYMENU_MUTEONLOGOUT - MENUITEM SEPARATOR - MENUITEM "Mute now", ID_TRAYMENU_MUTE - MENUITEM SEPARATOR - MENUITEM "Exit", ID_TRAYMENU_EXIT - END -END - - ///////////////////////////////////////////////////////////////////////////// // // Dialog // -IDD_ABOUT DIALOGEX 0, 0, 251, 56 -STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION +IDD_ABOUT DIALOGEX 0, 0, 236, 56 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION CAPTION "About WinMute" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK",IDOK,194,7,50,14 - LTEXT "WinMute v1.6.0",IDC_STATIC,43,9,67,11 + DEFPUSHBUTTON "OK",IDOK,178,7,50,14 + LTEXT "WinMute v1.6.0",IDC_STATIC,35,7,82,10 + LTEXT "Copyright (c) 2020, Alexander Steinhöfer",IDC_STATIC,35,20,135,8 + ICON IDI_APP,IDC_STATIC,7,7,20,20,SS_CENTERIMAGE CONTROL "lx-systems - lx-s.de",IDC_LINK_HOMEPAGE, - "SysLink",WS_TABSTOP,43,35,69,13 - LTEXT "Copyright � 2020, Alexander Steinh�fer",IDC_STATIC,43,22,148,12 - ICON IDI_APP,IDC_STATIC,13,12,20,20,SS_CENTERIMAGE + "SysLink",WS_TABSTOP,34,33,82,14 CONTROL "Support",IDC_LINK_SUPPORT, - "SysLink",WS_TABSTOP,119,35,36,13 + "SysLink",WS_TABSTOP,106,33,60,14 END -IDD_QUIETHOURS DIALOGEX 0, 0, 201, 205 +IDD_QUIETHOURS DIALOGEX 0, 0, 212, 197 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Configure Quiet Hours" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "Enable Quiet Hours",IDC_ENABLEQUIETHOURS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,42,77,10 - CONTROL "",IDC_QUIETHOURS_START,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,79,58,54,15 - CONTROL "",IDC_QUIETHOURS_END,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,79,80,54,15 - CONTROL "Force unmute",IDC_FORCEUNMUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,31,102,60,10 - DEFPUSHBUTTON "Save",IDOK,63,174,50,14 - PUSHBUTTON "Cancel",IDCANCEL,123,174,50,14 - LTEXT "If force unmute is enabled, WinMute will unmute your workstation when quiet hours end and not take into account if your workstation was already muted before quiet hours started.",IDC_STATIC,32,115,162,38 - LTEXT "Start time:",IDC_STATIC,31,60,42,12 - LTEXT "End time:",IDC_STATIC,31,82,43,12 - LTEXT "During Quiet Hours WinMute automatically mutes your PC volumes and unmutes it afterwards.",IDC_STATIC,14,15,180,24 - CONTROL "Show notifications",IDC_SHOWNOTIFICATIONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,32,153,74,10 + DEFPUSHBUTTON "Save",IDOK,101,176,50,14 + PUSHBUTTON "Cancel",IDCANCEL,155,176,50,14 + LTEXT "During Quiet Hours WinMute automatically mutes your PC volumes and unmutes it afterwards.",IDC_STATIC,11,10,182,22 + CONTROL "Enable Quiet Hours",IDC_ENABLEQUIETHOURS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,34,120,15 + CONTROL "",IDC_QUIETHOURS_START,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,77,51,65,18 + CONTROL "",IDC_QUIETHOURS_END,"SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | WS_TABSTOP | 0x8,76,74,67,19 + CONTROL "Force unmute",IDC_FORCEUNMUTE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,97,86,16 + CONTROL "Show notifications",IDC_SHOWNOTIFICATIONS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,150,81,21 + LTEXT "If force unmute is enabled, WinMute will unmute your workstation when quiet hours end and not take into account if your workstation was already muted before quiet hours started.",IDC_STATIC,27,115,161,37 + LTEXT "Start time:",IDC_STATIC,27,54,43,13 + LTEXT "End time:",IDC_STATIC,28,76,32,16 +END + +IDD_SETTINGS DIALOGEX 0, 0, 403, 238 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Settings" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,294,217,50,14 + PUSHBUTTON "Cancel",IDCANCEL,346,217,50,14 + CONTROL "",IDC_TREE1,"SysTreeView32",WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,7,99,167 + CONTROL "",IDC_TAB1,"SysTabControl32",0x0,111,7,285,167 +END + +IDD_SETTINGS_GENERAL DIALOGEX 0, 0, 297, 171 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + CONTROL "Start WinMute on system startup",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,15,132,26 +END + +IDD_SETTINGS_QUIETHOURS DIALOGEX 0, 0, 310, 177 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + LTEXT "QUIET HOURS",IDC_STATIC,14,26,110,33 END @@ -126,8 +120,7 @@ BEGIN IDD_ABOUT, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 244 - VERTGUIDE, 43 + RIGHTMARGIN, 229 TOPMARGIN, 7 BOTTOMMARGIN, 49 END @@ -135,14 +128,114 @@ BEGIN IDD_QUIETHOURS, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 194 + RIGHTMARGIN, 205 + TOPMARGIN, 7 + BOTTOMMARGIN, 190 + END + + IDD_SETTINGS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 396 TOPMARGIN, 7 - BOTTOMMARGIN, 198 + BOTTOMMARGIN, 231 + END + + IDD_SETTINGS_GENERAL, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 290 + TOPMARGIN, 7 + BOTTOMMARGIN, 164 + END + + IDD_SETTINGS_QUIETHOURS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 303 + TOPMARGIN, 7 + BOTTOMMARGIN, 170 END END #endif // APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// AFX_DIALOG_LAYOUT +// + +IDD_ABOUT AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +IDD_QUIETHOURS AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +IDD_SETTINGS AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +IDD_SETTINGS_GENERAL AFX_DIALOG_LAYOUT +BEGIN + 0 +END + +IDD_SETTINGS_QUIETHOURS AFX_DIALOG_LAYOUT +BEGIN + 0 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP ICON "icons\\app.ico" + +IDI_TRAY_BRIGHT ICON "icons\\tray_bright.ico" + +IDI_TRAY_DARK ICON "icons\\tray_dark.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_TRAYMENU MENU +BEGIN + POPUP "TrayMenu" + BEGIN + MENUITEM "Info", ID_TRAYMENU_INFO + MENUITEM SEPARATOR + MENUITEM "Mute when...", 40003, INACTIVE + MENUITEM "... Workstation is locked", ID_TRAYMENU_MUTEONLOCK, CHECKED + MENUITEM "... Screensaver starts", ID_TRAYMENU_MUTEONSCREENSAVER, CHECKED + MENUITEM SEPARATOR + MENUITEM "Restore volume when returning", ID_TRAYMENU_RESTOREAUDIO, CHECKED + MENUITEM SEPARATOR + MENUITEM "Configure Quiet Hours...", ID_TRAYMENU_CONFIGUREQUIETHOURS + MENUITEM SEPARATOR + MENUITEM "Mute on (no volume restore)", ID_TRAYMENU_AFTERWARDS, INACTIVE + MENUITEM "... Shutdown", ID_TRAYMENU_MUTEONSHUTDOWN + MENUITEM "... Sleep", ID_TRAYMENU_MUTEONSUSPEND + MENUITEM "... Logout", ID_TRAYMENU_MUTEONLOGOUT + MENUITEM SEPARATOR + MENUITEM "Mute now", ID_TRAYMENU_MUTE + MENUITEM SEPARATOR + MENUITEM "Exit", ID_TRAYMENU_EXIT + END +END + + ///////////////////////////////////////////////////////////////////////////// // // Version @@ -151,36 +244,36 @@ END VS_VERSION_INFO VERSIONINFO FILEVERSION 1,7,0,0 PRODUCTVERSION 1,7,0,0 - FILEFLAGSMASK 0x17L + FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif - FILEOS 0x4L + FILEOS 0x40004L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN - BLOCK "000004b0" + BLOCK "040004b0" BEGIN - VALUE "CompanyName", "lx-systems" + VALUE "CompanyName", "LX-Systems" VALUE "FileDescription", "WinMute" VALUE "FileVersion", "1.7.0.0" - VALUE "InternalName", "WinMute" - VALUE "LegalCopyright", "Copyright (c) 2022, Alexander Steinh�fer" + VALUE "InternalName", "WinMute.exe" + VALUE "LegalCopyright", "Copyright (C) 2022, Alexander Steinhöfer" VALUE "OriginalFilename", "WinMute.exe" VALUE "ProductName", "WinMute" VALUE "ProductVersion", "1.7.0.0" END BLOCK "040704b0" BEGIN - VALUE "CompanyName", "lx-systems" + VALUE "CompanyName", "LX-Systems" VALUE "FileDescription", "WinMute" VALUE "FileVersion", "1.7.0.0" - VALUE "InternalName", "WinMute" - VALUE "LegalCopyright", "Copyright (c) 2022, Alexander Steinh�fer" + VALUE "InternalName", "WinMute.exe" + VALUE "LegalCopyright", "Copyright (C) 2022, Alexander Steinhöfer" VALUE "OriginalFilename", "WinMute.exe" VALUE "ProductName", "WinMute" VALUE "ProductVersion", "1.7.0.0" @@ -188,40 +281,10 @@ BEGIN END BLOCK "VarFileInfo" BEGIN - VALUE "Translation", 0x0, 1200, 0x407, 1200 + VALUE "Translation", 0x400, 1200, 0x407, 1200 END END - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_APP ICON "app.ico" - -IDI_TRAY_DARK ICON "tray_dark.ico" - -IDI_TRAY_BRIGHT ICON "tray_bright.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// AFX_DIALOG_LAYOUT -// - -IDD_ABOUT AFX_DIALOG_LAYOUT -BEGIN - 0 -END - -IDD_QUIETHOURS AFX_DIALOG_LAYOUT -BEGIN - 0 -END - #endif // German (Germany) resources ///////////////////////////////////////////////////////////////////////////// @@ -236,3 +299,4 @@ END ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED + diff --git a/WinMute/WinMute.vcxproj b/WinMute/WinMute.vcxproj index 3e47fdc..b8e4c0b 100644 --- a/WinMute/WinMute.vcxproj +++ b/WinMute/WinMute.vcxproj @@ -1,262 +1,189 @@ - - + + Debug Win32 - - Debug - x64 - Release Win32 + + Debug + x64 + Release x64 - {488617F0-5DD3-42B5-81ED-A1E9B3117551} - WinMute + 16.0 Win32Proj + {479d2958-3ffc-43f8-8217-44d0ff9c11b1} + WinMute 10.0 + WinMute - + Application - Unicode - true + true v143 + Unicode Spectre - + Application - Unicode - true + false v143 + true + Unicode Spectre - + Application - Unicode + true v143 + Unicode Spectre - + Application - Unicode + false v143 + true + Unicode Spectre - + + + - + - + - + - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)Bin\$(PlatformShortName)\ - $(SolutionDir)Bin\$(PlatformShortName)\ - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - true - true - $(SolutionDir)Bin\$(PlatformShortName)\ - $(SolutionDir)Bin\$(PlatformShortName)\ - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - $(SolutionDir).buildtmp\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - false - false - NativeRecommendedRules.ruleset - NativeRecommendedRules.ruleset - - - - - NativeRecommendedRules.ruleset - NativeRecommendedRules.ruleset - - - - - $(ProjectName) - $(ProjectName) - - - true - false - false - - true - false - false + true + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - true - false - false + false + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - true - false - false + true + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ + + + false + $(SolutionDir)Bin\ + $(SolutionDir)Build\$(Configuration)\$(PlatformShortName)\$(ProjectName)\ - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Use Level4 - EditAndContinue - true true - true - Caret + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true stdcpp20 + true + Caret + Use + common.h - strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies) - true Windows - MachineX86 - + true + strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies) - - PerMonitorHighDPIAware - - + - Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Use Level4 - EditAndContinue - true - true - Caret + true + true true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true stdcpp20 + true + Caret + true + Use + common.h - strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies) - true Windows + true + true + true + strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies) - - PerMonitorHighDPIAware - - + - /MP %(AdditionalOptions) - MaxSpeed - true - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Use Level4 - ProgramDatabase - true - true true - true - Caret - Guard - + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true stdcpp20 + true + Caret + Use + common.h - strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies) - $(OutDir)$(TargetName)$(TargetExt) - true Windows - true - true - MachineX86 + true + strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies) - - copy "$(TargetPath)" "$(SolutionDir)dist\bin\$(PlatformShortName)\$(TargetFileName)" - - /MP %(AdditionalOptions) - MaxSpeed - true - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDLL - true - Use Level4 - ProgramDatabase + true + true + true + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + stdcpp20 true - true Caret - true true - Guard - stdcpp20 + Use + common.h - strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies) - $(OutDir)$(TargetName)$(TargetExt) - true Windows - true true + true + true + strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies) - - copy "$(TargetPath)" "$(SolutionDir)dist\bin\$(PlatformShortName)\$(TargetFileName)" - - - - - - - - - Create - Create - Create - Create - - - - - - - - - + - - + @@ -264,14 +191,32 @@ - - + - + + + - + + + Create + Create + Create + Create + + + + + + + + + + + + diff --git a/WinMute/WinMute.vcxproj.filters b/WinMute/WinMute.vcxproj.filters index ce204de..f464b6e 100644 --- a/WinMute/WinMute.vcxproj.filters +++ b/WinMute/WinMute.vcxproj.filters @@ -3,123 +3,121 @@ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - {065a6082-9732-43e4-ad7b-714757809908} + {6fe7a132-28a9-4b7b-aa69-1380069e7ee3} - - {19d0b819-b48e-4418-917c-f92abc4c2160} - - - {4ea37611-be22-4541-bfcb-ca9d271b5166} + + {50123732-775b-41e8-9f2b-fc5925475924} - {aca601be-bf13-4396-89b2-8252b3fd2703} - - - {f9c118fc-0a72-4278-a710-841604aeb3e3} + {5f81f4a6-31a5-4c91-8563-6b63f79478fc} - {dc591c83-7135-4757-b9cb-54405dbc8d86} + {b90f43eb-497c-4b84-b7d9-df7a809e9cab} + + + {8054b676-f98f-4a0b-bf41-266bac229306} + + + {0cfb448e-c954-4181-96c8-c89e8d1728aa} - - Source Files - - - Source Files - - - Source Files - - + Source Files\Audio - - - Source Files\UI - - - Source Files\UI - - - Source Files\Audio\Vista Notification - - - Source Files\Audio\Vista Notification - - - Source Files\Helper - - + + + Source Files + + + Source Files\Audio\VistaAudio + + + Source Files\Audio\VistaAudio + + Source Files\Helper - - - Source Files\Settings - - - Source Files\UI - - + + Source Files\Log - - - - - Source Files\UI - + Source Files Source Files\UI - - Source Files\Audio - Source Files - - Source Files\Audio\Vista Notification - - - Source Files\Audio\Vista Notification - - - Source Files\Helper + + Source Files\Settings Source Files\Helper - - Source Files\Settings - - - Source Files\Log - - - - - Resource Files - - - Resource Files - - + Resource Files - + + Resource Files + + Resource Files + + Resource Files + + + + + Source Files + + + Source Files\Audio + + + Source Files\Audio\VistaAudio + + + Source Files\Audio\VistaAudio + + + Source Files\Helper + + + Source Files\Helper + + + Source Files\Log + + + Source Files\UI + + + Source Files\UI + + + Source Files\UI + + + Source Files + + + Source Files + + + Source Files\Settings + \ No newline at end of file diff --git a/WinMute/WinMute.vcxproj.user b/WinMute/WinMute.vcxproj.user index d7f1df8..88a5509 100644 --- a/WinMute/WinMute.vcxproj.user +++ b/WinMute/WinMute.vcxproj.user @@ -1,19 +1,4 @@  - - - $(OutputPath) - WindowsLocalDebugger - - - $(OutputPath) - WindowsLocalDebugger - - - $(OutputPath) - WindowsLocalDebugger - - - $(OutputPath) - WindowsLocalDebugger - + + \ No newline at end of file diff --git a/WinMute/StdAfx.cpp b/WinMute/common.cpp similarity index 95% rename from WinMute/StdAfx.cpp rename to WinMute/common.cpp index ea86dd7..6e47737 100644 --- a/WinMute/StdAfx.cpp +++ b/WinMute/common.cpp @@ -1,5 +1,5 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -30,4 +30,4 @@ POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ -#include "StdAfx.h" +#include "common.h" diff --git a/WinMute/StdAfx.h b/WinMute/common.h similarity index 71% rename from WinMute/StdAfx.h rename to WinMute/common.h index d04f373..0968c58 100644 --- a/WinMute/StdAfx.h +++ b/WinMute/common.h @@ -1,6 +1,6 @@ /* WinMute - Copyright (c) 2021, Alexander Steinhoefer + Copyright (c) 2022, Alexander Steinhoefer ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -34,15 +34,15 @@ POSSIBILITY OF SUCH DAMAGE. #pragma once #ifdef _UNICODE - #if defined _M_IX86 - #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") - #elif defined _M_IA64 - #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") - #elif defined _M_X64 - #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") - #else - #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") - #endif +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_IA64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif #endif #define STRICT @@ -87,9 +87,9 @@ inline void SafeRelease(Interface** ppInterfaceToRelease) } #ifdef UNICODE - typedef std::basic_string tstring; +typedef std::basic_string tstring; #else - typedef std::basic_string tstring; +typedef std::basic_string tstring; #endif // Utility diff --git a/WinMute/app.ico b/WinMute/icons/app.ico similarity index 100% rename from WinMute/app.ico rename to WinMute/icons/app.ico diff --git a/WinMute/tray_bright.ico b/WinMute/icons/tray_bright.ico similarity index 100% rename from WinMute/tray_bright.ico rename to WinMute/icons/tray_bright.ico diff --git a/WinMute/tray_dark.ico b/WinMute/icons/tray_dark.ico similarity index 100% rename from WinMute/tray_dark.ico rename to WinMute/icons/tray_dark.ico diff --git a/WinMute/resource.h b/WinMute/resource.h index c03b640..36de0f8 100644 --- a/WinMute/resource.h +++ b/WinMute/resource.h @@ -1,60 +1,58 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by res.rc +// Used by WinMute.rc // -#define IDR_TRAYMENU 101 -#define IDD_ABOUT 102 -#define IDI_APP 106 -#define IDI_ICON1 107 -#define IDI_TRAY 107 -#define IDI_TRAY_DARK 107 -#define IDD_QUIETHOURS 108 -#define IDI_TRAY_BRIGHT 110 +#define IDI_APP 5 +#define IDD_ABOUT 9 +#define IDI_TRAY_BRIGHT 104 +#define IDI_TRAY_DARK 105 +#define IDR_TRAYMENU 106 +#define IDD_QUIETHOURS 107 +#define IDD_SETTINGS 109 +#define IDD_SETTINGS_GENERAL 114 +#define IDD_SETTINGS_QUIETHOURS 116 #define IDC_LINK_HOMEPAGE 1001 -#define IDC_LINK_HOMEPAGE2 1002 #define IDC_LINK_SUPPORT 1002 -#define IDC_QUIETHOURS_START 1002 #define IDC_ENABLEQUIETHOURS 1003 -#define IDC_QUIETHOURS_END 1004 -#define IDC_FORCEUNMUTE 1005 -#define IDC_FORCEUNMUTE2 1006 -#define IDC_SHOWNOTIFICATIONS 1006 +#define IDC_QUIETHOURS_START 1004 +#define IDC_QUIETHOURS_END 1005 +#define IDC_FORCEUNMUTE 1006 +#define IDC_SHOWNOTIFICATIONS 1007 +#define IDC_TREE1 1008 +#define IDC_TAB1 1010 +#define IDC_CHECK1 1011 #define ID_TRAYMENU_INFO 40001 -#define ID_TRAYMENU_EXIT 40002 -#define ID_TRAYMENU_MUTEONLOCK 40003 -#define ID_TRAYMENU_MUTEONSCREENSAVER 40004 -#define ID_TRAYMENU_ 40005 -#define ID_TRAYMENU_MUTEONMONITOROFF 40006 -#define ID_TRAYMENU_MUTE 40007 -#define ID_TRAYMENU_MUTEONSCREENSAVER40008 40008 -#define ID_TRAYMENU_RESTOREAUDIO 40009 +#define ID_TRAYMENU_ 40002 +#define ID_TRAYMENU_MUTEON 40003 +#define ID_TRAYMENU_ID 40004 +#define ID_TRAYMENU_MUTEONSCREENSAVER 40005 +#define ID_TRAYMENU_40006 40006 +#define ID_TRAYMENU_RESTOREAUDIO 40007 +#define ID_TRAYMENU_40008 40008 +#define ID_TRAYMENU_CONFIGUREQUIETHOURS 40009 #define ID_TRAYMENU_40010 40010 -#define ID_TRAYMENU_40011 40011 -#define ID_TRAYMENU_MUTEON 40012 -#define ID_TRAYMENU_AFTERWARDS 40013 -#define ID_TRAYMENU_MUTEONSUSPEND 40014 +#define ID_TRAYMENU_MUTEON40011 40011 +#define ID_TRAYMENU_AFTERWARDS 40012 +#define ID_TRAYMENU_40013 40013 +#define ID_TRAYMENU_MUTEONSHUTDOWN 40014 #define ID_TRAYMENU_40015 40015 -#define ID_TRAYMENU_SPECIAL 40016 -#define ID_SPECIAL_MUTEWHEN 40017 -#define ID_TRAYMENU_40018 40018 +#define ID_TRAYMENU_MUTEONSUSPEND 40016 +#define ID_TRAYMENU_40017 40017 +#define ID_TRAYMENU_MUTEONLOGOUT 40018 #define ID_TRAYMENU_40019 40019 -#define ID_TRAYMENU_40020 40020 -#define ID_TRAYMENU_MUTEONSHUTDOWN 40021 -#define ID_TRAYMENU_MUTEONSLEEP 40022 -#define ID_TRAYMENU_MUTEONLOGOFF 40023 -#define ID_TRAYMENU_MUTEONLOGOUT 40024 -#define ID_TRAYMENU_40025 40025 -#define ID_TRAYMENU_CONFIGUREQUIETHOURS 40026 -#define ID_TRAYMENU_40027 40027 -#define ID_TRAYMENU_QUIETHO 40028 +#define ID_TRAYMENU_MUTENOW 40020 +#define ID_TRAYMENU_40021 40021 +#define ID_TRAYMENU_EXIT 40022 +#define ID_TRAYMENU_MUTE 40023 +#define ID_TRAYMENU_MUTEONLOCK 40024 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 112 -#define _APS_NEXT_COMMAND_VALUE 40029 -#define _APS_NEXT_CONTROL_VALUE 1004 +#define _APS_NEXT_RESOURCE_VALUE 118 +#define _APS_NEXT_COMMAND_VALUE 40025 +#define _APS_NEXT_CONTROL_VALUE 1012 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif -- 2.43.0