diff --git a/ExplorerPatcher/lvt.c b/ExplorerPatcher/lvt.c index ecf2072..4b4aae5 100644 --- a/ExplorerPatcher/lvt.c +++ b/ExplorerPatcher/lvt.c @@ -517,6 +517,79 @@ void LVT_StartUI_EnableRoundedCorners(HWND hWnd, DWORD dwReceipe, DWORD dwPos, H } } +void LVT_StartDocked_120DPIHack(int maxHeight) +{ + HRESULT hr = S_OK; + Windows_UI_Xaml_IDependencyObject* pRootDependencyObject = NULL; + if (SUCCEEDED(hr)) + { + HSTRING_HEADER hshWindowStatics; + HSTRING hsWindowStatics = NULL; + hr = WindowsCreateStringReference(L"Windows.UI.Xaml.Window", 22, &hshWindowStatics, &hsWindowStatics); + if (SUCCEEDED(hr) && hsWindowStatics) + { + Windows_UI_Xaml_IWindowStatics* pWindowStatics = NULL; + hr = RoGetActivationFactory(hsWindowStatics, &IID_Windows_UI_Xaml_IWindowStatics, &pWindowStatics); + if (SUCCEEDED(hr)) + { + Windows_UI_Xaml_IWindow* pWindow = NULL; + hr = pWindowStatics->lpVtbl->get_Current(pWindowStatics, &pWindow); + if (SUCCEEDED(hr)) + { + IInspectable* pUIElement = NULL; + hr = pWindow->lpVtbl->get_Content(pWindow, &pUIElement); + if (SUCCEEDED(hr)) + { + hr = pUIElement->lpVtbl->QueryInterface(pUIElement, &IID_Windows_UI_Xaml_IDependencyObject, &pRootDependencyObject); + + pUIElement->lpVtbl->Release(pUIElement); + } + pWindow->lpVtbl->Release(pWindow); + } + pWindowStatics->lpVtbl->Release(pWindowStatics); + } + WindowsDeleteString(hsWindowStatics); + } + } + if (pRootDependencyObject) + { + HSTRING_HEADER hshVisualTreeHelperStatics; + HSTRING hsVisualTreeHelperStatics = NULL; + hr = WindowsCreateStringReference(L"Windows.UI.Xaml.Media.VisualTreeHelper", 38, &hshVisualTreeHelperStatics, &hsVisualTreeHelperStatics); + if (SUCCEEDED(hr) && hsVisualTreeHelperStatics) + { + Windows_UI_Xaml_IVisualTreeHelperStatics* pVisualTreeHelperStatics = NULL; + hr = RoGetActivationFactory(hsVisualTreeHelperStatics, &IID_Windows_UI_Xaml_IVisualTreeHelperStatics, &pVisualTreeHelperStatics); + if (SUCCEEDED(hr)) + { + Windows_UI_Xaml_IDependencyObject* pStartSizingFrame = LVT_FindChildByClassName(pRootDependencyObject, pVisualTreeHelperStatics, L"StartDocked.StartSizingFrame", NULL); + if (pStartSizingFrame) + { + Windows_UI_Xaml_IUIElement* pIUIElement = NULL; + pStartSizingFrame->lpVtbl->QueryInterface(pStartSizingFrame, &IID_Windows_UI_Xaml_IUIElement, &pIUIElement); + if (pIUIElement) + { + Windows_UI_Xaml_IFrameworkElement* pFrameworkElement = NULL; + pStartSizingFrame->lpVtbl->QueryInterface(pStartSizingFrame, &IID_Windows_UI_Xaml_IFrameworkElement, &pFrameworkElement); + if (pFrameworkElement) + { + pIUIElement->lpVtbl->put_Visibility(pIUIElement, Windows_UI_Xaml_Visibility_Collapsed); + pFrameworkElement->lpVtbl->put_MaxHeight(pFrameworkElement, maxHeight); + pIUIElement->lpVtbl->put_Visibility(pIUIElement, Windows_UI_Xaml_Visibility_Visible); + pFrameworkElement->lpVtbl->Release(pFrameworkElement); + } + pIUIElement->lpVtbl->Release(pIUIElement); + } + pStartSizingFrame->lpVtbl->Release(pStartSizingFrame); + } + pVisualTreeHelperStatics->lpVtbl->Release(pVisualTreeHelperStatics); + } + WindowsDeleteString(hsVisualTreeHelperStatics); + } + pRootDependencyObject->lpVtbl->Release(pRootDependencyObject); + } +} + // Reference: https://www.reddit.com/r/Windows11/comments/p1ksou/this_is_not_a_concept_microsoft_in_windows_11/ void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply, RECT* rect) { @@ -604,6 +677,20 @@ void LVT_StartDocked_DisableRecommendedSection(HWND hWnd, BOOL bApply, RECT* rec 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; + if (bApply && dpi == 120) + { + HANDLE hRealThreadHandle = NULL; + DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hRealThreadHandle, THREAD_SET_CONTEXT, FALSE, 0); + if (hRealThreadHandle) + { + QueueUserAPC(LVT_StartDocked_120DPIHack, hRealThreadHandle, 826); + CloseHandle(hRealThreadHandle); + } + } + else if (pFrameworkElement) + { + pFrameworkElement->lpVtbl->put_MaxHeight(pFrameworkElement, 726.0); + } if (pFrameworkElement) { pFrameworkElement->lpVtbl->Release(pFrameworkElement); diff --git a/ExplorerPatcher/lvt.h b/ExplorerPatcher/lvt.h index fc1a2f0..49691b6 100644 --- a/ExplorerPatcher/lvt.h +++ b/ExplorerPatcher/lvt.h @@ -6,6 +6,7 @@ #include #include #include +#include #define LVT_LOC_NONE 0 #define LVT_LOC_BOTTOMLEFT 1 @@ -460,10 +461,12 @@ typedef struct Windows_UI_Xaml_IFrameworkElement_Vtbl __RPC__in Windows_UI_Xaml_IFrameworkElement* This); HRESULT(STDMETHODCALLTYPE* get_MaxHeight)( - __RPC__in Windows_UI_Xaml_IFrameworkElement* This); + __RPC__in Windows_UI_Xaml_IFrameworkElement* This, + /* [out] */ __RPC__out DOUBLE* value); HRESULT(STDMETHODCALLTYPE* put_MaxHeight)( - __RPC__in Windows_UI_Xaml_IFrameworkElement* This); + __RPC__in Windows_UI_Xaml_IFrameworkElement* This, + /* [in] */ __RPC__in DOUBLE value); HRESULT(STDMETHODCALLTYPE* get_HorizontalAlignment)( __RPC__in Windows_UI_Xaml_IFrameworkElement* This);