/*-------------------------------------------------- initialize ----------------------------------------------------*/ void InitTrayNotify(HWND hwndClock) { HWND hwnd; EndTrayNotify(); if(GetMyRegLong(NULL, "NoClock", FALSE)) return; if(GetMyRegLong(NULL, "FillTray", FALSE) == FALSE) return; if(GetMyRegLong(NULL, "UseBackColor", TRUE) == FALSE) return; m_hwndClock = hwndClock; m_hwndTrayNotify = GetParent(hwndClock); // TrayNotifyWnd if(IsSubclassed(m_hwndTrayNotify)) return; /* ---------- search toolbar ----------- */ m_hwndToolbar = NULL; hwnd = FindWindowEx(m_hwndTrayNotify, NULL, "ToolbarWindow32", NULL); if(!hwnd) { hwnd = FindWindowEx(m_hwndTrayNotify, NULL, "SysPager", NULL); if(hwnd) hwnd = FindWindowEx(hwnd, NULL, "ToolbarWindow32", NULL); } m_hwndToolbar = hwnd; /* ---------- subclassify ------------ */ m_oldClassStyle = GetClassLong(m_hwndTrayNotify, GCL_STYLE); SetClassLong(m_hwndTrayNotify, GCL_STYLE, m_oldClassStyle|CS_HREDRAW|CS_VREDRAW); SetWindowSubclass(m_hwndTrayNotify, SubclassProcTrayNotify, 0, 0); m_oldStyle = GetWindowLong(m_hwndTrayNotify, GWL_STYLE); SetWindowLong(m_hwndTrayNotify, GWL_STYLE, m_oldStyle & ~(WS_CLIPCHILDREN|WS_CLIPSIBLINGS)); InvalidateRect(m_hwndTrayNotify, NULL, TRUE); if(m_hwndToolbar) { SendMessage(GetParent(m_hwndToolbar), WM_SYSCOLORCHANGE, 0, 0); } }
/*------------------------------------------------ ending process --------------------------------------------------*/ void EndClock(HWND hwnd) { static BOOL bEndClock = FALSE; if(bEndClock) return; // avoid to be called twice bEndClock = TRUE; g_bVisualStyle = IsXPVisualStyle(); #if TC_ENABLE_MOUSEDROP DragAcceptFiles(hwnd, FALSE); #endif #if TC_ENABLE_DESKTOPICON EndDesktopIcons(); // desktop.c #endif #if TC_ENABLE_SYSINFO EndSysInfo(hwnd); // sysinfo.c #endif #if TC_ENABLE_VOLUME ReleaseMixer(); // mixer.c #endif #if TC_ENABLE_TRAYNOTIFY EndTrayNotify(); // traynotify.c #endif #if TC_ENABLE_TASKSWITCH EndTaskSwitch(); // taskswitch.c #endif #if TC_ENABLE_TASKBAR EndTaskbar(hwnd); // taskbar.c #endif #if TC_ENABLE_STARTMENU EndStartMenu(); // startmenu.c #endif #if TC_ENABLE_STARTBUTTON EndStartButton(); // startbtn.c #endif ClearDrawing(); // drawing.c EndTooltip(hwnd); // tooltip.c EndNewAPI(); // newapi.c // Stop timers KillTimer(hwnd, IDTIMER_MAIN); // restore window procedure RemoveWindowSubclass(hwnd, SubclassProc, SUBCLASS_ID); if(g_winver&WIN10RS1) { RemoveWindowSubclass(GetParent(hwnd), SubclassTrayProc, SUBCLASSTRAY_ID); } #if TC_ENABLE_TASKBAR RefreshTaskbar(hwnd); // taskbar.c #else PostMessage(GetParent(GetParent(hwnd)), WM_SIZE, SIZE_RESTORED, 0); InvalidateRect(GetParent(GetParent(hwnd)), NULL, TRUE); #endif // close window of tclock.exe PostMessage(g_hwndTClockMain, WM_CLOSE, 0, 0); PostMessage(hwnd, WM_TIMER, 0, 0); }
/*-------------------------------------------------- initialize ----------------------------------------------------*/ void InitTrayNotify(HWND hwndClock) { HWND hwnd, hwnd2; char classname[80]; EndTrayNotify(); bFillTray = GetMyRegLong(NULL, "FillTray", FALSE); bFlatTray = GetMyRegLong(NULL, "FlatTray", TRUE); bSkinTray = GetMyRegLong(NULL, "SkinTray", FALSE); // if(bSkinTray) bFillTray = FALSE; // ちょっと強引に設定の矛盾をなくす if(!bFillTray && !bFlatTray && !bSkinTray) return ; // get window handle of TrayNotifyWnd hwndTrayNotify = GetParent(hwndClock); // TrayNotifyWnd // search toolbar if(bFillTray) { hwndToolbar = NULL; hwnd = GetWindow(hwndTrayNotify, GW_CHILD); while(hwnd) { GetClassName(hwnd, classname, 80); if(lstrcmpi(classname, "ToolbarWindow32") == 0) { hwndToolbar = hwnd; break; }else if(lstrcmpi(classname, "SysPager") == 0) { hwnd2 = GetWindow(hwnd, GW_CHILD); while(hwnd2) { GetClassName(hwnd2, classname, 80); if(lstrcmpi(classname, "ToolbarWindow32") == 0) { hwndToolbar = hwnd2; break; } } hwnd2 = GetWindow(hwnd2, GW_HWNDNEXT); } hwnd = GetWindow(hwnd, GW_HWNDNEXT); } if(hwndToolbar == NULL) { bFillTray = FALSE; } } if(bFillTray) { s_hwndClock = hwndClock; oldClassStyleTrayNotify = GetClassLongPtr(hwndTrayNotify, GCL_STYLE); SetClassLongPtr(hwndTrayNotify, GCL_STYLE, oldClassStyleTrayNotify|CS_HREDRAW|CS_VREDRAW); oldWndProcTrayNotify = (WNDPROC)GetWindowLongPtr(hwndTrayNotify, GWLP_WNDPROC); SubclassWindow(hwndTrayNotify, WndProcTrayNotify); oldStyleTrayNotify = GetWindowLongPtr(hwndTrayNotify, GWL_STYLE); SetWindowLongPtr(hwndTrayNotify, GWL_STYLE, oldStyleTrayNotify & ~(WS_CLIPCHILDREN|WS_CLIPSIBLINGS)); } if(bFlatTray) { oldExStyleTrayNotify = GetWindowLongPtr(hwndTrayNotify, GWL_EXSTYLE); SetWindowLongPtr(hwndTrayNotify, GWL_EXSTYLE, oldExStyleTrayNotify & ~WS_EX_STATICEDGE); SetWindowPos(hwndTrayNotify, NULL, 0, 0, 0, 0, SWP_DRAWFRAME|SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER); } if(bFillTray || bFlatTray) InvalidateRect(hwndTrayNotify, NULL, TRUE); // if(bFillTray) // SendMessage(hwndToolbar, WM_SYSCOLORCHANGE, 0, 0); if(bFillTray) { if(!bWinXP) SendMessage(hwndToolbar, WM_SYSCOLORCHANGE, 0, 0); else SendMessage(GetParent(hwndToolbar), WM_SYSCOLORCHANGE, 0, 0); } #ifdef TEST_505 { RECT rc; LONG style; style = GetWindowLongPtr(hwndTrayNotify, GWL_STYLE); style |= WS_POPUPWINDOW | WS_CAPTION; SetWindowLongPtr(hwndTrayNotify, GWL_STYLE, style); GetWindowRect(hwndTrayNotify, &rc); SetWindowPos(hwndTrayNotify, NULL, rc.left - 20, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); } #endif //TEST_505 }