/*------------------------------------------------ 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; }
/*------------------------------------------------ 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 }
void InitFunction(HWND hDlg, int id) { int index; int i; for(i = 0; i < MAX_MOUSEFUNC; i++) { index = CBAddString(hDlg, id, (LPARAM)MyString(m_mousefunc[i].idStr, m_mousefunc[i].entry)); CBSetItemData(hDlg, id, index, m_mousefunc[i].nCommand); } }
/*------------------------------------------------ selected an alarm name by combobox --------------------------------------------------*/ void OnChangeAutoExec(HWND hDlg) { PAUTOEXECSTRUCT pAS; int index; index = CBGetCurSel(hDlg, IDC_COMBOAUTOEXEC); if(curAutoExec >= 0 && index == curAutoExec) return; 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; //リスト項目の表示数を指定 AdjustDlgConboBoxDropDown(hDlg, IDC_COMBOAUTOEXEC, 7); } } } else { pAS = (PAUTOEXECSTRUCT)CBGetItemData(hDlg, IDC_COMBOAUTOEXEC, curAutoExec); if(pAS) GetAutoExecFromDlg(hDlg, pAS); } pAS = (PAUTOEXECSTRUCT)CBGetItemData(hDlg, IDC_COMBOAUTOEXEC, index); if(pAS) { SetAutoExecToDlg(hDlg, pAS); EnableDlgItem(hDlg, IDC_DELAUTOEXEC, TRUE); curAutoExec = index; } else { AUTOEXECSTRUCT as; memset(&as, 0, sizeof(as)); as.hour = 0xffffff; as.days = 0x7f; SetAutoExecToDlg(hDlg, &as); EnableDlgItem(hDlg, IDC_DELAUTOEXEC, FALSE); curAutoExec = -1; } }
/*------------------------------------------------ combo box is about to be made visible --------------------------------------------------*/ void OnDropDownAutoExec(HWND hDlg) { PAUTOEXECSTRUCT pAS; char name[40]; int index; if(curAutoExec < 0) return; pAS = (PAUTOEXECSTRUCT)CBGetItemData(hDlg, IDC_COMBOAUTOEXEC, curAutoExec); if(pAS == 0) return; GetDlgItemText(hDlg, IDC_COMBOAUTOEXEC, name, 40); if(strcmp(name, pAS->name) != 0) { strcpy(pAS->name, name); CBDeleteString(hDlg, IDC_COMBOAUTOEXEC, curAutoExec); index = CBInsertString(hDlg, IDC_COMBOAUTOEXEC, curAutoExec, name); CBSetItemData(hDlg, IDC_COMBOAUTOEXEC, index, (LPARAM)pAS); CBSetCurSel(hDlg, IDC_COMBOAUTOEXEC, index); curAutoExec = index; } }