示例#1
0
CStringArray* DataBase::GetAllUserSpeech(CString UserId)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();

	//设置SELECT语句
	_bstr_t vSQL;
	vSQL = _T("SELECT * FROM SpeechLib WHERE UserId ='" + UserId + "'");
	//执行SELETE语句
	_RecordsetPtr m_pRecordset;
	m_pRecordset = m_AdoConn.GetRecordSet(vSQL);

	CStringArray* wavArray = new CStringArray;

	CString wavname;
	//返回各列的值
	while (!m_pRecordset->adoEOF)
	{
		wavname = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("WavName");// wait to check the correctness!
		
		wavArray->Add(wavname);

		m_pRecordset->MoveNext();
	}
	
	//断开与数据库的连接
	m_AdoConn.ExitConnect();
	return wavArray;

}
void CDiagramEntityContainer::Export( CStringArray& stra, UINT format ) const
/* ============================================================
	Function :		CDiagramEntityContainer::Export
	Description :	Exports all objects to format format.
					
	Return :		void
	Parameters :	CStringArray& stra	-	CStingArray that 
											will be filled with 
											data on return. 
					UINT format			-	Format to save to.
					
	Usage :			Call to export the contents of the container 
					to a CStringArray. Export will - of course - 
					have to be defined for the derived objects.

   ============================================================*/
{

	int max = GetSize();
	for( int t = 0 ; t < max ; t++ )
	{
		CDiagramEntity* obj = GetAt( t );
		stra.Add( obj->Export( format ) );
	}

}
bool ReadTxt::ReadCircuitSum(CStdioFile *s_file,CString cmdstr,CStringArray &rstr)
{
	CString str,strs;
	bool rtrn = false;
	int i=0;
	s_file->SeekToBegin();
	while(s_file->ReadString(str))
		if(str.Find(cmdstr) > -1) 
		{
			rtrn = true;
			break;
		}
	if(rtrn)
	{
		for(i = 0;i < 3;i++)
		{
			s_file->ReadString(str);
			strs += str;
		}
		int token = 0;
		for( i = 0; i < 14; i++)
		{
			strs.Tokenize(" ",token);
			str = strs.Tokenize(" ",token);
			str.Replace(",","");  //去掉逗号
			rstr.Add(str);
		}
	}
	return rtrn;
}
示例#4
0
int CSendMailPatch::SendAsCombinedMail(const CTGitPathList &list, CGitProgressList* instance)
{
	ASSERT(instance);

	CStringArray attachments;
	CString body;
	for (int i = 0; i < list.GetCount(); ++i)
	{
		CPatch patch;
		if (patch.Parse((CString&)list[i].GetWinPathString(), !m_bAttachment))
		{
			instance->ReportError(_T("Could not open/parse ") + list[i].GetWinPathString());
			return -2;
		}
		if (m_bAttachment)
		{
			attachments.Add(list[i].GetWinPathString());
			body += patch.m_Subject;
			body += _T("\r\n");
		}
		else
		{
			try
			{
				CGit::StringAppend(&body, (BYTE*)(LPCSTR)patch.m_Body, CP_UTF8, patch.m_Body.GetLength());
			}
			catch (CMemoryException *)
			{
				instance->ReportError(_T("Out of memory. Could not parse ") + list[i].GetWinPathString());
				return -2;
			}
		}
	}
	return SendMail(CTGitPath(), instance, m_sSenderName, m_sSenderMail, m_sTo, m_sCC, m_sSubject, body, attachments);
}
示例#5
0
int CSendMailCombineable::SendAsCombinedMail(CTGitPathList &list, CGitProgressList * instance)
{
	ASSERT(instance);

	CStringArray attachments;
	CString body;
	for (int i = 0; i < list.GetCount(); ++i)
	{
		if (m_bAttachment)
		{
			attachments.Add(list[i].GetWinPathString());
		}
		else
		{
			CString filename(list[i].GetWinPathString());
			body += filename + _T(":\n");
			if (GetFileContents(filename, body))
			{
				instance->ReportError(_T("Could not open ") + filename);
				return -2;
			}
			body += _T("\n");
		}
	}
	return SendMail(CTGitPath(), instance, m_sSenderName, m_sSenderMail, m_sTo, m_sCC, m_sSubject, body, attachments);
}
示例#6
0
/* Parse MAC concatened into String Array */
UINT CDeviceid::parseMacs( CString &csMac, CStringArray &csMacArray)
{
	UINT uNumber = 0,
		 uIndex = 0;
	CString csOneMac;

	try
	{
		csMacArray.RemoveAll();
		while (csMac.Mid( uIndex, MAC_STRING_LENGTH).GetLength() > 0)
		{
			csOneMac = csMac.Mid( uIndex, MAC_STRING_LENGTH);
			if (csOneMac.GetLength() == MAC_STRING_LENGTH)
			{
				// This a MAC address
				csMacArray.Add( csOneMac);
				uNumber ++;
			}
			uIndex += MAC_STRING_LENGTH;
		}
		return uNumber;
	}
	catch (CException *pEx)
	{
		pEx->Delete();
		return 0;
	}
}
示例#7
0
void CSkinManager::GetSkinList(CStringArray &skins)
{
	CFileFind finder;
	CString dir = CMyUtility::GetCurDir();
	CString strSkins;
	strSkins.Format(_T("%s\\skins\\*.*"), dir);

	BOOL bFind = finder.FindFile(strSkins);
	if(!bFind)
		return;

	while(bFind)
	{
		bFind = finder.FindNextFile();
		if(finder.IsDots())
			continue;

		if(finder.IsDirectory())
		{
			skins.Add(finder.GetFileName());
			continue;
		}
	}

	finder.Close();

}
示例#8
0
int CRegKey2::GetNames(CStringArray& aNames, BOOL bSubKey) const
{
	ASSERT(m_hKey);

	aNames.RemoveAll();

	DWORD nKey = 0;
	TCHAR szName[1024];
	LONG lResult = ERROR_SUCCESS;

	while (lResult == ERROR_SUCCESS)
	{ 
		// Inside the loop because RegEnumValue will change it
		DWORD nNameLen = 1024;

		if (bSubKey)
			lResult = ::RegEnumKey(m_hKey, nKey, szName, nNameLen);
		else
			lResult = ::RegEnumValue(m_hKey, nKey, szName, &nNameLen, NULL, NULL, NULL, NULL);

		// we have a valid key name
		if (lResult == ERROR_SUCCESS)
			aNames.Add(szName);

		nKey++; // next 
	}

	return aNames.GetSize();
}
示例#9
0
int CIpAddressesDlg::GetIPs( CStringArray &arrIPS )
{
    BOOL bRet = TRUE;
    char name[255];
    int i=0;
    PHOSTENT hostinfo;

  //first, clear the list
    arrIPS.RemoveAll();

  //get the host name
  if( gethostname ( name, sizeof(name)) == 0)
  {
    // get the host info
    if((hostinfo = gethostbyname(name)) != NULL)
    {
      // now, loop until the address list = null
      while( hostinfo->h_addr_list[i] != NULL )
      {
        //get the IP address
        char *ip_addr = inet_ntoa (*(struct in_addr *)
                        hostinfo->h_addr_list[i]);
        //add it to the array
        arrIPS.Add(CString(ip_addr)); 
        //increment the counter
        i++;
      }
    }
  }
  //return the array count
  return int(arrIPS.GetSize());
}
示例#10
0
CStringArray* DataBase::GetAllUserInfo(CString Attribute)
{
	//连接数据库
	ADOConn m_AdoConn;
	m_AdoConn.OnInitADOConn();

	//设置SELECT语句
	_bstr_t vSQL;
	vSQL = _T("SELECT * FROM UserInfo");
	//执行SELETE语句
	_RecordsetPtr m_pRecordset;
	m_pRecordset = m_AdoConn.GetRecordSet(vSQL);

	CStringArray* itemArray = new CStringArray;

	CString item;
	//返回各列的值
	while (!m_pRecordset->adoEOF)
	{
		item = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect((const _variant_t)Attribute);// wait to check the correctness!
		
		itemArray->Add(item);

		m_pRecordset->MoveNext();
	}
	
	//断开与数据库的连接
	m_AdoConn.ExitConnect();
	return itemArray;
}
示例#11
0
int CDbfFile::AddDBF(CStringArray* psDBFAttList,CString sDelimiter)
{
	DBFHandle	hDBF;

	int			kk;
	CFileFind	ShapeFile;
	CString		sTmp;
	CStringArray	*psDBFAtt;
	psDBFAtt = new CStringArray();

	if (_bInit)
	{
		_bInit = false;
		ValidateDBF();
		DBFSetColumn(&_psDBFAttList);
	}
    // Open/Create the database.						
	hDBF = DBFOpen("r+b" );
	if( hDBF == NULL )
	{
		printf("DBFOpen failed: %s\n", _szDBFName);
		return 1;
	}

	for (kk = 0; kk < psDBFAttList->GetSize(); kk++)
	{
		psDBFAtt->RemoveAll();
		sTmp = psDBFAttList->GetAt(kk);
		while (sTmp.Find(sDelimiter) != -1)
		{
			psDBFAtt->Add(sTmp.Left(sTmp.Find(sDelimiter)));
			sTmp.Delete(0, (sTmp.Find(sDelimiter) + 1));
		}
		if (!sTmp.IsEmpty())
			psDBFAtt->Add(sTmp);
		DBFAddRecord(hDBF, psDBFAtt);
	}

	psDBFAtt->RemoveAll();

/* -------------------------------------------------------------------- */
/*      Close and cleanup.                                              */
/* -------------------------------------------------------------------- */
	DBFClose( hDBF );
	delete(psDBFAtt);
	return 0;
}
示例#12
0
BOOL INISetting::ReadIni(CString sFileName, CString sAppName, CStringArray& asKeyName, CStringArray& asKeyValue)
{
	BOOL bReturn = TRUE;

	CFileStatus fs;

	if (CFile::GetStatus(sFileName,fs) == FALSE)
		return false;

	if (m_pBuffer != NULL)
		delete [] m_pBuffer;

	m_pBuffer=new char[int(fs.m_size*1.5)];

	if (m_pBuffer == NULL)
	{
		CString sPrompt;

		sPrompt.Format("ini文件分配内存错!\n[%d]字节",int(fs.m_size*1.2));

		AfxMessageBox(sPrompt);
	}

	CStringArray saValue;

	if (GetPrivateProfileSection(sAppName,m_pBuffer,256,sFileName) && Get00Strings(m_pBuffer,saValue))
	{
		for (int i=0;i<saValue.GetSize();i++)
		{
			CString sValue =  saValue[i];

			int n= sValue.ReverseFind('=');

			if(n!=-1)
			{
				asKeyName.Add(sValue.Left(n));

				asKeyValue.Add(sValue.Mid(n+1));
			}
		}
	}

	if ((asKeyName.GetSize() == 0) || (asKeyName.GetSize() != asKeyValue.GetSize()))
		bReturn = FALSE;

	return bReturn;
}
示例#13
0
int CSimpleReportView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CXTPReportView::OnCreate(lpCreateStruct) == -1)
		return -1;


	CSimpleReport& m_list = (CSimpleReport&)GetReportCtrl();

	// 컬럼 셋업

	CXTPReportColumn* p = m_list.ColSet(0, "first", 100);
	m_list.ColSet(1, "second", 200);
	m_list.ColSet(2, "third", 200);

	m_list.SetFontText("Arial", 16);
	m_list.SetFontHeader("맑은 명조", 16);
	
	// 콤보 박스

	CStringArray s;
	s.Add("hello");
	s.Add("world");
	s.Add("mind");
	s.Add("boggling");
	m_list.ColSetComboData(p, s);

	// 레코드 삽입

	for (int i = 0; i < 20; i++) {
		CXTPReportRecord* pRec = m_list.RowAdd();
		m_list.ColAdd(pRec, "hello");
		m_list.ColAdd(pRec, i * 10.0, "%5.2f");
		m_list.ColAdd(pRec, i, "%3.0f");
	}

	// 컬러/볼드 세팅

	m_list.ColSetColor(0, 2, RGB(255, 255, 255), RGB(0, 200, 0));
	m_list.ColSetBold(0, 1);
	m_list.RowSetBold(1);
	m_list.RowSetColor(5, RGB(255, 255, 255), RGB(200, 0, 0));

	m_list.Populate();

	
	return 0;
}
示例#14
0
//--------------------------------------------------------------------------------
bool CWordWrap::Wrap(CStringArray& sReturn, LPCTSTR pText, int nWidth, LPCTSTR pBreakChars)
	{
	// dont do anything if we dont have to
	if(pText == NULL || nWidth < 1 || *pText == 0)
		return false;

	CString sText(pText);

	if(sText.GetLength() < nWidth)
		return false;

	CString sBreak;
	if(pBreakChars == NULL)
		sBreak = " \t";
	else
		sBreak = pBreakChars;

	int nBegin = 0;
	int nEnd = nWidth;

	if(sText[nEnd] == 0)
		return false;

	for(;;)
		{
		// find a place to break
		while(sBreak.Find(sText[nEnd]) == -1 && nEnd > nBegin)
			nEnd--;
		// no place to break nicely so force a break
		if(nBegin == nEnd)
			nEnd = nBegin + nWidth;
		// copy the string
		sReturn.Add(sText.Mid(nBegin, nEnd - nBegin));
		// advance indexes
		nBegin = nEnd;
		nEnd += nWidth;
		// are we at the end?
		if(nEnd >= sText.GetLength())
			{
			if(nBegin < sText.GetLength())
				sReturn.Add(sText.Mid(nBegin));
			break;
			}
		}

	return true;
	}
