diff --git a/source/dll/draw.c b/source/dll/draw.c index 8b74783..235ed14 100644 --- a/source/dll/draw.c +++ b/source/dll/draw.c @@ -407,6 +407,12 @@ void DrawClock(HWND hwnd, HDC hdc, const SYSTEMTIME* pt) GetClientRect(hwnd, &rcClock); wclock = rcClock.right; hclock = rcClock.bottom; + if(g_bTaskbarPosChanging) + { + g_OrigClockWidth = wclock; + g_OrigClockHeight = hclock; + g_bTaskbarPosChanging = FALSE; + } size = (DWORD)CalcRect(hwnd, &wtext, &htext); if(wclock < LOWORD(size) || hclock < HIWORD(size)) diff --git a/source/dll/main2.c b/source/dll/main2.c index 02043c3..53b2c29 100644 --- a/source/dll/main2.c +++ b/source/dll/main2.c @@ -20,6 +20,8 @@ BOOL g_bVisualStyle; // Windows XP theme is used BOOL g_bNoClock; // don't customize clock int g_OrigClockWidth; // original clock width int g_OrigClockHeight; // original clock height +RECT g_rcTaskbar; +BOOL g_bTaskbarPosChanging; BOOL g_bLMousePassThru; // pass through left button messages #define SUBCLASS_ID 1 @@ -66,6 +68,9 @@ void InitClock(HWND hwnd) GetWindowRect(hwnd, &rc); g_OrigClockWidth = rc.right - rc.left; g_OrigClockHeight = rc.bottom - rc.top; + // Save taskbar position + GetWindowRect(GetParent(GetParent(hwnd)), &g_rcTaskbar); + g_bTaskbarPosChanging = FALSE; // tell tclock.exe clock's HWND PostMessage(g_hwndTClockMain, TCM_HWNDCLOCK, 0, (LPARAM)hwnd); @@ -77,8 +82,11 @@ void InitClock(HWND hwnd) InitUserStr(); // userstr.c // subclassfy the clock window !! - SetWindowSubclass(GetParent(hwnd), SubclassTrayProc, SUBCLASSTRAY_ID, - (DWORD_PTR)hwnd); + if(g_winver&WIN10RS1) + { + SetWindowSubclass(GetParent(hwnd), SubclassTrayProc, + SUBCLASSTRAY_ID, (DWORD_PTR)hwnd); + } SetWindowSubclass(hwnd, SubclassProc, SUBCLASS_ID, 0); // don't accept double clicks @@ -171,7 +179,11 @@ void EndClock(HWND hwnd) // restore window procedure RemoveWindowSubclass(hwnd, SubclassProc, SUBCLASS_ID); - RemoveWindowSubclass(GetParent(hwnd), SubclassTrayProc, SUBCLASSTRAY_ID); + if(g_winver&WIN10RS1) + { + RemoveWindowSubclass(GetParent(hwnd), SubclassTrayProc, + SUBCLASSTRAY_ID); + } #if TC_ENABLE_TASKBAR RefreshTaskbar(hwnd); // taskbar.c diff --git a/source/dll/tcdll.h b/source/dll/tcdll.h index 2d4233c..dac03c9 100644 --- a/source/dll/tcdll.h +++ b/source/dll/tcdll.h @@ -54,6 +54,8 @@ extern BOOL g_bVisualStyle; extern BOOL g_bNoClock; extern int g_OrigClockWidth; extern int g_OrigClockHeight; +extern RECT g_rcTaskbar; +extern BOOL g_bTaskbarPosChanging; extern BOOL g_bLMousePassThru; /* ---------- wndproc.c ----------- */ diff --git a/source/dll/wndproc.c b/source/dll/wndproc.c index 2ae95a7..1f9905d 100644 --- a/source/dll/wndproc.c +++ b/source/dll/wndproc.c @@ -70,11 +70,9 @@ LRESULT CALLBACK SubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case WM_ERASEBKGND: break; -#if 0 case (WM_USER+100): // a message requesting for clock size if(g_bNoClock) break; // sent from parent window - return OnCalcRect(hwnd); -#endif + return OnCalcRect(hwnd); // (only before Win10RS1) case WM_WINDOWPOSCHANGING: // size arrangement if(g_bNoClock) break; @@ -232,7 +230,7 @@ static void RearrangeNotifyArea(HWND hwnd, HWND hwndClock) POINT posclk = {0, 0}; int wclock, hclock; HWND hwndChild; - + size = OnCalcRect(hwndClock); wclock = LOWORD(size); hclock = HIWORD(size); @@ -289,12 +287,29 @@ LRESULT CALLBACK SubclassTrayProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM NMHDR *nmh = (NMHDR*)lParam; HWND hwndClock = (HWND)dwRefData; - if(g_bNoClock || nmh->code != PGN_CALCSIZE) + if(g_bNoClock || nmh->code != PGN_CALCSIZE || + g_bTaskbarPosChanging) break; ret = DefSubclassProc(hwnd, message, wParam, lParam); RearrangeNotifyArea(hwnd, hwndClock); return ret; } + case WM_WINDOWPOSCHANGING: + { + RECT rc; + + GetWindowRect(GetParent(hwnd), &rc); + if (!EqualRect(&rc, &g_rcTaskbar)) + { + g_rcTaskbar = rc; + g_bTaskbarPosChanging = TRUE; + } + else + { + g_bTaskbarPosChanging = FALSE; + } + break; + } } return DefSubclassProc(hwnd, message, wParam, lParam);