Example #1
0
int CPreferences::ItrPreferencesTableRowsCallbackFn(sqlite3_stmt *statement, void *pUserData)
{
    UNREFERENCED_PARAMETER(pUserData);
	CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
	CString prefName =
		SystemUtils::UTF8ToUnicode((const char *)sqlite3_column_text(statement, Preferences_PreferenceName)).c_str();
	listBox->AddString(prefName);
	CComboBox *pComboBox((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF));
	pComboBox->AddString(prefName);
	return 0;
}
FWL_Error CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) {
  if (m_pIface)
    return FWL_Error::Indefinite;
  if (pProperties) {
    *m_pProperties = *pProperties;
  }
  std::unique_ptr<IFWL_ComboBox> pComboBox(IFWL_ComboBox::Create(
      m_pProperties->MakeWidgetImpProperties(&m_comboBoxData)));
  FWL_Error ret = pComboBox->Initialize();
  if (ret != FWL_Error::Succeeded) {
    return ret;
  }
  m_pIface = pComboBox.release();
  CFWL_Widget::Initialize();
  return FWL_Error::Succeeded;
}
Example #3
0
void CPreferences::LoadPreferences()
{
	CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
	int prefCount = listBox->GetCount();
	// Remove all existing pre before reloading
	listBox->DeleteString(prefCount);
	ItrTableRowsCallbackData_CPreferences itSHTable(this,
		&CPreferences::ItrPreferencesTableRowsCallbackFn);
	FindDataBase prefDataBase(FDB_PrefDatabase, true);
	if (prefDataBase.Open() == 0) {
		itSHTable.IterateTableRows(prefDataBase, "Preferences");
	}
	CComboBox *pComboBox((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF));
	pComboBox->InsertString(0, _T(""));
	pComboBox->SelectString(0, mLoadedPreferenceName);
}
Example #4
0
void CPreferences::OnBnClickedOk()
{
	// Call the funtion
	/// check which check box is sleated
	// Load/Save
	if (IsDlgButtonChecked(IDC_RADIO_SAVE)) { // Save
		CString prefName;
		GetDlgItemText(IDC_EDIT_PREFERENCE_NAME, prefName);
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int indexInListBox = listBox->FindString(-1, prefName);
		if (indexInListBox >= 0) { // Already has this preference name
			if (MessageBox(prefName + _T(" already exists.\nDo you want to overwrite."),
				0, MB_YESNO) == IDNO) {
					CEdit *pEdit((CEdit*)GetDlgItem(IDC_EDIT_PREFERENCE_NAME));
					pEdit->SetFocus();
					pEdit->SetSel(0, -1);
					return;
			}
		}
		SavePreference(prefName);
		listBox->AddString(prefName);
		((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF))->AddString(prefName);
	}
	else if (IsDlgButtonChecked(IDC_RADIO_LOAD)) { // Load
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int curSel = listBox->GetCurSel();
		if (curSel >= 0) { // User has selected
			CString prefName;
			listBox->GetText(curSel, prefName);
			LoadPreference(prefName);
		}
	}
	else if (IsDlgButtonChecked(IDC_RADIO_DELETE)) { // Delete
		CListBox *listBox = (CListBox *)GetDlgItem(IDC_LIST_PREFERENCES);
		int curSel = listBox->GetCurSel();
		if (curSel >= 0) { // User has selected
			CString prefName;
			listBox->GetText(curSel, prefName);
			if (DeletePreference(prefName)) {
				listBox->DeleteString(curSel);
				CComboBox *pComboBox((CComboBox *)GetDlgItem(IDC_COMBO_DEFPREF));
				pComboBox->DeleteString(pComboBox->FindString(1, prefName));
			}
		}
	}
}