From b243793076ce53c208da4d25344ee8307123b0d5 Mon Sep 17 00:00:00 2001 From: krlvm <51774833+krlvm@users.noreply.github.com> Date: Sun, 12 Jun 2022 17:15:21 +0300 Subject: [PATCH] Fixed taskbar media controls colorization on Windows < 10 --- AccentColorizer/AccentColorizer.cpp | 6 +++-- AccentColorizer/AccentColorizer.vcxproj | 2 ++ .../AccentColorizer.vcxproj.filters | 6 +++++ AccentColorizer/StyleModifier.cpp | 6 ++--- AccentColorizer/SystemHelper.cpp | 24 +++++++++++++++++++ AccentColorizer/SystemHelper.h | 5 ++++ 6 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 AccentColorizer/SystemHelper.cpp create mode 100644 AccentColorizer/SystemHelper.h diff --git a/AccentColorizer/AccentColorizer.cpp b/AccentColorizer/AccentColorizer.cpp index f30c391..bbaf5be 100644 --- a/AccentColorizer/AccentColorizer.cpp +++ b/AccentColorizer/AccentColorizer.cpp @@ -3,7 +3,7 @@ #include "SysColorsModifier.h" #include "StyleModifier.h" #include "SettingsHelper.h" -#include +#include "SystemHelper.h" const LPCWSTR szWindowClass = L"ACCENTCOLORIZER"; HANDLE hHandle; @@ -44,6 +44,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, return 1; } + DetectWindowsVersion(); + colorizeMenus = IsMenuColorizationEnabled(); colorizeProgressBar = IsProgressBarColorizationEnabled(); @@ -59,7 +61,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, return 1; } HWND hwnd = CreateWindowEx(0, szWindowClass, nullptr, 0, 0, 0, 0, 0, nullptr, NULL, NULL, NULL); - if (!IsWindows8OrGreater()) + if (winver < 8) { SendMessageTimeout(HWND_BROADCAST, WM_DWMCOLORIZATIONCOLORCHANGED, _accentRgb, _accentOpaque, SMTO_NORMAL, 2000, nullptr); } diff --git a/AccentColorizer/AccentColorizer.vcxproj b/AccentColorizer/AccentColorizer.vcxproj index bfa6275..5f3fb53 100644 --- a/AccentColorizer/AccentColorizer.vcxproj +++ b/AccentColorizer/AccentColorizer.vcxproj @@ -222,6 +222,7 @@ + @@ -231,6 +232,7 @@ + diff --git a/AccentColorizer/AccentColorizer.vcxproj.filters b/AccentColorizer/AccentColorizer.vcxproj.filters index 22d43b0..3a48ded 100644 --- a/AccentColorizer/AccentColorizer.vcxproj.filters +++ b/AccentColorizer/AccentColorizer.vcxproj.filters @@ -22,6 +22,9 @@ Source Files + + Source Files + @@ -51,6 +54,9 @@ Header Files + + Header Files + diff --git a/AccentColorizer/StyleModifier.cpp b/AccentColorizer/StyleModifier.cpp index 20a02a4..d132a11 100644 --- a/AccentColorizer/StyleModifier.cpp +++ b/AccentColorizer/StyleModifier.cpp @@ -2,7 +2,7 @@ #include "BitmapHelper.h" #include "ColorHelper.h" #include "AccentColorHelper.h" -#include +#include "SystemHelper.h" int hsvAccentH; @@ -233,7 +233,7 @@ void ModifyStyles() { } // Taskbar Thumbnail Media Controls - for (i = 6; i <= 9; i++) + for (i = (winver >= 10 ? 6 : 8); i <= (winver >= 10 ? 9 : 11); i++) { ModifyStyle(L"TaskbandExtendedUI", i, 0, TMT_DIBDATA); ModifyStyle(L"TaskbandExtendedUI", i, 1, TMT_DIBDATA); @@ -274,7 +274,7 @@ void ModifyStyles() { ModifyStyle(L"StartPanelComposited::StartPanelPriv", i, 0, TMT_DIBDATA); } - if (!IsWindows8OrGreater()) + if (winver < 8) { for (i = 1; i <= 8; i++) { diff --git a/AccentColorizer/SystemHelper.cpp b/AccentColorizer/SystemHelper.cpp new file mode 100644 index 0000000..092d77b --- /dev/null +++ b/AccentColorizer/SystemHelper.cpp @@ -0,0 +1,24 @@ +#include "SystemHelper.h" +#include + +int winver; + +void DetectWindowsVersion() +{ + if (IsWindows10OrGreater()) + { + winver = 10; + } + else if (IsWindows8OrGreater()) + { + winver = 8; + } + else if (IsWindows7OrGreater()) + { + winver = 7; + } + else + { + winver = 6; + } +} \ No newline at end of file diff --git a/AccentColorizer/SystemHelper.h b/AccentColorizer/SystemHelper.h new file mode 100644 index 0000000..c837b3a --- /dev/null +++ b/AccentColorizer/SystemHelper.h @@ -0,0 +1,5 @@ +#pragma once +#include "framework.h" + +extern int winver; +void DetectWindowsVersion(); \ No newline at end of file