void CSiteGroupsTree::OnSiteGroupExport() { ASSERT(m_actionGroup); CWnd *parent = GetParent(); ASSERT(parent); std::string defaultFileName(m_actionGroup->GetName()); defaultFileName += '.'; defaultFileName += DefaultExtension; CFileDialog dlg(FALSE, DefaultExtension, defaultFileName.c_str(), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST, DefaultFilter, parent); char currentDir[_MAX_PATH]; dlg.m_ofn.lpstrInitialDir = _getcwd(currentDir, _MAX_PATH); if (dlg.DoModal() != IDOK) return; CString filename = dlg.GetPathName(); try { WebWatch::Store::Instance().ExportGroup(*m_actionGroup, filename); } catch(const WebWatch::StoreError & ex) { parent->MessageBox(ex.what(), "Failure", MB_OK | MB_ICONERROR); return; } std::string message("Group '"); message += m_actionGroup->GetName(); message += "' exported successfully to '"; message += dlg.GetFileName(); message += '\''; parent->MessageBox(message.c_str(), "Success", MB_OK | MB_ICONINFORMATION); }
void FatalError (UINT nMsgID, ...) { va_list argList; va_start (argList, nMsgID); CString fmt; fmt.LoadString (nMsgID); LPVOID lpMsgBuf; FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING, (const char *) fmt, 0, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, &argList); g_sLastError = (char *) lpMsgBuf; LocalFree (lpMsgBuf); va_end (argList); CWnd *hWnd = AfxGetMainWnd(); hWnd->MessageBox(g_sLastError, NULL, MB_ICONERROR | MB_OK); throw (nMsgID); }
BOOL CHelpDlg::OnInitDialog() { CDialog::OnInitDialog(); // CWnd ThatWind; // char buffer[MAX_SIZE]; FILE *fPtr; CString Helptext = CString(iniFilePath) + "\\" + iniTracker; // ThatWind.MessageBox(Helptext,"something",MB_OK); if( !( fPtr = fopen(Helptext, "rb") ) ) { CWnd myWnd; myWnd.MessageBox("Unable to open file" + Helptext, "ERROR", MB_OK); // exit( 3 ); } else fseek(fPtr, 0,2); long f_size = ftell(fPtr); fseek (fPtr,0,0); char *file_buffer; file_buffer = (char *) malloc (f_size); fread (file_buffer,1,f_size,fPtr); file_buffer[f_size]=NULL; // ThatWind.MessageBox(file_buffer,"buffer",MB_OK); CEdit *ebptr =(CEdit *) GetDlgItem(IDC_EDIT1); ebptr->SetWindowText(file_buffer); return TRUE; }
void CSiteGroupsTree::OnSiteGroupRemove() { // Ask user whether to delete the selected group or not ASSERT(m_actionGroup); ASSERT(WebWatch::Store::Instance().IsRootGroup(*m_actionGroup) == false); CWnd *parent = GetParent(); ASSERT(parent); std::string query("Are you sure you want to remove the group '"); query += m_actionGroup->GetName(); query += "' ?"; UINT ret = parent->MessageBox(query.c_str(), "Remove group?", MB_YESNO | MB_ICONQUESTION); if (ret == IDNO) return; // Remove group // Gather all groups to remove from tree typedef std::vector<WebWatch::SiteItemGroup *> Groups; Groups groupsToRemove(1, m_actionGroup); groupsToRemove.reserve(m_actionGroup->GetGroupCount() + groupsToRemove.size()); WebWatch::GatherChildGroups(*m_actionGroup, std::back_inserter(groupsToRemove)); // Make sure site list is in stable state ASSERT(m_siteList); WebWatch::SiteItemGroup dummy("Dummy"); m_siteList->SetSiteItemGroup(dummy); SetRedraw(FALSE); // Delete actual group and its sub-groups WebWatch::SiteItemGroup *parentGroup = m_actionGroup->GetParentGroup(); ASSERT(parentGroup); parentGroup->DeleteGroup(*m_actionGroup); // Remove groups/items from tree and update tree std::for_each(groupsToRemove.begin(), groupsToRemove.end(), GroupRemover(*this)); UpdateTree(); SetRedraw(); SelectGroup(*parentGroup, true); }
int __cdecl VMessageBox (LPCSTR pcCaption, UINT uiType, UINT uiText, ...) { CString strText; VERIFY(strText.LoadString (uiText)); CWnd Wnd; CString strOut; LPTSTR pcOut = NULL; ATLTRY(pcOut = strOut.GetBufferSetLength(_MAX_PATH*4)); if (NULL != pcOut) { va_list params; va_start (params, uiText); //lint --e(534) wvsprintf (pcOut, strText, params); va_end (params); return Wnd.MessageBox (pcOut, pcCaption, uiType); } return Wnd.MessageBox (strText, pcCaption, uiType); }
void CSiteGroupsTree::OnSiteGroupImportChildGroup() { ASSERT(m_actionGroup); CWnd *parent = GetParent(); ASSERT(parent); CFileDialog dlg(TRUE, DefaultExtension, 0, OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST, DefaultFilter, parent); char currentDir[_MAX_PATH]; dlg.m_ofn.lpstrInitialDir = _getcwd(currentDir, _MAX_PATH); if (dlg.DoModal() != IDOK) return; CString filename = dlg.GetPathName(); try { WebWatch::SiteItemGroup & importedGroup = WebWatch::Store::Instance().ImportGroup(*m_actionGroup, filename); GroupAppender appender(*this, GetItemFromGroup(*m_actionGroup)); appender(&importedGroup); } catch(const WebWatch::StoreError & ex) { parent->MessageBox(ex.what(), "Failure", MB_OK | MB_ICONERROR); return; } UpdateTree(); WebWatch::SiteItemGroup & selectedGroup = GetGroupFromItem(GetSelectedItem()); RefreshSiteList(selectedGroup); std::string message("Group(s) in file '"); message += dlg.GetFileName(); message += "' imported successfully under group '"; message += m_actionGroup->GetName(); message += '\''; parent->MessageBox(message.c_str(), "Success", MB_OK | MB_ICONINFORMATION); }
void CNewDialog::DDV_INIFile(CDataExchange* pDX, CString value) { if(pDX->m_bSaveAndValidate) { value.TrimRight(); if(value.IsEmpty()) { CWnd nbox; nbox.MessageBox("Please enter a Configuration Name" ,"Error",MB_ICONEXCLAMATION); pDX->Fail(); } else if(value.Right(4) != ".nci") value = value +".nci"; myData = value; } }