/*------------------------------------------------ CLOCKM_REFRESHTASKBAR message --------------------------------------------------*/ void OnRefreshTaskbar(HWND hwnd) { g_bVisualStyle = IsXPVisualStyle(); #if TC_ENABLE_STARTBUTTON ResetStartButton(hwnd); // startbtn.c #endif InitTaskbar(hwnd); // taskbar.c #if TC_ENABLE_TASKSWITCH InitTaskSwitch(hwnd); // taskswitch.c #endif RefreshTaskbar(hwnd); // taskbar.c }
/*------------------------------------------------ Initialize --------------------------------------------------*/ void OnInit(HWND hDlg) { LOGFONT logfont; m_bInit = FALSE; // common/tclang.c SetDialogLanguage(hDlg, "Color", g_hfontDialog); // settings of "background" and "text" InitColor(hDlg); CheckDlgButton(hDlg, IDC_CHKCOLOR, GetMyRegLong(NULL, "UseBackColor", IsXPVisualStyle() ? FALSE : TRUE)); CheckDlgButton(hDlg, IDC_CHKCOLOR2, GetMyRegLong(NULL, "UseBackColor2", FALSE)); CheckRadioButton(hDlg, IDC_GRAD1, IDC_GRAD2, (GetMyRegLong(NULL, "GradDir", 0) == 0) ? IDC_GRAD1 : IDC_GRAD2); CheckDlgButton(hDlg, IDC_FILLTRAY, GetMyRegLong(NULL, "FillTray", FALSE)); EnableDlgItem(hDlg, IDC_FILLTRAY, IsDlgButtonChecked(hDlg, IDC_CHKCOLOR)); OnCheckColor(hDlg); #if TC_ENABLE_CLOCKDECORATION // settings for decoration CheckRadioButton(hDlg, IDC_DECONONE, IDC_DECOBORDER, GetMyRegLong(NULL, "ClockDecoration", 0) + IDC_DECONONE); OnSelectDecoration(hDlg); UpDown_SetBuddy(hDlg, IDC_SHADOWRANGESPIN, IDC_SHADOWRANGE); UpDown_SetRange(hDlg, IDC_SHADOWRANGESPIN, 10, 1); UpDown_SetPos(hDlg, IDC_SHADOWRANGESPIN, GetMyRegLong(NULL, "ShadowRange", 1)); #endif // settings of "font" and "font size" InitFont(hDlg); OnFont(hDlg, TRUE); CheckDlgButton(hDlg, IDC_BOLD, GetMyRegLong(NULL, "Bold", FALSE)); CheckDlgButton(hDlg, IDC_ITALIC, GetMyRegLong(NULL, "Italic", FALSE)); m_hfontb = m_hfonti = NULL; if(g_hfontDialog) { char s[80]; GetObject(g_hfontDialog, sizeof(LOGFONT), &logfont); logfont.lfWeight = FW_BOLD; m_hfontb = CreateFontIndirect(&logfont); SendDlgItemMessage(hDlg, IDC_BOLD, WM_SETFONT, (WPARAM)m_hfontb, 0); logfont.lfWeight = FW_NORMAL; logfont.lfItalic = 1; m_hfonti = CreateFontIndirect(&logfont); SendDlgItemMessage(hDlg, IDC_ITALIC, WM_SETFONT, (WPARAM)m_hfonti, 0); GetDlgItemText(hDlg, IDC_ITALIC, s, 77); strcat(s, " "); SetDlgItemText(hDlg, IDC_ITALIC, s); } m_bInit = TRUE; }
/*------------------------------------------------ initialize the clock --------------------------------------------------*/ void InitClock(HWND hwnd) { RECT rc; if(g_bInitClock) return; g_bInitClock = TRUE; g_hInst = GetModuleHandle(DLLFILENAME); g_winver = CheckWinVersion(); // common/utl.c g_bVisualStyle = IsXPVisualStyle(); // common/utl.c #if 0 if(!(g_winver&WIN10RS1)) { // check subclassification if(IsSubclassed(hwnd)) { SendMessage(g_hwndTClockMain, TCM_CLOCKERROR, 0, 6); return; } } #endif GetModuleFileName(g_hInst, g_mydir, MAX_PATH); del_title(g_mydir); strcpy(g_inifile, g_mydir); add_title(g_inifile, "tclock.ini"); g_bIniSetting = TRUE; /* g_bIniSetting = FALSE; if(IsFile(g_inifile)) g_bIniSetting = TRUE; */ // Save the original window size GetWindowRect(hwnd, &rc); g_OrigClockWidth = rc.right - rc.left; g_OrigClockHeight = rc.bottom - rc.top; // Save taskbar direction g_bVertTaskbar = IsVertTaskbar(GetParent(GetParent(hwnd))); g_bTaskbarPosChanging = FALSE; // tell tclock.exe clock's HWND PostMessage(g_hwndTClockMain, TCM_HWNDCLOCK, 0, (LPARAM)hwnd); // read settings LoadSetting(hwnd); InitTooltip(hwnd); // tooltip.c InitUserStr(); // userstr.c // subclassfy the clock window !! if(g_winver&WIN10RS1) { SetWindowSubclass(GetParent(hwnd), SubclassTrayProc, SUBCLASSTRAY_ID, (DWORD_PTR)hwnd); } SetWindowSubclass(hwnd, SubclassProc, SUBCLASS_ID, 0); // don't accept double clicks SetClassLong(hwnd, GCL_STYLE, GetClassLong(hwnd, GCL_STYLE) & ~CS_DBLCLKS); #if TC_ENABLE_STARTBUTTON InitStartButton(hwnd); // startbtn.c #endif #if TC_ENABLE_STARTMENU InitStartMenu(hwnd); // startmenu.c #endif #if TC_ENABLE_TASKBAR InitTaskbar(hwnd); // taskbar.c #endif #if TC_ENABLE_TASKSWITCH InitTaskSwitch(hwnd); // taskswitch.c #endif #if TC_ENABLE_TRAYNOTIFY InitTrayNotify(hwnd); // traynotify.c #endif #if TC_ENABLE_VOLUME InitMixer(); // mixer.c #endif #if TC_ENABLE_SYSINFO InitSysInfo(hwnd); // sysinfo.c #endif #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 SetTimer(hwnd, IDTIMER_MAIN, 1000, NULL); #if TC_ENABLE_DESKTOPICON SetDesktopIcons(); // desktop.c #endif }
/*------------------------------------------------ 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); }