示例#1
0
/*------------------------------------------------
   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
}
示例#2
0
/*-------------------------------------------
  "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);
}