mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-23 23:21:08 +01:00
Weather widget adjusts its size vertically to accommodate the entire contents
This commit is contained in:
parent
22a5a1e3c7
commit
fd710a1544
@ -15,6 +15,7 @@ Tested on OS build 22000.434.
|
||||
* The weather widget recomputes its area automatically, by default, in order to fit its contents, instead of remaining at a fixed size; there is also an option to choose between the two behaviors (.1)
|
||||
* Possibility to disable the icon in the weather widget (.1)
|
||||
* The weather widget defaults to showing in the preferred language set in Windows, instead of English (#734) (.2)
|
||||
* The weather widget shows an error screen when an error happens (like, using an incorrect location, or the network not working etc) (.3)
|
||||
|
||||
#### Fixes
|
||||
|
||||
@ -24,6 +25,7 @@ Tested on OS build 22000.434.
|
||||
* Changing the Start button style or weather widget layout does not toggle taskbar auto-hide now; instead, the settings take effect immediately (.1)
|
||||
* Fixed a bug that could corrupt registry entries of type REG_SZ set via the Properties UI (#734) (.2)
|
||||
* Fixed a bug that reset the setting when pressing "Cancel" in an input box in the Properties UI (#734) (.2)
|
||||
* The weather widget adjusts its size vertically to accommodate the entire contents (#734) (.3)
|
||||
|
||||
## 22000.469.41
|
||||
|
||||
|
@ -3597,6 +3597,79 @@ BOOL explorer_DeleteMenu(HMENU hMenu, UINT uPosition, UINT uFlags)
|
||||
return DeleteMenu(hMenu, uPosition, uFlags);
|
||||
}
|
||||
|
||||
HWND hWndWeatherFlyout;
|
||||
void RecomputeWeatherFlyoutLocation(HWND hWnd)
|
||||
{
|
||||
RECT rcButton;
|
||||
GetWindowRect(PeopleButton_LastHWND, &rcButton);
|
||||
POINT pButton;
|
||||
pButton.x = rcButton.left;
|
||||
pButton.y = rcButton.top;
|
||||
|
||||
RECT rcWeatherFlyoutWindow;
|
||||
GetWindowRect(hWnd, &rcWeatherFlyoutWindow);
|
||||
|
||||
POINT pNewWindow;
|
||||
|
||||
RECT rc;
|
||||
UINT tbPos = GetTaskbarLocationAndSize(pButton, &rc);
|
||||
if (tbPos == TB_POS_BOTTOM)
|
||||
{
|
||||
pNewWindow.y = rcButton.top - (rcWeatherFlyoutWindow.bottom - rcWeatherFlyoutWindow.top);
|
||||
}
|
||||
else if (tbPos == TB_POS_TOP)
|
||||
{
|
||||
pNewWindow.y = rcButton.bottom;
|
||||
}
|
||||
else if (tbPos == TB_POS_LEFT)
|
||||
{
|
||||
pNewWindow.x = rcButton.right;
|
||||
}
|
||||
if (tbPos == TB_POS_RIGHT)
|
||||
{
|
||||
pNewWindow.x = rcButton.left - (rcWeatherFlyoutWindow.right - rcWeatherFlyoutWindow.left);
|
||||
}
|
||||
|
||||
if (tbPos == TB_POS_BOTTOM || tbPos == TB_POS_TOP)
|
||||
{
|
||||
pNewWindow.x = rcButton.left + ((rcButton.right - rcButton.left) / 2) - ((rcWeatherFlyoutWindow.right - rcWeatherFlyoutWindow.left) / 2);
|
||||
|
||||
HMONITOR hMonitor = MonitorFromPoint(pButton, MONITOR_DEFAULTTOPRIMARY);
|
||||
if (hMonitor)
|
||||
{
|
||||
MONITORINFO mi;
|
||||
mi.cbSize = sizeof(MONITORINFO);
|
||||
if (GetMonitorInfoW(hMonitor, &mi))
|
||||
{
|
||||
if (mi.rcWork.right < pNewWindow.x + (rcWeatherFlyoutWindow.right - rcWeatherFlyoutWindow.left))
|
||||
{
|
||||
pNewWindow.x = mi.rcWork.right - (rcWeatherFlyoutWindow.right - rcWeatherFlyoutWindow.left);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tbPos == TB_POS_LEFT || tbPos == TB_POS_RIGHT)
|
||||
{
|
||||
pNewWindow.y = rcButton.top + ((rcButton.bottom - rcButton.top) / 2) - ((rcWeatherFlyoutWindow.bottom - rcWeatherFlyoutWindow.top) / 2);
|
||||
|
||||
HMONITOR hMonitor = MonitorFromPoint(pButton, MONITOR_DEFAULTTOPRIMARY);
|
||||
if (hMonitor)
|
||||
{
|
||||
MONITORINFO mi;
|
||||
mi.cbSize = sizeof(MONITORINFO);
|
||||
if (GetMonitorInfoW(hMonitor, &mi))
|
||||
{
|
||||
if (mi.rcWork.bottom < pNewWindow.y + (rcWeatherFlyoutWindow.bottom - rcWeatherFlyoutWindow.top))
|
||||
{
|
||||
pNewWindow.y = mi.rcWork.bottom - (rcWeatherFlyoutWindow.bottom - rcWeatherFlyoutWindow.top);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetWindowPos(hWnd, NULL, pNewWindow.x, pNewWindow.y, 0, 0, SWP_NOSIZE | SWP_NOSENDCHANGING);
|
||||
}
|
||||
|
||||
int prev_total_h = 0;
|
||||
SIZE (*PeopleButton_CalculateMinimumSizeFunc)(void*, SIZE*);
|
||||
SIZE WINAPI PeopleButton_CalculateMinimumSizeHook(void* _this, SIZE* pSz)
|
||||
@ -3650,10 +3723,22 @@ SIZE WINAPI PeopleButton_CalculateMinimumSizeHook(void* _this, SIZE* pSz)
|
||||
epw->lpVtbl->SetTerm(epw, MAX_PATH * sizeof(WCHAR), wszWeatherTerm);
|
||||
epw->lpVtbl->SetLanguage(epw, MAX_PATH * sizeof(WCHAR), wszWeatherLanguage);
|
||||
UINT dpiX = 0, dpiY = 0;
|
||||
HRESULT hr = GetDpiForMonitor(MonitorFromWindow(PeopleButton_LastHWND, MONITOR_DEFAULTTOPRIMARY), MDT_DEFAULT, &dpiX, &dpiY);
|
||||
if (FAILED(epw->lpVtbl->Initialize(epw, wszEPWeatherKillswitch, bAllocConsole, EP_WEATHER_PROVIDER_GOOGLE, rt, rt, dwWeatherTemperatureUnit, dwWeatherUpdateSchedule * 1000, dpiX / 96.0)))
|
||||
HMONITOR hMonitor = MonitorFromWindow(PeopleButton_LastHWND, MONITOR_DEFAULTTOPRIMARY);
|
||||
HRESULT hr = GetDpiForMonitor(hMonitor, MDT_DEFAULT, &dpiX, &dpiY);
|
||||
MONITORINFO mi;
|
||||
ZeroMemory(&mi, sizeof(MONITORINFO));
|
||||
mi.cbSize = sizeof(MONITORINFO);
|
||||
if (GetMonitorInfoW(hMonitor, &mi))
|
||||
{
|
||||
epw->lpVtbl->Release(epw);
|
||||
RECT rcWeatherFlyoutWindow;
|
||||
rcWeatherFlyoutWindow.left = mi.rcWork.left;
|
||||
rcWeatherFlyoutWindow.top = mi.rcWork.top;
|
||||
rcWeatherFlyoutWindow.right = rcWeatherFlyoutWindow.left + MulDiv(EP_WEATHER_HEIGHT, dpiX, 96);
|
||||
rcWeatherFlyoutWindow.bottom = rcWeatherFlyoutWindow.top + MulDiv(EP_WEATHER_WIDTH, dpiX, 96);
|
||||
if (FAILED(epw->lpVtbl->Initialize(epw, wszEPWeatherKillswitch, bAllocConsole, EP_WEATHER_PROVIDER_GOOGLE, rt, rt, dwWeatherTemperatureUnit, dwWeatherUpdateSchedule * 1000, rcWeatherFlyoutWindow, &hWndWeatherFlyout)))
|
||||
{
|
||||
epw->lpVtbl->Release(epw);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -4101,6 +4186,10 @@ __int64 __fastcall PeopleBand_DrawTextWithGlowHook(
|
||||
DeleteDC(hDC);
|
||||
}
|
||||
}
|
||||
if (IsWindowVisible(hWndWeatherFlyout))
|
||||
{
|
||||
RecomputeWeatherFlyoutLocation(hWndWeatherFlyout);
|
||||
}
|
||||
}
|
||||
/*free(epw_pImage);
|
||||
free(epw_wszCondition);
|
||||
@ -4192,14 +4281,17 @@ __int64 PeopleButton_OnClickHook(__int64 a1, __int64 a2)
|
||||
{
|
||||
if (epw)
|
||||
{
|
||||
HWND hWnd = NULL;
|
||||
if (SUCCEEDED(epw->lpVtbl->GetWindowHandle(epw, &hWnd)) && hWnd)
|
||||
if (!hWndWeatherFlyout)
|
||||
{
|
||||
if (IsWindowVisible(hWnd))
|
||||
epw->lpVtbl->GetWindowHandle(epw, &hWndWeatherFlyout);
|
||||
}
|
||||
if (hWndWeatherFlyout)
|
||||
{
|
||||
if (IsWindowVisible(hWndWeatherFlyout))
|
||||
{
|
||||
if (GetForegroundWindow() != hWnd)
|
||||
if (GetForegroundWindow() != hWndWeatherFlyout)
|
||||
{
|
||||
SwitchToThisWindow(hWnd, TRUE);
|
||||
SwitchToThisWindow(hWndWeatherFlyout, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4209,78 +4301,11 @@ __int64 PeopleButton_OnClickHook(__int64 a1, __int64 a2)
|
||||
}
|
||||
else
|
||||
{
|
||||
RECT rcButton;
|
||||
GetWindowRect(PeopleButton_LastHWND, &rcButton);
|
||||
POINT pButton;
|
||||
pButton.x = rcButton.left;
|
||||
pButton.y = rcButton.top;
|
||||
|
||||
RECT rcWindow;
|
||||
GetWindowRect(hWnd, &rcWindow);
|
||||
|
||||
POINT pNewWindow;
|
||||
|
||||
RECT rc;
|
||||
UINT tbPos = GetTaskbarLocationAndSize(pButton, &rc);
|
||||
if (tbPos == TB_POS_BOTTOM)
|
||||
{
|
||||
pNewWindow.y = rcButton.top - (rcWindow.bottom - rcWindow.top);
|
||||
}
|
||||
else if (tbPos == TB_POS_TOP)
|
||||
{
|
||||
pNewWindow.y = rcButton.bottom;
|
||||
}
|
||||
else if (tbPos == TB_POS_LEFT)
|
||||
{
|
||||
pNewWindow.x = rcButton.right;
|
||||
}
|
||||
if (tbPos == TB_POS_RIGHT)
|
||||
{
|
||||
pNewWindow.x = rcButton.left - (rcWindow.right - rcWindow.left);
|
||||
}
|
||||
|
||||
if (tbPos == TB_POS_BOTTOM || tbPos == TB_POS_TOP)
|
||||
{
|
||||
pNewWindow.x = rcButton.left + ((rcButton.right - rcButton.left) / 2) - ((rcWindow.right - rcWindow.left) / 2);
|
||||
|
||||
HMONITOR hMonitor = MonitorFromPoint(pButton, MONITOR_DEFAULTTOPRIMARY);
|
||||
if (hMonitor)
|
||||
{
|
||||
MONITORINFO mi;
|
||||
mi.cbSize = sizeof(MONITORINFO);
|
||||
if (GetMonitorInfoW(hMonitor, &mi))
|
||||
{
|
||||
if (mi.rcWork.right < pNewWindow.x + (rcWindow.right - rcWindow.left))
|
||||
{
|
||||
pNewWindow.x = mi.rcWork.right - (rcWindow.right - rcWindow.left);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tbPos == TB_POS_LEFT || tbPos == TB_POS_RIGHT)
|
||||
{
|
||||
pNewWindow.y = rcButton.top + ((rcButton.bottom - rcButton.top) / 2) - ((rcWindow.bottom - rcWindow.top) / 2);
|
||||
|
||||
HMONITOR hMonitor = MonitorFromPoint(pButton, MONITOR_DEFAULTTOPRIMARY);
|
||||
if (hMonitor)
|
||||
{
|
||||
MONITORINFO mi;
|
||||
mi.cbSize = sizeof(MONITORINFO);
|
||||
if (GetMonitorInfoW(hMonitor, &mi))
|
||||
{
|
||||
if (mi.rcWork.bottom < pNewWindow.y + (rcWindow.bottom - rcWindow.top))
|
||||
{
|
||||
pNewWindow.y = mi.rcWork.bottom - (rcWindow.bottom - rcWindow.top);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetWindowPos(hWnd, NULL, pNewWindow.x, pNewWindow.y, 0, 0, SWP_NOSIZE, SWP_SHOWWINDOW | SWP_FRAMECHANGED);
|
||||
RecomputeWeatherFlyoutLocation(hWndWeatherFlyout);
|
||||
|
||||
epw->lpVtbl->Show(epw);
|
||||
|
||||
SwitchToThisWindow(hWnd, TRUE);
|
||||
SwitchToThisWindow(hWndWeatherFlyout, TRUE);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -50,4 +50,7 @@ DEFINE_GUID(IID_IEPWeather,
|
||||
#define EP_WEATHER_UPDATE_REDUCED 3600
|
||||
|
||||
#define EP_WEATHER_WM_FETCH_DATA (WM_USER + 10)
|
||||
|
||||
#define EP_WEATHER_WIDTH 425
|
||||
#define EP_WEATHER_HEIGHT 690
|
||||
#endif
|
||||
|
@ -21,7 +21,7 @@ body {\n\
|
||||
</style>\n\
|
||||
</head>\n\
|
||||
<body><center>\n\
|
||||
<h1>🖱</h1>\n\
|
||||
<h1>📰</h1>\n\
|
||||
<h2>Unable to load weather information</h2>\n\
|
||||
<p>Check to make sure that the location you have entered is correct.<br/>\n\
|
||||
Verify that you are connected to the Internet.</p>\n\
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "ep_weather_provider_google_script.h"
|
||||
#include "ep_weather_error_html.h"
|
||||
|
||||
LPCWSTR EP_Weather_Script_Provider_Google = L"<!DOCTYPE html>\n";
|
||||
EPWeather* EPWeather_Instance;
|
||||
|
||||
HRESULT STDMETHODCALLTYPE INetworkListManagerEvents_QueryInterface(void* _this, REFIID riid, void** ppv)
|
||||
{
|
||||
@ -24,7 +24,7 @@ ULONG STDMETHODCALLTYPE INetworkListManagerEvents_AddRefRelease(void* _this)
|
||||
|
||||
HRESULT STDMETHODCALLTYPE INetworkListManagerEvents_ConnectivityChanged(void* _this2, NLM_CONNECTIVITY newConnectivity)
|
||||
{
|
||||
EPWeather* _this = GetWindowLongPtrW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), GWLP_USERDATA);
|
||||
EPWeather* _this = EPWeather_Instance; // GetWindowLongPtrW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), GWLP_USERDATA);
|
||||
if (_this)
|
||||
{
|
||||
if ((newConnectivity & (NLM_CONNECTIVITY_IPV4_INTERNET | NLM_CONNECTIVITY_IPV6_INTERNET)) != 0)
|
||||
@ -99,14 +99,40 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_get_AllowSingleSignOnUsingOSPrimaryAccou
|
||||
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_CreateCoreWebView2EnvironmentCompleted(ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler* _this, HRESULT hr, ICoreWebView2Environment* pCoreWebView2Environemnt)
|
||||
{
|
||||
pCoreWebView2Environemnt->lpVtbl->CreateCoreWebView2Controller(pCoreWebView2Environemnt, FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), &EPWeather_ICoreWebView2CreateCoreWebView2ControllerCompletedHandler);
|
||||
pCoreWebView2Environemnt->lpVtbl->CreateCoreWebView2Controller(pCoreWebView2Environemnt, EPWeather_Instance->hWnd /* FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL) */, &EPWeather_ICoreWebView2CreateCoreWebView2ControllerCompletedHandler);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE _epw_Weather_NavigateToError(EPWeather* _this)
|
||||
{
|
||||
InterlockedExchange64(&_this->bIsNavigatingToError, TRUE);
|
||||
return _this->pCoreWebView2->lpVtbl->NavigateToString(_this->pCoreWebView2, ep_weather_error_html);
|
||||
UINT dpi = GetDpiForWindow(_this->hWnd);
|
||||
int ch = MulDiv(305, dpi, 96);
|
||||
RECT rc;
|
||||
GetWindowRect(_this->hWnd, &rc);
|
||||
if (rc.bottom - rc.top != ch)
|
||||
{
|
||||
SetWindowPos(_this->hWnd, NULL, 0, 0, rc.right - rc.left, ch, SWP_NOMOVE | SWP_NOSENDCHANGING);
|
||||
RECT bounds;
|
||||
GetClientRect(_this->hWnd, &bounds);
|
||||
if (_this->pCoreWebView2Controller)
|
||||
{
|
||||
_this->pCoreWebView2Controller->lpVtbl->put_Bounds(_this->pCoreWebView2Controller, bounds);
|
||||
}
|
||||
HWND hNotifyWnd = InterlockedAdd64(&_this->hNotifyWnd, 0);
|
||||
if (hNotifyWnd)
|
||||
{
|
||||
InvalidateRect(hNotifyWnd, NULL, TRUE);
|
||||
}
|
||||
}
|
||||
if (_this->pCoreWebView2)
|
||||
{
|
||||
return _this->pCoreWebView2->lpVtbl->NavigateToString(_this->pCoreWebView2, ep_weather_error_html);
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE _epw_Weather_NavigateToProvider(EPWeather* _this)
|
||||
@ -123,7 +149,14 @@ HRESULT STDMETHODCALLTYPE _epw_Weather_NavigateToProvider(EPWeather* _this)
|
||||
if (_this->wszScriptData)
|
||||
{
|
||||
swprintf_s(_this->wszScriptData, EP_WEATHER_PROVIDER_GOOGLE_HTML_LEN, ep_weather_provider_google_html, _this->wszLanguage, _this->wszTerm[0] ? L" " : L"", _this->wszTerm);
|
||||
hr = _this->pCoreWebView2->lpVtbl->NavigateToString(_this->pCoreWebView2, _this->wszScriptData);
|
||||
if (_this->pCoreWebView2)
|
||||
{
|
||||
hr = _this->pCoreWebView2->lpVtbl->NavigateToString(_this->pCoreWebView2, _this->wszScriptData);
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = E_FAIL;
|
||||
}
|
||||
if (FAILED(hr))
|
||||
{
|
||||
InterlockedExchange64(&_this->bBrowserBusy, FALSE);
|
||||
@ -154,7 +187,14 @@ HRESULT STDMETHODCALLTYPE _epw_Weather_ExecuteDataScript(EPWeather* _this)
|
||||
LONG64 cbx = InterlockedAdd64(&_this->cbx, 0);
|
||||
swprintf_s(_this->wszScriptData, EP_WEATHER_PROVIDER_GOOGLE_SCRIPT_LEN, ep_weather_provider_google_script, dwTemperatureUnit == EP_WEATHER_TUNIT_FAHRENHEIT ? L'F' : L'C', cbx, cbx);
|
||||
//wprintf(L"%s\n", _this->wszScriptData);
|
||||
hr = _this->pCoreWebView2->lpVtbl->ExecuteScript(_this->pCoreWebView2, _this->wszScriptData, &EPWeather_ICoreWebView2ExecuteScriptCompletedHandler);
|
||||
if (_this->pCoreWebView2)
|
||||
{
|
||||
hr = _this->pCoreWebView2->lpVtbl->ExecuteScript(_this->pCoreWebView2, _this->wszScriptData, &EPWeather_ICoreWebView2ExecuteScriptCompletedHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(hr))
|
||||
{
|
||||
InterlockedExchange64(&_this->bBrowserBusy, FALSE);
|
||||
@ -171,7 +211,7 @@ HRESULT STDMETHODCALLTYPE _epw_Weather_ExecuteDataScript(EPWeather* _this)
|
||||
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_CreateCoreWebView2ControllerCompleted(ICoreWebView2CreateCoreWebView2ControllerCompletedHandler* _this2, HRESULT hr, ICoreWebView2Controller* pCoreWebView2Controller)
|
||||
{
|
||||
EPWeather* _this = GetWindowLongPtrW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), GWLP_USERDATA);
|
||||
EPWeather* _this = EPWeather_Instance; // GetWindowLongPtrW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), GWLP_USERDATA);
|
||||
if (!_this->pCoreWebView2Controller)
|
||||
{
|
||||
_this->pCoreWebView2Controller = pCoreWebView2Controller;
|
||||
@ -228,7 +268,7 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_CreateCoreWebView2ControllerCompleted(IC
|
||||
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_NavigationCompleted(ICoreWebView2NavigationCompletedEventHandler* _this2, ICoreWebView2* pCoreWebView2, ICoreWebView2NavigationCompletedEventArgs* pCoreWebView2NavigationCompletedEventArgs)
|
||||
{
|
||||
EPWeather* _this = GetWindowLongPtrW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), GWLP_USERDATA);
|
||||
EPWeather* _this = EPWeather_Instance; // GetWindowLongPtrW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), GWLP_USERDATA);
|
||||
if (_this->wszScriptData)
|
||||
{
|
||||
free(_this->wszScriptData);
|
||||
@ -259,7 +299,7 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_NavigationCompleted(ICoreWebView2Navigat
|
||||
|
||||
HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2ExecuteScriptCompletedHandler* _this2, HRESULT hr, LPCWSTR pResultObjectAsJson)
|
||||
{
|
||||
EPWeather* _this = GetWindowLongPtrW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), GWLP_USERDATA);
|
||||
EPWeather* _this = EPWeather_Instance; // GetWindowLongPtrW(FindWindowW(_T(EPW_WEATHER_CLASSNAME), NULL), GWLP_USERDATA);
|
||||
if (_this)
|
||||
{
|
||||
BOOL bOk = FALSE;
|
||||
@ -283,80 +323,104 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2Exec
|
||||
|
||||
epw_Weather_LockData(_this);
|
||||
|
||||
WCHAR* wszTemperature = pResultObjectAsJson + 1;
|
||||
if (wszTemperature)
|
||||
WCHAR* wszHeight = pResultObjectAsJson + 1;
|
||||
if (wszHeight)
|
||||
{
|
||||
WCHAR* wszUnit = wcschr(wszTemperature, L'#');
|
||||
if (wszUnit)
|
||||
WCHAR* wszTemperature = wcschr(wszHeight, L'#');
|
||||
if (wszTemperature)
|
||||
{
|
||||
wszUnit[0] = 0;
|
||||
wszUnit++;
|
||||
WCHAR* wszCondition = wcschr(wszUnit, L'#');
|
||||
if (wszCondition)
|
||||
wszTemperature[0] = 0;
|
||||
wszTemperature++;
|
||||
WCHAR* wszUnit = wcschr(wszTemperature, L'#');
|
||||
if (wszUnit)
|
||||
{
|
||||
wszCondition[0] = 0;
|
||||
wszCondition++;
|
||||
WCHAR* wszLocation = wcschr(wszCondition, L'#');
|
||||
if (wszLocation)
|
||||
wszUnit[0] = 0;
|
||||
wszUnit++;
|
||||
WCHAR* wszCondition = wcschr(wszUnit, L'#');
|
||||
if (wszCondition)
|
||||
{
|
||||
wszLocation[0] = 0;
|
||||
wszLocation++;
|
||||
WCHAR* pImage = wcschr(wszLocation, L'#');
|
||||
if (pImage)
|
||||
wszCondition[0] = 0;
|
||||
wszCondition++;
|
||||
WCHAR* wszLocation = wcschr(wszCondition, L'#');
|
||||
if (wszLocation)
|
||||
{
|
||||
pImage[0] = 0;
|
||||
pImage++;
|
||||
WCHAR* pTerm = wcschr(pImage, L'"');
|
||||
if (pTerm)
|
||||
wszLocation[0] = 0;
|
||||
wszLocation++;
|
||||
WCHAR* pImage = wcschr(wszLocation, L'#');
|
||||
if (pImage)
|
||||
{
|
||||
pTerm[0] = 0;
|
||||
if (_this->wszTemperature)
|
||||
pImage[0] = 0;
|
||||
pImage++;
|
||||
WCHAR* pTerm = wcschr(pImage, L'"');
|
||||
if (pTerm)
|
||||
{
|
||||
free(_this->wszTemperature);
|
||||
}
|
||||
if (_this->wszUnit)
|
||||
{
|
||||
free(_this->wszUnit);
|
||||
}
|
||||
if (_this->wszCondition)
|
||||
{
|
||||
free(_this->wszCondition);
|
||||
}
|
||||
if (_this->pImage)
|
||||
{
|
||||
free(_this->pImage);
|
||||
}
|
||||
if (_this->wszLocation)
|
||||
{
|
||||
free(_this->wszLocation);
|
||||
}
|
||||
_this->cbTemperature = (wcslen(wszTemperature) + 1) * sizeof(WCHAR);
|
||||
_this->wszTemperature = malloc(_this->cbTemperature);
|
||||
_this->cbUnit = (wcslen(wszUnit) + 1) * sizeof(WCHAR);
|
||||
_this->wszUnit = malloc(_this->cbUnit);
|
||||
_this->cbCondition = (wcslen(wszCondition) + 1) * sizeof(WCHAR);
|
||||
_this->wszCondition = malloc(_this->cbCondition);
|
||||
_this->cbImage = wcslen(pImage) / 2;
|
||||
_this->pImage = malloc(_this->cbImage);
|
||||
_this->cbLocation = (wcslen(wszLocation) + 1) * sizeof(WCHAR);
|
||||
_this->wszLocation = malloc(_this->cbLocation);
|
||||
if (_this->wszTemperature && _this->wszUnit && _this->wszCondition && _this->pImage && _this->wszLocation)
|
||||
{
|
||||
wcscpy_s(_this->wszTemperature, _this->cbTemperature / 2, wszTemperature);
|
||||
wcscpy_s(_this->wszUnit, _this->cbUnit / 2, wszUnit);
|
||||
wcscpy_s(_this->wszCondition, _this->cbCondition / 2, wszCondition);
|
||||
wcscpy_s(_this->wszLocation, _this->cbLocation / 2, wszLocation);
|
||||
|
||||
for (unsigned int i = 0; i < _this->cbImage * 2; i = i + 2)
|
||||
pTerm[0] = 0;
|
||||
if (_this->wszTemperature)
|
||||
{
|
||||
WCHAR tmp[3];
|
||||
tmp[0] = pImage[i];
|
||||
tmp[1] = pImage[i + 1];
|
||||
tmp[2] = 0;
|
||||
_this->pImage[i / 2] = wcstol(tmp, NULL, 16);
|
||||
free(_this->wszTemperature);
|
||||
}
|
||||
if (_this->wszUnit)
|
||||
{
|
||||
free(_this->wszUnit);
|
||||
}
|
||||
if (_this->wszCondition)
|
||||
{
|
||||
free(_this->wszCondition);
|
||||
}
|
||||
if (_this->pImage)
|
||||
{
|
||||
free(_this->pImage);
|
||||
}
|
||||
if (_this->wszLocation)
|
||||
{
|
||||
free(_this->wszLocation);
|
||||
}
|
||||
_this->cbTemperature = (wcslen(wszTemperature) + 1) * sizeof(WCHAR);
|
||||
_this->wszTemperature = malloc(_this->cbTemperature);
|
||||
_this->cbUnit = (wcslen(wszUnit) + 1) * sizeof(WCHAR);
|
||||
_this->wszUnit = malloc(_this->cbUnit);
|
||||
_this->cbCondition = (wcslen(wszCondition) + 1) * sizeof(WCHAR);
|
||||
_this->wszCondition = malloc(_this->cbCondition);
|
||||
_this->cbImage = wcslen(pImage) / 2;
|
||||
_this->pImage = malloc(_this->cbImage);
|
||||
_this->cbLocation = (wcslen(wszLocation) + 1) * sizeof(WCHAR);
|
||||
_this->wszLocation = malloc(_this->cbLocation);
|
||||
if (_this->wszTemperature && _this->wszUnit && _this->wszCondition && _this->pImage && _this->wszLocation)
|
||||
{
|
||||
wcscpy_s(_this->wszTemperature, _this->cbTemperature / 2, wszTemperature);
|
||||
wcscpy_s(_this->wszUnit, _this->cbUnit / 2, wszUnit);
|
||||
wcscpy_s(_this->wszCondition, _this->cbCondition / 2, wszCondition);
|
||||
wcscpy_s(_this->wszLocation, _this->cbLocation / 2, wszLocation);
|
||||
|
||||
bOk = TRUE;
|
||||
for (unsigned int i = 0; i < _this->cbImage * 2; i = i + 2)
|
||||
{
|
||||
WCHAR tmp[3];
|
||||
tmp[0] = pImage[i];
|
||||
tmp[1] = pImage[i + 1];
|
||||
tmp[2] = 0;
|
||||
_this->pImage[i / 2] = wcstol(tmp, NULL, 16);
|
||||
}
|
||||
|
||||
bOk = TRUE;
|
||||
}
|
||||
int h = _wtoi(wszHeight);
|
||||
int ch = MulDiv(h, EP_WEATHER_WIDTH, 367);
|
||||
UINT dpi = GetDpiForWindow(_this->hWnd);
|
||||
ch = MulDiv(ch, dpi, 96);
|
||||
RECT rc;
|
||||
GetWindowRect(_this->hWnd, &rc);
|
||||
if (rc.bottom - rc.top != ch)
|
||||
{
|
||||
SetWindowPos(_this->hWnd, NULL, 0, 0, rc.right - rc.left, ch, SWP_NOMOVE | SWP_NOSENDCHANGING);
|
||||
RECT bounds;
|
||||
GetClientRect(_this->hWnd, &bounds);
|
||||
_this->pCoreWebView2Controller->lpVtbl->put_Bounds(_this->pCoreWebView2Controller, bounds);
|
||||
HWND hNotifyWnd = InterlockedAdd64(&_this->hNotifyWnd, 0);
|
||||
if (hNotifyWnd)
|
||||
{
|
||||
InvalidateRect(hNotifyWnd, NULL, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -515,8 +579,12 @@ LRESULT CALLBACK epw_Weather_WindowProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPA
|
||||
{
|
||||
RECT bounds;
|
||||
GetClientRect(_this->hWnd, &bounds);
|
||||
_this->pCoreWebView2Controller->lpVtbl->put_Bounds(_this->pCoreWebView2Controller, bounds);
|
||||
if (_this->pCoreWebView2Controller)
|
||||
{
|
||||
_this->pCoreWebView2Controller->lpVtbl->put_Bounds(_this->pCoreWebView2Controller, bounds);
|
||||
}
|
||||
KillTimer(_this->hWnd, EP_WEATHER_TIMER_REBOUND_BROWSER);
|
||||
return 0;
|
||||
}
|
||||
else if (uMsg == EP_WEATHER_WM_FETCH_DATA)
|
||||
{
|
||||
@ -655,7 +723,7 @@ DWORD WINAPI epw_Weather_MainThread(EPWeather* _this)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
_this->hWnd = CreateWindowExW(0, _T(EPW_WEATHER_CLASSNAME), L"", WS_OVERLAPPED | WS_CAPTION, 100, 100, 690 * _this->dpi, 425 * _this->dpi, NULL, NULL, epw_hModule, _this); // 1030, 630
|
||||
_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
|
||||
if (!_this->hWnd)
|
||||
{
|
||||
_this->hrLastError = HRESULT_FROM_WIN32(GetLastError());
|
||||
@ -822,7 +890,7 @@ DWORD WINAPI epw_Weather_MainThread(EPWeather* _this)
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_Initialize(EPWeather* _this, WCHAR wszName[MAX_PATH], BOOL bAllocConsole, LONG64 dwProvider, LONG64 cbx, LONG64 cby, LONG64 dwTemperatureUnit, LONG64 dwUpdateSchedule, double dpi)
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_Initialize(EPWeather* _this, WCHAR wszName[MAX_PATH], BOOL bAllocConsole, LONG64 dwProvider, LONG64 cbx, LONG64 cby, LONG64 dwTemperatureUnit, LONG64 dwUpdateSchedule, RECT rc, HWND* hWnd)
|
||||
{
|
||||
if (bAllocConsole)
|
||||
{
|
||||
@ -836,7 +904,11 @@ HRESULT STDMETHODCALLTYPE epw_Weather_Initialize(EPWeather* _this, WCHAR wszName
|
||||
);
|
||||
}
|
||||
|
||||
_this->dpi = dpi;
|
||||
if (EPWeather_Instance)
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
EPWeather_Instance = _this;
|
||||
|
||||
if (dwUpdateSchedule < 0)
|
||||
{
|
||||
@ -887,6 +959,8 @@ HRESULT STDMETHODCALLTYPE epw_Weather_Initialize(EPWeather* _this, WCHAR wszName
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
_this->rc = rc;
|
||||
|
||||
_this->hMainThread = CreateThread(NULL, 0, epw_Weather_MainThread, _this, 0, NULL);
|
||||
if (!_this->hMainThread)
|
||||
{
|
||||
@ -899,6 +973,8 @@ HRESULT STDMETHODCALLTYPE epw_Weather_Initialize(EPWeather* _this, WCHAR wszName
|
||||
return _this->hrLastError;
|
||||
}
|
||||
|
||||
*hWnd = _this->hWnd;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#pragma comment(lib, "IPHLPAPI.lib")
|
||||
#include "WebView2.h"
|
||||
#pragma comment(lib, "uxtheme.lib")
|
||||
#include <ShellScalingApi.h>
|
||||
|
||||
DEFINE_GUID(IID_ITaskbarList,
|
||||
0x56FDF342, 0xFD6D, 0x11d0, 0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90);
|
||||
@ -45,8 +46,6 @@ typedef interface EPWeather
|
||||
LONG64 dwProvider; // interlocked
|
||||
LONG64 bIsNavigatingToError; // interlocked
|
||||
|
||||
double dpi;
|
||||
|
||||
HANDLE hMutexData; // protects the following:
|
||||
DWORD cbTemperature;
|
||||
LPCWSTR wszTemperature;
|
||||
@ -65,6 +64,7 @@ typedef interface EPWeather
|
||||
ICoreWebView2* pCoreWebView2;
|
||||
EventRegistrationToken* tkOnNavigationCompleted;
|
||||
LPCWSTR wszScriptData;
|
||||
RECT rc;
|
||||
|
||||
HANDLE hSignalExitMainThread;
|
||||
HANDLE hSignalKillSwitch;
|
||||
@ -75,7 +75,7 @@ ULONG STDMETHODCALLTYPE epw_Weather_Release(EPWeather* _this);
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_QueryInterface(EPWeather* _this, REFIID riid, void** ppv);
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_About(EPWeather* _this, HWND hWnd);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_Initialize(EPWeather* _this, WCHAR wszName[MAX_PATH], BOOL bAllocConsole, LONG64 dwProvider, LONG64 cbx, LONG64 cby, LONG64 dwTemperatureUnit, LONG64 dwUpdateSchedule, double dpi);
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_Initialize(EPWeather* _this, WCHAR wszName[MAX_PATH], BOOL bAllocConsole, LONG64 dwProvider, LONG64 cbx, LONG64 cby, LONG64 dwTemperatureUnit, LONG64 dwUpdateSchedule, RECT rc, HWND* hWnd);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_Show(EPWeather* _this);
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_Hide(EPWeather* _this);
|
||||
|
@ -21,9 +21,6 @@ html {\n\
|
||||
transition: 0.3s; \n\
|
||||
position: absolute;\n\
|
||||
}\n\
|
||||
.google-weather-crop:hover {\n\
|
||||
width: 655px; height: 370px;\n\
|
||||
}\n\
|
||||
.google-weather {\n\
|
||||
position: relative;\n\
|
||||
left: -180px; top: -180px;\n\
|
||||
|
@ -51,13 +51,14 @@ function ep_weather_getData(imageBitmap, ch) {\n\
|
||||
}\n\
|
||||
}\n\
|
||||
let res = (\n\
|
||||
document.getElementById(\"frame\").contentWindow.document.getElementsByClassName(\"ULSxyf\")[0].offsetHeight + \"#\" + \n\
|
||||
document.getElementById(\"frame\").contentWindow.document.getElementById(ch.includes('x') ? \"wob_ttm\" : \"wob_tm\").innerText + \"#\" + \n\
|
||||
Array.from(document.getElementById(\"frame\").contentWindow.document.getElementsByClassName('wob-unit')[0].getElementsByTagName('span')).filter(e => e.className == 'wob_t').filter(e => !e.style.display.toString().includes(\"none\"))[0].innerText + \"#\" + \n\
|
||||
document.getElementById(\"frame\").contentWindow.document.getElementById(\"wob_tci\").alt + \"#\" + \n\
|
||||
document.getElementById(\"frame\").contentWindow.document.getElementById(\"wob_loc\").innerText + \"#\" + \n\
|
||||
ep_weather_toHexString(result)\n\
|
||||
);\n\
|
||||
console.log(res);\n\
|
||||
//console.log(res);\n\
|
||||
document.body.style.backgroundColor='transparent';\n\
|
||||
document.getElementById(\"frame\").contentWindow.document.body.style.backgroundColor='transparent';\n\
|
||||
return res;\n\
|
||||
@ -84,6 +85,9 @@ ep_weather_part1();\n\
|
||||
|
||||
LPCWSTR ep_weather_provider_google_script2 = L"\
|
||||
function ep_weather_part2() {\n\
|
||||
let h = document.getElementById(\"frame\").contentWindow.document.getElementsByClassName(\"ULSxyf\")[0].offsetHeight;\n\
|
||||
document.getElementsByClassName(\"google-weather-place\")[0].style.height = h + 'px';\n\
|
||||
document.getElementsByClassName(\"google-weather-crop\")[0].style.height = h + 'px';\n\
|
||||
document.getElementById(\"frame\").contentWindow.document.getElementsByClassName(\"KFFQ0c\")[0].style.display = 'none';\n\
|
||||
document.getElementById(\"frame\").contentWindow.document.getElementById(\"search\").scrollIntoView(true);\n\
|
||||
return ep_result;\n\
|
||||
|
@ -11,7 +11,7 @@ import "unknwn.idl";
|
||||
{
|
||||
HRESULT About([in] HWND hWnd);
|
||||
|
||||
HRESULT Initialize([in] WCHAR wszName[260], [in] BOOL bAllocConsole, [in] LONG64 dwProvider, [in] LONG64 cbx, [in] LONG64 cby, [in] LONG64 dwTemperatureUnit, [in] LONG64 dwUpdateSchedule, [in] double dpi);
|
||||
HRESULT Initialize([in] WCHAR wszName[260], [in] BOOL bAllocConsole, [in] LONG64 dwProvider, [in] LONG64 cbx, [in] LONG64 cby, [in] LONG64 dwTemperatureUnit, [in] LONG64 dwUpdateSchedule, [in] RECT rc, [out] HWND* hWnd);
|
||||
|
||||
HRESULT Show();
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#define VER_MAJOR 22000
|
||||
#define VER_MINOR 469
|
||||
#define VER_BUILD_HI 42
|
||||
#define VER_BUILD_LO 2
|
||||
#define VER_BUILD_LO 3
|
||||
#define VER_FLAGS VS_FF_PRERELEASE
|
||||
|
||||
|
||||
@ -12,5 +12,5 @@
|
||||
#define VER_STR(arg) #arg
|
||||
|
||||
// The String form of the version numbers
|
||||
#define VER_FILE_STRING VALUE "FileVersion", "22000.469.42.2"
|
||||
#define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.469.42.2"
|
||||
#define VER_FILE_STRING VALUE "FileVersion", "22000.469.42.3"
|
||||
#define VER_PRODUCT_STRING VALUE "ProductVersion", "22000.469.42.3"
|
||||
|
Loading…
Reference in New Issue
Block a user