Exemple #1
0
/*------------------------------------------------
  "Add" button
--------------------------------------------------*/
void OnAdd(HWND hDlg)
{
	PTIMERSTRUCT pitem;
	int count, index;
	
	count = CBGetCount(hDlg, IDC_TIMERNAME);
	if(count < 0) return;
	
	OnNameDropDown(hDlg);
	
	GetTimerFromDlg(hDlg, get_listitem(m_pTimer, m_nCurrent));
	
	pitem = malloc(sizeof(TIMERSTRUCT));
	memset(pitem, 0, sizeof(TIMERSTRUCT));
	wsprintf(pitem->name, "Timer%d", count + 1);
	pitem->minute = 3;
	pitem->nDispType = 1;
	// common/list.c
	m_pTimer = add_listitem(m_pTimer, pitem);
	
	index = CBAddString(hDlg, IDC_TIMERNAME, (LPARAM)pitem->name);
	CBSetCurSel(hDlg, IDC_TIMERNAME, index);
	
	if(count == 0)
		EnableTimerDlgItems(hDlg);
	
	SetTimerToDlg(hDlg, pitem);
	m_nCurrent = index;
	
	PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE);
}
Exemple #2
0
/*------------------------------------------------
  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);
}
Exemple #3
0
/*------------------------------------------------
  "Add"
--------------------------------------------------*/
void OnAdd(HWND hDlg)
{
	PMOUSESTRUCT pitem;
	int count, index;
	
	count = CBGetCount(hDlg, IDC_NAMECLICK);
	if(count < 0) return;
	
	OnNameDropDown(hDlg);
	
	GetMouseCommandFromDlg(hDlg, get_listitem(m_pMouseCommand, m_nCurrent));
	
	pitem = malloc(sizeof(MOUSESTRUCT));
	memset(pitem, 0, sizeof(MOUSESTRUCT));
	wsprintf(pitem->name, "Mouse%d", count+1);
	pitem->nClick = 1;
	pitem->nCommand = 0;
	// common/list.c
	m_pMouseCommand = add_listitem(m_pMouseCommand, pitem);
	
	index = CBAddString(hDlg, IDC_NAMECLICK, (LPARAM)pitem->name);
	CBSetCurSel(hDlg, IDC_NAMECLICK, index);
	m_nCurrent = index;
	
	if(count == 0)
		EnableMousePageItems(hDlg);
	
	SetMouseCommandToDlg(hDlg, pitem);
	OnFunction(hDlg, FALSE);
#if TC_ENABLE_WHEEL
	OnMouseButton(hDlg);
#endif
	
	PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE);
}
Exemple #4
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
}
Exemple #5
0
/*------------------------------------------------
  free memories associated with combo box.
--------------------------------------------------*/
void OnDestroy(HWND hDlg)
{
	int i, count;

	count = CBGetCount(hDlg, IDC_COMBOAUTOEXEC);
	for(i = 0; i < count; i++)
	{
		PAUTOEXECSTRUCT pAS;
		pAS = (PAUTOEXECSTRUCT)CBGetItemData(hDlg, IDC_COMBOAUTOEXEC, i);
		if(pAS) free(pAS);
	}
}
Exemple #6
0
/*------------------------------------------------
  set MOUSESTRUCT data to dialog
--------------------------------------------------*/
void SetMouseCommandToDlg(HWND hDlg, PMOUSESTRUCT pitem)
{
	MOUSESTRUCT item;
	int i, count;
	
	m_prevcommand = -1;
	
	if(!pitem)
	{
		memset(&item, 0, sizeof(item));
		item.nClick = 1;
		pitem = &item;
	}
	
	CBSetCurSel(hDlg, IDC_MOUSEBUTTON, pitem->nButton);
	
	CheckRadioButton(hDlg, IDC_RADSINGLE, IDC_RADQUADRUPLE,
		IDC_RADSINGLE + pitem->nClick - 1);
	
	CheckDlgButton(hDlg, IDC_MOUSECTRL,  pitem->bCtrl);
	CheckDlgButton(hDlg, IDC_MOUSESHIFT, pitem->bShift);
	CheckDlgButton(hDlg, IDC_MOUSEALT,   pitem->bAlt);
	
	CBSetCurSel(hDlg, IDC_MOUSEFUNC, 0);
	count = CBGetCount(hDlg, IDC_MOUSEFUNC);
	for(i = 0; i < count; i++)
	{
		if(CBGetItemData(hDlg, IDC_MOUSEFUNC, i) == pitem->nCommand)
		{
			CBSetCurSel(hDlg, IDC_MOUSEFUNC, i);
			m_prevcommand = pitem->nCommand;
			break;
		}
	}
	if(i == count && pitem->nCommand > 100)
	{
		wsprintf(pitem->option, "%d", pitem->nCommand);
		pitem->nCommand = IDC_COMMAND;
		for(i = 0; i < count; i++)
		{
			if(CBGetItemData(hDlg, IDC_MOUSEFUNC, i) == IDC_COMMAND)
			{
				CBSetCurSel(hDlg, IDC_MOUSEFUNC, i);
				m_prevcommand = IDC_COMMAND;
				break;
			}
		}
	}
	
	SetDlgItemText(hDlg, IDC_MOUSEOPT, pitem->option);
}
Exemple #7
0
/*------------------------------------------------
  "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);
}