void COptionsBackup::ExpandBackupPath() { bool bSetRealPath(false); if (m_BackupLocation == 1) { wchar_t wsExpandedPath[MAX_PATH + 1]; DWORD dwResult = ExpandEnvironmentStrings(m_UserBackupOtherLocation, wsExpandedPath, MAX_PATH + 1); if (dwResult == 0 || dwResult > (MAX_PATH + 1)) { CGeneralMsgBox gmb; CString cs_msg, cs_title(MAKEINTRESOURCE(IDS_EXPANDPATH)); cs_msg.Format(IDS_CANT_EXPANDPATH, static_cast<LPCWSTR>(m_UserBackupOtherLocation)); gmb.MessageBox(cs_msg, cs_title, MB_OK | MB_ICONEXCLAMATION); } else { m_csExpandedPath = wsExpandedPath; if (m_UserBackupOtherLocation != m_csExpandedPath) { bSetRealPath = true; } } } if (!bSetRealPath) m_csExpandedPath.Empty(); GetDlgItem(IDC_EXPANDEDUSERBACKUPOTHRLOC)->EnableWindow(TRUE); GetDlgItem(IDC_EXPANDEDUSERBACKUPOTHRLOC)->ShowWindow(SW_SHOW); GetDlgItem(IDC_EXPANDEDUSERBACKUPOTHRLOC)->SetWindowText(bSetRealPath ? m_csExpandedPath : L""); m_Help3.EnableWindow(TRUE); m_Help3.ShowWindow(SW_SHOW); }
// Used by AddEdit_Attachment & ViewAttachment - so single place for this void CImgStatic::IssueError(int rc, HRESULT hr) { CGeneralMsgBox gmb; CString cs_errmsg, cs_title(MAKEINTRESOURCE(IDS_IMAGE_LOAD_FAILED)); switch (rc) { case 0: // Use hr value - but need to convert to Windows error code if (HRESULT_FACILITY(hr) == FACILITY_WIN32 || HRESULT_FACILITY(hr) == FACILITY_WINDOWS) { DWORD dwlasterror = HRESULT_CODE(hr); SetLastError(dwlasterror); pws_os::IssueError((LPCWSTR)cs_title, true); return; } else { cs_errmsg.Format(L"Unknown HRESULT error 0x%08x.", hr); } break; case 1: cs_errmsg.LoadString(IDS_IMAGE_IMPORT_FAILED); break; case 2: cs_errmsg.LoadString(IDS_MEM_ALLOC_FAILED); break; case 3: cs_errmsg.LoadString(IDS_MEM_LOCK_FAILED); break; } gmb.MessageBox(cs_errmsg, cs_title, MB_OK); }
void CManageFiltersDlg::OnFilterNew() { st_filters filters; st_Filterkey flt_key; bool bJustDoIt(false), bCreated; flt_key.fpool = FPOOL_SESSION; do_edit: bCreated = GetMainDlg()->EditFilter(&filters, false); flt_key.cs_filtername = filters.fname; if (bCreated) { PWSFilters::const_iterator mf_citer; mf_citer = m_MapMFDFilters.find(flt_key); // Check if already there (i.e. ask user if to replace) if (mf_citer != m_MapMFDFilters.end()) { CGeneralMsgBox gmb; CString cs_msg(MAKEINTRESOURCE(IDS_REPLACEFILTER)); CString cs_title(MAKEINTRESOURCE(IDS_FILTEREXISTS)); INT_PTR rc = gmb.MessageBox(cs_msg, cs_title, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); // If NO, go to edit again! Not best practice to jump out of loop // to prior call! if (rc == IDNO) goto do_edit; m_MapMFDFilters.erase(flt_key); // If this was active, we need to clear it and re-apply if (m_bMFFilterActive && m_activefilterpool == FPOOL_SESSION && m_activefiltername == filters.fname.c_str()) { bJustDoIt = true; } } m_MapMFDFilters.insert(PWSFilters::Pair(flt_key, filters)); // Update DboxMain GetMainDlg()->SetFilter(FPOOL_SESSION, filters.fname.c_str()); if (bJustDoIt) GetMainDlg()->ApplyFilter(true); m_selectedfiltername = flt_key.cs_filtername.c_str(); m_selectedfilterpool = flt_key.fpool; UpdateFilterList(); DisplayFilterProperties(&filters); } }
void CManageFiltersDlg::OnFilterCopy() { int numfilters = m_FilterLC.GetItemCount(); bool bCopied(false); for (int i = 0; i < numfilters; i++) { st_FilterItemData *pflt_idata = (st_FilterItemData *)m_FilterLC.GetItemData(i); if ((pflt_idata->flt_flags & MFLT_REQUEST_COPY_TO_DB) != MFLT_REQUEST_COPY_TO_DB) continue; PWSFilters::iterator mf_iter; st_Filterkey flt_key; flt_key = pflt_idata->flt_key; mf_iter = m_MapMFDFilters.find(flt_key); if (mf_iter == m_MapMFDFilters.end()) return; PWSFilters::const_iterator mf_citer; st_Filterkey flt_keydb; flt_keydb.fpool = FPOOL_DATABASE; flt_keydb.cs_filtername = flt_key.cs_filtername; mf_citer = m_MapMFDFilters.find(flt_keydb); // Check if already there (i.e. ask user if to replace) if (mf_citer != m_MapMFDFilters.end()) { CGeneralMsgBox gmb; CString cs_msg(MAKEINTRESOURCE(IDS_REPLACEFILTER)); CString cs_title(MAKEINTRESOURCE(IDS_FILTEREXISTS)); INT_PTR rc = gmb.MessageBox(cs_msg, cs_title, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); if (rc == IDNO) continue; // skip this one // User agrees to replace m_MapMFDFilters.erase(flt_keydb); } m_MapMFDFilters.insert(PWSFilters::Pair(flt_keydb, mf_iter->second)); // Turn off copy flag pflt_idata->flt_flags &= ~MFLT_REQUEST_COPY_TO_DB; m_num_to_copy--; bCopied = true; } if (bCopied) { m_bDBFiltersChanged = true; GetMainDlg()->ChangeOkUpdate(); } UpdateFilterList(); }
void CManageFiltersDlg::OnFilterEdit() { bool bJustDoIt(false), bChanged, bReplacedOther(false); PWSFilters::iterator mf_iter; st_Filterkey flt_key, flt_otherkey; flt_key.fpool = m_selectedfilterpool; flt_key.cs_filtername = m_selectedfiltername; mf_iter = m_MapMFDFilters.find(flt_key); if (mf_iter == m_MapMFDFilters.end()) return; // Pass a copy of (not reference to) of the current filter in case // the user cancels the change and the current state is invalid and // corrupts the copy in the map st_filters filters = mf_iter->second; do_edit: bChanged = GetMainDlg()->EditFilter(&filters, false); if (bChanged) { // Has user changed the filter's name? // If so, check for conflict. if (m_selectedfiltername != filters.fname.c_str()) { PWSFilters::const_iterator mf_citer; flt_otherkey.fpool = m_selectedfilterpool; flt_otherkey.cs_filtername = filters.fname; mf_citer = m_MapMFDFilters.find(flt_otherkey); // Check if already there (i.e. ask user if to replace) if (mf_citer != m_MapMFDFilters.end()) { CGeneralMsgBox gmb; CString cs_msg(MAKEINTRESOURCE(IDS_REPLACEFILTER)); CString cs_title(MAKEINTRESOURCE(IDS_FILTEREXISTS)); INT_PTR rc = gmb.MessageBox(cs_msg, cs_title, MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); // If NO, go to edit again! Not best practice to jump out of loop // to prior call! if (rc == IDNO) goto do_edit; bReplacedOther = true; } } if (flt_key.fpool == FPOOL_DATABASE) m_bDBFiltersChanged = true; // If the original was active, we need to clear it and re-apply if (m_bMFFilterActive && m_activefilterpool == flt_key.fpool && m_activefiltername == m_selectedfiltername) { bJustDoIt = true; } // User may have changed name (and so key) - delete and add again // Have to anyway, even if name not changed. m_MapMFDFilters.erase(bReplacedOther ? flt_otherkey : flt_key); flt_key.cs_filtername = filters.fname; m_MapMFDFilters.insert(PWSFilters::Pair(flt_key, filters)); m_selectedfiltername = flt_key.cs_filtername.c_str(); // Update DboxMain's current filter GetMainDlg()->SetFilter(flt_key.fpool, filters.fname.c_str()); if (bJustDoIt) GetMainDlg()->ApplyFilter(true); UpdateFilterList(); DisplayFilterProperties(&filters); } }