Skip to content

Instantly share code, notes, and snippets.

@krlvm
Last active August 10, 2023 09:39
Show Gist options
  • Save krlvm/758ea960569e927e6008126f3b910048 to your computer and use it in GitHub Desktop.
Save krlvm/758ea960569e927e6008126f3b910048 to your computer and use it in GitHub Desktop.
Changing Windows 11 Start Button to match Windows 11 logo when using ExplorerPatcher
/*
* MIT License
*
* Copyright (c) 2021 krlvm
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <Windows.h>
#include <Uxtheme.h>
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "uxtheme.lib")
#define SEPARATOR 2
int UpdateBitmap(HBITMAP hbm)
{
BITMAP bm;
GetObject(hbm, sizeof(bm), &bm);
if (!hbm || bm.bmBitsPixel != 32 || bm.bmWidth > 64)
{
return FALSE;
}
int side = bm.bmWidth / 2;
BYTE* pBits = new BYTE[bm.bmWidth * bm.bmHeight * 4];
GetBitmapBits(hbm, bm.bmWidth * bm.bmHeight * 4, pBits);
for (int y = 0; y < bm.bmHeight; y++) {
BYTE* pPixel = (BYTE*)pBits + bm.bmWidth * 4 * y;
for (int x = 0; x < bm.bmWidth; x++) {
if ( ((x + 1) >= side && (x + 1) < (side + SEPARATOR)) || ((y + 1) >= side && (y + 1) < (side + SEPARATOR)))
{
pPixel[3] = 0;
}
else
{
// Windows 11 Logo Color
//pPixel[2] = 0;
//pPixel[1] = 120;
//pPixel[0] = 212;
pPixel[2] = 255;
pPixel[1] = 255;
pPixel[0] = 255;
pPixel[3] = 255;
}
pPixel += 4;
}
}
SetBitmapBits(hbm, bm.bmWidth * bm.bmHeight * 4, pBits);
delete[] pBits;
return TRUE;
}
int ModifyStyle(LPCWSTR pszClassList, int iPartId, int iStateId, int iPropId)
{
HBITMAP hBitmap;
HTHEME hTheme = OpenThemeDataForDpi(HWND_DESKTOP, pszClassList, GetDpiForWindow(HWND_DESKTOP));
GetThemeBitmap(hTheme, iPartId, iStateId, iPropId, GBF_DIRECT, &hBitmap);
CloseThemeData(hTheme);
if (!hBitmap) return 0;
return UpdateBitmap(hBitmap);
}
int main()
{
for (int i = 1; i <= 7; i++)
{
ModifyStyle(L"TaskbarPearl", i, 0, 0);
}
}
@Galixte
Copy link

Galixte commented Nov 24, 2021

Hi @krlvm,

How does it work? Is there an executable file?

Regards.

@krlvm
Copy link
Author

krlvm commented Nov 24, 2021

This code should be compiled as a command line VS2019 C++ project.
You can also execute this binary, it will replace the start button until reboot if you're using 100% or 125% DPI Scaling.

@Gentleman2292
Copy link

how do i remove this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment