diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 7b5064c..111b6b5 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -5636,6 +5636,7 @@ HINSTANCE explorer_ShellExecuteW( #pragma region "Change language UI style" +#ifdef _WIN64 DEFINE_GUID(CLSID_InputSwitchControl, 0xB9BC2A50, 0x43C3, 0x41AA, 0xa0, 0x86, @@ -5685,6 +5686,15 @@ typedef struct IInputSwitchControlVtbl IInputSwitchControl* This, /* [in] */ void* pInputSwitchCallback); + HRESULT(STDMETHODCALLTYPE* ShowInputSwitch)( + IInputSwitchControl* This, + /* [in] */ RECT* lpRect); + + HRESULT(STDMETHODCALLTYPE* GetProfileCount)( + IInputSwitchControl* This, + /* [in] */ unsigned int* pOutNumberOfProfiles, + /* [in] */ int* a3); + // ... END_INTERFACE @@ -5701,6 +5711,39 @@ HRESULT CInputSwitchControl_InitHook(IInputSwitchControl* _this, unsigned int dw return CInputSwitchControl_InitFunc(_this, dwIMEStyle ? dwIMEStyle : dwOriginalIMEStyle); } +HRESULT (*CInputSwitchControl_ShowInputSwitchFunc)(IInputSwitchControl*, RECT*); +HRESULT CInputSwitchControl_ShowInputSwitchHook(IInputSwitchControl* _this, RECT* lpRect) +{ + if (!dwIMEStyle) // impossible case (this is not called for the Windows 11 language switcher), but just in case + { + return CInputSwitchControl_ShowInputSwitchFunc(_this, lpRect); + } + + unsigned int dwNumberOfProfiles = 0; + int a3 = 0; + _this->lpVtbl->GetProfileCount(_this, &dwNumberOfProfiles, &a3); + + HWND hWndTaskbar = FindWindowW(L"Shell_TrayWnd", NULL); + + UINT dpiX = 96, dpiY = 96; + HRESULT hr = GetDpiForMonitor( + MonitorFromWindow(hWndTaskbar, MONITOR_DEFAULTTOPRIMARY), + MDT_DEFAULT, + &dpiX, + &dpiY + ); + double dpix = dpiX / 96.0; + double dpiy = dpiY / 96.0; + + //printf("RECT %d %d %d %d - %d %d\n", lpRect->left, lpRect->right, lpRect->top, lpRect->bottom, dwNumberOfProfiles, a3); + if (dwIMEStyle == 4) + { + lpRect->right -= (UINT)((double)(300.0 * dpix)) - (lpRect->right - lpRect->left); + } + + return CInputSwitchControl_ShowInputSwitchFunc(_this, lpRect); +} + HRESULT explorer_CoCreateInstanceHook( REFCLSID rclsid, LPUNKNOWN pUnkOuter, @@ -5722,6 +5765,8 @@ HRESULT explorer_CoCreateInstanceHook( DWORD flOldProtect = 0; if (VirtualProtect(pInputSwitchControl->lpVtbl, sizeof(IInputSwitchControlVtbl), PAGE_EXECUTE_READWRITE, &flOldProtect)) { + CInputSwitchControl_ShowInputSwitchFunc = pInputSwitchControl->lpVtbl->ShowInputSwitch; + pInputSwitchControl->lpVtbl->ShowInputSwitch = CInputSwitchControl_ShowInputSwitchHook; CInputSwitchControl_InitFunc = pInputSwitchControl->lpVtbl->Init; pInputSwitchControl->lpVtbl->Init = CInputSwitchControl_InitHook; VirtualProtect(pInputSwitchControl->lpVtbl, sizeof(IInputSwitchControlVtbl), flOldProtect, &flOldProtect); @@ -5783,6 +5828,7 @@ HRESULT explorer_CoCreateInstanceHook( } return CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv); } +#endif #pragma endregion diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index 54def6e..ebd2496 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -130,13 +130,10 @@ ;x 1 Windows 7 "UseWin32BatteryFlyout"=dword:00000000 [HKEY_CURRENT_USER\Software\ExplorerPatcher] -;c 6 Language switcher * +;c 3 Language switcher * ;x 0 Windows 11 (default) -;x 1 Windows 10 -;x 2 "LOGONUI" -;x 3 "UAC" -;x 4 "SETTINGSPANE" -;x 5 "OOBE" +;x 1 Windows 10 (with link to "Language Preferences") +;x 4 Windows 10 "IMEStyle"=dword:00000000