/*------------------------------------------------ delete a timer --------------------------------------------------*/ void OnDelete(HWND hDlg) { int count, index; PTIMERSTRUCT pitem; count = CBGetCount(hDlg, IDC_TIMERNAME); if(count < 1) return; index = CBGetCurSel(hDlg, IDC_TIMERNAME); if(index < 0) return; pitem = get_listitem(m_pTimer, index); if(pitem == NULL) return; // common/list.c m_pTimer = del_listitem(m_pTimer, pitem); CBDeleteString(hDlg, IDC_TIMERNAME, index); if(count > 1) { if(index == count - 1) index--; CBSetCurSel(hDlg, IDC_TIMERNAME, index); } else { index = -1; EnableTimerDlgItems(hDlg); } SetTimerToDlg(hDlg, get_listitem(m_pTimer, index)); m_nCurrent = index; PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE); }
/*------------------------------------------------ delete an alarm --------------------------------------------------*/ void OnDelAutoExec(HWND hDlg) { PAUTOEXECSTRUCT pAS; if(curAutoExec < 0) return; pAS = (PAUTOEXECSTRUCT)CBGetItemData(hDlg, IDC_COMBOAUTOEXEC, curAutoExec); if(pAS) { PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE); CBDeleteString(hDlg, IDC_COMBOAUTOEXEC, curAutoExec); free(pAS); if(curAutoExec > 0) curAutoExec--; CBSetCurSel(hDlg, IDC_COMBOAUTOEXEC, curAutoExec); pAS = (PAUTOEXECSTRUCT)CBGetItemData(hDlg, IDC_COMBOAUTOEXEC, curAutoExec); if(pAS) SetAutoExecToDlg(hDlg, pAS); 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 visible set edited text to combo box --------------------------------------------------*/ void OnNameDropDown(HWND hDlg) { char name[BUFSIZE_NAME]; PTIMERSTRUCT pitem; pitem = get_listitem(m_pTimer, m_nCurrent); if(pitem == NULL) return; GetDlgItemText(hDlg, IDC_TIMERNAME, name, BUFSIZE_NAME); if(strcmp(name, pitem->name) != 0) { strcpy(pitem->name, name); CBDeleteString(hDlg, IDC_TIMERNAME, m_nCurrent); CBInsertString(hDlg, IDC_TIMERNAME, m_nCurrent, name); } }
/*------------------------------------------------ combo box is about to be visible set edited text to combo box --------------------------------------------------*/ void OnNameDropDown(HWND hDlg) { char name[BUFSIZE_NAME]; PMOUSESTRUCT pitem; pitem = get_listitem(m_pMouseCommand, m_nCurrent); if(pitem == NULL) return; GetDlgItemText(hDlg, IDC_NAMECLICK, name, BUFSIZE_NAME); if(strcmp(name, pitem->name) != 0) { strcpy(pitem->name, name); CBDeleteString(hDlg, IDC_NAMECLICK, m_nCurrent); CBInsertString(hDlg, IDC_NAMECLICK, m_nCurrent, name); } }
/*------------------------------------------------ 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; } }
/*------------------------------------------------ "Delete" --------------------------------------------------*/ void OnDelete(HWND hDlg) { int count, index; PMOUSESTRUCT pitem; count = CBGetCount(hDlg, IDC_NAMECLICK); if(count < 1) return; index = CBGetCurSel(hDlg, IDC_NAMECLICK); if(index < 0) return; pitem = get_listitem(m_pMouseCommand, index); if(pitem == NULL) return; // common/list.c m_pMouseCommand = del_listitem(m_pMouseCommand, pitem); CBDeleteString(hDlg, IDC_NAMECLICK, index); if(count > 0) { if(index == count - 1) index--; CBSetCurSel(hDlg, IDC_NAMECLICK, index); SetMouseCommandToDlg(hDlg, get_listitem(m_pMouseCommand, index)); OnFunction(hDlg, TRUE); } else { index = -1; EnableMousePageItems(hDlg); SetMouseCommandToDlg(hDlg, NULL); OnFunction(hDlg, FALSE); #if TC_ENABLE_WHEEL OnMouseButton(hDlg); #endif } m_nCurrent = index; PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE); }