/*--------------------------------------------------- initialize WinSock and read settings ---------------------------------------------------*/ BOOL InitSNTP(HWND hwndMain) { WORD ver; WSADATA wsaData; char s[80]; m_socket = INVALID_SOCKET; m_hGetHost = NULL; // initialize WinSock ver = 0x0101; // MAKEWORD(1, 1); if(WSAStartup(ver, &wsaData) != 0) { Log(NULL, "failed to initialize"); return FALSE; } GetMyRegStr(m_section, "Server", m_servername, 80, ""); m_nTimeOut = GetMyRegLong(m_section, "Timeout", 1000); if(!(0 < m_nTimeOut && m_nTimeOut <= 30000)) m_nTimeOut = 1000; m_bSaveLog = GetMyRegLong(m_section, "SaveLog", TRUE); GetMyRegStr(m_section, "Sound", m_soundfile, MAX_PATH, ""); m_nMinuteDif = 0; GetMyRegStr(m_section, "Dif", s, 80, ""); if(s[0]) { int h, m; time2int(&h, &m, s); m_nMinuteDif = h * 60 + m; } return TRUE; }
//================================================================================================ //--------------------------------------------------------------+++--> Create a Font For the Clock: HFONT CreateMyFont(char* fontname, int fontsize, LONG weight, LONG italic, int angle) { //--+++--> LOGFONT lf; POINT pt; HDC hdc; WORD langid; char s[11]; int cp, i; BYTE charset; int FontQty; memset(&lf, 0, sizeof(LOGFONT)); langid = (WORD)GetMyRegLong("Format", "Locale", (int)GetUserDefaultLangID()); FontQty = GetMyRegLong("Clock", "FontQuality", CLEARTYPE_QUALITY); cp = CP_ACP; if(GetLocaleInfo(langid, LOCALE_IDEFAULTANSICODEPAGE, s, 10) > 0) { char *p; p = s; cp = 0; while('0' <= *p && *p <= '9') cp = cp * 10 + *p++ - '0'; if(!IsValidCodePage(cp)) cp = CP_ACP; } charset = 0; for(i = 0; codepage_charset[i].cp; i++) { if(cp == codepage_charset[i].cp) { charset = codepage_charset[i].charset; break; } } hdc = GetDC(NULL); // find a font named "fontname" if(charset == 0) charset = GetTextCharset(hdc); lf.lfCharSet = charset; if(EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)fontname, 0)) { lf.lfCharSet = OEM_CHARSET; if(EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)fontname, 0)) { lf.lfCharSet = ANSI_CHARSET; EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)fontname, 0); } } pt.x = 0; pt.y = MulDiv(fontsize, GetDeviceCaps(hdc, LOGPIXELSY), 72); DPtoLP(hdc, &pt, 1); lf.lfHeight = -pt.y; ReleaseDC(NULL, hdc); lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0; lf.lfWeight = weight; lf.lfItalic = (BYTE)italic; lf.lfUnderline = 0; lf.lfStrikeOut = 0; if(angle >0) lf.lfEscapement = angle; lf.lfOutPrecision = OUT_DEFAULT_PRECIS; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; lf.lfQuality = FontQty; // This Just HAD To be Adjustable. lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; strcpy(lf.lfFaceName, fontname); return CreateFontIndirect(&lf); }
/*------------------------------------------------ initialize --------------------------------------------------*/ void InitAlarm(void) { ALARMSTRUCT item; PALARMSTRUCT pitem; int jihou; clear_list(m_pAlarm); m_pAlarm = NULL; jihou = 0; if(GetMyRegLong("", "Jihou", FALSE)) jihou = 1; // read settings m_pAlarm = LoadAlarm(); // common/alarmstruct.c // cuckoo clock if(jihou) { memset(&item, 0, sizeof(ALARMSTRUCT)); strcpy(item.name, "cuckoo"); strcpy(item.strHours, "*"); strcpy(item.strMinutes, "0"); strcpy(item.strWDays, "*"); SetAlarmTime(&item); // common/alarmstruct.c item.bEnable = TRUE; item.bHour12 = TRUE; GetMyRegStr("", "JihouFile", item.fname, MAX_PATH, ""); if(GetMyRegLong("", "JihouRepeat", FALSE)) item.bRepeatJihou = TRUE; if(GetMyRegLong("", "JihouBlink", FALSE)) { item.bBlink = TRUE; item.nBlinkSec = 60; } m_pAlarm = copy_listitem(m_pAlarm, &item, sizeof(item)); } m_bCheckEverySeconds = FALSE; pitem = m_pAlarm; while(pitem) { if(pitem->bEnable) { if(pitem->second) m_bCheckEverySeconds = TRUE; else if(pitem->bInterval) { if(!pitem->bBootExec) pitem->tickLast = GetTickCount(); m_bCheckEverySeconds = TRUE; } if(pitem->bResumeExec) m_bCheckEverySeconds = TRUE; } pitem = pitem->next; } }
/*------------------------------------------------ initiazlize "Color" comboboxes --------------------------------------------------*/ void InitColor(HWND hDlg) { InitColorCombo(hDlg, IDC_COLHOUR, NULL, 0, GetMyRegLong(m_section, "HourHandColor", 0)); InitColorCombo(hDlg, IDC_COLMIN, NULL, 0, GetMyRegLong(m_section, "MinHandColor", 0)); }
/*------------------------------------------------------------- read settings and initialize this function is called in InitClock() and OnRefreshClock() ReadData() in old version ---------------------------------------------------------------*/ void LoadSetting(HWND hwnd) { g_bNoClock = GetMyRegLong(NULL, "NoClock", FALSE); g_bLMousePassThru = GetMyRegLong("Mouse", "LeftMousePassThrough", (g_winver&WIN10RS1) != 0); #if TC_ENABLE_MOUSEDROP DragAcceptFiles(hwnd, GetMyRegLong(NULL, "DropFiles", FALSE)); #endif LoadFormatSetting(hwnd); // format.c LoadDrawingSetting(hwnd); // drawing.c }
void TooltipReadData(void) { char fontname[80]; int fontsize; LONG weight, italic; GetMyRegStrEx(NULL, "TipFont", fontname, 80, "", gConfigNo); if (fontname[0] == 0) { HFONT hfont; hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if(hfont) { LOGFONT lf; GetObject(hfont, sizeof(lf),(LPVOID)&lf); strcpy(fontname, lf.lfFaceName); } } fontsize = GetMyRegLongEx(NULL, "TipFontSize", 9, gConfigNo); weight = GetMyRegLongEx(NULL, "TipBold", 0, gConfigNo); if(weight) weight = FW_BOLD; else weight = 0; italic = GetMyRegLongEx(NULL, "TipItalic", 0, gConfigNo); if(hFonTooltip) DeleteObject(hFonTooltip); hFonTooltip = CreateMyFont(fontname, fontsize, weight, italic); dwTooltipType = GetMyRegLong(NULL, "BalloonFlg", 0); alphaTooltip = (int)(short)GetMyRegLongEx(NULL, "AlphaTip", 0, gConfigNo); iTooltipDispTime = (int)(short)GetMyRegLong(NULL, "TipDispTime", 5); bTooltipCustomDrawDisable = GetMyRegLong("Tooltip", "TipDisableCustomDraw", TRUE); bTooltipUpdateEnable[0] = GetMyRegLong("Tooltip", "Tip1Update", 0); bTooltipUpdateEnable[1] = GetMyRegLong("Tooltip", "Tip2Update", 0); bTooltipUpdateEnable[2] = GetMyRegLong("Tooltip", "Tip3Update", 0); dwTooltipFonCol = GetMyRegLongEx(NULL, "TipFonColor", 0x80000000 | COLOR_INFOTEXT, gConfigNo); dwTooltipBakCol = GetMyRegLongEx(NULL, "TipBakColor", 0x80000000 | COLOR_INFOBK, gConfigNo); bTooltipEnableDoubleBuffering = GetMyRegLong("Tooltip", "TipEnableDoubleBuffering", FALSE); nTooltipIcon = GetMyRegLongEx("", "TipIcon", 0, gConfigNo); iTooltipDispInterval = (int)(short)GetMyRegLong("Tooltip", "TipDispInterval", 1); if (iTooltipDispInterval > 30) iTooltipDispInterval = 30; if (iTooltipDispInterval < 1) iTooltipDispInterval = 1; iTooltipSizeX = GetMyRegLong("Tooltip", "HTMLTipDispSizeX", 200); iTooltipSizeY = GetMyRegLong("Tooltip", "HTMLTipDispSizeY", 200); }
/*-------------------------------------------------- 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); } }
/*------------------------------------------- set items to left tree view ---------------------------------------------*/ void InitTreeView(HWND hDlg) { HWND hTree; TV_INSERTSTRUCT tv; HTREEITEM hTreeItem[MAX_TREEITEM]; int i; hTree = GetDlgItem(hDlg, IDC_TREE); memset(&tv, 0, sizeof(TV_INSERTSTRUCT)); tv.hInsertAfter = TVI_LAST; tv.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM; tv.item.state = TVIS_EXPANDED; tv.item.stateMask = TVIS_EXPANDED; for(i = 0; i < MAX_TREEITEM; i++) { int nParent = g_treeItem[i].nParent; tv.item.lParam = i; if(nParent < 0) tv.hParent = TVI_ROOT; else tv.hParent = hTreeItem[nParent]; tv.item.pszText = MyString(g_treeItem[i].idStr, g_treeItem[i].entry); hTreeItem[i] = TreeView_InsertItem(hTree, &tv); } m_lastTreeItem = GetMyRegLong("", "LastTreeItem", 0); if(m_lastTreeItem >= MAX_TREEITEM) m_lastTreeItem = 0; TreeView_SelectItem(hTree, hTreeItem[m_lastTreeItem]); }
/*------------------------------------------------ apply - save settings --------------------------------------------------*/ void OnApply(HWND hDlg) { int i, count, n_autoexec; PAUTOEXECSTRUCT pAS; n_autoexec = 0; if(curAutoExec < 0) { char name[40]; GetDlgItemText(hDlg, IDC_COMBOAUTOEXEC, name, 40); if(name[0] && IsDlgButtonChecked(hDlg, IDC_AUTOEXEC)) { pAS = malloc(sizeof(AUTOEXECSTRUCT)); if(pAS) { int index; GetAutoExecFromDlg(hDlg, pAS); index = CBAddString(hDlg, IDC_COMBOAUTOEXEC, (LPARAM)pAS->name); CBSetItemData(hDlg, IDC_COMBOAUTOEXEC, index, (LPARAM)pAS); curAutoExec = index; CBSetCurSel(hDlg, IDC_COMBOAUTOEXEC, index); EnableDlgItem(hDlg, IDC_DELAUTOEXEC, TRUE); } } } else { pAS = (PAUTOEXECSTRUCT)CBGetItemData(hDlg, IDC_COMBOAUTOEXEC, curAutoExec); if(pAS) GetAutoExecFromDlg(hDlg, pAS); } count = CBGetCount(hDlg, IDC_COMBOAUTOEXEC); for(i = 0; i < count; i++) { PAUTOEXECSTRUCT pAS; pAS = (PAUTOEXECSTRUCT)CBGetItemData(hDlg, IDC_COMBOAUTOEXEC, i); if(pAS) { SaveAutoExecToReg(pAS, n_autoexec); n_autoexec++; } } for(i = n_autoexec; ; i++) { char subkey[20]; wsprintf(subkey, "AutoExec%d", i + 1); if(GetMyRegLong(subkey, "Hour", -1) >= 0) DelMyRegKey(subkey); else break; } SetMyRegLong("", "AutoExecNum", n_autoexec); InitAlarm(); // alarm.c }
/*------------------------------------------------ initialize --------------------------------------------------*/ void OnInit(HWND hDlg) { int i, count, index; HFONT hfont; hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if(hfont) { SendDlgItemMessage(hDlg, IDC_COMBOAUTOEXEC, WM_SETFONT, (WPARAM)hfont, 0); SendDlgItemMessage(hDlg, IDC_FILEAUTOEXEC, WM_SETFONT, (WPARAM)hfont, 0); } index = CBAddString(hDlg, IDC_COMBOAUTOEXEC, (LPARAM)MyString(IDS_ADDALARM)); CBSetItemData(hDlg, IDC_COMBOAUTOEXEC, index, 0); count = GetMyRegLong("", "AutoExecNum", 0); if(count < 1) count = 0; for(i = 0; i < count; i++) { PAUTOEXECSTRUCT pAS; pAS = malloc(sizeof(AUTOEXECSTRUCT)); ReadAutoExecFromReg(pAS, i); index = CBAddString(hDlg, IDC_COMBOAUTOEXEC, (LPARAM)pAS->name); CBSetItemData(hDlg, IDC_COMBOAUTOEXEC, index, (LPARAM)pAS); if(i == 0) SetAutoExecToDlg(hDlg, pAS); } //リスト項目の表示数を指定 AdjustDlgConboBoxDropDown(hDlg, IDC_COMBOAUTOEXEC, 7); if(count > 0) { CBSetCurSel(hDlg, IDC_COMBOAUTOEXEC, 1); curAutoExec = 1; } else { AUTOEXECSTRUCT as; CBSetCurSel(hDlg, IDC_COMBOAUTOEXEC, 0); curAutoExec = -1; memset(&as, 0, sizeof(as)); as.hour = 12; as.days = 0x7f; SetAutoExecToDlg(hDlg, &as); } SendDlgItemMessage(hDlg, IDC_TESTAUTOEXEC, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_hIconPlay); OnFileChange(hDlg, IDC_FILEAUTOEXEC); SendDlgItemMessage(hDlg, IDC_DELAUTOEXEC, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_hIconDel); OnAutoExec(hDlg, IDC_AUTOEXEC); bPlaying = FALSE; }
//================================================================================================ //-------------------------------//---------------------------+++--> Initialize the HotKeys Dialog: static void OnInit(HWND hDlg) { //----------------------------------------------------------+++--> char subkey[TNY_BUFF] = {0}; int i; bFirstTime = TRUE; tchk = malloc(sizeof(TCHOTKEY) * 5); for(i=0; i <= 4; i++) { wsprintf(subkey, "%s\\HK%d", szHotKeySubKey, i); tchk[i].bValid = GetMyRegLong(subkey, "bValid", 0); // GetMyRegStrEx(subkey, "szText", tchk[i].szText, GEN_BUFF, "None"); GetMyRegStrEx(subkey, "szText", tchk[i].szText, TNY_BUFF, "None"); tchk[i].fsMod = GetMyRegLong(subkey, "fsMod", 0); tchk[i].vk = GetMyRegLong(subkey, "vk", 0); } SetDlgItemText(hDlg, IDCE_HK_ADD, tchk[0].szText); SetDlgItemText(hDlg, IDCE_HK_STOP, tchk[1].szText); SetDlgItemText(hDlg, IDCE_HK_TIME, tchk[2].szText); SetDlgItemText(hDlg, IDCE_HK_PROP, tchk[3].szText); SetDlgItemText(hDlg, IDCE_HK_CALN, tchk[4].szText); // Subclass the Edit Controls OldEditClassProc = (WNDPROC)(LONG_PTR)GetWindowLongPtr(GetDlgItem(hDlg, IDCE_HK_ADD), GWL_WNDPROC); //================================================================================== #if defined _M_IX86 //---------------+++--> IF Compiling This as a 32-bit Clock Use: SetWindowLongPtr(GetDlgItem(hDlg, IDCE_HK_ADD), GWL_WNDPROC, (LONG)(LRESULT)SubClassEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDCE_HK_STOP), GWL_WNDPROC, (LONG)(LRESULT)SubClassEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDCE_HK_TIME), GWL_WNDPROC, (LONG)(LRESULT)SubClassEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDCE_HK_PROP), GWL_WNDPROC, (LONG)(LRESULT)SubClassEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDCE_HK_CALN), GWL_WNDPROC, (LONG)(LRESULT)SubClassEditProc); //================================================================================== #else //-------------------+++--> ELSE Assume: _M_X64 - IT's a 64-bit Clock and Use: SetWindowLongPtr(GetDlgItem(hDlg, IDCE_HK_ADD), GWL_WNDPROC, (LONG_PTR)(LRESULT)SubClassEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDCE_HK_STOP), GWL_WNDPROC, (LONG_PTR)(LRESULT)SubClassEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDCE_HK_TIME), GWL_WNDPROC, (LONG_PTR)(LRESULT)SubClassEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDCE_HK_PROP), GWL_WNDPROC, (LONG_PTR)(LRESULT)SubClassEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDCE_HK_CALN), GWL_WNDPROC, (LONG_PTR)(LRESULT)SubClassEditProc); #endif //================================================================================== }
/*------------------------------------------------ initialize --------------------------------------------------*/ void OnInit(HWND hDlg) { char s[MAX_PATH]; // common/tclang.c SetDialogLanguage(hDlg, "Misc", g_hfontDialog); CheckDlgButton(hDlg, IDC_NOCLOCK, GetMyRegLong(NULL, "NoClock", FALSE)); CheckDlgButton(hDlg, IDC_MCIWAVE, GetMyRegLong(NULL, "MCIWave", FALSE)); SetDlgItemInt(hDlg, IDC_DELAYSTART, GetMyRegLong(NULL, "DelayStart", 0), FALSE); CheckDlgButton(hDlg, IDC_TASKBARRESTART, GetMyRegLong(NULL, "TaskbarRestart", FALSE)); #if TC_ENABLE_DESKTOPICON CheckDlgButton(hDlg, IDC_DESKTOPICON, GetMyRegLong(NULL, "DeskTopIcon", FALSE)); CheckDlgButton(hDlg, IDC_TRANSDESKTOPICONBK, GetMyRegLong(NULL, "TransDeskTopIconBK", FALSE)); #endif GetMyRegStr(NULL, "HelpURL", s, MAX_PATH, ""); SetDlgItemText(hDlg, IDC_HELPURL, s); m_bInit = TRUE; }
/*------------------------------------------- initialize main dialog ---------------------------------------------*/ void OnInit(HWND hDlg) { HICON hIcon; // common/tclang.c SetDialogLanguage(hDlg, "Player", g_hfontDialog); hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_TCLOCK)); SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); // common/dialog.c SetMyDialgPos(hDlg, 32, 32); CheckDlgButton(hDlg, IDC_SHOWTIME, GetMyRegLong(m_section, "Disp", FALSE)); CheckRadioButton(hDlg, IDC_SHOWWHOLE, IDC_SHOWUSTR, IDC_SHOWWHOLE + GetMyRegLong(m_section, "DispType", 1)); SetDlgItemInt(hDlg, IDC_SHOWUSTRNUM, GetMyRegLong(m_section, "UserStr", 0), FALSE); OnShowTime(hDlg); }
/*--------------------------------------------------- send SNTP data ---------------------------------------------------*/ void SNTPSend(HWND hwndSNTP, unsigned long serveraddr) { struct sockaddr_in serversockaddr; struct NTP_Packet NTP_Send; unsigned int sntpver; HOSTTIME ht; // request notification of events if(WSAAsyncSelect(m_socket, hwndSNTP, WSOCK_SELECT, FD_READ) == SOCKET_ERROR) { SocketClose(hwndSNTP, "WSAAsyncSelect() failed"); PostMessage(hwndSNTP, SNTPM_ERROR, 0, 0); return; } // set IP address and port serversockaddr.sin_family = AF_INET; serversockaddr.sin_addr.s_addr = serveraddr; serversockaddr.sin_port = htons((unsigned short)m_port); memset(serversockaddr.sin_zero,(int)0,sizeof(serversockaddr.sin_zero)); // init a packet memset(&NTP_Send, 0, sizeof(struct NTP_Packet)); // NTP/SNTP version number = 4 // Mode = 3 (client) // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // |LI | VN |Mode | Stratum | Poll | Precision | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ sntpver = GetMyRegLong(m_section, "SNTPVer", 4); NTP_Send.Control_Byte = (BYTE)(((sntpver&0x7) << 3) | 3); GetRealSystemTimeAsFileTime((FILETIME*)&ht); // save tickcount m_dwTickCountOnSend = timeGetTime(); HostTimeToNTPTime(&ht, &NTP_Send.transmit_timestamp); // send a packet if(sendto(m_socket, (const char *)&NTP_Send, sizeof(NTP_Send), 0, (struct sockaddr *)&serversockaddr, sizeof(serversockaddr)) == SOCKET_ERROR) { SocketClose(hwndSNTP, "sendto() failed"); PostMessage(hwndSNTP, SNTPM_ERROR, 0, 0); return; } SetTimer(hwndSNTP, IDTIMER_MAIN, m_nTimeOut, NULL); }
/*------------------------------------------------ initialize "Color" comboboxes --------------------------------------------------*/ void InitColor(HWND hDlg) { COLORREF cols[4], colDef; cols[0] = 0x80000000|COLOR_3DFACE; cols[1] = 0x80000000|COLOR_3DSHADOW; cols[2] = 0x80000000|COLOR_3DHILIGHT; cols[3] = 0x80000000|COLOR_BTNTEXT; colDef = GetMyRegLong("", "BackColor", 0x80000000 | COLOR_3DFACE); InitColorCombo(hDlg, IDC_COLBACK, cols, 4, colDef); colDef = GetMyRegLong("", "BackColor2", colDef); InitColorCombo(hDlg, IDC_COLBACK2, cols, 4, colDef); colDef = GetMyRegLong("", "ForeColor", 0x80000000 | COLOR_BTNTEXT); InitColorCombo(hDlg, IDC_COLFORE, cols, 4, colDef); colDef = GetMyRegLong("", "ShadowColor", 0); InitColorCombo(hDlg, IDC_COLSHADOW, cols, 4, colDef); }
/*--------------------------------------------------- load settings for time syncronizing ---------------------------------------------------*/ void InitSyncTimeSetting(void) { char section[] = "SNTP"; char s[80]; bSyncTimer = GetMyRegLong(section, "Timer", FALSE); bSyncADay = GetMyRegLong(section, "ADay", TRUE); nMinutes = GetMyRegLong(section, "Minutes", 60); bNoDial = FALSE; if(hRASAPI) bNoDial = GetMyRegLong(section, "NoDial", TRUE); nLastDay = GetMyRegLong(section, "LastDay", -1); GetMyRegStr(section, "Begin", s, 80, ""); if(s[0]) { time2int(&nHourStart, &nMinuteStart, s); GetMyRegStr(section, "End", s, 80, ""); if(s[0]) time2int(&nHourEnd, &nMinuteEnd, s); else nHourStart = nMinuteStart = -1; } }
/*-------------------------------------------------- start customizing desktop icons ----------------------------------------------------*/ void SetDesktopIcons(void) { LONG s; //BOOL c; if(!GetMyRegLong(NULL, "DeskTopIcon", FALSE)) { EndDesktopIcons(); return; } GetDesktopIcons(); if(hwndDesktop) { // small icon s = GetWindowLong(hwndDesktop, GWL_STYLE); if((s & LVS_SMALLICON) == 0) { SetWindowLong(hwndDesktop, GWL_STYLE, s | LVS_SMALLICON); } #if 0 // transparent c = (ListView_GetTextBkColor(hwndDesktop) == CLR_NONE); if(GetMyRegLong(NULL, "TransDeskTopIconBK", FALSE)) { if(!c) DesktopIconsTransparentSetReset(TRUE); } else { if(c) DesktopIconsTransparentSetReset(FALSE); } #endif } }
/*--------------------------------------------------- send SNTP data ---------------------------------------------------*/ void SNTPSend(HWND hwnd, unsigned long serveraddr) { struct sockaddr_in serversockaddr; struct NTP_Packet NTP_Send; unsigned int sntpver; unsigned int Control_Word; // request notification of events if(WSAAsyncSelect(g_socket, hwnd, WSOCK_SELECT, FD_READ) == SOCKET_ERROR) { SocketClose(hwnd, "WSAAsyncSelect() failed"); return; } // set IP address and port serversockaddr.sin_family = AF_INET; serversockaddr.sin_addr.s_addr = serveraddr; serversockaddr.sin_port = htons((unsigned short)g_port); memset(serversockaddr.sin_zero,(int)0,sizeof(serversockaddr.sin_zero)); // init a packet memset(&NTP_Send, 0, sizeof(struct NTP_Packet)); // NTP/SNTP version number = 4 // Mode = 3 (client) // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // |LI | VN |Mode | Stratum | Poll | Precision | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ sntpver = GetMyRegLong("SNTP", "SNTPVer", 4); Control_Word = (sntpver << 27) | (3 << 24); NTP_Send.Control_Word = htonl(Control_Word); // send a packet if(sendto(g_socket, (const char *)&NTP_Send, sizeof(NTP_Send), 0, (struct sockaddr *)&serversockaddr, sizeof(serversockaddr)) == SOCKET_ERROR) { SocketClose(hwnd, "sendto() failed"); return; } // save tickcount dwTickCountOnSend = GetTickCount(); bSendingData = TRUE; }
/*-------------------------------------------------- read settings ----------------------------------------------------*/ void InitStartMenuSetting(HWND hwndClock) { char fname[MAX_PATH], s[MAX_PATH]; m_bStartMenu = GetMyRegLong(NULL, "StartMenu", FALSE); m_bStartMenu = GetMyRegLong(m_section, "StartMenu", m_bStartMenu); m_alpha = GetMyRegLong(NULL, "AlphaStartMenu", 0); m_alpha = GetMyRegLong(m_section, "Alpha", m_alpha); m_alpha = 255 - (m_alpha * 255 / 100); if(m_alpha < 8) m_alpha = 8; else if(m_alpha > 255) m_alpha = 255; if(m_bStartMenu || m_alpha < 255) m_bSubclass = TRUE; if(!m_bStartMenu) return; m_colMenu = GetMyRegLong(NULL, "StartMenuCol", RGB(128, 128, 128)); m_colMenu = GetMyRegLong(m_section, "Color", m_colMenu); m_bTile = GetMyRegLong(NULL, "StartMenuTile", FALSE); m_bTile = GetMyRegLong(m_section, "Tile", m_bTile); GetMyRegStr(NULL, "StartMenuBmp", s, MAX_PATH, ""); GetMyRegStr(m_section, "Bitmap", fname, MAX_PATH, s); if(fname[0]) // load bitmap { char fname2[MAX_PATH]; RelToAbs(fname2, fname); m_hbmpMenu = ReadBitmap(hwndClock, fname2, FALSE); if(m_hbmpMenu) { HDC hdc; hdc = GetDC(hwndClock); m_hdcMemMenu = CreateCompatibleDC(hdc); SelectObject(m_hdcMemMenu, m_hbmpMenu); ReleaseDC(hwndClock, hdc); } } }
/*------------------------------------------- "Start" button ---------------------------------------------*/ void OnOK(HWND hDlg) { PTIMERSTRUCT pitem; char section[20]; int i, nOldTimer; /* save settings */ GetTimerFromDlg(hDlg, get_listitem(m_pTimer, m_nCurrent)); nOldTimer = GetMyRegLong(NULL, "TimerNum", 0); pitem = m_pTimer; for(i = 0; pitem; i++) { wsprintf(section, "Timer%d", i + 1); SetMyRegStr(section, "Name", pitem->name); SetMyRegLong(section, "Minute", pitem->minute); SetMyRegLong(section, "Second", pitem->second); SetMyRegStr(section, "File", pitem->fname); SetMyRegLong(section, "Repeat", pitem->bRepeat); SetMyRegLong(section, "Blink", pitem->bBlink); SetMyRegLong(section, "Disp", pitem->bDisp); SetMyRegLong(section, "DispType", pitem->nDispType); SetMyRegLong(section, "UserStr", pitem->nUserStr); pitem = pitem->next; } SetMyRegLong(NULL, "TimerNum", i); for(; i < nOldTimer; i++) { wsprintf(section, "Timer%d", i + 1); DelMyRegKey(section); } /* start a timer */ TimerStart(get_listitem(m_pTimer, m_nCurrent)); DestroyWindow(hDlg); }
/*------------------------------------------------ initialize --------------------------------------------------*/ void OnInit(HWND hDlg) { char s[MAX_PATH]; m_bInit = FALSE; // common/tclang.c SetDialogLanguage(hDlg, "AnalogClock", g_hfontDialog); CheckDlgButton(hDlg, IDC_ANALOGCLOCK, GetMyRegLong(m_section, "UseAnalogClock", FALSE)); OnAnalogClock(hDlg); InitColor(hDlg); CheckDlgButton(hDlg, IDC_HOURHANDBOLD, GetMyRegLong(m_section, "HourHandBold", FALSE)); CheckDlgButton(hDlg, IDC_MINHANDBOLD, GetMyRegLong(m_section, "MinHandBold", FALSE)); CheckRadioButton(hDlg, IDC_ANALOGPOSMIDDLE, IDC_ANALOGPOSRIGHT, GetMyRegLong(m_section, "AnalogClockPos", 0) + IDC_ANALOGPOSMIDDLE); UpDown_SetBuddy(hDlg, IDC_ANALOGHPOSSPIN, IDC_ANALOGHPOS); UpDown_SetRange(hDlg, IDC_ANALOGHPOSSPIN, 999, -999); UpDown_SetPos(hDlg, IDC_ANALOGHPOSSPIN, GetMyRegLong(m_section, "HorizontalPos", 0)); UpDown_SetBuddy(hDlg, IDC_ANALOGVPOSSPIN, IDC_ANALOGVPOS); UpDown_SetRange(hDlg, IDC_ANALOGVPOSSPIN, 999, -999); UpDown_SetPos(hDlg, IDC_ANALOGVPOSSPIN, GetMyRegLong(m_section, "VerticalPos", 0)); UpDown_SetBuddy(hDlg, IDC_ANALOGSIZESPIN, IDC_ANALOGSIZE); UpDown_SetRange(hDlg, IDC_ANALOGSIZESPIN, 99, 0); UpDown_SetPos(hDlg, IDC_ANALOGSIZESPIN, GetMyRegLong(m_section, "Size", 0)); GetMyRegStr(m_section, "Bitmap", s, MAX_PATH, ""); SetDlgItemText(hDlg, IDC_ANALOGBMP, s); m_bInit = TRUE; }
/*--------------------------------------------------- command to start syncronizing ---------------------------------------------------*/ void StartSyncTime(HWND hwndParent, char* pServer, int nto) { HWND hwnd; SYSTEMTIME st; char section[] = "SNTP"; char server[80], s[80]; if(g_socket != -1 || g_hGetHost != NULL) return; if(pServer == NULL || *pServer == 0) { GetMyRegStr(section, "Server", server, 80, ""); pServer = server; } if(nto == 0) nto = GetMyRegLong(section, "Timeout", 1000); if(*pServer == 0) return; hwnd = GetDlgItem(hwndParent, 1); if(!hwnd) return; nMinuteDif = 0; GetMyRegStr(section, "Dif", s, 80, ""); if(s[0]) { int h, m; time2int(&h, &m, s); nMinuteDif = h * 60 + m; } GetLocalTime(&st); nLastDay = st.wDay; SetMyRegLong(section, "LastDay", nLastDay); dwTickCount = GetTickCount(); bFirst = FALSE; nTimeout = nto; SNTPStart(hwnd, pServer); }
/*--------------------------------------------------- check RAS connection ---------------------------------------------------*/ BOOL IsRASConnection(void) { RASCONN rc; RASCONNSTATUS rcs; DWORD cb, cConnections; // load DLL of RAS API if(!m_hRASAPI && !GetMyRegLong(m_section, "NoRASAPI", FALSE)) { m_hRASAPI = LoadLibrary("RASAPI32.dll"); if(m_hRASAPI) { (FARPROC)m_pRasEnumConnections = GetProcAddress(m_hRASAPI, "RasEnumConnectionsA"); (FARPROC)m_pRasGetConnectStatus = GetProcAddress(m_hRASAPI, "RasGetConnectStatusA"); if(m_pRasEnumConnections == NULL || m_pRasGetConnectStatus == NULL) { FreeLibrary(m_hRASAPI); m_hRASAPI = NULL; } } } if(!m_hRASAPI) return FALSE; memset(&rc, 0, sizeof(rc)); rc.dwSize = sizeof(rc); cb = sizeof(rc); if(m_pRasEnumConnections(&rc, &cb, &cConnections) == 0 && cConnections > 0) { memset(&rcs, 0, sizeof(rcs)); rcs.dwSize = sizeof(rcs); if(m_pRasGetConnectStatus(rc.hrasconn, &rcs) == 0 && rcs.rasconnstate == RASCS_Connected) return TRUE; } return FALSE; }
/*------------------------------------------------ read settings of an alarm --------------------------------------------------*/ void ReadAutoExecFromReg(PAUTOEXECSTRUCT pAS, int num) { char subkey[20]; wsprintf(subkey, "AutoExec%d", num + 1); GetMyRegStr(subkey, "Name", pAS->name, 40, ""); pAS->bAutoExec = GetMyRegLong(subkey, "AutoExec", FALSE); pAS->hour = GetMyRegLong(subkey, "Hour", 0xffffff); pAS->minute1 = GetMyRegLong(subkey, "Minute1", 0); pAS->minute2 = GetMyRegLong(subkey, "Minute2", 0); GetMyRegStr(subkey, "File", pAS->fname, 1024, ""); pAS->days = GetMyRegLong(subkey, "Days", 0x7f); pAS->bOnBoot = GetMyRegLong(subkey, "OnBoot", FALSE); if(pAS->name[0] == 0) wsprintf(pAS->name, "自動実行%d", num); }
/*------------------------------------------- save log data ---------------------------------------------*/ void Log(const char* msg) { SYSTEMTIME st; char s[160]; int count, index; GetLocalTime(&st); wsprintf(s, "%02d/%02d %02d:%02d:%02d ", st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); strcat(s, msg); // save to listbox count = SendMessage(hwndSNTPLog, LB_GETCOUNT, 0, 0); if(count > 100) SendMessage(hwndSNTPLog, LB_DELETESTRING, 0, 0); index = SendMessage(hwndSNTPLog, LB_ADDSTRING, 0, (LPARAM)s); SendMessage(hwndSNTPLog, LB_SETCURSEL, index, 0); // save to file if(GetMyRegLong("SNTP", "SaveLog", TRUE)) { HFILE hf; char fname[MAX_PATH]; strcpy(fname, g_mydir); add_title(fname, "SNTP.txt"); hf = _lopen(fname, OF_WRITE); if(hf == HFILE_ERROR) hf = _lcreat(fname, 0); if(hf == HFILE_ERROR) return; _llseek(hf, 0, 2); _lwrite(hf, s, strlen(s)); _lwrite(hf, "\x0d\x0a", 2); _lclose(hf); } }
/*------------------------------------------------ ページの初期化 --------------------------------------------------*/ void OnInit(HWND hDlg) { char s[1024]; HFONT hfont; DWORD dw; hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if(hfont) SendDlgItemMessage(hDlg, IDC_COMDESKCAL, WM_SETFONT, (WPARAM)hfont, 0); CheckDlgButton(hDlg, IDC_NOCLOCK, GetMyRegLong("", "NoClock", FALSE)); CheckDlgButton(hDlg, IDC_MCIWAVE, GetMyRegLong("", "MCIWave", FALSE)); SendDlgItemMessage(hDlg, IDC_SPINDELAYSTART, UDM_SETRANGE, 0, MAKELONG(600, 0)); SendDlgItemMessage(hDlg, IDC_SPINDELAYSTART, UDM_SETPOS, 0, (int)(short)GetMyRegLong("", "DelayStart", 0)); SendDlgItemMessage(hDlg, IDC_SPINDELAYNET, UDM_SETRANGE, 0, MAKELONG(600, 0)); SendDlgItemMessage(hDlg, IDC_SPINDELAYNET, UDM_SETPOS, 0, (int)(short)GetMyRegLong("", "DelayNet", 0)); SendDlgItemMessage(hDlg, IDC_SPINCHECKNETINTERVAL, UDM_SETRANGE, 0, MAKELONG(0, 600)); SendDlgItemMessage(hDlg, IDC_SPINCHECKNETINTERVAL, UDM_SETPOS, 0, (int)(short)GetMyRegLong("", "NetRestartInterval", 0)); CheckDlgButton(hDlg, IDC_DESKCAL, GetMyRegLong("", "Deskcal", FALSE)); CheckDlgButton(hDlg, IDC_CHECKNETWORK, GetMyRegLong("", "DoNetRestart", FALSE)); GetMyRegStr("", "DeskcalCommand", s, 1024, ""); if(s[0] == '\0') { GetRegStr(HKEY_CURRENT_USER, "Software\\Shinonon\\Deskcal", "ExeFileName", s, 1024, ""); } SetDlgItemText(hDlg, IDC_COMDESKCAL, s); CheckDlgButton(hDlg, IDC_ONLYDATECHANGED, GetMyRegLong("", "DeskcalOnlyDate", FALSE)); CheckDlgButton(hDlg, IDC_RESUMESUSPEND, GetMyRegLong("", "DeskcalResumeSuspend", FALSE)); CheckDlgButton(hDlg, IDC_TONIKAKU, GetMyRegLong("", "DeskcalTonikaku", FALSE)); CheckDlgButton(hDlg, IDC_WATCHWALL, GetMyRegLong("", "WatchWallpaper", FALSE)); CheckDlgButton(hDlg, IDC_TASKWNDCTRL, GetMyRegLong("", "WatchTaskbarWindow", FALSE)); dw = GetMyRegLong(NULL, "ConfigMax", 1); if(dw > 30) dw = 30; if(dw < 1 ) dw = 1; SendDlgItemMessage(hDlg,IDC_CFMAXSPIN,UDM_SETRANGE,0, (LPARAM) MAKELONG((short)30, (short)1)); SendDlgItemMessage(hDlg, IDC_CFMAXSPIN, UDM_SETPOS, 0, (int)(short)dw); OnDeskcal(hDlg); OnCheckNet(hDlg); }
/*--------------------------------------------------- create a window, initialize WinSock ---------------------------------------------------*/ BOOL InitSyncTime(HWND hwndParent) { char classname[] = "TClockSNTPWnd"; WNDCLASS wndclass; WORD wVersionRequested; int nErrorStatus; WSADATA wsaData; g_socket = (SOCKET)-1; g_hGetHost = NULL; // initialize WinSock wVersionRequested = MAKEWORD(1, 1); nErrorStatus = WSAStartup(wVersionRequested, &wsaData); if(nErrorStatus != 0) { Log("failed to initialize"); return FALSE; } // load DLL of RAS API if(!GetMyRegLong("SNTP", "NoRASAPI", FALSE)) { hRASAPI = LoadLibrary("RASAPI32.dll"); if(hRASAPI) { RasEnumConnections = (pfnRasEnumConnections) GetProcAddress(hRASAPI, "RasEnumConnectionsA"); RasGetConnectStatus = (pfnRasGetConnectStatus) GetProcAddress(hRASAPI, "RasGetConnectStatusA"); if(RasEnumConnections == NULL || RasGetConnectStatus == NULL) { FreeLibrary(hRASAPI); hRASAPI = NULL; } } } // register a window class and create wndclass.style = 0; wndclass.lpfnWndProc = SNTPWndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = g_hInst; wndclass.hIcon = NULL; wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wndclass.lpszMenuName = NULL; wndclass.lpszClassName = classname; RegisterClass(&wndclass); hwndSNTP = CreateWindow(classname, "TClockSNTP", WS_CHILD, 0, 0, 0, 0, hwndParent, (HMENU)1, g_hInst, NULL); hwndSNTPLog = CreateWindowEx(WS_EX_CLIENTEDGE, "listbox", "", WS_CHILD|WS_VSCROLL|WS_TABSTOP, 0, 0, 0, 0, hwndSNTP, (HMENU)1, g_hInst, NULL); InitSyncTimeSetting(); return TRUE; }
/*------------------------------------------------ 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 "Format" page --------------------------------------------------*/ void OnInit(HWND hDlg) { HFONT hfont; char s[BUFSIZE_FORMAT]; int i, ilang; // common/tclang.c SetDialogLanguage(hDlg, "Format", g_hfontDialog); hfont = (HFONT)GetStockObject(SYSTEM_FIXED_FONT); if(hfont) SendDlgItemMessage(hDlg, IDC_FORMAT, WM_SETFONT, (WPARAM)hfont, 0); // "Locale" combobox ilang = GetMyRegLong("", "Locale", (int)GetUserDefaultLangID()); InitLocaleCombo(hDlg, IDC_LOCALE, ilang); // common/combobox.c InitAutoFormat(ilang); // common/autoformat.c // "year" -- "second" for(i = IDC_YEAR4; i <= IDC_KAIGYO; i++) { CheckDlgButton(hDlg, i, GetMyRegLong("", ENTRY(i), TRUE)); } if(IsDlgButtonChecked(hDlg, IDC_YEAR)) CheckRadioButton(hDlg, IDC_YEAR4, IDC_YEAR, IDC_YEAR); if(IsDlgButtonChecked(hDlg, IDC_YEAR4)) CheckRadioButton(hDlg, IDC_YEAR4, IDC_YEAR, IDC_YEAR4); if(IsDlgButtonChecked(hDlg, IDC_MONTH)) CheckRadioButton(hDlg, IDC_MONTH, IDC_MONTHS, IDC_MONTH); if(IsDlgButtonChecked(hDlg, IDC_MONTHS)) CheckRadioButton(hDlg, IDC_MONTH, IDC_MONTHS, IDC_MONTHS); // "Internet Time" -- "Customize format" for(i = IDC_AMPM; i <= IDC_CUSTOM; i++) { CheckDlgButton(hDlg, i, GetMyRegLong("", ENTRY(i), FALSE)); } GetMyRegStr("", "Format", s, BUFSIZE_FORMAT, ""); SetDlgItemText(hDlg, IDC_FORMAT, s); GetMyRegStr("", "CustomFormat", m_CustomFormat, BUFSIZE_FORMAT, ""); On12Hour(hDlg); OnCustom(hDlg, FALSE); #if TC_ENABLE_SYSINFO // "Update interval" UpDown_SetBuddy(hDlg, IDC_SYSIISPIN, IDC_SYSII); UpDown_SetRange(hDlg, IDC_SYSIISPIN, 60, 1); i = GetMyRegLong(NULL, "IntervalSysInfo", 4); if(i < 1 || 60 < i) i = 4; UpDown_SetPos(hDlg, IDC_SYSIISPIN, i); #endif m_bInit = TRUE; }
/*------------------------------------------- initialize main dialog ---------------------------------------------*/ void OnInit(HWND hDlg) { HICON hIcon; char section[20]; int i, count; TIMERSTRUCT item; PTIMERSTRUCT pitem; // common/tclang.c SetDialogLanguage(hDlg, "Timer", g_hfontDialog); hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_TCLOCK)); SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); // ../common/dialog.c SetMyDialgPos(hDlg, 32, 32); SendDlgItemMessage(hDlg, IDC_TIMERTEST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_hIconPlay); UpDown_SetBuddy(hDlg, IDC_TIMERSPIN1, IDC_TIMERMINUTE); UpDown_SetBuddy(hDlg, IDC_TIMERSPIN2, IDC_TIMERSECOND); UpDown_SetRange(hDlg, IDC_TIMERSPIN1, 1440, 0); UpDown_SetRange(hDlg, IDC_TIMERSPIN2, 59, 0); count = GetMyRegLong(NULL, "TimerNum", 0); m_pTimer = NULL; if(count > 0) { for(i = 0; i < count; i++) { memset(&item, 0, sizeof(TIMERSTRUCT)); wsprintf(section, "Timer%d", i + 1); GetMyRegStr(section, "Name", item.name, BUFSIZE_NAME, section); item.minute = GetMyRegLong(section, "Minute", 3); item.second = GetMyRegLong(section, "Second", 0); GetMyRegStr(section, "File", item.fname, MAX_PATH, ""); item.bRepeat = GetMyRegLong(section, "Repeat", FALSE); item.bBlink = GetMyRegLong(section, "Blink", FALSE); item.bDisp = GetMyRegLong(section, "Disp", FALSE); item.nDispType = GetMyRegLong(section, "DispType", 1); item.nUserStr = GetMyRegLong(section, "UserStr", 0); m_pTimer = copy_listitem(m_pTimer, &item, sizeof(TIMERSTRUCT)); // common/list.c } } else { memset(&item, 0, sizeof(TIMERSTRUCT)); strcpy(item.name, "Timer1"); item.minute = 3; item.nDispType = 1; m_pTimer = copy_listitem(m_pTimer, &item, sizeof(TIMERSTRUCT)); } pitem = m_pTimer; while(pitem) { CBAddString(hDlg, IDC_TIMERNAME, (LPARAM)pitem->name); pitem = pitem->next; } m_nCurrent = -1; CBSetCurSel(hDlg, IDC_TIMERNAME, 0); OnName(hDlg); }