From 5e17f5a8175aabf6155614661f535080ed61f97b Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Sat, 30 Apr 2022 03:35:13 +0300 Subject: [PATCH] Weather: Fixed a bug that had "COM Surrogate" display as a running app in Task Manager after the widget flyout was opened the first time --- ep_weather_host/ep_weather_host.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ep_weather_host/ep_weather_host.c b/ep_weather_host/ep_weather_host.c index 67d3fa6..293fda7 100644 --- a/ep_weather_host/ep_weather_host.c +++ b/ep_weather_host/ep_weather_host.c @@ -1560,6 +1560,12 @@ HRESULT STDMETHODCALLTYPE epw_Weather_Initialize(EPWeather* _this, WCHAR wszName HRESULT STDMETHODCALLTYPE epw_Weather_Show(EPWeather* _this) { + SetLastError(0); + LONG_PTR dwExStyle = GetWindowLongPtrW(_this->hWnd, GWL_EXSTYLE); + if (!GetLastError()) + { + SetWindowLongPtrW(_this->hWnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW | dwExStyle); + } INT preference = InterlockedAdd64(&_this->dwWindowCornerPreference, 0); DwmSetWindowAttribute(_this->hWnd, DWMWA_WINDOW_CORNER_PREFERENCE, &preference, sizeof(preference)); PostMessageW(_this->hWnd, EP_WEATHER_WM_REBOUND_BROWSER, 0, 0); @@ -1570,6 +1576,12 @@ HRESULT STDMETHODCALLTYPE epw_Weather_Show(EPWeather* _this) HRESULT STDMETHODCALLTYPE epw_Weather_Hide(EPWeather* _this) { + SetLastError(0); + LONG_PTR dwExStyle = GetWindowLongPtrW(_this->hWnd, GWL_EXSTYLE); + if (!GetLastError()) + { + SetWindowLongPtrW(_this->hWnd, GWL_EXSTYLE, ~WS_EX_TOOLWINDOW & dwExStyle); + } ShowWindow(_this->hWnd, SW_HIDE); return S_OK; }