Skip to content

Commit

Permalink
Fixed taskbar media controls colorization on Windows < 10
Browse files Browse the repository at this point in the history
  • Loading branch information
krlvm committed Jun 12, 2022
1 parent a4de704 commit b243793
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
6 changes: 4 additions & 2 deletions AccentColorizer/AccentColorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "SysColorsModifier.h"
#include "StyleModifier.h"
#include "SettingsHelper.h"
#include <VersionHelpers.h>
#include "SystemHelper.h"

const LPCWSTR szWindowClass = L"ACCENTCOLORIZER";
HANDLE hHandle;
Expand Down Expand Up @@ -44,6 +44,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
return 1;
}

DetectWindowsVersion();

colorizeMenus = IsMenuColorizationEnabled();
colorizeProgressBar = IsProgressBarColorizationEnabled();

Expand All @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions AccentColorizer/AccentColorizer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
<ClInclude Include="StyleModifier.h" />
<ClInclude Include="SysColorsModifier.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="SystemHelper.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AccentColorHelper.cpp" />
Expand All @@ -231,6 +232,7 @@
<ClCompile Include="SettingsHelper.cpp" />
<ClCompile Include="StyleModifier.cpp" />
<ClCompile Include="SysColorsModifier.cpp" />
<ClCompile Include="SystemHelper.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="VersionInfo.rc" />
Expand Down
6 changes: 6 additions & 0 deletions AccentColorizer/AccentColorizer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
<ClCompile Include="SettingsHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SystemHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="AccentColorHelper.h">
Expand Down Expand Up @@ -51,6 +54,9 @@
<ClInclude Include="SettingsHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SystemHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Source Files">
Expand Down
6 changes: 3 additions & 3 deletions AccentColorizer/StyleModifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "BitmapHelper.h"
#include "ColorHelper.h"
#include "AccentColorHelper.h"
#include <VersionHelpers.h>
#include "SystemHelper.h"

int hsvAccentH;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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++)
{
Expand Down
24 changes: 24 additions & 0 deletions AccentColorizer/SystemHelper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "SystemHelper.h"
#include <VersionHelpers.h>

int winver;

void DetectWindowsVersion()
{
if (IsWindows10OrGreater())
{
winver = 10;
}
else if (IsWindows8OrGreater())
{
winver = 8;
}
else if (IsWindows7OrGreater())
{
winver = 7;
}
else
{
winver = 6;
}
}
5 changes: 5 additions & 0 deletions AccentColorizer/SystemHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once
#include "framework.h"

extern int winver;
void DetectWindowsVersion();

0 comments on commit b243793

Please sign in to comment.