示例#15
0
BOOL COutWnd::bAddString(CStringArray& omStrArray)
{
    BOOL bReturn     = TRUE;
    INT  nTotalCount = (COMMANINT)omStrArray.GetSize();
    INT  nReturnAdd  = 0;
    //   vResetContent();
    MDIActivate();
    omStrArray.Add(" ");
    INT nCount; //nCount declared outside
    for( nCount=0; nCount<nTotalCount; nCount++)
    {
        nReturnAdd = m_omListBox.AddString(omStrArray.GetAt(nCount));
        if(nReturnAdd<0)
        {
            bReturn = FALSE;
        }
    }
    // Set horizontal extent of the list box to max string availaable
    // so that user can scroll
    CSize   sz(0,0);
    CString omStrText   = "";
    CDC*  pDC = m_omListBox.GetDC();
    //Check for valid dc and then set the horizontal extent
    if( pDC != nullptr)
    {
        TEXTMETRIC   tm;
        pDC->GetTextMetrics(&tm);

        //Select the new font object to calculte the extent
        //because font is set for window not for CDC
        CFont* pOldFont = pDC->SelectObject(&m_omNewFont);
        INT nTotalItem =  m_omListBox.GetCount();
        INT nDx = 0;
        for (nCount = 0; nCount < nTotalItem; nCount++)
        {
            m_omListBox.GetText( nCount, omStrText );
            // remove space
            omStrText.TrimRight();
            sz = pDC->GetTextExtent(omStrText);
            //Add avg char width for avoiding any wrapping up
            sz.cx += tm.tmAveCharWidth;
            if (sz.cx > nDx)
            {
                nDx = sz.cx;
            }
        }
        //release the new font
        pDC->SelectObject(pOldFont);
        m_omListBox.ReleaseDC(pDC);
        // Set the horizontal extent so every character of all strings
        // can be scrolled to.
        m_omListBox.SetHorizontalExtent(nDx);
    }
    else
    {
        bReturn = FALSE;
    }
    return bReturn;
}
BOOL CTextFile::ReadTextFile( CString& filename, CStringArray& contents )
/* ============================================================
	Function :		CTextFile::ReadTextFile
	Description :	Will read the contents of the file filename 
					into the CStringArray contents, one line 
					from the file at a time.
					If filename is empty, the standard file 
					dialog will be displayed, and - if OK is 
					selected - filename will contain the 
					selected filename on return.

	Return :		BOOL					-	TRUE if OK. 
												GetErrorMessage 
												will contain errors.
	Parameters :	CString& filename		-	file to read from
					CStringArray& contents	-	will be filled 
												with the contents 
												of the file

   ============================================================*/
{

	ClearError();
	BOOL result = TRUE;

	if( filename.IsEmpty() )
		result = GetFilename( FALSE, filename );

	if( result )
	{
		CStdioFile file;
		CFileException feError;

		if( file.Open( filename, CFile::modeRead, &feError ) )
		{

			contents.RemoveAll();

			CString line;
			while( file.ReadString( line ) )
				contents.Add( line );

			file.Close();

		}
		else
		{

			TCHAR	errBuff[256];
			feError.GetErrorMessage( errBuff, 256 );
			m_error = errBuff;
			result = FALSE;

		}
	}

	return result;

}
示例#17
0
int CUserListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CP4ListCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	CStringArray colnames;
	colnames.Add ( LoadStringResource(IDS_NAME) );
	colnames.Add ( LoadStringResource(IDS_E_MAIL) );
	colnames.Add ( LoadStringResource(IDS_FULL_NAME) );
	colnames.Add ( LoadStringResource(IDS_ACCESS) );
	ASSERT( USER_MAXCOL == colnames.GetSize( ) );
	int width[ USER_MAXCOL ]={90,150,150,90};
	RestoreSavedWidths( width, colnames.GetSize( ), sRegValue_UserList );
	InsertColumnHeaders( colnames, width );

	return 0;
}
示例#18
0
void CMidiDevice::GetDevInNames(CStringArray &strArrDevIn)
{
	strArrDevIn.RemoveAll();
	for(int i  = 0; i < m_nTotalNumOfDevIn; i++)
	{
		strArrDevIn.Add((LPCTSTR)(m_midiDevIn[i].szPnameIn));
	}
}
示例#19
0
DWORD CSetupApp::GetFilesToCopy(CStringArray& files)
{
	files.RemoveAll();

	ULONGLONG total= 0;

	CFileFind finder;

	BOOL b= finder.FindFile(GetAppFolder() + _T("\\windirstat.*"));
	while (b)
	{
		b= finder.FindNextFile();
		if (finder.IsDirectory())
			continue;
		files.Add(finder.GetFilePath());
                // Retrieve file size
		total+= finder.GetLength();
	}
	finder.Close();

	b= finder.FindFile(GetAppFolder() + _T("\\wdsr*.dll"));
	while (b)
	{
		b= finder.FindNextFile();
		if (finder.IsDirectory())
			continue;
		files.Add(finder.GetFilePath());
		// Retrieve file size
                total+= finder.GetLength();
	}
	finder.Close();

	b= finder.FindFile(GetAppFolder() + _T("\\wdsh*.chm"));
	while (b)
	{
		b= finder.FindNextFile();
		if (finder.IsDirectory())
			continue;
		files.Add(finder.GetFilePath());
		// Retrieve file size
                total+= finder.GetLength();
	}
	finder.Close();

	return (DWORD)total;
}
示例#20
0
void CMidiDevice::GetDevOutNames(CStringArray &strArrDevOut)
{
	strArrDevOut.RemoveAll();
	for(int i = 0; i < m_nTotalNumOfDevOut; i++)
	{
		strArrDevOut.Add((LPCTSTR)(m_midiDevOut[i].szPnameOut));
	}
}
示例#21
0
BOOL CSkinSection::ParseStringToStringArray(const CString &str, CStringArray &strArr, TCHAR ch)
{
	int nLength = str.GetLength();
	if (nLength <= 0)
		return FALSE;
	int nPos = str.Find(ch,0);
	int nHead = 0;
	while (nPos > 0)
	{
		strArr.Add(str.Mid(nHead,nPos - nHead));
		nHead = nPos + 1;
		nPos = str.Find(ch,nHead);
	}
	strArr.Add(str.Mid(nHead,nLength - nHead));

	return TRUE;
}
示例#22
0
int CParseString::Parse(CStringArray& array, CString separ)
{
   Init(separ);
   CString word;
   array.RemoveAll();
   while (GetNextWord(word)) array.Add(word);
   return (int)array.GetSize();
}
// 更新数据
BOOL CDlgCheckRuleFamInstName::UpdateControlByCheckRule(const CheckRule &checkRule)
{
	

	DWORD dwFilter = checkRule.dwMdlFilter;
	// 强制过滤工程图
	dwFilter &= ~MODELFILTER_DRW;
	GetDlgItem(IDC_CHECK_DRW)->EnableWindow(FALSE);

	m_cmbCheckType.ResetContent();

	CString strMdlNameCheckType, strCheckContent;
	if (checkRule.arrRuleContent.GetSize() >= 2)
	{
		strMdlNameCheckType=checkRule.arrRuleContent.GetAt(0);	//特征类型
		strCheckContent = checkRule.arrRuleContent.GetAt(1);	//检查类型
	}

	CStringArray arrCheckType;
	arrCheckType.Add(L"包含");
	arrCheckType.Add(L"不包含");

	int nFind = -1;
	for (int i=0; i<arrCheckType.GetSize(); i++)
	{
		m_cmbCheckType.AddString(arrCheckType[i]);
		if (strMdlNameCheckType.CompareNoCase(arrCheckType[i]) == 0)
		{
			nFind = i;
		}
	}

	if (nFind >= 0)
		m_cmbCheckType.SetCurSel(nFind);
	else
		m_cmbCheckType.SetCurSel(0);
						
	m_strKeyWord = strCheckContent;

	// 设置默认模型类型
	SetModelFilterControl(this, checkRule.dwMdlFilter);

	UpdateData(FALSE);

	return TRUE;
}
示例#24
0
void AddIncludeDirectory( char *pString ){
    CString s = pString;
	int len = s.GetLength();
    if(len > 0 && s[len - 1] != '\\' ){
        s += "\\";
    }
    includeDirectories.Add(s);
}
示例#25
0
bool DestroyTagControls()
{
	int sub1Width = s_ftListCtrl->GetColumnWidth(0);
	int sub1_5Width = s_ftListCtrl->GetColumnWidth(1);
	int sub2Width = s_ftListCtrl->GetColumnWidth(2);
	int sub3Width = s_ftListCtrl->GetColumnWidth(3);
	int sub4Width = s_ftListCtrl->GetColumnWidth(4);
	int sub5Width = s_ftListCtrl->GetColumnWidth(5);
//	int sub6Width = s_ftListCtrl->GetColumnWidth(6);

	CString windowProfile = "WindowPositions\\" + MakeWindowID(s_ftID);
	AfxGetApp()->WriteProfileInt(windowProfile, "Sub1", sub1Width);
	AfxGetApp()->WriteProfileInt(windowProfile, "Sub1_5", sub1_5Width);
	AfxGetApp()->WriteProfileInt(windowProfile, "Sub2", sub2Width);
	AfxGetApp()->WriteProfileInt(windowProfile, "Sub3", sub3Width);
	AfxGetApp()->WriteProfileInt(windowProfile, "Sub4", sub4Width);
	AfxGetApp()->WriteProfileInt(windowProfile, "Sub5", sub5Width);
//	AfxGetApp()->WriteProfileInt(windowProfile, "Sub6", sub6Width);

	m_tagParentEditStringArray.RemoveAll();
	if (s_ftEditParentCtrl->GetSafeHwnd())
	{
		int itemCount = s_ftEditParentCtrl->GetCount();
		for (int i = 0; i < itemCount; ++i)
		{
			CString str;
			s_ftEditParentCtrl->GetLBText(i, str);
			m_tagParentEditStringArray.Add(str);
		}
	}
	
	m_tagEditStringArray.RemoveAll();
	int itemCount = s_ftEditTagCtrl->GetCount();
	for (int i = 0; i < itemCount; ++i)
	{
		CString str;
		s_ftEditTagCtrl->GetLBText(i, str);
		m_tagEditStringArray.Add(str);
	}
	
	delete s_ftEditParentCtrl;
	delete s_ftEditTagCtrl;
	delete s_ftListCtrl;

	return true;
}
示例#26
0
void CMixereView::AddStringUnique(CStringArray& StrArr, LPCSTR Str)
{
	for (int i = 0; i < StrArr.GetSize(); i++) {
		if (StrArr[i] == Str)
			return;
	}
	StrArr.Add(Str);
}
示例#27
0
/////////////////////////////////////////////////////////////////////////////
// 枚举参数名
/////////////////////////////////////////////////////////////////////////////
int CPlugIn::EnumParameters(CStringArray& asName)
{
	for(int i=0; i<m_arParameter.GetSize(); i++)
	{
		asName.Add(m_arParameter[i].m_strName);
	}
	return asName.GetSize();
}
示例#28
0
void CConfigDlg::GetStringsFromListCtrl(CStringArray& arrayOut, const CVSListBox& lb) const
{
	int nCount = lb.GetCount();
	for (int i=0; i<nCount; ++i)
	{
		arrayOut.Add(lb.GetItemText(i));
	}
}
void Cwhu_FaxSettingDlg::Lin_ImportAutoForArr(CString m_FilePath,CStringArray &m_AutoForward)
{
	int Number = 0;
	//m_DutyArr数组必须足够大//
	//导入
	CApplication app;
	CWorkbook book;
	CWorkbooks books;
	CWorksheet sheet;
	CWorksheets sheets;
	CRange range;
	LPDISPATCH lpDisp;
	//定义变量//
	COleVariant covOptional((long)
		DISP_E_PARAMNOTFOUND,VT_ERROR);
	if (!app.CreateDispatch(_T("Excel.Application")))
	{
		this->MessageBox(_T("无法创建Excel应用"));
	}
	books = app.get_Workbooks();
	//打开Excel,其中m_FilePath为Excel表的路径名//
	lpDisp = books.Open(m_FilePath,covOptional
		,covOptional,covOptional,covOptional
		,covOptional,covOptional,covOptional
		,covOptional,covOptional,covOptional
		,covOptional,covOptional,covOptional
		,covOptional);
	book.AttachDispatch(lpDisp);
	sheets = book.get_Worksheets();
	sheet = sheets.get_Item(COleVariant((short)1));
	
	CStringArray m_ContentArr;
	for (int ItemNum = 2;ItemNum<40;ItemNum++)
	{
		
		for (int ColumNum=1;ColumNum<11;ColumNum++)
		{
			CString m_pos = Lin_GetEnglishCharacter(ColumNum);
			CString m_Itempos;
			m_Itempos.Format(_T("%d"),ItemNum);
			CString m_str = m_pos+m_Itempos;
			range = sheet.get_Range(COleVariant(m_str),COleVariant(m_str));
			//获得单元格的内容
			COleVariant rValue;
			rValue = COleVariant(range.get_Value2());
			//转换成宽字符//
			rValue.ChangeType(VT_BSTR);
			//转换格式,并输出//
			CString m_content = CString(rValue.bstrVal);
			if (m_content!=_T(""))
			{
				m_AutoForward.Add(m_content);
			}
		}
	}
	book.put_Saved(TRUE);
	app.Quit();
}
示例#30
0
void CUIControler::OnOpenTestSuite()
{
	CString m_strSelectedFolder;
	if (!theApp.GetShellManager()->BrowseForFolder(m_strSelectedFolder, AfxGetMainWnd(), m_strSelectedFolder))
		return;
	

	std::string folderPath=CCommonUtilities::toBasicString(m_strSelectedFolder);
	//
	for (foldersVectorT::iterator myIt=foldersVector.begin();
		myIt!=foldersVector.end();myIt++)
	{
		std::string thisFolderPath=*myIt;
		if (thisFolderPath==folderPath)
		{
			AfxMessageBox(_T("Already opened, choose update instead"));
			return;
		}
	}


	CStringArray files;

	CFileFind finder;
	BOOL bWorking = finder.FindFile(m_strSelectedFolder+_T("/*.xml"));
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		files.Add(finder.GetFilePath());
	} 

	if (files.GetCount()!=0)
	{
		HTREEITEM hSuiteItem=pHistoryTree->createSuiteTreeItem(m_strSelectedFolder);
		foldersVector.push_back(folderPath);
		addFolderToHomeCombo(m_strSelectedFolder);
		//
		for (int i=0;i<files.GetCount();i++)
		{
			std::string filePath=CCommonUtilities::toBasicString(files[i]);

			testsFilesMapT::iterator myIt=testsFilesMap.find(filePath);
			if(myIt==testsFilesMap.end())
			{
				CTestsFile* pTests=openFile(filePath);
				if (pTests)
				{
					pTests->setParentFolder(folderPath);
					pHistoryTree->renderFile(pTests,hSuiteItem);
				}
			}	
		}
	}
	else
	{
		AfxMessageBox(_T("Folder is empty"));
	}	
}