extern "C" DWORD PASCAL EXPORT STDFUFILES_GetImageNbElement(HANDLE Handle, PDWORD pNbElements) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); BOOL bFound=FALSE; DWORD dwRet=STDFUFILES_NOERROR; for (int i=0;i<=g_Images.GetUpperBound();i++) { if ((HANDLE)g_Images.GetAt(i)==Handle) { CImage *pImage=(CImage *)Handle; bFound=TRUE; *pNbElements=pImage->GetNbElements(); break; } } if (!bFound) dwRet=STDFUFILES_BADPARAMETER; return dwRet; }
extern "C" DWORD PASCAL EXPORT STDFUFILES_AppendImageToDFUFile(HANDLE hFile, HANDLE Image) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); BOOL bFound=FALSE; DWORD dwRet=STDFUPRT_NOERROR; for (int i=0;i<=g_DFUFiles.GetUpperBound();i++) { if ((HANDLE)g_DFUFiles.GetAt(i)==hFile) { CDFUFile *pFile=(CDFUFile *)hFile; dwRet=pFile->AppendImage(Image); bFound=TRUE; break; } } if (!bFound) dwRet=STDFUPRT_BADPARAMETER; return dwRet; }
extern "C" DWORD PASCAL EXPORT STDFUFILES_CreateImageFromMapping(PHANDLE pHandle, PMAPPING pMapping) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); DWORD Ret=STDFUFILES_BADPARAMETER; CImage *pImage=new CImage(pMapping, FALSE, NULL); if (pImage) { g_Images.Add(pImage); *pHandle=(HANDLE)pImage; Ret=STDFUFILES_NOERROR; } return Ret; }
extern "C" DWORD PASCAL EXPORT STDFUFILES_ImageToFile(PSTR pPathFile, HANDLE Image) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); BOOL bFound=FALSE; DWORD dwRet=STDFUFILES_NOERROR; for (int i=0;i<=g_Images.GetUpperBound();i++) { if ((HANDLE)g_Images.GetAt(i)==Image) { CImage *pImage=(CImage *)(Image); if (!pImage->DumpToFile(pPathFile)) dwRet=STDFUFILES_BADPARAMETER; bFound=TRUE; break; } } if (!bFound) dwRet=STDFUFILES_BADPARAMETER; return dwRet; }
extern "C" DWORD PASCAL EXPORT STDFUFILES_GetImageName(HANDLE Image, PSTR Name) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); BOOL bFound=FALSE; DWORD dwRet=STDFUFILES_NOERROR; for (int i=0;i<=g_Images.GetUpperBound();i++) { if ((HANDLE)g_Images.GetAt(i)==Image) { CImage *pImage=(CImage *)(Image); if (!pImage->GetName(Name)) lstrcpy(Name, ""); bFound=TRUE; break; } } if (!bFound) dwRet=STDFUFILES_BADPARAMETER; return dwRet; }
//----------------------------------------------------------------- void CMRCFrameWndSizeDock::GetFloatingBars(CObArray & arrWnd) // Appends the floating bars, visible bars to an array //----------------------------------------------------------------- { CPtrList & listControlBars = m_listControlBars; POSITION pos = listControlBars.GetHeadPosition(); while (pos != NULL) { CControlBar* pBar = (CControlBar*)listControlBars.GetNext(pos); ASSERT(pBar != NULL); if (!pBar->IsDockBar() && pBar->IsFloating() && pBar->IsVisible()) // not a dockbar and floating.... { ASSERT(pBar->m_pDockBar != NULL); CWnd * pFloatFrame = ((CWnd *)pBar->m_pDockBar)->GetParent(); ASSERT(pBar != NULL); arrWnd.Add(pFloatFrame); } } }
extern "C" DWORD PASCAL EXPORT STDFUFILES_ImageFromFile(PSTR pPathFile, PHANDLE pImage, BYTE nAlternate) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); DWORD Ret=STDFUFILES_BADPARAMETER; CImage *obImage=new CImage(nAlternate, pPathFile, FALSE, NULL); if (obImage) { if (obImage->GetImageState()) { g_Images.Add(obImage); *pImage=(HANDLE)obImage; Ret=STDFUFILES_NOERROR; } else { delete obImage; Ret=STDFUFILES_BADFORMAT; } } return Ret; }
//---------------------------------------- void CPlotBase::GetAllInternalFiles(CObArray& allInternalFiles) { CObArray::iterator itField; CObArray::iterator itInternalFile; CPlotField* field = NULL; for (itField = m_fields.begin() ; itField != m_fields.end() ; itField++) { field = CPlotField::GetPlotField(*itField); if (field == NULL) { continue; } for (itInternalFile = field->m_internalFiles.begin() ; itInternalFile != field->m_internalFiles.end() ; itInternalFile++) { CInternalFiles* f = GetInternalFiles(*itInternalFile); allInternalFiles.Insert(f); } } }
int CSTDFUFILESApp::ExitInstance() { int i; for (i=0;i<=g_Images.GetUpperBound();i++) { CImage *pImage=(CImage*)g_Images.GetAt(i); delete pImage; } g_Images.RemoveAll(); for (i=0;i<=g_DFUFiles.GetUpperBound();i++) { CDFUFile *pFile=(CDFUFile*)g_DFUFiles.GetAt(i); delete pFile; } g_DFUFiles.RemoveAll(); return CWinApp::ExitInstance(); }
//---------------------------------------------------- void CAliasesDictionary::GetAliases(CXmlNode* parent, CObArray& arrayAliases) { if (parent == NULL) { throw CXMLException("Error in CAliasesDictionary::arrayAliases - Unable to get node because parent argument is NULL", BRATHL_LOGIC_ERROR); } CObArray arrayNodes(false); FindAllNodesByName(CAliasesDictionary::m_ALIASES_ELT, parent, arrayNodes, true); CObArray::const_iterator it; for(it = arrayNodes.begin() ; it != arrayNodes.end() ; it++) { CXmlNode* node = dynamic_cast<CXmlNode*>(*it); CAliases* aliases = CreateAliases(node); if (aliases != NULL) { arrayAliases.Insert(aliases); } } }
//---------------------------------------------------- void CAliasesDictionary::GetDefaultRecords(CXmlNode* parent, CObArray& arrayDefaultRecord) { if (parent == NULL) { throw CXMLException("Error in CAliasesDictionary::GetDefaultRecordNodes - Unable to get node because parent argument is NULL", BRATHL_LOGIC_ERROR); } CObArray arrayNodes(false); FindAllNodesByName(CAliasesDictionary::m_DEFAULT_RECORD_ELT, parent, arrayNodes, true); CObArray::const_iterator it; for(it = arrayNodes.begin() ; it != arrayNodes.end() ; it++) { CXmlNode* node = dynamic_cast<CXmlNode*>(*it); CDefaultRecord* defaultRecord = CreateDefaultRecord(node); if (defaultRecord != NULL) { arrayDefaultRecord.Insert(defaultRecord); } } }
// 合并之后重新计算loop的邻接优先级 void CP_LoopExt::CalcLoopAdjFaceNum() { CObArray tmpAdjLoopArr; int halfSize = GetHalfNumber(); for(int i = 0; i < halfSize; i++) { CP_LoopExt * adjLoop = (CP_LoopExt *)GetHalf(i)->m_pTwin->m_pLoop; if(adjLoop->m_adjFaceNum != -1) continue; int j; for (j = 0; j < tmpAdjLoopArr.GetSize(); ++j) { if (tmpAdjLoopArr[j] == adjLoop) break; } if (j == tmpAdjLoopArr.GetSize()) tmpAdjLoopArr.Add(adjLoop); } m_adjFaceNum = tmpAdjLoopArr.GetSize(); tmpAdjLoopArr.RemoveAll(); }
CObArray arr; CAge* pa1; CAge* pa2; arr.Add(pa1 = new CAge(21)); // Element 0 arr.Add(pa2 = new CAge(40)); // Element 1 ASSERT(arr.GetSize() == 2); arr.RemoveAll(); // Pointers removed but objects not deleted. ASSERT(arr.GetSize() == 0); delete pa1; delete pa2; // Cleans up memory.
int CExecCommand::execWaitForAllChilds( LPCTSTR lpstrCommand, LPCTSTR lpstrPath) { CObArray myProcessList; CProcessProps *pProcess; DWORD dwExitCode, dwProcessID, dwTime = 0; try { ASSERT( lpstrCommand); // Start process initialize(); if ((dwProcessID = realCreateProcess( lpstrCommand, lpstrPath)) == 0) { closeHandles(); return EXEC_ERROR_START_COMMAND; } // We need high priority on OS to follow thread/process created by main command SetPriorityClass( GetCurrentProcess(), HIGH_PRIORITY_CLASS); // Store first process pProcess = new CProcessProps(); pProcess->set( dwProcessID, GetCurrentProcessId(), lpstrCommand); myProcessList.Add( pProcess); // While there is running processes or timeout not reached while ((myProcessList.GetCount() > 0) && (dwTime < m_dwTimeout)) { // Parse memory processes for new childs process or terminated processes if (!parseRunningProcesses( &myProcessList)) { SetPriorityClass( GetCurrentProcess(), NORMAL_PRIORITY_CLASS); m_csOutput.Format( "Parse running processes Error: %s", GetAnsiFromUnicode( LookupError( GetLastError()))); freeProcessList( &myProcessList); closeHandles(); return EXEC_ERROR_WAIT_COMMAND; } Sleep( EXEC_WAIT_CHECK_LATENCY); dwTime += EXEC_WAIT_CHECK_LATENCY; } freeProcessList( &myProcessList); // Now return to normal prioity SetPriorityClass( GetCurrentProcess(), NORMAL_PRIORITY_CLASS); // Get exit code if (GetExitCodeProcess( m_hProcessHandle, &dwExitCode)) { m_nExitValue = dwExitCode; } else { m_nExitValue = -1; m_csOutput.Format( "GetExitCode Error: %s", GetAnsiFromUnicode( LookupError( GetLastError()))); closeHandles(); return EXEC_ERROR_WAIT_COMMAND; } closeHandles(); return EXEC_SUCCESSFULL; } catch (CException *pEx) { pEx->Delete(); closeHandles(); m_csOutput = "Unhandled exception Error"; return EXEC_ERROR_START_COMMAND; } }
// ************************************************************************** // WorkerThread () // // Description: // Worker thread function. // // Parameters: // void *pvArgs Pointer to a WORKERTHREADARG structure which // describes task to be performed. // // Returns: // unsigned int - 0 // ************************************************************************** unsigned _stdcall CKDocument::WorkerThread (void *pvArgs) { // Cast argument to proper type so we can extract the required data // about the task we are to perform: WORKERTHREADARG *pWTA = (WORKERTHREADARG *)pvArgs; ASSERT (pWTA); // Execute specified task: switch (pWTA->eTask) { case WORKERTHREADARG::START_SINGLE_SERVER: case WORKERTHREADARG::STOP_SINGLE_SERVER: { // Extract pointer to server we are to start or stop from // argument structure: CKServer *pServer = (CKServer *)pWTA->pvObjectA; ASSERT (pServer); // Start or stop the server as the case may be: if (pWTA->eTask == WORKERTHREADARG::START_SINGLE_SERVER) pServer->Start (); else pServer->Stop (); } break; case WORKERTHREADARG::START_MULTIPLE_SERVER: case WORKERTHREADARG::STOP_MULTIPLE_SERVER: { // Extract the list (object array) of servers to start or stop // from argument structure: CObArray *pList = (CObArray *)pWTA->pvObjectA; ASSERT (pList); // Get the number of server in the list: int cnServers = pList->GetSize (); CKServer *pServer = NULL; // Loop over the servers in the list: while (--cnServers >= 0) { // Get pointer to next server in list: pServer = (CKServer *) pList->GetAt (cnServers); ASSERT (pServer); // Start or stop that server as the case may be: if (pWTA->eTask == WORKERTHREADARG::START_MULTIPLE_SERVER) pServer->Start (); else pServer->Stop (); } } break; case WORKERTHREADARG::ADD_ITEMS: { // Extract the list (object array) of items to add from // argument structure: CObArray *pList = (CObArray *)pWTA->pvObjectA; ASSERT (pList); // Extract the number of items from the argument structure: int cnItems = *(int *)pWTA->pvObjectB; // Get pointer to first item from list. We will use it to // get the group object these items will be added to: CKItem *pItem = (CKItem *)pList->GetAt (0); ASSERT (pItem); // Get group that we are adding the items to: CKGroup *pGroup = pItem->GetParentGroup (); ASSERT (pGroup); // Add the items to this group: pGroup->AddItems (*pList, cnItems); } break; default: // unhandled task ? ASSERT (FALSE); break; } return (0); }
// ************************************************************************** // OnOpenDocument () // // Description: // Open document event handler. // // Parameters: // none // // Returns: // BOOL - TRUE if success. // ************************************************************************** BOOL CKDocument::OnOpenDocument (LPCTSTR lpszPathName) { // Perform default processing: if (!CDocument::OnOpenDocument (lpszPathName)) return (FALSE); // Must do some additional work if we have a server object: if (m_pServerHead) { // Update status bar text to indicate we are loading project: CKStatusBarText cText (IDS_LOADING_PROJECT); // Update all views so the user can see progress: UpdateAllViews (NULL, HINT_LOAD_PROJECT, m_pServerHead); // Build a list of servers to load to pass along to a worker thread // for processing: CObArray cServerList; // Catch memory exceptions that could get thrown by object array: try { // Allocate memory for array of server objects: cServerList.SetSize (m_cdwServers); // Create a CKServer pointer and set it to first server in linked list: CKServer *pServer = m_pServerHead; // Loop over servers in linked list: for (DWORD dw = 0; dw < m_cdwServers; dw++) { // Put pointer to server in object array: ASSERT (pServer); cServerList [dw] = (CObArray *)pServer; // Get next server in linked list: pServer = pServer->GetNext (); } ASSERT (pServer == NULL); // list and count in sync ? } catch (CMemoryException *e) { // If memory exception thrown, delet exception object and return FALSE // to indicate failure. e->Delete (); return (FALSE); } // Fill a structre to pass along to worker thread. Structure will // contain a pointer to out list of servers and task specification // (start multiple servers). WORKERTHREADARG tArg; tArg.eTask = WORKERTHREADARG::START_MULTIPLE_SERVER; tArg.pvObjectA = (void *)&cServerList; // Run the worker thread to start all server connections: RunWorkerThread (&tArg); } // If we make it here, all went OK, so return TRUE: return (TRUE); }
/** * OnLoadUrl * * Description: Load a url into the view * * Parameters: wparam: - 0 = no callback, 1 = yes callback * lparam: CString url path */ LRESULT CMainFrame::OnLoadUrl(WPARAM wParam, LPARAM lParam) { CConnectionListView * connectionView = (CConnectionListView *)m_mainSplitter.GetPane(0,0); CFileListView * fileListView = (CFileListView *)m_mainSplitter.GetPane(0,1); CString * urlArg = (CString*)lParam; if(urlArg){ TRACE1(" Load url: %s \n", urlArg->AllocSysString()); CString url(urlArg->AllocSysString()); delete urlArg; CString host(_T("")); CString dir(_T("")); // Parse if(url.Find(_T("ftp://")) != -1){ url = url.Mid(url.Find(_T("ftp://")) + 6, url.GetLength() - url.Find(_T("ftp://"))); } int pos = url.Find('/'); if(pos != -1){ host = url.Mid(0, pos); dir = url.Mid(pos, url.GetLength() - pos); } else { host = CString(url); dir = CString(_T("/")); } // select connection int connection_id = -1; CObArray * listOfConnections; listOfConnections = m_connectionManager.GetConnections(); int i = 0; for(i = 0; i < listOfConnections->GetSize(); i++){ CConnection * con = (CConnection *)listOfConnections->GetAt(i); if(con->host.Compare(host) == 0){ connection_id = i; connectionView->SelectConnection(connection_id); } } // Prompt for new connection information if(connection_id < 0){ CConnectionDialog dlg; dlg.SetHost(host); // prefill in host dlg.DoModal(); // Update view with updated connections connectionView->UpdateConnections(); // Re check host in connections m_connectionManager.Load(); listOfConnections = m_connectionManager.GetConnections(); int i = 0; for(i = 0; i < listOfConnections->GetSize(); i++){ CConnection * con = (CConnection *)listOfConnections->GetAt(i); if(con->host.Compare(host) == 0){ connection_id = i; connectionView->SelectConnection(connection_id); } } if(connection_id < 0){ return 1; // No connection entered, abort } } // Load file list view fileListView->LoadServerConnection(connection_id); fileListView->LoadDirectory(dir); // Load url in header history. if(m_headerDoc && ((int)wParam) == 1){ m_headerDoc.SetUrl( CString(host + dir) ); m_headerDoc.SetConnectionID(connection_id); m_headerDoc.m_path = CString(dir); // This needs work CFileListView * v = (CFileListView *)m_mainSplitter.GetPane(0,1); m_headerDoc.m_path = CString(v->GetPath()); } // Cleanup delete urlArg; } return 1; }
/** * OnCreate * * Description: App crete event. Initalize threads and objects. */ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) return -1; HICON icon=LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME)); SetIcon(icon, FALSE); BOOL bNameValid; // set the visual manager and style based on persisted value //OnApplicationLook(theApp.m_nAppLook); CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMyVisualManager)); // CMyVisualManager CMFCVisualManagerVS2008 CDockingManager::SetDockingMode(DT_SMART); if (!m_wndMenuBar.Create(this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); // prevent the menu bar from taking the focus on activation CMFCPopupMenu::SetForceMenuFocus(FALSE); // Replaced with split view // create a view to occupy the client area of the frame /* if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 10, 10), this, AFX_IDW_PANE_FIRST, NULL)) { TRACE0("Failed to create view window\n"); return -1; } */ /* //theApp.m_bHiColorIcons = 0; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar( IDR_MAINFRAME )) // theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } CString strToolBarName; bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); ASSERT(bNameValid); m_wndToolBar.SetWindowText(strToolBarName); CString strCustomize; bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); ASSERT(bNameValid); //m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); // Allow user-defined toolbars operations: InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId); */ if (!m_headerDoc.Create(_T("test"), this, CSize(400, 40), false, // gripper 4, // nID child win id (kinda works with 0) WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_TOP | CBRS_FLOAT_MULTI, // WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_HIDE_INPLACE AFX_CBRS_REGULAR_TABS, AFX_DEFAULT_DOCKING_PANE_STYLE) ) { TRACE0("Failed to create Header Bar \n"); return -1; // fail to create } // m_headerDoc.EnableDocking(CBRS_ALIGN_ANY); //m_headerDoc.SetResizeMode(false); m_headerDoc.SetMinSize(CSize(200, 40)); m_headerDoc.OnInitialUpdate(); //m_headerDoc.ShowPane(TRUE, FALSE, TRUE); m_headerDoc.ShowWindow(SW_SHOW); // FooterPane CRect r = CRect(400, 15, 10, 15); m_footerPane.Create(_T("CFooterPane"), WS_VISIBLE, r, this, 5, AFX_DEFAULT_DOCKING_PANE_STYLE, 0); /* if (!m_footerPane.Create(_T("footer"), this, CSize(400, 15), false, // gripper 4, // nID child win id (kinda works with 0) WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI, // WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_HIDE_INPLACE AFX_CBRS_REGULAR_TABS, AFX_DEFAULT_DOCKING_PANE_STYLE) ) { TRACE0("Failed to create Header Bar \n"); return -1; // fail to create } */ m_footerPane.SetMinSize(CSize(200, 15)); m_footerPane.OnInitialUpdate(); //m_footerPane.ShowWindow(SW_SHOW); //CDockBar *pTop = (CDockBar *)::AfxGetMainWnd()->GetControlBar(AFX_IDW_DOCKBAR_TOP); //DWORD x = m_headerDoc.GetEnabledAlignment(); //DWORD y = CBRS_ALIGN_ANY; //m_wndStatusBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM, AFX_IDW_STATUS_BAR); //if (!m_wndStatusBar.Create(this)) //{ // TRACE0("Failed to create status bar\n"); // return -1; // fail to create //} //m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); // TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable //m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); //m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); // required or won't show toolbar DockPane(&m_wndMenuBar); //DockPane(&m_wndToolBar); DockPane(&m_headerDoc); // Bottom pane //m_footerPane.EnableDocking(CBRS_ALIGN_BOTTOM); //DockPane(&m_footerPane, AFX_IDW_DOCKBAR_BOTTOM); //m_wndToolBar.ShowPane(SW_SHOW,0,0); //m_wndToolBar.SetWi // enable Visual Studio 2005 style docking window behavior //CDockingManager::SetDockingMode(DT_SMART); // enable Visual Studio 2005 style docking window auto-hide behavior EnableAutoHidePanes(CBRS_ALIGN_ANY); // Enable toolbar and docking window menu replacement //EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); // enable quick (Alt+drag) toolbar customization //CMFCToolBar::EnableQuickCustomization(); if (CMFCToolBar::GetUserImages() == NULL) { // load user-defined toolbar images if (m_UserImages.Load(_T(".\\UserImages.bmp"))) { CMFCToolBar::SetUserImages(&m_UserImages); } } // enable menu personalization (most-recently used commands) // TODO: define your own basic commands, ensuring that each pulldown menu has at least one basic command. CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail(ID_APP_EXIT); lstBasicCommands.AddTail(ID_EDIT_CUT); lstBasicCommands.AddTail(ID_EDIT_PASTE); lstBasicCommands.AddTail(ID_EDIT_UNDO); lstBasicCommands.AddTail(ID_APP_ABOUT); lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); //CMFCToolBar::SetBasicCommands(lstBasicCommands); // Display New Connection Dialog if no connections exist m_connectionManager.Load(); CObArray * listOfConnections; listOfConnections = m_connectionManager.GetConnections(); int connectionCount = listOfConnections->GetSize(); if(connectionCount == 0) { PostMessage( WM_COMMAND, ID_NEW_CONNECTION_MENU_ITEM, 0 ); } // Start sync thread // //m_ftpManager.SyncServerConnections(); THREADPARAM * _param = new THREADPARAM; _param->m = this; // THREAD_PRIORITY_IDLE THREAD_PRIORITY_LOWEST m_pFtpSyncThread = AfxBeginThread(CMainFrame::FtpSyncWorker, &_param, THREAD_PRIORITY_LOWEST); //, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); if (m_pFtpSyncThread != NULL) { //TRACE(_T("AfxBeginThread: 0x%08lX\n"), m_pFtpSyncThread->m_nThreadID); } // Start Ad manager //m_wndMenuBar.m_ad = m_ad; //m_ad.Start(); // Create tray icon. LoadTrayIcon(); // Check for an update CUpgrade update; update.CheckForUpgrade(); // Hostory m_historyDlg = new CHistoryDialog(this); m_historyDlg->Create(CHistoryDialog::IDD, GetDesktopWindow()); // Registry - GUID //CRegistry reg; //bool p = reg.IsPurchased(); //reg.Purchase(); //p = reg.IsPurchased(); //CString guid(_T("")); //reg.GetGUID(guid); return 0; }
void CHTMLFont::DeleteArray(CObArray & arrArray) { for ( int nObj=0; nObj < arrArray.GetSize(); nObj++) delete (CHTMLFont *) arrArray[nObj]; arrArray.RemoveAll(); }
void CDialogPlacePart::DoImportLibrary() { CDraftDrawDoc *pDoc = theApp.GetActiveDocument(); std::wstring sFilter = _T("External library file (*.xml)|*.xml||");//All Files (*.*)|*.*||; CStringArray saExtensions; saExtensions.Add(_T("xml")); CFileDialog fdialog( TRUE, //save dialog box NULL, NULL, 0, //no flags sFilter.c_str(), NULL); if (fdialog.DoModal() == IDOK){ //Get filename from dialog int offset = fdialog.m_ofn.nFileExtension; CString strFile = fdialog.m_ofn.lpstrFile; int nFilterIndex = fdialog.m_ofn.nFilterIndex; if ((!offset) || (fdialog.m_ofn.lpstrFile[offset] == 0)){ strFile += _T(".") + saExtensions[fdialog.m_ofn.nFilterIndex - 1]; sFilter = saExtensions[fdialog.m_ofn.nFilterIndex - 1]; } //Try to import library CImporter *pImporter = new CImporter(); CObArray *pObArray = new CObArray(); pImporter->ImportLibrary(strFile, pObArray, pDoc->m_szGrid); //Create new library CString strLib = strFile.Left(strFile.ReverseFind('.')); if (strLib.ReverseFind(_T('\\')) >= 0){ strLib = strLib.Right(strLib.GetLength() - strLib.ReverseFind(_T('\\')) - 1); } if (strLib.GetLength() == 0) strLib = strFile; DoInsertNewLibrary(strLib, TRUE); //Iterate all shapes to bounding rect union CRect rectUnion; for (int i = 0; i < pObArray->GetSize(); i++){ CShapeUnit *pSh = (CShapeUnit *)pObArray->GetAt(i); CRect rect; pSh->GetRectTemp(rect); TRACE(_T("Importing part %s.\n"),(LPCTSTR)(pSh->m_sUnitName)); //rectUnion.UnionRect(rectUnion, rect); if (rect.Width()>rectUnion.Width()){ rectUnion = CRect(CPoint(0, 0), CSize(rect.Width(), rectUnion.Height())); } if (rect.Height()>rectUnion.Height()){ rectUnion = CRect(CPoint(0, 0), CSize(rectUnion.Width(), rect.Height())); } } //rectUnion.InflateRect(DCABLE_PADDINGX_DEFAULT << 1, DCABLE_PADDINGY_DEFAULT << 1); rectUnion.InflateRect(DCABLE_GRIDX_DEFAULT, DCABLE_GRIDY_DEFAULT); CSize size=rectUnion.Size(); rectUnion = CRect(CPoint(0, 0), rectUnion.Size()); //Insert/update parts for (int i = 0; i<pObArray->GetSize(); i++){ //Insert part CShapeUnit *pSh = (CShapeUnit *)pObArray->GetAt(i); //Do insert in librarry DoInsertPart(pSh->m_sUnitName); //Get bounding rect CRect rectTemp; pSh->GetRectTemp(rectTemp); ((CShapeFrmRect*)pSh->m_obarrShapearr[0])->m_Rect = rectUnion; CPoint offset = CPoint((rectUnion.Width() - rectTemp.Width()) >> 1, (rectUnion.Height() - rectTemp.Height()) >> 1); //Call a method to normalize ShapeUnit from bounding rect TopLeft to (0,0) or any other offset //pSh->NormalizeChildShapes(CPoint(DCABLE_PADDINGX_DEFAULT, DCABLE_PADDINGY_DEFAULT)); pSh->NormalizeChildShapes(offset); //Save parts //Create new method in CDocument to be called from here and serialize the parts CString strFile = pSh->m_sUnitName; //Keep previous part edition status BOOL bFlagPartEdit = pDoc->m_bFlagPartEdit; //Set part edition mode to save the save pDoc->m_bFlagPartEdit = TRUE; CObArray* prevObArray = pDoc->m_pObArray; pDoc->m_pObArray = &pSh->m_obarrShapearr; pDoc->OnDatabaseSave(strLib + _T(".") + strFile); pDoc->m_pObArray = prevObArray; //Restore flag pDoc->m_bFlagPartEdit = bFlagPartEdit; } }//End dialog result OK
BOOL CExMapi::GetContacts(CObArray& contactArray,CTRError& error) { BOOL doLog = m_pCtrl->IsEnableLog(); if(doLog) { m_logHelper.LogPAB(L"------------------------------------"); m_logHelper.LogPAB(L"Function GetPABCotacts START:"); m_logHelper.LogPAB(L"------------------------------------"); } CString strFilterBy = m_pCtrl->GetPABSerachBy(); CString strStartWith = m_pCtrl->GetPABSerachStartWith(); strStartWith = strStartWith.MakeLower(); ULONG pageSize; m_pCtrl->get_PABPageSize(&pageSize); ULONG pageNumber = m_pCtrl->GetPABPageNumber(); LONG contactCount = 0; LONG skipCount = 0; LONG startIndex = -1; LONG contactIndex = 0; LONG folderCount = 0; if(pageSize>0) { startIndex = (pageSize * pageNumber) - pageSize; } CString strFolder; int msgStoreCount = 0; wchar_t buffer[5]; LPMAPIFOLDER pSubFolder=NULL; LPMAPITABLE lpMsgStoreTable = NULL; lpMsgStoreTable = GetMessageStoresTable(); if(lpMsgStoreTable) { while(OpenNextMessageStore(lpMsgStoreTable)) { //GetContacts(OpenRootFolder(),folderCount,contactCount,skipCount,contactIndex,contactArray); msgStoreCount++; _itow(msgStoreCount,buffer,10); if(doLog) { if(msgStoreCount > 1) m_logHelper.LogPAB(L"-------------------------------------"); m_logHelper.LogPAB(L"Message Store No : "+CString(buffer)); m_logHelper.LogPAB(L"-------------------------------------"); } pSubFolder = OpenContacts(); if(pSubFolder && IsContactFolder(pSubFolder)) { if(doLog) m_logHelper.LogPAB(L"Open Main Contacts Folder"); strFolder = GetFolderName(pSubFolder); folderCount++; if(GetContents(pSubFolder)) { SortContents(TABLE_SORT_ASCEND,PR_DISPLAY_NAME); //SortContents(TABLE_SORT_ASCEND,PR_SUBJECT); CString strText; CExMapiContact mapiContact; CString name; CString email; BOOL mustFilter = FALSE; mustFilter = strStartWith != ""; if(doLog) m_logHelper.LogPAB(L"Start reading contacts from main contact fodler"); while(GetNextContact(mapiContact) && !m_pCtrl->IsPABSearchAbort()) { if(pageSize > 0) { if(contactCount == pageSize) { break; } } contactIndex++; if(mustFilter) { if(strFilterBy == "Name") { mapiContact.GetName(name,PR_GIVEN_NAME); name = name.MakeLower(); if(name.Find(strStartWith) != 0) { continue; } } if(strFilterBy == "Email") { mapiContact.GetEmail(email); email = email.MakeLower(); if(email.Find(strStartWith) != 0) { continue; } } } if(startIndex > 0 && skipCount < startIndex) { skipCount++; continue; } CContact* pContact = new CContact(); pContact->SetId(contactIndex); pContact->SetFolderName(strFolder); mapiContact.GetName(strText); pContact->SetFullName(strText); mapiContact.GetCompany(strText); pContact->SetCompany(strText); mapiContact.GetIMAddress(strText); pContact->SetIMAddress(strText); mapiContact.GetName(strText,PR_GIVEN_NAME); pContact->SetFirstName(strText); mapiContact.GetName(strText,PR_MIDDLE_NAME); pContact->SetMiddleName(strText); mapiContact.GetName(strText,PR_SURNAME); pContact->SetLastName(strText); mapiContact.GetEmail(strText); pContact->SetEmail(strText); mapiContact.GetEmail(strText,2);//Email 2 pContact->SetEmail2(strText); mapiContact.GetEmail(strText,3);//Email 3 pContact->SetEmail3(strText); mapiContact.GetPhoneNumber(strText,PR_BUSINESS_TELEPHONE_NUMBER); pContact->SetBusinessPhone(strText); mapiContact.GetPhoneNumber(strText,PR_COMPANY_MAIN_PHONE_NUMBER); pContact->SetCompanyPhone(strText); mapiContact.GetPhoneNumber(strText,PR_BUSINESS_FAX_NUMBER); pContact->SetFax(strText); mapiContact.GetPhoneNumber(strText,PR_MOBILE_TELEPHONE_NUMBER); pContact->SetMobilePhone(strText); mapiContact.GetPhoneNumber(strText,PR_HOME_TELEPHONE_NUMBER); pContact->SetHomePhone(strText); if(m_pCtrl->FetchUnique()) { BOOL isContactExist = FALSE; for(int i=0;i<contactArray.GetCount();i++) { CContact* pTemp = (CContact*)contactArray.GetAt(i); if(pContact->GetEmail() != "" && pTemp->GetEmail() == pContact->GetEmail()) { isContactExist = TRUE; break; } else if(pContact->GetFullName() != "" && pTemp->GetFullName() == pContact->GetFullName()) { isContactExist = TRUE; break; } else if(pContact->GetMobilePhone() != "" && pTemp->GetMobilePhone() == pContact->GetMobilePhone()) { isContactExist = TRUE; break; } else if(pContact->GetHomePhone() != "" && pTemp->GetHomePhone() == pContact->GetHomePhone()) { isContactExist = TRUE; break; } else if(pContact->GetBusinessPhone() != "" && pTemp->GetBusinessPhone() == pContact->GetBusinessPhone()) { isContactExist = TRUE; break; } } if(isContactExist) { continue; } } contactArray.Add(pContact); contactCount++; } } if(doLog) m_logHelper.LogPAB(L"Open Sub Contacts Folder"); GetContacts(pSubFolder,folderCount,contactCount,skipCount,contactIndex,contactArray,doLog); } if(pageSize > 0) { if(contactCount == pageSize) break; } if(m_pCtrl->IsPABSearchAbort()) break; __recursionCount = 0; } } if(doLog) { m_logHelper.LogPAB(L"------------------------------------"); m_logHelper.LogPAB(L"Function GetPABCotacts END:"); m_logHelper.LogPAB(L"------------------------------------"); m_logHelper.ClosePABLog(); } __recursionCount = 0; RELEASE(lpMsgStoreTable); if(folderCount == 0 && !m_pCtrl->IsPABSearchAbort()) { error.code = 107; error.err = "TRContactFinder Cannot find private folders."; return FALSE; } return TRUE; }
LPMAPIFOLDER CExMapi::GetContacts(LPMAPIFOLDER pFolder,LONG& folderCount,LONG& contactCount,LONG& skipCount,LONG& contactIndex,CObArray& contactArray,BOOL doLog) { __recursionCount++; wchar_t buffer[5]; _itow(__recursionCount,buffer,10); if(doLog) { if(__recursionCount > 1) m_logHelper.LogPAB(L"-------------------------------------"); m_logHelper.LogPAB(L"Recursive Call No: "+CString(buffer)); m_logHelper.LogPAB(L"-------------------------------------"); } CString strFilterBy = m_pCtrl->GetPABSerachBy(); CString strStartWith = m_pCtrl->GetPABSerachStartWith(); strStartWith = strStartWith.MakeLower(); ULONG pageSize; m_pCtrl->get_PABPageSize(&pageSize); LONG pageNumber = m_pCtrl->GetPABPageNumber(); LONG startIndex = -1; if(pageSize>0) { startIndex = (pageSize * pageNumber) - pageSize; } LPMAPIFOLDER pSubFolder=NULL; LPMAPITABLE pHierarchy; CString strFolder; try { if(doLog) m_logHelper.LogPAB(L"RELEASE(m_pHierarchy); START"); RELEASE(m_pHierarchy); if(doLog) m_logHelper.LogPAB(L"RELEASE(m_pHierarchy); END"); if(doLog) m_logHelper.LogPAB(L"pHierarchy = GetHierarchy(pFolder); START"); pHierarchy = GetHierarchy(pFolder); if(doLog) m_logHelper.LogPAB(L"pHierarchy = GetHierarchy(pFolder); END"); if(pHierarchy) { LPMAPIFOLDER pRecurse = NULL; do { RELEASE(pSubFolder); m_pHierarchy = pHierarchy; if(doLog) m_logHelper.LogPAB(L"pSubFolder = GetNextSubFolder(strFolder,pFolder); START"); pSubFolder = GetNextSubFolder(strFolder,pFolder); if(doLog) m_logHelper.LogPAB(L"pSubFolder = GetNextSubFolder(strFolder,pFolder); END"); if(pSubFolder) { //if(strFolder == L"Deleted Items") // continue; if(IsContactFolder(pSubFolder)) { folderCount++; if(doLog) m_logHelper.LogPAB(L"if(GetContents(pSubFolder)) START"); if(GetContents(pSubFolder)) { if(doLog) m_logHelper.LogPAB(L"if(GetContents(pSubFolder)) END"); SortContents(TABLE_SORT_ASCEND,PR_DISPLAY_NAME); //SortContents(TABLE_SORT_ASCEND,PR_SUBJECT); CString strText; CExMapiContact mapiContact; CString name; CString email; BOOL mustFilter = FALSE; mustFilter = strStartWith != ""; if(doLog) m_logHelper.LogPAB(L"Start Reading Contact properties"); while(GetNextContact(mapiContact) && !m_pCtrl->IsPABSearchAbort()) { if(pageSize > 0) { if(contactCount == pageSize) { break; } } contactIndex++; if(mustFilter) { if(strFilterBy == "Name") { mapiContact.GetName(name,PR_GIVEN_NAME); name = name.MakeLower(); if(name.Find(strStartWith) != 0) { continue; } } if(strFilterBy == "Email") { mapiContact.GetEmail(email); email = email.MakeLower(); if(email.Find(strStartWith) != 0) { continue; } } } if(startIndex > 0 && skipCount < startIndex) { skipCount++; continue; } CContact* pContact = new CContact(); pContact->SetId(contactIndex); pContact->SetFolderName(strFolder); mapiContact.GetName(strText); pContact->SetFullName(strText); mapiContact.GetCompany(strText); pContact->SetCompany(strText); mapiContact.GetIMAddress(strText); pContact->SetIMAddress(strText); mapiContact.GetName(strText,PR_GIVEN_NAME); pContact->SetFirstName(strText); mapiContact.GetName(strText,PR_MIDDLE_NAME); pContact->SetMiddleName(strText); mapiContact.GetName(strText,PR_SURNAME); pContact->SetLastName(strText); mapiContact.GetEmail(strText); pContact->SetEmail(strText); mapiContact.GetEmail(strText,2);//Email 2 pContact->SetEmail2(strText); mapiContact.GetEmail(strText,3);//Email 3 pContact->SetEmail3(strText); mapiContact.GetPhoneNumber(strText,PR_BUSINESS_TELEPHONE_NUMBER); pContact->SetBusinessPhone(strText); mapiContact.GetPhoneNumber(strText,PR_COMPANY_MAIN_PHONE_NUMBER); pContact->SetCompanyPhone(strText); mapiContact.GetPhoneNumber(strText,PR_BUSINESS_FAX_NUMBER); pContact->SetFax(strText); mapiContact.GetPhoneNumber(strText,PR_MOBILE_TELEPHONE_NUMBER); pContact->SetMobilePhone(strText); mapiContact.GetPhoneNumber(strText,PR_HOME_TELEPHONE_NUMBER); pContact->SetHomePhone(strText); if(m_pCtrl->FetchUnique()) { BOOL isContactExist = FALSE; for(int i=0;i<contactArray.GetCount();i++) { CContact* pTemp = (CContact*)contactArray.GetAt(i); if(pContact->GetEmail() != "" && pTemp->GetEmail() == pContact->GetEmail()) { isContactExist = TRUE; break; } else if(pContact->GetFullName() != "" && pTemp->GetFullName() == pContact->GetFullName()) { isContactExist = TRUE; break; } else if(pContact->GetMobilePhone() != "" && pTemp->GetMobilePhone() == pContact->GetMobilePhone()) { isContactExist = TRUE; break; } else if(pContact->GetHomePhone() != "" && pTemp->GetHomePhone() == pContact->GetHomePhone()) { isContactExist = TRUE; break; } else if(pContact->GetBusinessPhone() != "" && pTemp->GetBusinessPhone() == pContact->GetBusinessPhone()) { isContactExist = TRUE; break; } } if(isContactExist) { continue; } } contactArray.Add(pContact); contactCount++; } } } m_pHierarchy = NULL; // so we don't release it in subsequent drilldown if(pageSize > 0) { if(contactCount == pageSize) break; } if(__recursionCount < m_pCtrl->GetSubFOlderLevel()) { pRecurse = GetContacts(pSubFolder,folderCount,contactCount,skipCount,contactIndex,contactArray,doLog); } if(pRecurse) { RELEASE(pSubFolder); pSubFolder = pRecurse; break; } } else { __recursionCount = 1; } if(pageSize > 0) { if(contactCount == pageSize) break; } } while(pSubFolder && !m_pCtrl->IsPABSearchAbort()); RELEASE(pHierarchy); m_pHierarchy=NULL; } // this may occur many times depending on how deep the recursion is; make sure we haven't already assigned m_pFolder if(pSubFolder && m_pFolder!=pSubFolder) { RELEASE(m_pFolder); m_pFolder=pSubFolder; } } catch(_com_error &e) { if(doLog) { m_logHelper.LogPAB(L"GetContactFolderCount Exception Catch START:"); m_logHelper.LogPAB(L"FolderName: " + strFolder ); m_logHelper.LogPAB(e.ErrorMessage()); m_logHelper.LogPAB(L"GetContactFolderCount Exception Catch END:"); } } return pSubFolder; }
void CuDlgParameterInstallationExtra::RefreshParameter() { try { int nTopIndex = m_cListCtrl.GetTopIndex(); m_cListCtrl.HideProperty(FALSE); m_cListCtrl.DeleteAllItems(); while (!m_listParameter.IsEmpty()) delete m_listParameter.RemoveHead(); if (theApp.m_ingresVariable.QueryEnvironment (m_listParameter, FALSE, TRUE)) { // // Sort the parameter: CaEnvironmentParameter* pParam = NULL; CObArray a; int i, indx, nCount = 0; if (!m_listParameter.IsEmpty()) { a.SetSize(m_listParameter.GetCount()); POSITION pos = m_listParameter.GetHeadPosition(); while (pos != NULL) { pParam = (CaEnvironmentParameter*)m_listParameter.GetNext(pos); if (pParam->GetName().CompareNoCase(_T("II_NUM_OF_PROCESSORS"))==0) pParam->LoadDescription(IDS_II_NUM_OF_PROCESSORS); else if (pParam->GetName().CompareNoCase(_T("II_MAX_SEM_LOOPS"))==0) pParam->LoadDescription(IDS_II_MAX_SEM_LOOPS); a[nCount] = pParam; nCount++; } if (a.GetSize() > 1) IVM_DichotomySort(a, CompareSubItem, (LPARAM)&m_sortparam, NULL); } else return; for (i=0; i< a.GetSize(); i++) { pParam = (CaEnvironmentParameter*)a[i]; nCount = m_cListCtrl.GetItemCount(); indx = m_cListCtrl.InsertItem (nCount, pParam->GetName(), IM_ENV_SYSTEM); if (indx != -1) { m_cListCtrl.SetItemText (indx, 1, pParam->GetValue()); m_cListCtrl.SetItemText (indx, 2, pParam->GetDescription()); m_cListCtrl.SetItemData (indx, (DWORD_PTR)pParam); } } if (nTopIndex != -1) { CRect r; m_cListCtrl.GetItemRect (0, r, LVIR_BOUNDS); m_cListCtrl.Scroll (CSize(0, nTopIndex*r.Height())); } } } catch (...) { AfxMessageBox (_T("System error (CuDlgParameterInstallationExtra::RefreshParameter): \nRefresh parameter failed")); } }