diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index d3e1705..a5fdf0c 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -9252,6 +9252,17 @@ void StartMenu_LoadSettings(BOOL bRestartIfChanged) exit(0); } dwStartShowClassicMode = dwVal; + + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("TaskbarAl"), + 0, + NULL, + &dwTaskbarAl, + &dwSize + ); + RegCloseKey(hKey); } @@ -9517,6 +9528,7 @@ LSTATUS StartUI_RegCloseKey(HKEY hKey) int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) { + WCHAR wszDebug[MAX_PATH]; BOOL bIsWindowVisible = FALSE; HRESULT hr = IsThreadCoreWindowVisible(&bIsWindowVisible); if (SUCCEEDED(hr)) @@ -9524,11 +9536,99 @@ int StartUI_SetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw) ShowWindow(hWnd, bIsWindowVisible ? SW_SHOW : SW_HIDE); if (bIsWindowVisible && StartUI_EnableRoundedCornersApply) { - LVT_StartUI_EnableRoundedCorners(hWnd, StartUI_EnableRoundedCorners); + HWND hWndTaskbar = NULL; + if (InterlockedAdd(&dwTaskbarAl, 0)) + { + HWND hWndTemp = NULL; + + HWND hShellTray_Wnd = FindWindowExW(NULL, NULL, L"Shell_TrayWnd", NULL); + if (hShellTray_Wnd && !hWndTaskbar && MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) == MonitorFromWindow(hShellTray_Wnd, MONITOR_DEFAULTTOPRIMARY) && dwOldTaskbarAl) + { + hWndTaskbar = hShellTray_Wnd; + } + + if (!hWndTaskbar) + { + do + { + hWndTemp = FindWindowExW( + NULL, + hWndTemp, + L"Shell_SecondaryTrayWnd", + NULL + ); + if (hWndTemp && !hWndTaskbar && MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY) == MonitorFromWindow(hWndTemp, MONITOR_DEFAULTTOPRIMARY) && dwMMOldTaskbarAl) + { + hWndTaskbar = hWndTemp; + break; + } + } while (hWndTemp); + } + + if(!hWndTaskbar) + { + hWndTaskbar = hShellTray_Wnd; + } + } + MONITORINFO mi; + ZeroMemory(&mi, sizeof(MONITORINFO)); + mi.cbSize = sizeof(MONITORINFO); + GetMonitorInfoW(MonitorFromWindow(hWndTaskbar ? hWndTaskbar : hWnd, MONITOR_DEFAULTTOPRIMARY), &mi); + DWORD dwPos = 0; + RECT rcC; + if (hWndTaskbar) + { + GetWindowRect(hWndTaskbar, &rcC); + rcC.left -= mi.rcMonitor.left; + rcC.right -= mi.rcMonitor.left; + rcC.top -= mi.rcMonitor.top; + rcC.bottom -= mi.rcMonitor.top; + if (rcC.left < 5 && rcC.top > 5) + { + dwPos = TB_POS_BOTTOM; + } + else if (rcC.left < 5 && rcC.top < 5 && rcC.right > rcC.bottom) + { + dwPos = TB_POS_TOP; + } + else if (rcC.left < 5 && rcC.top < 5 && rcC.right < rcC.bottom) + { + dwPos = TB_POS_LEFT; + } + else if (rcC.left > 5 && rcC.top < 5) + { + dwPos = TB_POS_RIGHT; + } + } + RECT rc; + LVT_StartUI_EnableRoundedCorners(hWnd, StartUI_EnableRoundedCorners, dwPos, hWndTaskbar, &rc); if (!StartUI_EnableRoundedCorners) { StartUI_EnableRoundedCornersApply = FALSE; } + if (hWndTaskbar) + { + if (rcC.left < 5 && rcC.top > 5) + { + SetWindowPos(hWnd, NULL, mi.rcMonitor.left + (((mi.rcMonitor.right - mi.rcMonitor.left) - (rc.right - rc.left)) / 2), mi.rcMonitor.top, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS); + } + else if (rcC.left < 5 && rcC.top < 5 && rcC.right > rcC.bottom) + { + SetWindowPos(hWnd, NULL, mi.rcMonitor.left + (((mi.rcMonitor.right - mi.rcMonitor.left) - (rc.right - rc.left)) / 2), mi.rcMonitor.top + (rcC.bottom - rcC.top), 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS); + } + else if (rcC.left < 5 && rcC.top < 5 && rcC.right < rcC.bottom) + { + SetWindowPos(hWnd, NULL, mi.rcMonitor.left + (rcC.right - rcC.left), mi.rcMonitor.top + (((mi.rcMonitor.bottom - mi.rcMonitor.top) - (rc.bottom - rc.top)) / 2), 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS); + } + else if (rcC.left > 5 && rcC.top < 5) + { + SetWindowPos(hWnd, NULL, mi.rcMonitor.left, mi.rcMonitor.top + (((mi.rcMonitor.bottom - mi.rcMonitor.top) - (rc.bottom - rc.top)) / 2), 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS); + } + } + else + { + SetWindowPos(hWnd, NULL, mi.rcWork.left, mi.rcWork.top, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED | SWP_ASYNCWINDOWPOS); + } } } return SetWindowRgn(hWnd, hRgn, bRedraw); diff --git a/ExplorerPatcher/lvt.c b/ExplorerPatcher/lvt.c index e1614d8..4b005d6 100644 --- a/ExplorerPatcher/lvt.c +++ b/ExplorerPatcher/lvt.c @@ -92,7 +92,7 @@ Windows_UI_Xaml_IDependencyObject* LVT_FindChildByName(Windows_UI_Xaml_IDependen } // Referenece: https://www.reddit.com/r/Windows10/comments/nvcrie/windows_11_start_menu_how_to_temporary_make_your/ -void LVT_StartUI_EnableRoundedCorners(HWND hWnd, DWORD dwReceipe) +void LVT_StartUI_EnableRoundedCorners(HWND hWnd, DWORD dwReceipe, DWORD dwPos, HWND hWndTaskbar, RECT* rect) { WCHAR wszDebug[MAX_PATH]; HRESULT hr = S_OK; @@ -181,6 +181,7 @@ void LVT_StartUI_EnableRoundedCorners(HWND hWnd, DWORD dwReceipe) RECT rc; SetRect(&rc, drc.Left, drc.Top, drc.Right, drc.Bottom); SetRect(&rc, MulDiv(rc.left, dpi, 96), MulDiv(rc.top, dpi, 96), MulDiv(rc.right, dpi, 96), MulDiv(rc.bottom, dpi, 96)); + *rect = rc; HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY); MONITORINFO mi; ZeroMemory(&mi, sizeof(MONITORINFO)); @@ -259,20 +260,20 @@ void LVT_StartUI_EnableRoundedCorners(HWND hWnd, DWORD dwReceipe) { th.Left = dwReceipe ? pad : 0.0; th.Bottom = dwReceipe ? pad : 0.0; - th.Right = 0.0; - th.Top = 0.0; + th.Right = hWndTaskbar ? (dwReceipe ? pad : 0.0) : 0.0; + th.Top = hWndTaskbar ? (dwReceipe ? pad : 0.0) : 0.0; } else if (location == LVT_LOC_TOPLEFT) { th.Left = dwReceipe ? pad : 0.0; - th.Bottom = 0.0; - th.Right = 0.0; + th.Bottom = hWndTaskbar ? (dwReceipe ? pad : 0.0) : 0.0; + th.Right = hWndTaskbar ? (dwReceipe ? pad : 0.0) : 0.0; th.Top = dwReceipe ? pad : 0.0; } else if (location == LVT_LOC_TOPRIGHT) { - th.Left = 0.0; - th.Bottom = 0.0; + th.Left = hWndTaskbar ? (dwReceipe ? pad : 0.0) : 0.0; + th.Bottom = hWndTaskbar ? (dwReceipe ? pad : 0.0) : 0.0; th.Right = dwReceipe ? pad : 0.0; th.Top = dwReceipe ? pad : 0.0; } @@ -312,21 +313,21 @@ void LVT_StartUI_EnableRoundedCorners(HWND hWnd, DWORD dwReceipe) { cr.BottomLeft = 0.0; cr.BottomRight = 0.0; - cr.TopLeft = 0.0; + cr.TopLeft = hWndTaskbar ? (dwReceipe ? pad : 0.0) : 0.0; cr.TopRight = dwReceipe ? pad : 0.0; } else if (location == LVT_LOC_TOPLEFT) { - cr.BottomLeft = 0.0; + cr.BottomLeft = (hWndTaskbar && (dwPos == 2)) ? (dwReceipe ? pad : 0.0) : 0.0; cr.BottomRight = dwReceipe ? pad : 0.0; cr.TopLeft = 0.0; - cr.TopRight = 0.0; + cr.TopRight = (hWndTaskbar && (dwPos != 2)) ? (dwReceipe ? pad : 0.0) : 0.0; } else if (location == LVT_LOC_TOPRIGHT) { cr.BottomLeft = dwReceipe ? pad : 0.0; cr.BottomRight = 0.0; - cr.TopLeft = 0.0; + cr.TopLeft = hWndTaskbar ? (dwReceipe ? pad : 0.0) : 0.0; cr.TopRight = 0.0; } } diff --git a/ExplorerPatcher/lvt.h b/ExplorerPatcher/lvt.h index 24e2ecd..8815d63 100644 --- a/ExplorerPatcher/lvt.h +++ b/ExplorerPatcher/lvt.h @@ -1022,7 +1022,7 @@ Windows_UI_Xaml_IDependencyObject* LVT_FindChildByClassName(Windows_UI_Xaml_IDep Windows_UI_Xaml_IDependencyObject* LVT_FindChildByName(Windows_UI_Xaml_IDependencyObject* pRootDependencyObject, Windows_UI_Xaml_IVisualTreeHelperStatics* pVisualTreeHelperStatics, LPCWSTR pwszRefName); -void LVT_StartUI_EnableRoundedCorners(HWND, DWORD); +void LVT_StartUI_EnableRoundedCorners(HWND, DWORD, DWORD, HWND, RECT*); void LVT_StartDocked_DisableRecommendedSection(HWND, BOOL); diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index d13ffb1..498d714 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -189,6 +189,11 @@ "Start_ShowClassicMode"=dword:00000000 ;y More Start menu options in the Settings app 🡕 ;ms-settings:personalization-start +[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] +;c 2 Position on screen +;x 0 At screen edge +;x 1 Center (default) +"TaskbarAl"=dword:00000001 [HKEY_CURRENT_USER\Software\ExplorerPatcher] ;c 22 Maximum number of frequent apps to show ;x 0 None @@ -235,11 +240,6 @@ [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\StartPage] ;b Open Start in All apps by default "MakeAllAppsDefault"=dword:00000000 -[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced] -;c 2 Position on screen -;x 0 At screen edge -;x 1 Center (default) -"TaskbarAl"=dword:00000001 ;t The following settings only apply to the Windows 10 Start menu: [HKEY_CURRENT_USER\Software\ExplorerPatcher] ;b Show more tiles