/** * \brief Populate Tree * * This function will populate the tree with database * messages. */ BOOL CMsgSgTreeView::bPopulateTree() { // Insert the database filename as the root item // CMainFrame* pMainFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd; BOOL bReturnValue = TRUE; CMsgSignal* pTempMsgSg = NULL; pTempMsgSg = *((CMsgSignal**)m_sDbParams.m_ppvActiveDB); // Get reference to the tree control CTreeCtrl& om_tree = GetTreeCtrl(); // om_tree.DeleteAllItems(); om_tree.SetTextColor( BLUE_COLOR ); CString omStrDatabaseFilename = m_omCurrDbName; if ( omStrDatabaseFilename.IsEmpty() ) { bReturnValue = FALSE; AfxMessageBox(MSG_DB_NOT_FOUND, MB_OK); } else { // om_tree.DeleteAllItems(); // Insert database filename HTREEITEM hRootItem = om_tree.InsertItem( omStrDatabaseFilename ); om_tree.SetItemImage(hRootItem, 0, 0); CStringList omMessageNames; // Clean the list omMessageNames.RemoveAll(); // Get all the database message names pTempMsgSg->omStrListGetMessageNamesInactive(omMessageNames); POSITION pos = omMessageNames.GetHeadPosition(); BOOL bSelFirstChild = FALSE; // Insert all message names while ( pos != NULL ) { CString omStrMsgName = omMessageNames.GetNext(pos); HTREEITEM hMsg = om_tree.InsertItem( omStrMsgName, hRootItem ); if(bSelFirstChild != TRUE ) { om_tree.SelectItem( hMsg ); bSelFirstChild = TRUE; } om_tree.SetItemImage(hMsg, 1, 1); } // Expand the root om_tree.Expand( hRootItem, TVE_EXPAND ); if(bSelFirstChild != TRUE ) { // Select the root item om_tree.SelectItem( hRootItem ); } } return (bReturnValue); }
// takes a string like "apples,peaches,pears" and converts to a list of strings void StringToList (const CString str, const char * delim, CStringList & thelist) { int iStart = 0, iEnd; CString strFound; thelist.RemoveAll (); if (str.IsEmpty ()) return; while ((iEnd = str.Find (delim, iStart)) != -1) { strFound = str.Mid (iStart, iEnd - iStart); // strFound.TrimLeft (); // strFound.TrimRight (); thelist.AddTail (strFound); iStart = iEnd + strlen (delim); // bypass delimiter(s) } // end of adding each one // add final one after last delimiter strFound = str.Mid (iStart); // strFound.TrimLeft (); // strFound.TrimRight (); thelist.AddTail (strFound); } // end of StringToList
void CFileAndFolder::GetPaths(CStringList & list) { POSITION pos; list.RemoveAll(); for(pos = m_sSelections.GetHeadPosition() ; pos != NULL ;) { list.AddTail(m_sSelections.GetNext(pos)); } }
//*************************************************************************** BOOL CBCGPDAOGridCtrl::GetFieldList (CStringList& lstField) { lstField.RemoveAll (); try { ASSERT_VALID (m_pRecordSet); const short nColumns = m_pRecordSet->GetFieldCount (); for (short nColumn = 0; nColumn < nColumns; nColumn++) { CDaoFieldInfo info; m_pRecordSet->GetFieldInfo (nColumn, info); lstField.AddTail (info.m_strName); } } catch (CDaoException* pEx) { OnDaoException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
BOOL CBCGPODBCGridCtrl::GetFieldList (CStringList& lstField) { lstField.RemoveAll (); if (m_pRecordSet == NULL) { ASSERT (FALSE); return FALSE; } try { ASSERT_VALID (m_pRecordSet); const short nColumns = m_pRecordSet->GetODBCFieldCount (); for (short nColumn = 0; nColumn < nColumns; nColumn++) { CODBCFieldInfo fieldinfo; m_pRecordSet->GetODBCFieldInfo (nColumn, fieldinfo); lstField.AddTail (fieldinfo.m_strName); } } catch (CDBException* pEx) { OnODBCException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
LRESULT CStroeSet::PopulateComboList(WPARAM wParam, LPARAM lParam) { // Get the Combobox window pointer CComboBox* pInPlaceCombo = static_cast<CComboBox*> (GetFocus()); //去掉排序属性 // DWORD nStyle = GetWindowLong(pInPlaceCombo->m_hWnd,GWL_STYLE); // nStyle = nStyle &(~ LBS_SORT); // SetWindowLong(pInPlaceCombo->m_hWnd,GWL_STYLE,nStyle); CRect obWindowRect; pInPlaceCombo->GetWindowRect(&obWindowRect); //pInPlaceCombo->MoveWindow(obWindowRect.left,obWindowRect.top,obWindowRect.Width(),500); CPoint obInPlaceComboTopLeft(obWindowRect.TopLeft()); // Get the active list // Get the control window rect // If the inplace combobox top left is in the rect then // The control is the active control m_List.GetWindowRect(&obWindowRect); int iColIndex = wParam; CStringList* pComboList = reinterpret_cast<CStringList*>(lParam); pComboList->RemoveAll(); if (obWindowRect.PtInRect(obInPlaceComboTopLeft)) { if (1 == iColIndex) { InitComString(pComboList); } } return 0; }
//*************************************************************************** BOOL CBCGPDAOGridCtrl::GetFieldList (LPCTSTR lpszTable, CStringList& lstField) { ASSERT (lpszTable != NULL); lstField.RemoveAll (); try { if (m_pDataBase == NULL) { ASSERT (FALSE); return FALSE; } ASSERT_VALID (m_pDataBase); if (!m_pDataBase->IsOpen ()) { ASSERT (FALSE); return FALSE; } CDaoRecordset* pRecordSet = new CDaoRecordset (m_pDataBase); CString strSQL = _T("SELECT * FROM "); strSQL += lpszTable; pRecordSet->Open (AFX_DAO_USE_DEFAULT_TYPE, strSQL); if (!pRecordSet->IsOpen ()) { delete pRecordSet; return FALSE; } const short nColumns = pRecordSet->GetFieldCount (); for (short nColumn = 0; nColumn < nColumns; nColumn++) { CDaoFieldInfo info; pRecordSet->GetFieldInfo (nColumn, info); lstField.AddTail (info.m_strName); } pRecordSet->Close (); delete pRecordSet; } catch (CDaoException* pEx) { OnDaoException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
BOOL CBCGPODBCGridCtrl::GetFieldList (LPCTSTR lpszTable, CStringList& lstField) { ASSERT (lpszTable != NULL); lstField.RemoveAll (); if (m_pDataBase == NULL) { ASSERT (FALSE); return FALSE; } try { ASSERT_VALID (m_pDataBase); if (!m_pDataBase->IsOpen ()) { ASSERT (FALSE); return FALSE; } CRecordset* pRecordSet = new CRecordset (m_pDataBase); CString strSQL = _T("SELECT * FROM "); strSQL += lpszTable; if (!pRecordSet->Open (CRecordset::forwardOnly, strSQL)) { delete pRecordSet; return FALSE; } const short nColumns = pRecordSet->GetODBCFieldCount (); for (short nColumn = 0; nColumn < nColumns; nColumn++) { CODBCFieldInfo fieldinfo; pRecordSet->GetODBCFieldInfo (nColumn, fieldinfo); lstField.AddTail (fieldinfo.m_strName); } pRecordSet->Close (); delete pRecordSet; } catch (CDBException* pEx) { OnODBCException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
void CDlgWingspanAdjacancyConstraints::GetNodeListByTaxiway(Taxiway& pTaxiway, CStringList& lstNode) { lstNode.RemoveAll(); IntersectionNodeList vNodeList = pTaxiway.GetIntersectNodes(); std::vector<IntersectionNode>::iterator iterNode = vNodeList.begin(); for (; iterNode != vNodeList.end(); ++iterNode) { CString strNodeName = iterNode->GetName(); lstNode.InsertAfter( lstNode.GetTailPosition(), strNodeName); } }
void CCmd_PrepEdit::PreProcess(BOOL& done) { Error e; CStringList files; CString temp; // Get the file at head if required if(m_GetHead) { CCmd_Get *pCmd1= new CCmd_Get(m_pClient); pCmd1->Init(m_ReplyWnd, RUN_SYNC, HOLD_LOCK); pCmd1->SetOpeningForEdit(TRUE); temp= m_FileName+_T("#head"); files.AddHead(temp); if(pCmd1->Run(&files, FALSE) ) m_FatalError= pCmd1->GetError(); else { delete pCmd1; m_ErrorTxt= _T("Unable to run Sync"); m_FatalError=TRUE; return; } pCmd1->CloseConn(&e); // Make sure depot window gets updated (and pCmd1 is deleted) ::PostMessage( m_ReplyWnd, pCmd1->GetReplyMsg(), (WPARAM) pCmd1, 0); } // Edit the file CCmd_ListOpStat *pCmd2= new CCmd_ListOpStat(m_pClient); pCmd2->Init(m_ReplyWnd, RUN_SYNC); pCmd2->SetWarnIfLocked(m_WarnIfLocked); files.RemoveAll(); files.AddHead(m_FileName); if(pCmd2->Run(&files, m_AddFile ? P4ADD : P4EDIT) ) m_FatalError= pCmd2->GetError(); else { delete pCmd2; m_ErrorTxt= _T("Unable to run Edit"); m_FatalError=TRUE; return; } pCmd2->CloseConn(&e); // Make sure depot window gets updated (and pCmd1 is deleted) ::PostMessage( m_ReplyWnd, pCmd2->GetReplyMsg(), (WPARAM) pCmd2, 0); // Note: // By setting done=TRUE, we prevent the main ExecCommand loop from running, // so this command will consist only of the subcommands that were invoked // in PreProcess() done=TRUE; }
void CStringTable::GetStringNames(CStringList &slNames, BOOL bMerge) const { if (!bMerge) slNames.RemoveAll(); POSITION pos = m_lstStrings.GetHeadPosition(); while (pos) { CVersionInfoString* pviString = (CVersionInfoString*)m_lstStrings.GetNext(pos); slNames.AddTail(pviString->GetKey()); } }
//************************************************************************************************ void CBCGPMouseManager::GetViewNames (CStringList& listOfNames) const { listOfNames.RemoveAll (); for (POSITION pos = m_ViewsNames.GetStartPosition (); pos != NULL;) { CString strName; int iId; m_ViewsNames.GetNextAssoc (pos, strName, iId); listOfNames.AddTail (strName); } }
void CDlgPerformanceTakeoff::SetListColumn() { CStringList strList; strList.RemoveAll(); LV_COLUMNEX lvc; lvc.mask = LVCF_WIDTH|LVCF_TEXT; lvc.cx = 100; lvc.csList = &strList; lvc.fmt = LVCFMT_NUMBER; lvc.pszText = _T("Min Acceleration (ft/sec2)"); m_wndListCtrl.InsertColumn(1, &lvc); lvc.fmt = LVCFMT_NUMBER; lvc.pszText = _T("Max Acceleration (ft/sec2)"); m_wndListCtrl.InsertColumn(2, &lvc); lvc.fmt = LVCFMT_NUMBER; lvc.pszText = _T("Min Lift Off(kts)"); m_wndListCtrl.InsertColumn(3, &lvc); lvc.fmt = LVCFMT_NUMBER; lvc.pszText = _T("Max Lift Off(kts)"); m_wndListCtrl.InsertColumn(4, &lvc); lvc.fmt = LVCFMT_NUMBER; lvc.pszText = _T("Min Position Time(sec)"); m_wndListCtrl.InsertColumn(5, &lvc); lvc.fmt = LVCFMT_NUMBER; lvc.pszText = _T("Max Position Time(sec)"); m_wndListCtrl.InsertColumn(6, &lvc); lvc.fmt = LVCFMT_NUMBER; lvc.pszText = _T("Min Take Off Roll(m)"); m_wndListCtrl.InsertColumn(7, &lvc); lvc.fmt = LVCFMT_NUMBER; lvc.pszText = _T("Max Take Off Roll(m)"); m_wndListCtrl.InsertColumn(8, &lvc); lvc.fmt = LVCFMT_NUMBER; lvc.pszText = _T("Fuel Burn(lbs/hr)"); m_wndListCtrl.InsertColumn(9, &lvc); lvc.fmt = LVCFMT_NUMBER; lvc.pszText = _T("Cost($/hr)"); m_wndListCtrl.InsertColumn(10, &lvc); }
void CServiceRequirementDlg::InitListCtrl(void) { // set list control window style DWORD dwStyle = m_ListFltTypeServiceRequirement.GetExtendedStyle(); dwStyle |= LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_GRIDLINES; m_ListFltTypeServiceRequirement.SetExtendedStyle(dwStyle); CStringList strList; strList.RemoveAll(); CString strCaption; LV_COLUMNEX lvc; lvc.mask = LVCF_WIDTH|LVCF_TEXT; strCaption.LoadString(IDS_NAME); lvc.pszText = (LPSTR)(LPCTSTR)strCaption; lvc.cx = 100; lvc.fmt = LVCFMT_NOEDIT; lvc.csList = &strList; m_ListFltTypeServiceRequirement.InsertColumn(0, &lvc); strCaption.LoadString(IDS_NUMBER); lvc.pszText = (LPSTR)(LPCTSTR)strCaption; lvc.cx = 100; lvc.fmt = LVCFMT_EDIT; m_ListFltTypeServiceRequirement.InsertColumn(1, &lvc); strCaption.LoadString(IDS_AIRSERVICETIME); lvc.pszText = (LPSTR)(LPCTSTR)strCaption; lvc.cx = 130; lvc.fmt = LVCFMT_DROPDOWN; lvc.csList = &m_ServiceTimeList; m_ListFltTypeServiceRequirement.InsertColumn(2, &lvc); strCaption.LoadString(IDS_SERVICETIME); lvc.pszText = (LPSTR)(LPCTSTR)strCaption; lvc.cx = 130; lvc.fmt = LVCFMT_NOEDIT; lvc.csList = &m_ServiceTimeList; m_ListFltTypeServiceRequirement.InsertColumn(3, &lvc); //condition strCaption.LoadString(IDS_CONDITION); lvc.pszText = (LPSTR)(LPCTSTR)strCaption; lvc.cx = 130; lvc.fmt = LVCFMT_DROPDOWN; lvc.csList = &m_ConditionNameList; m_ListFltTypeServiceRequirement.InsertColumn(4, &lvc); }
//ÅÅÐò½Ó¿Úº¯Êý(bAsc=TRUEÉýÐò) void SortList(CStringList &KeyList, CStringList &ValList, BOOL bAsc) { int Count = KeyList.GetCount(); _rec *r = new _rec[Count*sizeof(_rec)]; POSITION posKey = KeyList.FindIndex(0); POSITION posVal = ValList.FindIndex(0); int i=0; while(posKey && posVal) { CString Key = KeyList.GetNext(posKey); CString Val = ValList.GetNext(posVal); r[i].key = Key; r[i].val = Val; i++; } //ÅÅÐòº¯Êý _Sort(r,Count,bAsc); KeyList.RemoveAll(); ValList.RemoveAll(); for(int j=0; j<Count; j++) { CString s1 = r[j].key; CString s2 = r[j].val; KeyList.AddTail(r[j].key); ValList.AddTail(r[j].val); } delete[] r; }
void CExploreMsgSg::OnItemchangedLstcMsgs(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; // User wants the signal details if ( m_eSelectType == SEL_SIGNAL || m_eSelectType == SEL_PDU) { if(pNMListView->uNewState == (LVIS_FOCUSED |LVIS_SELECTED) ) { // Delete every other item from the list box. m_omSignalListBox.ResetContent(); // Get handle to selected message item int hSelItem = pNMListView->iItem; if ( (hSelItem != -1) ) { CStringList omSignalNames; omSignalNames.RemoveAll(); // Store last selection m_nMsgIndex = hSelItem; // Get selected message name m_omStrMessageName = m_omMsgList.GetItemText( hSelItem, 0 ); DWORD dwMsgCode = (COMMANDWORD)m_omMsgList.GetItemData(hSelItem); CString strChnlNum; ((CComboBox*)GetDlgItem(IDC_CMB_CHANNEL_SEL))->GetWindowTextA(strChnlNum); INT unChannelNum = atoi(strChnlNum) - 1; std::list<std::string> lstSigNames; vPopulateSignalList(unChannelNum, dwMsgCode, lstSigNames); m_omSignalListBox.SetCurSel(0); SetHorizExtentListBox(m_omSignalListBox); } } } else { // Store last selection m_nMsgIndex = pNMListView->iItem ; } *pResult = 0; }
bool ExtractParams(CString data, CStringList ¶ms) { CString param; params.RemoveAll(); for(int i = 0; ; i++) { if(ExtractParam(data, param, i)) { params.AddTail(param); } else { break; } } return !params.IsEmpty(); }
bool CRegistryKey::getValues(CStringList& values) { values.RemoveAll(); if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS) { for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; ++i) { TCHAR value[255] = { 0 }; DWORD size = _countof(value); rc = RegEnumValue(m_hKey, i, value, &size, nullptr, nullptr, nullptr, nullptr); if (rc == ERROR_SUCCESS) values.AddTail(value); } } return !values.IsEmpty(); }
bool CRegistryKey::getSubKeys(CStringList& subkeys) { subkeys.RemoveAll(); if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE|m_sam, &m_hKey)==ERROR_SUCCESS) { for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; ++i) { TCHAR value[1024] = { 0 }; DWORD size = _countof(value); FILETIME last_write_time; rc = RegEnumKeyEx(m_hKey, i, value, &size, nullptr, nullptr, nullptr, &last_write_time); if (rc == ERROR_SUCCESS) subkeys.AddTail(value); } } return !subkeys.IsEmpty(); }
//*************************************************************************** BOOL CBCGPDAOGridCtrl::GetTableList (CStringList& lstTable) { lstTable.RemoveAll (); try { if (m_pDataBase == NULL) { ASSERT (FALSE); return FALSE; } ASSERT_VALID (m_pDataBase); if (!m_pDataBase->IsOpen ()) { ASSERT (FALSE); return FALSE; } const int nTableDefCount = m_pDataBase->GetTableDefCount (); for (int i = 0; i < nTableDefCount; i++) { CDaoTableDefInfo tabInfo; m_pDataBase->GetTableDefInfo (i, tabInfo, AFX_DAO_ALL_INFO); if (!(tabInfo.m_lAttributes & dbSystemObject)) { lstTable.AddTail (tabInfo.m_strName); } } } catch (CDaoException* pEx) { OnDaoException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
bool CRegistryKey::getValues(CStringList& values) { values.RemoveAll(); if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE, &m_hKey)==ERROR_SUCCESS) { for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; i++) { TCHAR value[255]; DWORD size = sizeof value / sizeof TCHAR; rc = RegEnumValue(m_hKey, i, value, &size, NULL, NULL, NULL, NULL); if (rc == ERROR_SUCCESS) { values.AddTail(value); } } } return values.GetCount() > 0; }
void CConfigDisplay::readSkins(CStringList & skinlist) { AutoLog alog("CCD::readSkins"); skinlist.RemoveAll(); CString glob(m_SkinDir); glob += "\\"; glob += "*"; CFileFind finder; BOOL bWorking = finder.FindFile(glob); while (bWorking) { bWorking = finder.FindNextFile(); CString fname = finder.GetFileName(); CString skin = fname; if (skin != MUZIKBROWZER && skin != "." && skin != "..") { if (verifySkin(skin,FALSE)) skinlist.AddTail(skin); } } finder.Close(); }
void CExploreMsgSg::vGetSigNamesFromMsgCode(DWORD dwMsgCode, CStringList& omSignalNames) { SMSG_NAME_CODE sMsgCodeName; omSignalNames.RemoveAll(); sMsgCodeName.m_dwMsgCode = dwMsgCode; for(int nItr =0; nItr < m_odMsgNameCodeListDb.GetCount(); nItr++) { POSITION pos = m_odMsgNameCodeListDb.FindIndex(nItr); if( nullptr != pos ) { SDB_NAME_MSG& sDbNameMsg = m_odMsgNameCodeListDb.GetAt(pos); POSITION pos1 = sDbNameMsg.m_oMsgNameMsgCodeList.Find(sMsgCodeName); if (pos1 != nullptr) { sMsgCodeName = sDbNameMsg.m_oMsgNameMsgCodeList.GetAt(pos1); omSignalNames.AddTail(&(sMsgCodeName.m_omSignalNames)); } } } }
BOOL CRegistry::Read (LPCTSTR pszKey, CStringList& scStringList) { ASSERT(m_hKey); const int iMaxChars = 4096; DWORD dwType; DWORD dwData = iMaxChars; BYTE* byData = (BYTE*)::calloc(iMaxChars, sizeof(TCHAR)); ASSERT(byData); LONG lReturn = RegQueryValueEx(m_hKey, pszKey, NULL, &dwType, byData, &dwData); m_Info.lMessage = lReturn; m_Info.dwType = dwType; m_Info.dwSize = dwData; if(lReturn == ERROR_SUCCESS && dwType == REG_BINARY) { ASSERT(dwData < iMaxChars); CMemFile file(byData, dwData); CArchive ar(&file, CArchive::load); ar.m_bForceFlat = FALSE; ASSERT(ar.IsLoading()); ASSERT(scStringList.IsSerializable()); scStringList.RemoveAll(); scStringList.Serialize(ar); ar.Close(); file.Close(); } if(byData) { free(byData); byData = NULL; } if(lReturn == ERROR_SUCCESS) return TRUE; return FALSE; }
bool CRegistryKey::getSubKeys(CStringList& subkeys) { subkeys.RemoveAll(); if (RegOpenKeyEx(m_base, m_path, 0, KEY_EXECUTE, &m_hKey)==ERROR_SUCCESS) { for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; i++) { TCHAR value[1024]; DWORD size = sizeof value / sizeof TCHAR; FILETIME last_write_time; rc = RegEnumKeyEx(m_hKey, i, value, &size, NULL, NULL, NULL, &last_write_time); if (rc == ERROR_SUCCESS) { subkeys.AddTail(value); } } } return subkeys.GetCount() > 0; }
BOOL CBCGPODBCGridCtrl::GetTableList (CStringList& lstTable) { lstTable.RemoveAll (); if (m_pDataBase == NULL) { ASSERT (FALSE); return FALSE; } ASSERT_VALID (m_pDataBase); try { if (!m_pDataBase->IsOpen ()) { ASSERT (FALSE); return FALSE; } HSTMT hStmt; SQLRETURN rc = ::SQLAllocStmt(m_pDataBase->m_hdbc, &hStmt); if (!m_pDataBase->Check (rc)) { return FALSE; } #if _MSC_VER >= 1300 #ifdef UNICODE #define __BCGP_SQLCHAR SQLWCHAR #else #define __BCGP_SQLCHAR SQLCHAR #endif #else #define __BCGP_SQLCHAR SQLCHAR #endif rc = ::SQLTables (hStmt, NULL,SQL_NTS, NULL,SQL_NTS, NULL,SQL_NTS, (__BCGP_SQLCHAR*) _T("'TABLE'"), SQL_NTS); if (!m_pDataBase->Check (rc)) { AfxThrowDBException (rc, m_pDataBase, hStmt); } while ((rc = ::SQLFetch (hStmt)) != SQL_NO_DATA_FOUND) { if (!m_pDataBase->Check (rc)) { AfxThrowDBException (rc, m_pDataBase, hStmt); } UCHAR szName [256]; #if _MSC_VER < 1300 SDWORD cbName; #else SQLLEN cbName; #endif rc = ::SQLGetData (hStmt, 3, SQL_C_CHAR, szName, 256, &cbName); if (!m_pDataBase->Check (rc)) { AfxThrowDBException (rc, m_pDataBase, hStmt); } #ifdef _UNICODE lstTable.AddTail(CString(szName)); #else lstTable.AddTail ((LPCTSTR)szName); #endif } ::SQLFreeStmt (hStmt, SQL_CLOSE); } catch (CDBException* pEx) { OnODBCException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
void CSynBCGPEditView::GetUndoActions( CStringList& lstActions ) const { CDWordArray dwaUAT; m_pEdit->GetUndoActions(dwaUAT); lstActions.RemoveAll(); int nIndex = (int)dwaUAT.GetSize(); if ( nIndex != 0) { CString strAction; while (nIndex--) { strAction.Empty(); switch (dwaUAT.GetAt(nIndex) & UAT_REASON) { case g_dwUATUndefined: strAction.LoadString(IDS_STRING_UAT_UNDEF); break; case g_dwUATTyping: strAction.LoadString(IDS_STRING_UAT_TYPE); break; case g_dwUATCut: strAction.LoadString(IDS_STRING_UAT_CUT); break; case g_dwUATPaste: strAction.LoadString(IDS_STRING_UAT_PASTE); break; case g_dwUATDelete: strAction.LoadString(IDS_STRING_UAT_DEL); break; case g_dwUATBackspace: strAction.LoadString(IDS_STRING_UAT_BACK); break; case g_dwUATDragDrop: strAction.LoadString(IDS_STRING_UAT_DRAG); break; case g_dwUATEnter: strAction.LoadString(IDS_STRING_UAT_ENTER); break; case g_dwUATIndent: strAction.LoadString(IDS_STRING_UAT_INDENT); break; case g_dwUATUnindent: strAction.LoadString(IDS_STRING_UAT_UNINDENT); break; case g_dwUATTab: strAction.LoadString(IDS_STRING_UAT_TAB); break; case g_dwUATReplace: strAction.LoadString(IDS_STRING_UAT_REP); break; case g_dwUATComment: strAction.LoadString(IDS_STRING_UAT_COMM); break; case g_dwUATUncomment: strAction.LoadString(IDS_STRING_UAT_UNCOMM); break; case g_dwUATFormatter: strAction.LoadString(IDS_STRING_UAT_TIDY); break; default: strAction.LoadString(IDS_STRING_UAT_UNDEF); } if (strAction.IsEmpty()) { ASSERT(FALSE); strAction = _T("<?>"); } lstActions.AddHead(strAction); } } }
BOOL IJA_llQueryTableTransaction ( CaQueryTransactionInfo* pQueryInfo, CTypedPtrList<CObList, CaColumn*>* pListColumn, CTypedPtrList < CObList, CaTableTransactionItemData* >& listTransaction) { CString strDatabase; CString strDatabaseOwner; CString strTable; CString strTableOwner; CString strStatement; pQueryInfo->GetDatabase (strDatabase, strDatabaseOwner); pQueryInfo->GetTable (strTable, strTableOwner); // // Open the session: CaTemporarySession session (pQueryInfo->GetNode(), strDatabase); if (!session.IsConnected()) { // // Failedto get Session. CString strMsg; strMsg.LoadString (IDS_FAIL_TO_GETSESSION); AfxMessageBox (strMsg); return FALSE; } CString strTempTable = _T(""); CString csGranteeList = _T(""); /* no grantee list required here */ BOOL bOK = IJA_TableAuditdbOutput (pQueryInfo, &session, strTempTable, pListColumn, csGranteeList); if (!bOK) { session.Release(SESSION_ROLLBACK); return FALSE; } BOOL bOnLocal = session.IsLocalNode(); // // STEP 1: Select row that are INSERT, DELETE, REPOLD, REPNEW // Select the rows (table transactions) from the newly created Table: CString strSessionPrefix = _T(""); if (bOnLocal) strSessionPrefix = _T("session."); strStatement.Format ( _T("select * from %s%s where operation in ('repold', 'repnew', 'append', 'insert', 'delete')"), (LPCTSTR)strSessionPrefix, (LPCTSTR)strTempTable); CaIjaCursor cursor(1, strStatement); if (cursor.Open()) { int nCount = 0; CStringList listData; CString strItem1; CString strItem2; while (cursor.Fetch(listData, nCount)) { CaTableTransactionItemData* pTran = new CaTableTransactionItemData(); POSITION pos = listData.GetHeadPosition(); ASSERT (listData.GetCount() >= 10); // At least 10 columns; if (listData.GetCount() < 10) { delete pTran; return FALSE; } pTran->SetTable (strTable); pTran->SetTableOwner (strTableOwner); if (pos != NULL) { // LSN: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); pTran->SetLsn (_ttoul(strItem1), _ttoul(strItem2)); // TID: strItem1 = listData.GetNext (pos); pTran->SetTid(_ttol(strItem1)); // Date: strItem1 = listData.GetNext (pos); pTran->SetDate(strItem1); // User Name: strItem1 = listData.GetNext (pos); pTran->SetUser (strItem1); // Operation: strItem1 = listData.GetNext (pos); if (strItem1.CompareNoCase (_T("insert")) == 0 || strItem1.CompareNoCase (_T("append")) == 0) pTran->SetOperation (T_INSERT); else if (strItem1.CompareNoCase (_T("delete")) == 0) pTran->SetOperation (T_DELETE); else if (strItem1.CompareNoCase (_T("repold")) == 0) pTran->SetOperation (T_BEFOREUPDATE); else if (strItem1.CompareNoCase (_T("repnew")) == 0) pTran->SetOperation (T_AFTERUPDATE); else { ASSERT (FALSE); pTran->SetOperation (T_UNKNOWN); } // Transaction: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); pTran->SetTransactionID (_ttoul(strItem1), _ttoul(strItem2)); // Ignore: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); } pTran->SetCommit (TRUE); pTran->SetJournal (TRUE); CStringList& listAuditedData = pTran->GetListData(); while (pos != NULL) { strItem1 = listData.GetNext (pos); listAuditedData.AddTail(strItem1); } listTransaction.AddTail (pTran); listData.RemoveAll(); } cursor.Close(); } // // STEP 2: Select rows that are COMMIT, ABORT, COMMITNJ, ABORTNJ // to update the previous select result if the rows are commit, abort, ... // Select the rows (table transactions) from the newly created Table: strStatement.Format ( _T("select * from %s%s where operation in ('commit', 'abort', 'commitnj', 'abortnj')"), (LPCTSTR)strSessionPrefix, (LPCTSTR)strTempTable); CaIjaCursor cursor2(2, strStatement); if (cursor2.Open()) { CaTableTransactionItemData* pFound = NULL; int nCount = 0; CStringList listData; CString strItem1; CString strItem2; CString strOperation; while (cursor2.Fetch(listData, nCount)) { POSITION pos = listData.GetHeadPosition(); ASSERT (listData.GetCount() >= 10); // At least 10 columns; if (listData.GetCount() < 10) return FALSE; if (pos != NULL) { // LSN: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); // Ignore: strItem1 = listData.GetNext (pos); // Date: strItem1 = listData.GetNext (pos); // User Name: strItem1 = listData.GetNext (pos); // Operation: strOperation = listData.GetNext (pos); // Transaction: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); TRANSACTION_ChangeState (_ttoul(strItem1), _ttoul(strItem2), strOperation, listTransaction); // Ignore: strItem1 = listData.GetNext (pos); strItem2 = listData.GetNext (pos); } listData.RemoveAll(); } cursor2.Close(); } // // Make sure that the temporary table has been destroyed: if (!bOnLocal && bOK && !strTempTable.IsEmpty()) { strStatement.Format ( _T("drop table %s"), (LPCTSTR)strTempTable); CaLowlevelAddAlterDrop param (pQueryInfo->GetNode(), strDatabase, strStatement); param.NeedSession(FALSE); // Use the current open session. param.SetStatement(strStatement); if (!param.ExecuteStatement(NULL)) { CString strMsg; strMsg.LoadString(IDS_FAIL_DROP_TEMP_TABLE); AfxMessageBox(strMsg); } } session.Release(); // Release session and commit. return TRUE; }
BOOL CBCGPRegistry::Read (LPCTSTR pszKey, CStringList& scStringList) { scStringList.RemoveAll (); return Read (pszKey, (CObject&) scStringList); }
//////////////////////////////////////////// // OnExecute // Demonstrate: // IDirectorySearch::ExecuteSearch // IDirectorySearch::GetNextRow // IDirectorySearch::GetColumn // IDirectorySearch::SetSearchPreference // ///////////////////////////////////////////// void CDlgIDirectorySearch::OnExecute() { ASSERT( m_pSearch ); CWaitCursor wait; UpdateData(TRUE); // Get data from the Dialog Box HRESULT hr; ADS_SEARCH_HANDLE hSearch; ADS_SEARCH_COLUMN col; CString s; int idx=0; int nCount; LPWSTR *pszAttr=NULL; POSITION pos; USES_CONVERSION; ///////////////////////////////// // Reset the Total Number ////////////////////////////////// SetDlgItemText( IDC_TOTAL, _T("")); ///////////////////////////////////////////// // Get the attribute list, and preparing.. /////////////////////////////////////////// CStringList sAttrList; m_cListView.DeleteAllItems(); // Reset the UI while( m_cListView.DeleteColumn(0)) { ; } ////////////////////////////////////////////////// // Preparing for attribute list // and columns to display CString sTemp; m_cAttrList.GetWindowText(s); // we need to add adspath, so that we can refer to this object later when user dblclk the item if ( !s.IsEmpty() ) { sTemp = s; sTemp.MakeLower(); if ( s.Find(_T("adspath"),0) == -1 ) { s += _T(",ADsPath"); } } // convert to string list for easy manipulation StringToStringList( s, sAttrList ); nCount = sAttrList.GetCount(); idx=0; if ( nCount ) { pszAttr = (LPWSTR*) AllocADsMem( nCount * sizeof(LPWSTR)); pos = sAttrList.GetHeadPosition(); while ( pos != NULL ) { s = sAttrList.GetAt(pos); pszAttr[idx] = T2OLE(s); sAttrList.GetNext(pos ); idx++; } } else { nCount = -1; } ///////////////////////////////////////// // BEGIN Set the preferences /////////////////////////////////////// DWORD dwCountPref = 0; ADS_SEARCHPREF_INFO prefInfo[ MAX_SEARCH_PREF ]; ADS_SORTKEY *pSortKey = NULL; if ( m_bEnableFilter == FALSE ) { // Reset the preference m_pSearch->SetSearchPreference( prefInfo, dwCountPref ); } else // Preferences are specified { //////////////////////// // Timeout Pref //////////////////////////// if ( m_nTimeOut != 0 ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_TIMEOUT; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = m_nTimeOut; dwCountPref++; } ////////////////////////////// // Search Scope ///////////////////////////// idx = m_CADsSearchScope.GetCurSel(); if ( idx != CB_ERR ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = idx; dwCountPref++; } /////////////////////////////////////////////////// // Cache Result. The default is to cache the result ///////////////////////////////////////////////// if ( !m_bCacheResult ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SEARCH_SCOPE; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN; prefInfo[dwCountPref].vValue.Boolean = FALSE; dwCountPref++; } ////////////////////////////////////////////////// // Page Size /////////////////////////////////////////////////// if ( m_nPageSize > 0 ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_PAGESIZE; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER;; prefInfo[dwCountPref].vValue.Integer = m_nPageSize; dwCountPref++; } //////////////////////////////////////////////// // Chase Referrals /////////////////////////////////////////////// idx = m_cChaseReferrals.GetCurSel(); if ( idx != CB_ERR ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_CHASE_REFERRALS; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; switch( idx ) { case 0: prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_NEVER; break; case 1: prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_SUBORDINATE; break; case 2: prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_EXTERNAL; break; default: prefInfo[dwCountPref].vValue.Integer = ADS_CHASE_REFERRALS_EXTERNAL; } dwCountPref++; } /////////////////////////////////////////////// // Sort On //////////////////////////////////////////////// if ( !m_sSortOn.IsEmpty() ) { CStringList sList; UINT nCount; prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SORT_ON; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_PROV_SPECIFIC; StringToStringList( m_sSortOn, sList ); nCount = sList.GetCount(); if ( nCount > 0 ) { POSITION pos; pos= sList.GetHeadPosition(); pSortKey = (ADS_SORTKEY *) LocalAlloc( LMEM_FIXED | LMEM_ZEROINIT, sizeof(ADS_SORTKEY) * nCount ); idx = 0; while( pos != NULL ) { pSortKey[idx].pszAttrType = T2OLE(sList.GetAt(pos)); pSortKey[idx].pszReserved = NULL; pSortKey[idx].fReverseorder =0; // Next idx++; sList.GetNext( pos ); } prefInfo[dwCountPref].vValue.ProviderSpecific.dwLength = sizeof(ADS_SORTKEY) * nCount; prefInfo[dwCountPref].vValue.ProviderSpecific.lpValue = (LPBYTE) pSortKey; dwCountPref++; } } ////////////////////////////////////////////// // Size Limit ////////////////////////////////////////////// if ( m_nSizeLimit > 0 ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_SIZE_LIMIT; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = m_nSizeLimit; dwCountPref++; } ////////////////////////////////////////////////// // A Synchronous /////////////////////////////////////////////////// if ( m_bAsynch ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_ASYNCHRONOUS; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN; prefInfo[dwCountPref].vValue.Integer = TRUE; dwCountPref++; } ///////////////////////////////////////////////////// // Attribute Type Only ////////////////////////////////////////////////////// if ( m_bAttrib ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_ATTRIBTYPES_ONLY; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_BOOLEAN; prefInfo[dwCountPref].vValue.Integer = TRUE; dwCountPref++; } ///////////////////////////////////////////////////// // Derefence Alias ////////////////////////////////////////////////////// if ( m_nDeref != CB_ERR ) { prefInfo[dwCountPref].dwSearchPref = ADS_SEARCHPREF_DEREF_ALIASES; prefInfo[dwCountPref].vValue.dwType = ADSTYPE_INTEGER; prefInfo[dwCountPref].vValue.Integer = m_nDeref; dwCountPref++; } /////////////////////////////////////////////// // Now Set the selected preferences ////////////////////////////////////////////// hr = m_pSearch->SetSearchPreference( prefInfo, dwCountPref ); } ///////////////////////////////////////// // END Set the preferences /////////////////////////////////////// //////////////////////////////////////// // Execute the Search ////////////////////////////////////// DWORD dwCount=0; hr = m_pSearch->ExecuteSearch(T2OLE(m_sFilter), pszAttr, nCount, &hSearch ); //////////////////////////////// //// cleanup //////////////////////////////// if ( pszAttr ) { FreeADsMem( pszAttr ); } if ( pSortKey ) { LocalFree( pSortKey ); } if ( !SUCCEEDED(hr) ) { AfxMessageBox(GetErrorMessage(hr)); return; } //////////////////////////////////////////////////////// // Enumerate the rows //////////////////////////////////////////////////////// sAttrList.RemoveAll(); ///////////////////////////////////////////////////////// // Retrieve the column names returned from the server /////////////////////////////////////////////////////////// LPWSTR pszColumn; hr = m_pSearch->GetFirstRow( hSearch ); if ( !SUCCEEDED(hr) ) { return; } idx=0; while( (hr=m_pSearch->GetNextColumnName( hSearch, &pszColumn )) != S_ADS_NOMORE_COLUMNS ) { s = OLE2T( pszColumn ); m_cListView.InsertColumn(idx, s, LVCFMT_LEFT, 150 ); // adding columns to the UI sAttrList.AddTail(s); FreeADsMem( pszColumn ); idx++; } ///////////////////////////////////////////// // Start iterating the result set //////////////////////////////////////////// int nCol; CStringList sValueList; do { nCol=0; pos = sAttrList.GetHeadPosition(); while( pos != NULL ) { s = sAttrList.GetAt(pos); //column name // Get the Name and display it in the list hr = m_pSearch->GetColumn( hSearch, T2OLE(s), &col ); if ( SUCCEEDED(hr) ) { s =_T(""); if ( col.dwADsType != ADSTYPE_INVALID ) // if we request for attrib only, no value will be returned { ADsToStringList(col.pADsValues, col.dwNumValues, sValueList ); StringListToString( sValueList, s ); } if ( nCol ) { m_cListView.SetItemText(0,nCol, s); } else { m_cListView.InsertItem(0, s); } m_pSearch->FreeColumn( &col ); } nCol++; sAttrList.GetNext(pos); } dwCount++; ///////////////////////////// //Display the total so far //////////////////////////////// s.Format("%ld object(s)", dwCount ); SetDlgItemText( IDC_TOTAL, s ); } while( (hr=m_pSearch->GetNextRow( hSearch)) != S_ADS_NOMORE_ROWS ); m_pSearch->CloseSearchHandle( hSearch ); }