mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-24 07:30:22 +01:00
Weather: Allow widget resize and move when using dev mode
This commit is contained in:
parent
73154c4537
commit
d8269f1bbe
@ -4008,6 +4008,7 @@ SIZE WINAPI PeopleButton_CalculateMinimumSizeHook(void* _this, SIZE* pSz)
|
|||||||
AcquireSRWLockExclusive(&lock_epw);
|
AcquireSRWLockExclusive(&lock_epw);
|
||||||
epw->lpVtbl->SetTerm(epw, MAX_PATH * sizeof(WCHAR), wszWeatherTerm);
|
epw->lpVtbl->SetTerm(epw, MAX_PATH * sizeof(WCHAR), wszWeatherTerm);
|
||||||
epw->lpVtbl->SetLanguage(epw, MAX_PATH * sizeof(WCHAR), wszWeatherLanguage);
|
epw->lpVtbl->SetLanguage(epw, MAX_PATH * sizeof(WCHAR), wszWeatherLanguage);
|
||||||
|
epw->lpVtbl->SetDevMode(epw, dwWeatherDevMode, FALSE);
|
||||||
UINT dpiX = 0, dpiY = 0;
|
UINT dpiX = 0, dpiY = 0;
|
||||||
HMONITOR hMonitor = MonitorFromWindow(PeopleButton_LastHWND, MONITOR_DEFAULTTOPRIMARY);
|
HMONITOR hMonitor = MonitorFromWindow(PeopleButton_LastHWND, MONITOR_DEFAULTTOPRIMARY);
|
||||||
HRESULT hr = GetDpiForMonitor(hMonitor, MDT_DEFAULT, &dpiX, &dpiY);
|
HRESULT hr = GetDpiForMonitor(hMonitor, MDT_DEFAULT, &dpiX, &dpiY);
|
||||||
@ -4066,7 +4067,6 @@ SIZE WINAPI PeopleButton_CalculateMinimumSizeHook(void* _this, SIZE* pSz)
|
|||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
epw->lpVtbl->SetWindowCornerPreference(epw, dwWeatherWindowCornerPreference);
|
epw->lpVtbl->SetWindowCornerPreference(epw, dwWeatherWindowCornerPreference);
|
||||||
epw->lpVtbl->SetDevMode(epw, dwWeatherDevMode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReleaseSRWLockExclusive(&lock_epw);
|
ReleaseSRWLockExclusive(&lock_epw);
|
||||||
@ -6071,7 +6071,7 @@ void WINAPI LoadSettings(LPARAM lParam)
|
|||||||
{
|
{
|
||||||
if (epw)
|
if (epw)
|
||||||
{
|
{
|
||||||
epw->lpVtbl->SetDevMode(epw, (LONG64)dwWeatherDevMode);
|
epw->lpVtbl->SetDevMode(epw, (LONG64)dwWeatherDevMode, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,9 +156,10 @@ HRESULT STDMETHODCALLTYPE _epw_Weather_NavigateToError(EPWeather* _this)
|
|||||||
int ch = MulDiv(MulDiv(305, dpi, 96), epw_Weather_GetTextScaleFactor(_this), 100);
|
int ch = MulDiv(MulDiv(305, dpi, 96), epw_Weather_GetTextScaleFactor(_this), 100);
|
||||||
RECT rc;
|
RECT rc;
|
||||||
GetWindowRect(_this->hWnd, &rc);
|
GetWindowRect(_this->hWnd, &rc);
|
||||||
if (rc.bottom - rc.top != ch)
|
int w = MulDiv(MulDiv(EP_WEATHER_WIDTH, GetDpiForWindow(_this->hWnd), 96), epw_Weather_GetTextScaleFactor(_this), 100);
|
||||||
|
if ((rc.bottom - rc.top != ch) || (rc.right - rc.left != w))
|
||||||
{
|
{
|
||||||
SetWindowPos(_this->hWnd, NULL, 0, 0, rc.right - rc.left, ch, SWP_NOMOVE | SWP_NOSENDCHANGING);
|
SetWindowPos(_this->hWnd, NULL, 0, 0, w, ch, SWP_NOMOVE | SWP_NOSENDCHANGING);
|
||||||
HWND hNotifyWnd = InterlockedAdd64(&_this->hNotifyWnd, 0);
|
HWND hNotifyWnd = InterlockedAdd64(&_this->hNotifyWnd, 0);
|
||||||
if (hNotifyWnd)
|
if (hNotifyWnd)
|
||||||
{
|
{
|
||||||
@ -254,7 +255,8 @@ HRESULT STDMETHODCALLTYPE _ep_weather_ReboundBrowser(EPWeather* _this, LONG64 dw
|
|||||||
{
|
{
|
||||||
UINT dpi = GetDpiForWindow(_this->hWnd);
|
UINT dpi = GetDpiForWindow(_this->hWnd);
|
||||||
RECT bounds;
|
RECT bounds;
|
||||||
if (dwType)
|
DWORD dwDevMode = InterlockedAdd64(&_this->dwDevMode, 0);
|
||||||
|
if (dwType || dwDevMode)
|
||||||
{
|
{
|
||||||
GetClientRect(_this->hWnd, &bounds);
|
GetClientRect(_this->hWnd, &bounds);
|
||||||
}
|
}
|
||||||
@ -511,9 +513,10 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2Exec
|
|||||||
ch = MulDiv(MulDiv(ch, dpi, 96), epw_Weather_GetTextScaleFactor(_this), 100);
|
ch = MulDiv(MulDiv(ch, dpi, 96), epw_Weather_GetTextScaleFactor(_this), 100);
|
||||||
RECT rc;
|
RECT rc;
|
||||||
GetWindowRect(_this->hWnd, &rc);
|
GetWindowRect(_this->hWnd, &rc);
|
||||||
if (rc.bottom - rc.top != ch)
|
int w = MulDiv(MulDiv(EP_WEATHER_WIDTH, GetDpiForWindow(_this->hWnd), 96), epw_Weather_GetTextScaleFactor(_this), 100);
|
||||||
|
if ((rc.bottom - rc.top != ch) || (rc.right - rc.left != w))
|
||||||
{
|
{
|
||||||
SetWindowPos(_this->hWnd, NULL, 0, 0, rc.right - rc.left, ch, SWP_NOMOVE | SWP_NOSENDCHANGING);
|
SetWindowPos(_this->hWnd, NULL, 0, 0, w, ch, SWP_NOMOVE | SWP_NOSENDCHANGING);
|
||||||
_ep_weather_ReboundBrowser(_this, FALSE);
|
_ep_weather_ReboundBrowser(_this, FALSE);
|
||||||
HWND hNotifyWnd = InterlockedAdd64(&_this->hNotifyWnd, 0);
|
HWND hNotifyWnd = InterlockedAdd64(&_this->hNotifyWnd, 0);
|
||||||
if (hNotifyWnd)
|
if (hNotifyWnd)
|
||||||
@ -831,6 +834,14 @@ LRESULT CALLBACK epw_Weather_WindowProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPA
|
|||||||
pCoreWebView2Settings6->lpVtbl->put_AreBrowserAcceleratorKeysEnabled(pCoreWebView2Settings6, wParam);
|
pCoreWebView2Settings6->lpVtbl->put_AreBrowserAcceleratorKeysEnabled(pCoreWebView2Settings6, wParam);
|
||||||
pCoreWebView2Settings6->lpVtbl->put_AreDefaultScriptDialogsEnabled(pCoreWebView2Settings6, wParam);
|
pCoreWebView2Settings6->lpVtbl->put_AreDefaultScriptDialogsEnabled(pCoreWebView2Settings6, wParam);
|
||||||
pCoreWebView2Settings6->lpVtbl->Release(pCoreWebView2Settings6);
|
pCoreWebView2Settings6->lpVtbl->Release(pCoreWebView2Settings6);
|
||||||
|
SetLastError(0);
|
||||||
|
LONG dwStyle = GetWindowLongW(_this->hWnd, GWL_STYLE);
|
||||||
|
if (!GetLastError())
|
||||||
|
{
|
||||||
|
if (wParam) dwStyle |= WS_SIZEBOX;
|
||||||
|
else dwStyle &= ~WS_SIZEBOX;
|
||||||
|
SetWindowLong(_this->hWnd, GWL_STYLE, dwStyle);
|
||||||
|
}
|
||||||
PostMessageW(_this->hWnd, EP_WEATHER_WM_FETCH_DATA, 0, 0);
|
PostMessageW(_this->hWnd, EP_WEATHER_WM_FETCH_DATA, 0, 0);
|
||||||
}
|
}
|
||||||
pCoreWebView2Settings->lpVtbl->Release(pCoreWebView2Settings);
|
pCoreWebView2Settings->lpVtbl->Release(pCoreWebView2Settings);
|
||||||
@ -846,8 +857,13 @@ LRESULT CALLBACK epw_Weather_WindowProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPA
|
|||||||
{
|
{
|
||||||
if (IsWindowVisible(hWnd))
|
if (IsWindowVisible(hWnd))
|
||||||
{
|
{
|
||||||
|
LONG64 dwDevMode = InterlockedAdd64(&_this->dwDevMode, 0);
|
||||||
WINDOWPOS* pwp = (WINDOWPOS*)lParam;
|
WINDOWPOS* pwp = (WINDOWPOS*)lParam;
|
||||||
pwp->flags |= SWP_NOMOVE | SWP_NOSIZE;
|
pwp->flags |= (!dwDevMode ? (SWP_NOMOVE | SWP_NOSIZE) : 0);
|
||||||
|
if (dwDevMode)
|
||||||
|
{
|
||||||
|
_ep_weather_ReboundBrowser(_this, TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1047,10 +1063,13 @@ HRESULT STDMETHODCALLTYPE epw_Weather_SetWindowCornerPreference(EPWeather* _this
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE epw_Weather_SetDevMode(EPWeather* _this, LONG64 dwDevMode)
|
HRESULT STDMETHODCALLTYPE epw_Weather_SetDevMode(EPWeather* _this, LONG64 dwDevMode, LONG64 bRefresh)
|
||||||
{
|
{
|
||||||
InterlockedExchange64(&_this->dwDevMode, dwDevMode);
|
InterlockedExchange64(&_this->dwDevMode, dwDevMode);
|
||||||
|
if (bRefresh)
|
||||||
|
{
|
||||||
PostMessageW(_this->hWnd, EP_WEATHER_WM_SETDEVMODE, dwDevMode, 0);
|
PostMessageW(_this->hWnd, EP_WEATHER_WM_SETDEVMODE, dwDevMode, 0);
|
||||||
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1093,7 +1112,8 @@ DWORD WINAPI epw_Weather_MainThread(EPWeather* _this)
|
|||||||
//goto cleanup;
|
//goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
_this->hWnd = CreateWindowExW(0, _T(EPW_WEATHER_CLASSNAME), L"", WS_OVERLAPPED | WS_CAPTION, _this->rc.left, _this->rc.top, _this->rc.right - _this->rc.left, _this->rc.bottom - _this->rc.top, NULL, NULL, epw_hModule, _this); // 1030, 630
|
DWORD dwDevMode = InterlockedAdd64(&_this->dwDevMode, 0);
|
||||||
|
_this->hWnd = CreateWindowExW(0, _T(EPW_WEATHER_CLASSNAME), L"", WS_OVERLAPPED | WS_CAPTION | (dwDevMode ? WS_SIZEBOX : 0), _this->rc.left, _this->rc.top, _this->rc.right - _this->rc.left, _this->rc.bottom - _this->rc.top, NULL, NULL, epw_hModule, _this); // 1030, 630
|
||||||
if (!_this->hWnd)
|
if (!_this->hWnd)
|
||||||
{
|
{
|
||||||
_this->hrLastError = HRESULT_FROM_WIN32(GetLastError());
|
_this->hrLastError = HRESULT_FROM_WIN32(GetLastError());
|
||||||
|
@ -114,7 +114,7 @@ HRESULT STDMETHODCALLTYPE epw_Weather_SetDarkMode(EPWeather* _this, LONG64 dwDar
|
|||||||
HRESULT STDMETHODCALLTYPE epw_Weather_IsDarkMode(EPWeather* _this, LONG64 dwDarkMode, LONG64* bEnabled);
|
HRESULT STDMETHODCALLTYPE epw_Weather_IsDarkMode(EPWeather* _this, LONG64 dwDarkMode, LONG64* bEnabled);
|
||||||
HRESULT STDMETHODCALLTYPE epw_Weather_SetGeolocationMode(EPWeather* _this, LONG64 dwGeolocationMode);
|
HRESULT STDMETHODCALLTYPE epw_Weather_SetGeolocationMode(EPWeather* _this, LONG64 dwGeolocationMode);
|
||||||
HRESULT STDMETHODCALLTYPE epw_Weather_SetWindowCornerPreference(EPWeather* _this, LONG64 dwWindowCornerPreference);
|
HRESULT STDMETHODCALLTYPE epw_Weather_SetWindowCornerPreference(EPWeather* _this, LONG64 dwWindowCornerPreference);
|
||||||
HRESULT STDMETHODCALLTYPE epw_Weather_SetDevMode(EPWeather* _this, LONG64 dwDevMode);
|
HRESULT STDMETHODCALLTYPE epw_Weather_SetDevMode(EPWeather* _this, LONG64 dwDevMode, LONG64 bRefresh);
|
||||||
|
|
||||||
static const IEPWeatherVtbl IEPWeather_Vtbl = {
|
static const IEPWeatherVtbl IEPWeather_Vtbl = {
|
||||||
.QueryInterface = epw_Weather_QueryInterface,
|
.QueryInterface = epw_Weather_QueryInterface,
|
||||||
|
@ -65,5 +65,5 @@ import "unknwn.idl";
|
|||||||
|
|
||||||
HRESULT SetWindowCornerPreference([in] LONG64 dwWindowCornerPreference);
|
HRESULT SetWindowCornerPreference([in] LONG64 dwWindowCornerPreference);
|
||||||
|
|
||||||
HRESULT SetDevMode([in] LONG64 dwDevMode);
|
HRESULT SetDevMode([in] LONG64 dwDevMode, [in] LONG64 bRefresh);
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user