/*------------------------------------------------ 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; }
/*------------------------------------------- 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); }
/*------------------------------------------------ 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 --------------------------------------------------*/ 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; }
//"Arrow settings" dialog procedure INT_PTR CALLBACK ASDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch(uMsg) //Message switch { case WM_INITDIALOG: { //Associate the parameters to the window SetWindowLongPtr(hwndDlg,GWLP_USERDATA,(__int3264)(LONG_PTR)lParam); //Get the ASDP ArrowSettingsDlgParam * asdp=(ArrowSettingsDlgParam *)(LONG_PTR)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); //Load the captions of the child windows (and of itself) langFile->InitializeDialogCaptions(hwndDlg, IDD_ARROWSETTINGS); //Set the range of the width updown control UpDown_SetRange(GetDlgItem(hwndDlg,IDC_AS_UD_WIDTH),MAXARROWWL,MINARROWWL); //Set the current width to the current value SetDlgItemInt(hwndDlg,IDC_AS_TX_WIDTH,(UINT)asdp->as->arrowBase,FALSE); //Set the range of the length updown control UpDown_SetRange(GetDlgItem(hwndDlg,IDC_AS_UD_LENGTH),MAXARROWWL,MINARROWWL); //Set the current length to the current value SetDlgItemInt(hwndDlg,IDC_AS_TX_LENGTH,(UINT)asdp->as->arrowLength,FALSE); //Set the "first arrow" check Button_SetCheck(GetDlgItem(hwndDlg,IDC_AS_CH_FIRST),asdp->as->drawFirstArrow?BST_CHECKED:BST_UNCHECKED); //Set the "second arrow" check Button_SetCheck(GetDlgItem(hwndDlg,IDC_AS_CH_SECOND),asdp->as->drawSecondArrow?BST_CHECKED:BST_UNCHECKED); //Set the "open head" check Button_SetCheck(GetDlgItem(hwndDlg,IDC_AS_CH_OPENHEAD),asdp->as->openArrowHead?BST_CHECKED:BST_UNCHECKED); return TRUE; } break; case WM_COMMAND: //Selections, clicks, etc. switch(LOWORD(wParam)) //Controls switch { case IDC_AS_TX_WIDTH: case IDC_AS_TX_LENGTH: if(HIWORD(wParam)==EN_CHANGE) //The text in the textboxes has changed: let's validate it! { static UINT widthLastVal=MINARROWWL; static UINT lengthLastVal=MINARROWWL; if(ValidateUIntFieldChange(hwndDlg,LOWORD(wParam),((LOWORD(wParam)==IDC_AS_TX_WIDTH)?widthLastVal:lengthLastVal),MINARROWWL,MAXARROWWL)) InvalidateRect(GetDlgItem(hwndDlg,IDC_AS_PREVIEW),NULL,TRUE); //Repaint the preview frame } break; case IDC_AS_CH_FIRST: //The state of the checkboxes has changed case IDC_AS_CH_SECOND: case IDC_AS_CH_OPENHEAD: InvalidateRect(GetDlgItem(hwndDlg,IDC_AS_PREVIEW),NULL,TRUE); //Repaint the preview frame break; case IDOK: //The user pressed OK { //Get the ASDP ArrowSettingsDlgParam * asdp=(ArrowSettingsDlgParam *)(LONG_PTR)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); //Assign to the given ArrowSettings the new values *(asdp->as)=ASFromCtrls(hwndDlg); //save the settings } case IDCANCEL: //The user pressed Cancel (note: there's no break) EndDialog(hwndDlg,NULL); break; } return FALSE; case WM_DRAWITEM: //the system asks to draw an owner-draw control { LPDRAWITEMSTRUCT dis=(LPDRAWITEMSTRUCT)lParam; switch(dis->CtlID) { case IDC_AS_PREVIEW: { HRGN paintRgn=CreateRectRgnIndirect(&dis->rcItem); POINT pt1, pt2; ArrowSettings tAS=ASFromCtrls(hwndDlg); pt1.x=10; pt2.x=dis->rcItem.right-10; pt1.y=pt2.y=dis->rcItem.top+(dis->rcItem.bottom-dis->rcItem.top)/2; FillRgn(dis->hDC,paintRgn,GetSysColorBrush(COLOR_WINDOW)); //fill the background DeleteObject(paintRgn); DrawArrow(dis->hDC,pt1,pt2, &tAS); //draw the arrow return FALSE; } } return FALSE; } } return FALSE; }