Browse Source

Weather: Fixed buggy left/top positioning option (#1041)

pull/1080/head
Valentin Radu 4 years ago
parent
commit
d1b3dcc764
  1. 67
      ExplorerPatcher/TaskbarCenter.c
  2. 47
      ExplorerPatcher/dllmain.c

67
ExplorerPatcher/TaskbarCenter.c

@ -9,6 +9,9 @@ extern DWORD dwMMOldTaskbarAl;
extern wchar_t* EP_TASKBAR_LENGTH_PROP_NAME; extern wchar_t* EP_TASKBAR_LENGTH_PROP_NAME;
#define EP_TASKBAR_LENGTH_TOO_SMALL 20 #define EP_TASKBAR_LENGTH_TOO_SMALL 20
BOOL bTaskbarCenterHasPatchedSHWindowsPolicy = FALSE; BOOL bTaskbarCenterHasPatchedSHWindowsPolicy = FALSE;
UINT atomPeopleBand = 0;
UINT atomMSTaskListWClass = 0;
UINT atomMSTaskSwWClass = 0;
HRESULT TaskbarCenter_Center(HWND hWnd, HWND hWndTaskbar, RECT rc, BOOL bIsTaskbarHorizontal) HRESULT TaskbarCenter_Center(HWND hWnd, HWND hWndTaskbar, RECT rc, BOOL bIsTaskbarHorizontal)
{ {
@ -111,9 +114,11 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
HWND hWndStart = NULL; HWND hWndStart = NULL;
RECT rcStart; RECT rcStart;
SetRect(&rcStart, 0, 0, 0, 0); SetRect(&rcStart, 0, 0, 0, 0);
if (GetClassWord(hWnd, GCW_ATOM) == RegisterWindowMessageW(L"MSTaskListWClass")) if (!atomMSTaskListWClass) atomMSTaskListWClass = RegisterWindowMessageW(L"MSTaskListWClass");
if (GetClassWord(hWnd, GCW_ATOM) == atomMSTaskListWClass)
{ {
BOOL bIsPrimaryTaskbar = GetClassWord(GetParent(hWnd), GCW_ATOM) == RegisterWindowMessageW(L"MSTaskSwWClass"); if (!atomMSTaskSwWClass) atomMSTaskSwWClass = RegisterWindowMessageW(L"MSTaskSwWClass");
BOOL bIsPrimaryTaskbar = (GetClassWord(GetParent(hWnd), GCW_ATOM) == atomMSTaskSwWClass);
DWORD dwSetting = (bIsPrimaryTaskbar ? dwOldTaskbarAl : dwMMOldTaskbarAl); DWORD dwSetting = (bIsPrimaryTaskbar ? dwOldTaskbarAl : dwMMOldTaskbarAl);
HWND hWndTaskbar = NULL; HWND hWndTaskbar = NULL;
if (bIsPrimaryTaskbar) if (bIsPrimaryTaskbar)
@ -357,49 +362,73 @@ BOOL TaskbarCenter_GetClientRectHook(HWND hWnd, LPRECT lpRect)
{ {
bWeatherAlignment = FALSE; bWeatherAlignment = FALSE;
}*/ }*/
if (!atomPeopleBand) atomPeopleBand = RegisterWindowMessageW(L"PeopleBand");
REBARBANDINFOW rbi; REBARBANDINFOW rbi;
ZeroMemory(&rbi, sizeof(REBARBANDINFOW)); ZeroMemory(&rbi, sizeof(REBARBANDINFOW));
rbi.cbSize = sizeof(REBARBANDINFOW); rbi.cbSize = sizeof(REBARBANDINFOW);
rbi.fMask = RBBIM_CHILD; rbi.fMask = RBBIM_CHILD;
SendMessageW(hReBarWindow32, RB_GETBANDINFOW, 0, &rbi); SendMessageW(hReBarWindow32, RB_GETBANDINFOW, 0, &rbi);
BOOL bIsFirstBandPeopleBand = GetClassWord(rbi.hwndChild, GCW_ATOM) == RegisterWindowMessageW(L"PeopleBand"); BOOL bIsFirstBandPeopleBand = (GetClassWord(rbi.hwndChild, GCW_ATOM) == atomPeopleBand);
if (bWeatherAlignment ? !bIsFirstBandPeopleBand : bIsFirstBandPeopleBand) if (bWeatherAlignment ? !bIsFirstBandPeopleBand : bIsFirstBandPeopleBand)
{ {
int s = 0;
int k = SendMessageW(hReBarWindow32, RB_GETBANDCOUNT, 0, 0); int k = SendMessageW(hReBarWindow32, RB_GETBANDCOUNT, 0, 0);
int i = 1;
if (bWeatherAlignment) if (bWeatherAlignment)
{ {
for (i = 1; i < k; ++i) for (int i = k - 1; i >= 0; i--)
{
if (s == 0)
{ {
ZeroMemory(&rbi, sizeof(REBARBANDINFOW)); ZeroMemory(&rbi, sizeof(REBARBANDINFOW));
rbi.cbSize = sizeof(REBARBANDINFOW); rbi.cbSize = sizeof(REBARBANDINFOW);
rbi.fMask = RBBIM_CHILD; rbi.fMask = RBBIM_CHILD;
SendMessageW(hReBarWindow32, RB_GETBANDINFOW, i, &rbi); SendMessageW(hReBarWindow32, RB_GETBANDINFOW, i, &rbi);
if (rbi.hwndChild && GetClassWord(rbi.hwndChild, GCW_ATOM) == RegisterWindowMessageW(L"PeopleBand")) if (rbi.hwndChild && (GetClassWord(rbi.hwndChild, GCW_ATOM) == atomPeopleBand))
{ {
break; s = 1;
}
} }
if (s == 1 && i >= 1)
{
SendMessageW(hReBarWindow32, RB_MOVEBAND, i, i - 1);
} }
} }
else i = k - 1;
SendMessageW(hReBarWindow32, RB_MOVEBAND, 0, i);
SendNotifyMessageW(HWND_BROADCAST, WM_WININICHANGE, 0, (LPARAM)L"TraySettings"); SendNotifyMessageW(HWND_BROADCAST, WM_WININICHANGE, 0, (LPARAM)L"TraySettings");
/*if (PeopleButton_LastHWND) }
else
{ {
//if (epw_dummytext[0] == 0) epw_dummytext = L"\u2009"; for (int i = 0; i < k - 1; ++i)
//else epw_dummytext = L"";
//InvalidateRect(PeopleButton_LastHWND, NULL, TRUE);
if (FindWindowW(L"Shell_SecondaryTrayWnd", NULL))
{ {
PostMessageW(FindWindowW(L"Shell_TrayWnd", NULL), WM_COMMAND, 425, 0); SendMessageW(hReBarWindow32, RB_MOVEBAND, i, i + 1);
PostMessageW(FindWindowW(L"Shell_TrayWnd", NULL), WM_COMMAND, 425, 0); }
SendNotifyMessageW(HWND_BROADCAST, WM_WININICHANGE, 0, (LPARAM)L"TraySettings");
}
}
int k = SendMessageW(hReBarWindow32, RB_GETBANDCOUNT, 0, 0);
for (int i = 0; i < k - 1; ++i)
{
ZeroMemory(&rbi, sizeof(REBARBANDINFOW));
rbi.cbSize = sizeof(REBARBANDINFOW);
rbi.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE;
SendMessageW(hReBarWindow32, RB_GETBANDINFOW, i, &rbi);
if (rbi.hwndChild && (GetClassWord(rbi.hwndChild, GCW_ATOM) == atomPeopleBand))
{
RECT rcpp;
SetRect(&rcpp, 0, 0, 0, 0);
GetClientRect(rbi.hwndChild, &rcpp);
if (rcpp.right && rcpp.bottom)
{
if (bIsTaskbarHorizontal)
{
if (rcpp.right - rcpp.left != rbi.cxMinChild) SendMessageW(hReBarWindow32, RB_MINIMIZEBAND, i, 0);
} }
else else
{ {
PostMessageW(FindWindowW(L"Shell_TrayWnd", NULL), WM_COMMAND, 424, 0); if (rcpp.bottom - rcpp.top != rbi.cxMinChild) SendMessageW(hReBarWindow32, RB_MINIMIZEBAND, i, 0);
PostMessageW(FindWindowW(L"Shell_TrayWnd", NULL), WM_COMMAND, 424, 0); }
}
break;
} }
}*/
} }
} }
if ((!TaskbarCenter_ShouldCenter(dwSetting) || !TaskbarCenter_ShouldStartBeCentered(dwSetting)) && hWndStart) if ((!TaskbarCenter_ShouldCenter(dwSetting) || !TaskbarCenter_ShouldStartBeCentered(dwSetting)) && hWndStart)

47
ExplorerPatcher/dllmain.c

@ -757,40 +757,7 @@ HWND hWndServiceWindow = NULL;
void FixUpCenteredTaskbar() void FixUpCenteredTaskbar()
{ {
//SendNotifyMessageW(HWND_BROADCAST, WM_WININICHANGE, 0, (LPARAM)L"TraySettings"); PostMessageW(FindWindowW(L"Shell_TrayWnd", NULL), 798, 0, 0); // uMsg = 0x31E in explorer!TrayUI::WndProc
BOOL failed = FALSE;
int k = 0;
RECT rc;
BOOL vis = TRUE, vis2 = TRUE;
HWND htp = FindWindowExW(FindWindowExW(FindWindowW(L"Shell_TrayWnd", NULL), NULL, L"TrayNotifyWnd", NULL), NULL, L"TIPBand", NULL);
if (!htp) vis = FALSE;
else
{
GetClientRect(htp, &rc);
vis = !(!rc.right || !rc.bottom);
}
for (int i = 0; i < 2; ++i)
{
vis2 = !vis;
Sleep(50);
SendMessageW(FindWindowW(L"Shell_TrayWnd", NULL), WM_COMMAND, 436, 0);
while (vis != vis2)
{
if (!htp) htp = FindWindowExW(FindWindowExW(FindWindowW(L"Shell_TrayWnd", NULL), NULL, L"TrayNotifyWnd", NULL), NULL, L"TIPBand", NULL);
if (htp)
{
GetClientRect(htp, &rc);
vis = !(!rc.right || !rc.bottom);
}
k++;
if (k == 100)
{
failed = TRUE;
break;
}
Sleep(10);
}
}
} }
#define EP_SERVICE_WINDOW_CLASS_NAME L"EP_Service_Window_" _T(EP_CLSID) #define EP_SERVICE_WINDOW_CLASS_NAME L"EP_Service_Window_" _T(EP_CLSID)
@ -814,10 +781,10 @@ LRESULT CALLBACK EP_Service_Window_WndProc(
{ {
SetTimer(hWnd, 1, 1000, NULL); SetTimer(hWnd, 1, 1000, NULL);
} }
else if (uMsg == WM_TIMER && wParam < 2) else if (uMsg == WM_TIMER && wParam < 3)
{ {
FixUpCenteredTaskbar(); FixUpCenteredTaskbar();
if (wParam != 2 - 1) SetTimer(hWnd, wParam + 1, 1000, NULL); if (wParam != 3 - 1) SetTimer(hWnd, wParam + 1, 1000, NULL);
KillTimer(hWnd, wParam); KillTimer(hWnd, wParam);
return 0; return 0;
} }
@ -6539,7 +6506,7 @@ void WINAPI LoadSettings(LPARAM lParam)
); );
if (dwWeatherToLeft != dwOldWeatherToLeft && PeopleButton_LastHWND) if (dwWeatherToLeft != dwOldWeatherToLeft && PeopleButton_LastHWND)
{ {
dwRefreshUIMask = REFRESHUI_PEOPLE; dwRefreshUIMask |= REFRESHUI_CENTER;
} }
DWORD dwOldWeatherContentsMode = dwWeatherContentsMode; DWORD dwOldWeatherContentsMode = dwWeatherContentsMode;
@ -6554,7 +6521,7 @@ void WINAPI LoadSettings(LPARAM lParam)
); );
if (dwWeatherContentsMode != dwOldWeatherContentsMode && PeopleButton_LastHWND) if (dwWeatherContentsMode != dwOldWeatherContentsMode && PeopleButton_LastHWND)
{ {
dwRefreshUIMask |= REFRESHUI_PEOPLE; dwRefreshUIMask |= REFRESHUI_CENTER;
} }
DWORD dwOldWeatherZoomFactor = dwWeatherZoomFactor; DWORD dwOldWeatherZoomFactor = dwWeatherZoomFactor;
@ -6593,7 +6560,7 @@ void WINAPI LoadSettings(LPARAM lParam)
dwRefreshUIMask = REFRESHUI_GLOM; dwRefreshUIMask = REFRESHUI_GLOM;
if (dwOldTaskbarAl) if (dwOldTaskbarAl)
{ {
dwRefreshUIMask = REFRESHUI_CENTER; dwRefreshUIMask |= REFRESHUI_CENTER;
} }
} }
dwTaskbarGlomLevel = dwTemp; dwTaskbarGlomLevel = dwTemp;
@ -6612,7 +6579,7 @@ void WINAPI LoadSettings(LPARAM lParam)
dwRefreshUIMask = REFRESHUI_GLOM; dwRefreshUIMask = REFRESHUI_GLOM;
if (dwMMOldTaskbarAl) if (dwMMOldTaskbarAl)
{ {
dwRefreshUIMask = REFRESHUI_CENTER; dwRefreshUIMask |= REFRESHUI_CENTER;
} }
} }
dwMMTaskbarGlomLevel = dwTemp; dwMMTaskbarGlomLevel = dwTemp;

Loading…
Cancel
Save