From f62c53253c20d78df38228feac5a87597230b29b Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Sun, 12 Nov 2023 15:26:12 +0700 Subject: [PATCH] File Explorer: Restored "Apply Mica" functionality on 22H2 --- ExplorerPatcher-L10N | 2 +- ExplorerPatcher/dllmain.c | 16 ++++++++--- ep_gui/GUI.c | 7 ++--- ep_gui/resources/EPSettingsResources.h | 37 ++++++++++++-------------- ep_gui/resources/lang/ep_gui.en-US.rc | 5 +--- ep_gui/resources/settings.reg | 37 ++++++++++++-------------- ep_gui/resources/settings10.reg | 16 +++++------ 7 files changed, 60 insertions(+), 60 deletions(-) diff --git a/ExplorerPatcher-L10N b/ExplorerPatcher-L10N index 4a7eaa5..414761f 160000 --- a/ExplorerPatcher-L10N +++ b/ExplorerPatcher-L10N @@ -1 +1 @@ -Subproject commit 4a7eaa5ecb493a49ef33a206681de13fa6b413ec +Subproject commit 414761f62e8bc71f941a2e970432fff682d534eb diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 28cb4db..0a543c7 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -3898,7 +3898,7 @@ HWND WINAPI explorerframe_SHCreateWorkerWindowHook( { SetWindowSubclass(hWndParent, HideIconAndTitleInExplorerSubClass, HideIconAndTitleInExplorerSubClass, 0); } - if (bMicaEffectOnTitlebar) + if ((!bIsExplorerProcess || dwFileExplorerCommandUI == 2) && bMicaEffectOnTitlebar) { SetWindowSubclass(result, ExplorerMicaTitlebarSubclassProc, ExplorerMicaTitlebarSubclassProc, bMicaEffectOnTitlebar); } @@ -3906,12 +3906,20 @@ HWND WINAPI explorerframe_SHCreateWorkerWindowHook( { SetWindowSubclass(hWndParent, HideExplorerSearchBarSubClass, HideExplorerSearchBarSubClass, 0); } - if (IsWindows11Version22H2OrHigher()) + if (bIsExplorerProcess && dwFileExplorerCommandUI != 0 && IsWindows11Version22H2OrHigher()) { // Fix initial title bar style after disabling TIFE // If we don't do this, it will only fix itself once the user changes the system color scheme or toggling transparency effects - BOOL value = ShouldAppsUseDarkMode(); - DwmSetWindowAttribute(hWndParent, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(BOOL)); + if (!ShouldAppsUseDarkMode) + { + HANDLE hUxtheme = LoadLibraryW(L"uxtheme.dll"); + ShouldAppsUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)0x84); + } + if (ShouldAppsUseDarkMode) + { + BOOL value = ShouldAppsUseDarkMode(); + DwmSetWindowAttribute(hWndParent, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(BOOL)); + } } } return result; diff --git a/ep_gui/GUI.c b/ep_gui/GUI.c index 47cf8b6..9e5eedb 100644 --- a/ep_gui/GUI.c +++ b/ep_gui/GUI.c @@ -467,7 +467,8 @@ LSTATUS GUI_Internal_RegSetValueExW( } else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_FileExplorerCommandUI")) { - if (!*(DWORD*)lpData) + DWORD dwValue = *(DWORD*)lpData; + if (dwValue == 0 || dwValue == 3 || dwValue == 4) // This no longer has any effect on 22H2 { RegDeleteTreeW(HKEY_CURRENT_USER, L"SOFTWARE\\Classes\\CLSID\\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}"); } @@ -724,12 +725,12 @@ LSTATUS GUI_Internal_RegQueryValueExW( } else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_FileExplorerCommandUI")) { - if (RegGetValueW(HKEY_CURRENT_USER, L"SOFTWARE\\Classes\\CLSID\\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\\InProcServer32", L"", RRF_RT_REG_SZ, NULL, NULL, NULL) != ERROR_SUCCESS) + /*if (RegGetValueW(HKEY_CURRENT_USER, L"SOFTWARE\\Classes\\CLSID\\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\\InProcServer32", L"", RRF_RT_REG_SZ, NULL, NULL, NULL) != ERROR_SUCCESS) { *lpcbData = sizeof(DWORD); *(DWORD*)lpData = 0; return ERROR_SUCCESS; - } + }*/ return RegQueryValueExW(hKey, L"FileExplorerCommandUI", lpReserved, lpType, lpData, lpcbData); } else if (!wcscmp(lpValueName, L"Virtualized_" _T(EP_CLSID) L"_RegisterAsShellExtension")) diff --git a/ep_gui/resources/EPSettingsResources.h b/ep_gui/resources/EPSettingsResources.h index 72fc4bf..9f57c5e 100644 --- a/ep_gui/resources/EPSettingsResources.h +++ b/ep_gui/resources/EPSettingsResources.h @@ -101,26 +101,23 @@ #define IDS_EXP_CLASSICDRIVEGROUP 1208 #define IDS_EXP_CTRLINTF 1209 #define IDS_EXP_CTRLINTF_0_W11 1210 -#define IDS_EXP_CTRLINTF_0_W10 1211 -#define IDS_EXP_CTRLINTF_1_W11 1212 -#define IDS_EXP_CTRLINTF_2 1213 -#define IDS_EXP_NEWWINDOWS 1214 -#define IDS_EXP_IMMERSIVEMENUS 1215 -#define IDS_EXP_DISABLENAVBAR 1216 -#define IDS_EXP_DISABLESEARCHBAR 1217 -#define IDS_EXP_SHRINKADDRESSBAR 1218 -#define IDS_EXP_HIDESEARCHBAR 1219 -#define IDS_EXP_TITLEBAR 1220 -#define IDS_EXP_TITLEBAR_0 1221 -#define IDS_EXP_TITLEBAR_1 1222 -#define IDS_EXP_TITLEBAR_2 1223 -#define IDS_EXP_TITLEBAR_3 1224 -#define IDS_EXP_MICA 1225 -#define IDS_EXP_MICA_0 1226 -#define IDS_EXP_MICA_1 1227 -#define IDS_EXP_MICA_2 1228 -#define IDS_EXP_CTRLINTF_3 1229 -#define IDS_EXP_CTRLINTF_4 1230 +#define IDS_EXP_CTRLINTF_3 1211 +#define IDS_EXP_CTRLINTF_4 1212 +#define IDS_EXP_CTRLINTF_0_W10 1213 +#define IDS_EXP_CTRLINTF_1_W11 1214 +#define IDS_EXP_CTRLINTF_2 1215 +#define IDS_EXP_NEWWINDOWS 1216 +#define IDS_EXP_IMMERSIVEMENUS 1217 +#define IDS_EXP_DISABLENAVBAR 1218 +#define IDS_EXP_DISABLESEARCHBAR 1219 +#define IDS_EXP_SHRINKADDRESSBAR 1220 +#define IDS_EXP_HIDESEARCHBAR 1221 +#define IDS_EXP_TITLEBAR 1222 +#define IDS_EXP_TITLEBAR_0 1223 +#define IDS_EXP_TITLEBAR_1 1224 +#define IDS_EXP_TITLEBAR_2 1225 +#define IDS_EXP_TITLEBAR_3 1226 +#define IDS_EXP_MICA 1227 #define IDS_START 1301 #define IDS_START_STYLE 1302 diff --git a/ep_gui/resources/lang/ep_gui.en-US.rc b/ep_gui/resources/lang/ep_gui.en-US.rc index 2c837bb..f253107 100644 --- a/ep_gui/resources/lang/ep_gui.en-US.rc +++ b/ep_gui/resources/lang/ep_gui.en-US.rc @@ -153,10 +153,7 @@ BEGIN IDS_EXP_TITLEBAR_1 "Hide title, show icon" IDS_EXP_TITLEBAR_2 "Hide icon, show title" IDS_EXP_TITLEBAR_3 "Hide icon and title" - IDS_EXP_MICA "Apply Mica effect on these areas" - IDS_EXP_MICA_0 "Let File Explorer decide (default)" - IDS_EXP_MICA_1 "Title bar, command bar and navigation bar" - IDS_EXP_MICA_2 "Nowhere" + IDS_EXP_MICA "Apply Mica effect to the navigation bar of Windows 7 Explorer windows" IDS_START "Start menu" diff --git a/ep_gui/resources/settings.reg b/ep_gui/resources/settings.reg index cb57f05..18d71a8 100644 --- a/ep_gui/resources/settings.reg +++ b/ep_gui/resources/settings.reg @@ -207,41 +207,38 @@ [HKEY_CURRENT_USER\Software\ExplorerPatcher] ;c 4 %R:1209% * ;x 0 %R:1210% -;x 4 %R:1230% -;x 1 %R:1212% -;x 2 %R:1213% +;x 4 %R:1212% +;x 1 %R:1214% +;x 2 %R:1215% ;"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_FileExplorerCommandUI"=dword:00000000 -;t %R:1214% +;t %R:1216% [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;i %R:1215% ** +;i %R:1217% ** "DisableImmersiveContextMenu"=dword:00000000 [-HKEY_CURRENT_USER\Software\Classes\CLSID\{056440FD-8568-48e7-A632-72157243B55B}\InprocServer32] -;d %R:1216% ** +;d %R:1218% ** @="" [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;b %R:1217% +;b %R:1219% ;"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_DisableModernSearchBar"=dword:00000000 [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;b %R:1218% ** +;b %R:1220% ** "ShrinkExplorerAddressBar"=dword:00000000 [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;b %R:1219% ** +;b %R:1221% ** "HideExplorerSearchBar"=dword:00000000 ;s Explorer_TitlebarSection !IsWindows11Version22H2OrHigher [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;c 4 %R:1220% -;x 0 %R:1221% -;x 1 %R:1222% -;x 2 %R:1223% -;x 3 %R:1224% +;c 4 %R:1222% +;x 0 %R:1223% +;x 1 %R:1224% +;x 2 %R:1225% +;x 3 %R:1226% "HideIconAndTitleInExplorer"=dword:00000000 -[HKEY_CURRENT_USER\Software\ExplorerPatcher] -;c 3 %R:1225% -;x 0 %R:1226% -;x 1 %R:1227% -;x 2 %R:1228% -"MicaEffectOnTitlebar"=dword:00000000 ;g Explorer_TitlebarSection +[HKEY_CURRENT_USER\Software\ExplorerPatcher] +;b %R:1227% ** +"MicaEffectOnTitlebar"=dword:00000000 diff --git a/ep_gui/resources/settings10.reg b/ep_gui/resources/settings10.reg index ac23c31..68eb3d9 100644 --- a/ep_gui/resources/settings10.reg +++ b/ep_gui/resources/settings10.reg @@ -151,24 +151,24 @@ "UseClassicDriveGrouping"=dword:00000000 [HKEY_CURRENT_USER\Software\ExplorerPatcher] ;c 2 %R:1209% -;x 0 %R:1211% -;x 2 %R:1213% +;x 0 %R:1213% +;x 2 %R:1215% "FileExplorerCommandUI"=dword:00000000 -;t %R:1214% +;t %R:1216% [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;i %R:1215% ** +;i %R:1217% ** "DisableImmersiveContextMenu"=dword:00000000 [-HKEY_CURRENT_USER\Software\Classes\CLSID\{056440FD-8568-48e7-A632-72157243B55B}\InprocServer32] -;d %R:1216% ** +;d %R:1218% ** @="" [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;b %R:1217% +;b %R:1219% ;"Virtualized_{D17F1E1A-5919-4427-8F89-A1A8503CA3EB}_DisableModernSearchBar"=dword:00000000 [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;b %R:1218% ** +;b %R:1220% ** "ShrinkExplorerAddressBar"=dword:00000000 [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;b %R:1219% ** +;b %R:1221% ** "HideExplorerSearchBar"=dword:00000000 ;p 2 ;b Mica effect on title bar