From 1edcea111500413f74ebd926b40afb039569debe Mon Sep 17 00:00:00 2001 From: rikka0w0 <929513338@qq.com> Date: Tue, 29 Nov 2022 01:06:03 +1100 Subject: [PATCH 1/2] Add Win11 22H2 support --- .../ContextMenuNormalizer.cpp | 168 ++++++++---------- .../ContextMenuNormalizer.vcxproj | 12 +- .../ContextMenuNormalizer.vcxproj.filters | 12 ++ ContextMenuNormalizer/ThemeEditor.cpp | 140 +++++++++++++++ ContextMenuNormalizer/ThemeEditor.h | 34 ++++ ContextMenuNormalizer/Win8RP.cpp | 58 ++++++ ContextMenuNormalizer/Win8RP.h | 8 + 7 files changed, 339 insertions(+), 93 deletions(-) create mode 100644 ContextMenuNormalizer/ThemeEditor.cpp create mode 100644 ContextMenuNormalizer/ThemeEditor.h create mode 100644 ContextMenuNormalizer/Win8RP.cpp create mode 100644 ContextMenuNormalizer/Win8RP.h diff --git a/ContextMenuNormalizer/ContextMenuNormalizer.cpp b/ContextMenuNormalizer/ContextMenuNormalizer.cpp index 99adfd5..c8239b8 100644 --- a/ContextMenuNormalizer/ContextMenuNormalizer.cpp +++ b/ContextMenuNormalizer/ContextMenuNormalizer.cpp @@ -4,6 +4,9 @@ #include #include +#include "ThemeEditor.h" +#include "Win8RP.h" + #pragma comment(lib, "user32.lib") #pragma comment(lib, "uxtheme.lib") #pragma warning(disable : 4996) @@ -12,34 +15,6 @@ #include #endif -#pragma region Pixel Color - -inline int PixClr(int val) -{ - return val & 0xFFFFFF; -} - -inline int PixR(BYTE* pPixel) -{ - return PixClr(pPixel[2]); -} -inline int PixG(BYTE* pPixel) -{ - return PixClr(pPixel[1]); -} -inline int PixB(BYTE* pPixel) -{ - return PixClr(pPixel[0]); -} -inline int PixA(BYTE* pPixel) -{ - return PixClr(pPixel[3]); -} - -#pragma endregion - -typedef void (*BitmapHandler)(int* r, int* g, int* b, int* a); - #pragma region Recolorizators #define CONTEXT_MENU_BACKGROUND_LIGHT 238 @@ -162,59 +137,66 @@ void Recolorize_Menu_PopupSeparator11(int* r, int* g, int* b, int* a) { } #pragma endregion -int RecolorizeBitmap(HBITMAP hbm, BitmapHandler handler) -{ - BITMAP bm; - GetObject(hbm, sizeof(bm), &bm); - - if (!hbm || bm.bmBitsPixel != 32) { - return FALSE; +static void prvReplace(int iXPos, int iYPos, int iSize, Pixel_t xBoarder, Pixel_t xFill, Pixel_t* pPixels) { + Pixel_t xBackground; + xBackground.bits.r = 249; + xBackground.bits.g = 249; + xBackground.bits.b = 249; + xBackground.bits.a = 255; + for (int iX = iXPos; iX < iXPos + iSize; iX++) { + for (int iY = iYPos; iY < iYPos + iSize; iY++) { + if (iX == iXPos || iY == iYPos || iX == iXPos + iSize-1 || iY == iYPos + iSize-1) { + vSetPixel(pPixels, iX, iY, iSize, xBoarder); + } + else { + vSetPixel(pPixels, iX, iY, iSize, xFill); + } + } } + //vSetPixel(pPixels, 0, 0, iSize, xBoarder); +} - 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++) { - - int r = PixR(pPixel); // [2] - int g = PixG(pPixel); // [1] - int b = PixB(pPixel); // [0] - int a = PixA(pPixel); // [3] - -#if _DEBUG - _RPT1(0, "(%d, %d, %d / %d) \n", r, g, b, a); -#endif +int qwq(int iWidth, int iHeight, Pixel_t* pPixels, void* pParam) { + Pixel_t xBoarder; + Pixel_t xFill; - handler(&r, &g, &b, &a); + xBoarder.bits.r = 249; + xBoarder.bits.g = 249; + xBoarder.bits.b = 249; + xBoarder.bits.a = 255; - pPixel[2] = r; - pPixel[1] = g; - pPixel[0] = b; - pPixel[3] = a; + xFill.bits.r = 249; + xFill.bits.g = 249; + xFill.bits.b = 249; + xFill.bits.a = 255; - pPixel += 4; - } - } + //prvReplace(0, iWidth * 0, iWidth, xBoarder, xFill, pPixels); + //prvReplace(0, iWidth * 2, iWidth, xBoarder, xFill, pPixels); + xBoarder.bits.r = 127; + xBoarder.bits.g = 181; + xBoarder.bits.b = 236; + xBoarder.bits.a = 255; - SetBitmapBits(hbm, bm.bmWidth * bm.bmHeight * 4, pBits); + xFill.bits.r = 222; + xFill.bits.g = 239; + xFill.bits.b = 255; + xFill.bits.a = 255; - delete[] pBits; - return TRUE; -} + prvReplace(0, iWidth * 1, iWidth, xBoarder, xFill, pPixels); -int NormalizeContextMenu(LPCWSTR pszClassList, int iPartId, BitmapHandler handler) -{ - HBITMAP hBitmap; + xBoarder.bits.r = 181; + xBoarder.bits.g = 236; + xBoarder.bits.b = 255; + xBoarder.bits.a = 127; - HTHEME hTheme = OpenThemeData(GetForegroundWindow(), pszClassList); - GetThemeBitmap(hTheme, iPartId, 0, TMT_DIBDATA, GBF_DIRECT, &hBitmap); - CloseThemeData(hTheme); + xFill.bits.r = 222; + xFill.bits.g = 0; + xFill.bits.b = 0; + xFill.bits.a = 255; + prvReplace(0, iWidth * 3, iWidth, xBoarder, xFill, pPixels); - return RecolorizeBitmap(hBitmap, handler); + return 1; } int APIENTRY wWinMain(_In_ HINSTANCE hInstance, @@ -226,28 +208,36 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, OSVERSIONINFOEX info; info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); GetVersionEx((LPOSVERSIONINFO)&info); - + if (info.dwBuildNumber < 22000) { - NormalizeContextMenu(L"Menu", 14, Recolorize_Menu_PopupItem); - NormalizeContextMenu(L"Menu", 13, Recolorize_Menu_PopupGutter); - NormalizeContextMenu(L"Menu", 12, Recolorize_Menu_CheckBackground); - NormalizeContextMenu(L"Menu", 8, Recolorize_Menu_BarItem); - - NormalizeContextMenu(L"ImmersiveStart::Menu", 15, Recolorize_ImmersiveMenu_PopupSeparator); - NormalizeContextMenu(L"ImmersiveStart::Menu", 14, Recolorize_ImmersiveMenu_PopupItem); - NormalizeContextMenu(L"ImmersiveStart::Menu", 9, Recolorize_ImmersiveMenu_PopupBackground); - - NormalizeContextMenu(L"ImmersiveStartDark::Menu", 15, Recolorize_ImmersiveMenuDark_PopupSeparator); - NormalizeContextMenu(L"DarkMode_ImmersiveStart::Menu", 15, Recolorize_ImmersiveMenuDark_PopupSeparator); - NormalizeContextMenu(L"DarkMode::Menu", 15, Recolorize_ImmersiveMenuDark_PopupSeparator); - NormalizeContextMenu(L"DarkMode::Menu", 12, Recolorize_ImmersiveMenuDark_CheckBackground); - NormalizeContextMenu(L"DarkMode::Menu", 10, Recolorize_ImmersiveMenuDark_PopupBorders); - } - else + // Windows 10 + NormalizeContextMenu(L"Menu", MENU_POPUPITEM, Recolorize_Menu_PopupItem); + NormalizeContextMenu(L"Menu", MENU_POPUPGUTTER, Recolorize_Menu_PopupGutter); + NormalizeContextMenu(L"Menu", MENU_POPUPCHECKBACKGROUND, Recolorize_Menu_CheckBackground); + NormalizeContextMenu(L"Menu", MENU_BARITEM, Recolorize_Menu_BarItem); + + NormalizeContextMenu(L"ImmersiveStart::Menu", MENU_POPUPSEPARATOR, Recolorize_ImmersiveMenu_PopupSeparator); + NormalizeContextMenu(L"ImmersiveStart::Menu", MENU_POPUPITEM, Recolorize_ImmersiveMenu_PopupItem); + NormalizeContextMenu(L"ImmersiveStart::Menu", MENU_POPUPBACKGROUND, Recolorize_ImmersiveMenu_PopupBackground); + + NormalizeContextMenu(L"ImmersiveStartDark::Menu", MENU_POPUPSEPARATOR, Recolorize_ImmersiveMenuDark_PopupSeparator); + NormalizeContextMenu(L"DarkMode_ImmersiveStart::Menu", MENU_POPUPSEPARATOR, Recolorize_ImmersiveMenuDark_PopupSeparator); + NormalizeContextMenu(L"DarkMode::Menu", MENU_POPUPSEPARATOR, Recolorize_ImmersiveMenuDark_PopupSeparator); + NormalizeContextMenu(L"DarkMode::Menu", MENU_POPUPCHECKBACKGROUND, Recolorize_ImmersiveMenuDark_CheckBackground); + NormalizeContextMenu(L"DarkMode::Menu", MENU_POPUPBORDERS, Recolorize_ImmersiveMenuDark_PopupBorders); + } + else if (info.dwBuildNumber < 22621) { - NormalizeContextMenu(L"Menu", 14, Recolorize_Menu_PopupItem11); - NormalizeContextMenu(L"Menu", 15, Recolorize_Menu_PopupSeparator11); + // before Win11 22H2 + NormalizeContextMenu(L"Menu", MENU_POPUPITEM, Recolorize_Menu_PopupItem11); + NormalizeContextMenu(L"Menu", MENU_POPUPSEPARATOR, Recolorize_Menu_PopupSeparator11); + } + else { + // Win11 22H2 and after + ModifyContextMenuBitmap(L"Menu", 27, iWin8RP_PopupMenu, NULL); // The new "MENU_POPUPITEM" in use + ModifyContextMenuBitmap(L"Menu", MENU_POPUPITEM, iWin8RP_PopupMenu, NULL); + ModifyContextMenuBitmap(L"ImmersiveStart::Menu", MENU_POPUPITEM, iWin8RP_PopupMenu, NULL); } return 0; diff --git a/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj b/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj index 440706e..1894acc 100644 --- a/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj +++ b/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj @@ -29,26 +29,26 @@ Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode Application true - v142 + v143 Unicode Application false - v142 + v143 true Unicode @@ -140,6 +140,8 @@ + + @@ -149,6 +151,8 @@ + + diff --git a/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj.filters b/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj.filters index ac1e8d5..56e5239 100644 --- a/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj.filters +++ b/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj.filters @@ -18,6 +18,12 @@ Source Files + + Source Files + + + Source Files + @@ -33,5 +39,11 @@ Header Files + + Header Files + + + Header Files + \ No newline at end of file diff --git a/ContextMenuNormalizer/ThemeEditor.cpp b/ContextMenuNormalizer/ThemeEditor.cpp new file mode 100644 index 0000000..90abd89 --- /dev/null +++ b/ContextMenuNormalizer/ThemeEditor.cpp @@ -0,0 +1,140 @@ +#include "ThemeEditor.h" + +#include +#include + +#include +#include +#include +#include +#include + +#pragma comment(lib, "user32.lib") +#pragma comment(lib, "uxtheme.lib") +#pragma warning(disable : 4996) + +#if _DEBUG +#include +#endif + +#pragma region Pixel Color + +static inline int PixClr(int val) +{ + return val & 0xFFFFFF; +} + +static inline int PixR(BYTE* pPixel) +{ + return PixClr(pPixel[2]); +} +static inline int PixG(BYTE* pPixel) +{ + return PixClr(pPixel[1]); +} +static inline int PixB(BYTE* pPixel) +{ + return PixClr(pPixel[0]); +} +static inline int PixA(BYTE* pPixel) +{ + return PixClr(pPixel[3]); +} + +#pragma endregion + +typedef struct { + PixelModifier pmPixelModifier; + BitmapHandler pmSimpleReplacer; +} CallContext_t; + +static void prvSimpleWrapper(const RBContext_t* pxContext, Pixel_t* pPixel, void* pParam) { + CallContext_t* pCallContext = (CallContext_t*)pParam; + int r = pPixel->bits.r; + int g = pPixel->bits.g; + int b = pPixel->bits.b; + int a = pPixel->bits.a; + pCallContext->pmSimpleReplacer(&r, &g, &b, &a); + pPixel->bits.r = r; + pPixel->bits.g = g; + pPixel->bits.b = b; + pPixel->bits.a = a; +} + +static int prvRecolorizeBitmap(int iWidth, int iHeight, Pixel_t *pPixels, void* pParam) +{ + RBContext_t xRBContext; + xRBContext.width = iWidth; + xRBContext.height = iHeight; + + for (xRBContext.y = 0; xRBContext.y < iHeight; xRBContext.y++) { + Pixel_t* pPixel = pPixels + (iWidth * xRBContext.y); + + for (xRBContext.x = 0; xRBContext.x < iWidth; xRBContext.x++) { +#if _DEBUG + _RPT1(0, "(%d, %d, %d / %d) \n", pPixel->bits.r, pPixel->bits.g, pPixel->bits.b, pPixel->bits.a); +#endif + CallContext_t* pCallContext = (CallContext_t*) pParam; + pCallContext->pmPixelModifier(&xRBContext, pPixel, pParam); + + pPixel ++; + } + } + + return TRUE; +} + +int ModifyContextMenuBitmap(LPCWSTR pszClassList, int iPartId, BitmapModifier pmModifier, void* pParam) +{ + HBITMAP hBitmap; + + HTHEME hTheme = OpenThemeData(GetForegroundWindow(), pszClassList); + GetThemeBitmap(hTheme, iPartId, 0, TMT_DIBDATA, GBF_DIRECT, &hBitmap); + CloseThemeData(hTheme); + + BITMAP xBitMap; + GetObject(hBitmap, sizeof(xBitMap), &xBitMap); + + if (!hBitmap || xBitMap.bmBitsPixel != 32) { + // Format is not ARGB + return FALSE; + } + + int result = FALSE; + LONG xPixelCount = xBitMap.bmWidth * xBitMap.bmHeight; + LONG xBitCount = xPixelCount * sizeof(Pixel_t); + Pixel_t* pPixels = (Pixel_t*)malloc(xBitCount); + if (!pPixels) { + return result; + } + + if (!GetBitmapBits(hBitmap, xBitCount, pPixels)) { + goto free_bits; + } + + result = pmModifier(xBitMap.bmWidth, xBitMap.bmHeight, pPixels, pParam); + + if (!SetBitmapBits(hBitmap, xBitCount, pPixels)) { + goto free_bits; + } + +free_bits: + if (pPixels) { + free(pPixels); + } + + return result; +} + +int NormalizeContextMenu(LPCWSTR pszClassList, int iPartId, BitmapHandler pmHandler) { + CallContext_t xContext; + xContext.pmPixelModifier = prvSimpleWrapper; + xContext.pmSimpleReplacer = pmHandler; + return ModifyContextMenuBitmap(pszClassList, iPartId, prvRecolorizeBitmap, &xContext); +} + +int NormalizeContextMenuEx(LPCWSTR pszClassList, int iPartId, PixelModifier pmHandler) { + CallContext_t xContext; + xContext.pmPixelModifier = pmHandler; + return ModifyContextMenuBitmap(pszClassList, iPartId, prvRecolorizeBitmap, &xContext); +} \ No newline at end of file diff --git a/ContextMenuNormalizer/ThemeEditor.h b/ContextMenuNormalizer/ThemeEditor.h new file mode 100644 index 0000000..e3f390a --- /dev/null +++ b/ContextMenuNormalizer/ThemeEditor.h @@ -0,0 +1,34 @@ +#ifndef __INCLUDE_THEME_EDITOR_H_ +#define __INCLUDE_THEME_EDITOR_H_ + +#include + +#include + +// MSB --- ARGB --> LSB +typedef union { + uint32_t all; + struct { + uint8_t b, g, r, a; + } bits; +} Pixel_t; + +typedef struct { + int x, y; + int width, height; +} RBContext_t; + +static inline void vSetPixel(Pixel_t* pPixels, int iX, int iY, int iWidth, Pixel_t xPixel) { + pPixels[iWidth * iY + iX] = xPixel; +} + +typedef void (*BitmapHandler)(int* r, int* g, int* b, int* a); +typedef void (*PixelModifier)(const RBContext_t* pxContext, Pixel_t* pPixels, void* pParam); +typedef int (*BitmapModifier)(int iWidth, int iHeight, Pixel_t* pPixels, void* pParam); + +Pixel_t xGetPixel(uint32_t uiRawPixel); + +int ModifyContextMenuBitmap(LPCWSTR pszClassList, int iPartId, BitmapModifier pmModifier, void* pParam); +int NormalizeContextMenu(LPCWSTR pszClassList, int iPartId, BitmapHandler pmHandler); + +#endif // !__INCLUDE_THEME_EDITOR_H_ diff --git a/ContextMenuNormalizer/Win8RP.cpp b/ContextMenuNormalizer/Win8RP.cpp new file mode 100644 index 0000000..0ce231b --- /dev/null +++ b/ContextMenuNormalizer/Win8RP.cpp @@ -0,0 +1,58 @@ +#include "Win8RP.h" +#include "ThemeEditor.h" + +static void prvReplace(int iXPos, int iYPos, int iSize, Pixel_t xBoarder, Pixel_t xFill, Pixel_t* pPixels) { + for (int iX = iXPos; iX < iXPos + iSize; iX++) { + for (int iY = iYPos; iY < iYPos + iSize; iY++) { + if (iX == iXPos || iY == iYPos || iX == iXPos + iSize - 1 || iY == iYPos + iSize - 1) { + vSetPixel(pPixels, iX, iY, iSize, xBoarder); + } + else { + vSetPixel(pPixels, iX, iY, iSize, xFill); + } + } + } +} + +int iWin8RP_PopupMenu(int iWidth, int iHeight, Pixel_t* pPixels, void* pParam) { + Pixel_t xBoarder; + Pixel_t xFill; + + xBoarder.bits.r = 249; + xBoarder.bits.g = 249; + xBoarder.bits.b = 249; + xBoarder.bits.a = 255; + + xFill.bits.r = 249; + xFill.bits.g = 249; + xFill.bits.b = 249; + xFill.bits.a = 255; + + prvReplace(0, iWidth * 0, iWidth, xBoarder, xFill, pPixels); + prvReplace(0, iWidth * 2, iWidth, xBoarder, xFill, pPixels); + + xBoarder.bits.r = 127; + xBoarder.bits.g = 181; + xBoarder.bits.b = 236; + xBoarder.bits.a = 255; + + xFill.bits.r = 222; + xFill.bits.g = 239; + xFill.bits.b = 255; + xFill.bits.a = 255; + + prvReplace(0, iWidth * 1, iWidth, xBoarder, xFill, pPixels); + + xBoarder.bits.r = 219; + xBoarder.bits.g = 219; + xBoarder.bits.b = 219; + xBoarder.bits.a = 255; + + xFill.bits.r = 249; + xFill.bits.g = 249; + xFill.bits.b = 249; + xFill.bits.a = 255; + prvReplace(0, iWidth * 3, iWidth, xBoarder, xFill, pPixels); + + return 1; +} \ No newline at end of file diff --git a/ContextMenuNormalizer/Win8RP.h b/ContextMenuNormalizer/Win8RP.h new file mode 100644 index 0000000..ee7640b --- /dev/null +++ b/ContextMenuNormalizer/Win8RP.h @@ -0,0 +1,8 @@ +#ifndef __INCLUDE_WIN8RP_H_ +#define __INCLUDE_WIN8RP_H_ + +#include "ThemeEditor.h" + +int iWin8RP_PopupMenu(int iWidth, int iHeight, Pixel_t* pPixels, void* pParam); + +#endif // __INCLUDE_WIN8RP_H_ \ No newline at end of file From edd5f1360f4de66be59054be654d8725833e37cd Mon Sep 17 00:00:00 2001 From: rikka0w0 <929513338@qq.com> Date: Tue, 29 Nov 2022 01:53:15 +1100 Subject: [PATCH 2/2] Add Win11 21H1 menu --- .../ContextMenuNormalizer.cpp | 70 ++----------------- .../ContextMenuNormalizer.vcxproj | 3 +- .../ContextMenuNormalizer.vcxproj.filters | 5 +- ContextMenuNormalizer/PopupMenus.h | 9 +++ ContextMenuNormalizer/Win11_21H1.cpp | 70 +++++++++++++++++++ ContextMenuNormalizer/Win8RP.cpp | 4 +- ContextMenuNormalizer/Win8RP.h | 8 --- 7 files changed, 91 insertions(+), 78 deletions(-) create mode 100644 ContextMenuNormalizer/PopupMenus.h create mode 100644 ContextMenuNormalizer/Win11_21H1.cpp delete mode 100644 ContextMenuNormalizer/Win8RP.h diff --git a/ContextMenuNormalizer/ContextMenuNormalizer.cpp b/ContextMenuNormalizer/ContextMenuNormalizer.cpp index c8239b8..8bddb9d 100644 --- a/ContextMenuNormalizer/ContextMenuNormalizer.cpp +++ b/ContextMenuNormalizer/ContextMenuNormalizer.cpp @@ -5,7 +5,7 @@ #include #include "ThemeEditor.h" -#include "Win8RP.h" +#include "PopupMenus.h" #pragma comment(lib, "user32.lib") #pragma comment(lib, "uxtheme.lib") @@ -137,68 +137,6 @@ void Recolorize_Menu_PopupSeparator11(int* r, int* g, int* b, int* a) { } #pragma endregion -static void prvReplace(int iXPos, int iYPos, int iSize, Pixel_t xBoarder, Pixel_t xFill, Pixel_t* pPixels) { - Pixel_t xBackground; - xBackground.bits.r = 249; - xBackground.bits.g = 249; - xBackground.bits.b = 249; - xBackground.bits.a = 255; - for (int iX = iXPos; iX < iXPos + iSize; iX++) { - for (int iY = iYPos; iY < iYPos + iSize; iY++) { - if (iX == iXPos || iY == iYPos || iX == iXPos + iSize-1 || iY == iYPos + iSize-1) { - vSetPixel(pPixels, iX, iY, iSize, xBoarder); - } - else { - vSetPixel(pPixels, iX, iY, iSize, xFill); - } - } - } - //vSetPixel(pPixels, 0, 0, iSize, xBoarder); -} - -int qwq(int iWidth, int iHeight, Pixel_t* pPixels, void* pParam) { - Pixel_t xBoarder; - Pixel_t xFill; - - xBoarder.bits.r = 249; - xBoarder.bits.g = 249; - xBoarder.bits.b = 249; - xBoarder.bits.a = 255; - - xFill.bits.r = 249; - xFill.bits.g = 249; - xFill.bits.b = 249; - xFill.bits.a = 255; - - //prvReplace(0, iWidth * 0, iWidth, xBoarder, xFill, pPixels); - //prvReplace(0, iWidth * 2, iWidth, xBoarder, xFill, pPixels); - - xBoarder.bits.r = 127; - xBoarder.bits.g = 181; - xBoarder.bits.b = 236; - xBoarder.bits.a = 255; - - xFill.bits.r = 222; - xFill.bits.g = 239; - xFill.bits.b = 255; - xFill.bits.a = 255; - - prvReplace(0, iWidth * 1, iWidth, xBoarder, xFill, pPixels); - - xBoarder.bits.r = 181; - xBoarder.bits.g = 236; - xBoarder.bits.b = 255; - xBoarder.bits.a = 127; - - xFill.bits.r = 222; - xFill.bits.g = 0; - xFill.bits.b = 0; - xFill.bits.a = 255; - prvReplace(0, iWidth * 3, iWidth, xBoarder, xFill, pPixels); - - return 1; -} - int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, @@ -235,9 +173,9 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, } else { // Win11 22H2 and after - ModifyContextMenuBitmap(L"Menu", 27, iWin8RP_PopupMenu, NULL); // The new "MENU_POPUPITEM" in use - ModifyContextMenuBitmap(L"Menu", MENU_POPUPITEM, iWin8RP_PopupMenu, NULL); - ModifyContextMenuBitmap(L"ImmersiveStart::Menu", MENU_POPUPITEM, iWin8RP_PopupMenu, NULL); + ModifyContextMenuBitmap(L"Menu", 27, iWin11_21H1_PopupMenu, NULL); // The new "MENU_POPUPITEM" in use + ModifyContextMenuBitmap(L"Menu", MENU_POPUPITEM, iWin11_21H1_PopupMenu, NULL); + ModifyContextMenuBitmap(L"ImmersiveStart::Menu", MENU_POPUPITEM, iWin11_21H1_PopupMenu, NULL); } return 0; diff --git a/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj b/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj index 1894acc..e9654c3 100644 --- a/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj +++ b/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj @@ -140,6 +140,7 @@ + @@ -152,7 +153,7 @@ - + diff --git a/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj.filters b/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj.filters index 56e5239..c34e7a9 100644 --- a/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj.filters +++ b/ContextMenuNormalizer/ContextMenuNormalizer.vcxproj.filters @@ -24,6 +24,9 @@ Source Files + + Source Files + @@ -42,7 +45,7 @@ Header Files - + Header Files diff --git a/ContextMenuNormalizer/PopupMenus.h b/ContextMenuNormalizer/PopupMenus.h new file mode 100644 index 0000000..c25f9f0 --- /dev/null +++ b/ContextMenuNormalizer/PopupMenus.h @@ -0,0 +1,9 @@ +#ifndef __INCLUDE_WIN8RP_H_ +#define __INCLUDE_WIN8RP_H_ + +#include "ThemeEditor.h" + +int iWin8_RP_PopupMenu(int iWidth, int iHeight, Pixel_t* pPixels, void* pParam); +int iWin11_21H1_PopupMenu(int iWidth, int iHeight, Pixel_t* pPixels, void* pParam); + +#endif // __INCLUDE_WIN8RP_H_ \ No newline at end of file diff --git a/ContextMenuNormalizer/Win11_21H1.cpp b/ContextMenuNormalizer/Win11_21H1.cpp new file mode 100644 index 0000000..2de7b6d --- /dev/null +++ b/ContextMenuNormalizer/Win11_21H1.cpp @@ -0,0 +1,70 @@ +#include "PopupMenus.h" +#include "ThemeEditor.h" + +Pixel_t apxCorner[4][4] = { + {0xFFF9F9F9, 0xFFCAE1F2, 0xFF449BDE, 0xFF057BD5}, + {0xFFCAE1F2, 0xFF097DD6, 0xFF0078D4, 0xFF0078D4}, + {0xFF449BDE, 0xFF0078D4, 0xFF0078D4, 0xFF0078D4}, + {0xFF057BD5, 0xFF0078D4, 0xFF0078D4, 0xFF0078D4} +}; + +static void prvPaint(int iXPos, int iYPos, int iSize, Pixel_t* pPixels) { + // Top-Left + for (int iX = 0; iX < 4; iX++) { + for (int iY = 0; iY < 4; iY++) { + vSetPixel(pPixels, iXPos + iX, iYPos + iY, iSize, apxCorner[iX][iY]); + } + } + + // Top-Right + for (int iX = 0; iX < 4; iX++) { + for (int iY = 0; iY < 4; iY++) { + vSetPixel(pPixels, iXPos + iSize - iX - 1, iYPos + iY, iSize, apxCorner[iX][iY]); + } + } + + // Bottom-Left + for (int iX = 0; iX < 4; iX++) { + for (int iY = 0; iY < 4; iY++) { + vSetPixel(pPixels, iXPos + iX, iYPos + iSize - iY - 1, iSize, apxCorner[iX][iY]); + } + } + + // Bottom-Right + for (int iX = 0; iX < 4; iX++) { + for (int iY = 0; iY < 4; iY++) { + vSetPixel(pPixels, iXPos + iSize - iX - 1, iYPos + iSize - iY - 1, iSize, apxCorner[iX][iY]); + } + } +} + +static void prvFill(int iXPos, int iYPos, int iSize, Pixel_t xFill, Pixel_t* pPixels) { + for (int iX = iXPos; iX < iXPos + iSize; iX++) { + for (int iY = iYPos; iY < iYPos + iSize; iY++) { + vSetPixel(pPixels, iX, iY, iSize, xFill); + } + } +} + +int iWin11_21H1_PopupMenu(int iWidth, int iHeight, Pixel_t* pPixels, void* pParam) { + Pixel_t xFill; + + xFill.bits.r = 249; + xFill.bits.g = 249; + xFill.bits.b = 249; + xFill.bits.a = 255; + + prvFill(0, iWidth * 0, iWidth, xFill, pPixels); + prvFill(0, iWidth * 2, iWidth, xFill, pPixels); + prvFill(0, iWidth * 3, iWidth, xFill, pPixels); + + xFill.bits.r = 0; + xFill.bits.g = 120; + xFill.bits.b = 212; + xFill.bits.a = 255; + + prvFill(0, iWidth * 1, iWidth, xFill, pPixels); + prvPaint(0, iWidth * 1, iWidth, pPixels); + + return 1; +} \ No newline at end of file diff --git a/ContextMenuNormalizer/Win8RP.cpp b/ContextMenuNormalizer/Win8RP.cpp index 0ce231b..1e8005c 100644 --- a/ContextMenuNormalizer/Win8RP.cpp +++ b/ContextMenuNormalizer/Win8RP.cpp @@ -1,4 +1,4 @@ -#include "Win8RP.h" +#include "PopupMenus.h" #include "ThemeEditor.h" static void prvReplace(int iXPos, int iYPos, int iSize, Pixel_t xBoarder, Pixel_t xFill, Pixel_t* pPixels) { @@ -14,7 +14,7 @@ static void prvReplace(int iXPos, int iYPos, int iSize, Pixel_t xBoarder, Pixel_ } } -int iWin8RP_PopupMenu(int iWidth, int iHeight, Pixel_t* pPixels, void* pParam) { +int iWin8_RP_PopupMenu(int iWidth, int iHeight, Pixel_t* pPixels, void* pParam) { Pixel_t xBoarder; Pixel_t xFill; diff --git a/ContextMenuNormalizer/Win8RP.h b/ContextMenuNormalizer/Win8RP.h deleted file mode 100644 index ee7640b..0000000 --- a/ContextMenuNormalizer/Win8RP.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __INCLUDE_WIN8RP_H_ -#define __INCLUDE_WIN8RP_H_ - -#include "ThemeEditor.h" - -int iWin8RP_PopupMenu(int iWidth, int iHeight, Pixel_t* pPixels, void* pParam); - -#endif // __INCLUDE_WIN8RP_H_ \ No newline at end of file