Example #1
0
BOOL DeviceSelect::OnInitDialog()
{
	CDialog::OnInitDialog();

	listControl.SetExtendedStyle(listControl.GetExtendedStyle() | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT  );
	listControl.ModifyStyle(LVS_SINGLESEL , 0);
	listControl.InsertColumn(0, _T("Device ID"), LVCFMT_LEFT, 100);
	listControl.InsertColumn(1, _T("Device Name"), LVCFMT_LEFT, 206);

	int pos;
	int count = 0;
	CString id;
	pos = deviceList.Find(",",0);
	CString device;
	while(pos >= 0)
	{
		device = deviceList.Left(pos);
		deviceList.Delete(0,pos + 1);
		pos = deviceList.Find(",",0);
		id = deviceList.Left(pos);
		deviceList.Delete(0,pos + 1);
		char * temp = (char *)malloc(100);
		itoa(count,temp,10);
		CString str(temp);
		int nIndex = listControl.InsertItem(count, str);
		listControl.SetItemText(nIndex, 1, _T(device));
		pos = deviceList.Find(",",0);
		count++;
	}
	listControl.SetFocus();
	listControl.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED ); 
	selectedDevice = device;
	return true;
}
// Show Balloon
BOOL CDHtmlMainDialog::ShowBalloon(UINT id, DWORD infoFlag, CString infoTitle, CString info)
{
	if(m_FlagResident)
	{
		NOTIFYICONDATA nidata;
		nidata.cbSize = sizeof(NOTIFYICONDATA);
		nidata.hWnd = m_hWnd;
		nidata.uID = id;
		nidata.uFlags = NIF_INFO;
		nidata.dwInfoFlags = infoFlag;

		_tcscpy_s(nidata.szInfo, 256, info.Left(255));
		_tcscpy_s(nidata.szInfoTitle, 64, infoTitle.Left(63));

		for(int i = 0; i < 3; i++)
		{
			if(::Shell_NotifyIcon(NIM_MODIFY, &nidata))
			{
				return TRUE;
			}
			Sleep(100 * i);
		}
	}
	return FALSE;
}
Example #3
0
// returns NULL if error, else usable (local) path...
//
static LPCSTR Skins_ModelNameToSkinPath(LPCSTR psModelFilename)
{
	static CString str;
			str = psModelFilename;
			str.MakeLower();
 	while  (str.Replace('\\','/')){}	

	// special case for anything in the "objects" dir...
	//
	int i = str.Find("models/objects/");
	if (i>=0)
	{
		str = str.Left(i+strlen("models/objects/"));
		str+= "skins";
		return (LPCSTR) str;
	}

	// or anything else...
	//
	i = str.Find("models/");
	if (i>=0)
	{
		str = str.Left(i+strlen("models/"));
		str+= "characters/skins";		
		return (LPCSTR) str;
	}

	return NULL;
}
Example #4
0
void FixFilename(CString& str)
{
	str.Trim();

	for (int i = 0, l = str.GetLength(); i < l; i++) {
		switch (str[i]) {
			case '?':
			case '"':
			case '/':
			case '\\':
			case '<':
			case '>':
			case '*':
			case '|':
			case ':':
				str.SetAt(i, '_');
		}
	}

	CString tmp;
	// not support the following file names: "con", "con.txt" "con.name.txt". But supported "name.con" and "name.con.txt".
	if (str.GetLength() == 3 || str.Find('.') == 3) {
		tmp = str.Left(3).MakeUpper();
		if (tmp == _T("CON") || tmp == _T("AUX") || tmp == _T("PRN") || tmp == _T("NUL")) {
			str = _T("___") + str.Mid(3);
		}
	}
	if (str.GetLength() == 4 || str.Find('.') == 4) {
		tmp = str.Left(4).MakeUpper();
		if (tmp == _T("COM1") || tmp == _T("COM2") || tmp == _T("COM3") || tmp == _T("COM4") ||
				tmp == _T("LPT1") || tmp == _T("LPT2") || tmp == _T("LPT3")) {
			str = _T("____") + str.Mid(4);
		}
	}
}
CString CProjectDBI::StripConfiguration (const CString &strPath, CString &strRemainder)
{
    int iPos;

    if (strPath[0] == _T ('{'))
    {
        iPos = strPath.Find (_T ('}'));
        if (iPos == -1)
        {
            strRemainder = strPath;
            return ("");
        };

        strRemainder = strPath.Mid (iPos + 1);
        strRemainder.TrimLeft(_T('.'));
        return (strPath.Left (iPos+1));
    };

    iPos = strPath.Find (_T ('.'));
    if (iPos == -1)
    {
        strRemainder = "";
        return (strPath);
    };

    strRemainder = strPath.Mid (iPos + 1);
    return (strPath.Left (iPos));
}
bool CFormulaParser::VerifyFunctionNamingConventions(CString name) {
  if (p_function_collection->OpenPPLLibraryCorrectlyParsed()) {
    // User-defined bot-logic
    // Must be a f$-symbol or a list
    if (name.Left(2) == "f$") return true;
    if (name.Left(4) == "list") return true;
    // Special cases: notes, dll and date
    if (name == "notes") return true;
    if (name == "dll") return true;
    if (name.Left(2) == "20") return true;
  } else {
    // OpenPPL-library
    // Must start with upper cases
    if (isupper(name[0])) return true;
  }
  CString message;
  message.Format("Invalid function name: %s\n"
    "Naming conventions:\n"
    "  * Uppercases: OpenPPL-library\n"
    "  * lowercases: built-in OpenHoldem symbols\n"
    "  * f$symbols: user-defined functions\n"
    "  * listXYZ: user-defined lists\n",
    name);
  CParseErrors::Error(message);
  return false;
}
Example #7
0
void CCopyTagBlkDlg::BldTreeSelList(HTREEITEM h, char* TagPrefix, int& Cnt, CSVector& List)
  {
  CString s;
  int i;
  while (h)
    {
    BOOL b = m_CopyTree.GetItemSelected(h);
    if (b)
      {
      //rAccNdData d = AW.Data[LOWORD(dw)];
      //s = d.sFullTag();
      s = m_CopyTree.GetItemText(h);
      i = s.Find(" (");
      if (i>=0)
        s = s.Left(i);
      List[Cnt].Set("%s%s", TagPrefix, (const char*)s);
      Cnt++;
      }
    if (m_CopyTree.ItemHasChildren(h))
      {
      if (!b)
        {
        s = m_CopyTree.GetItemText(h);
        i = s.Find(" (");
        if (i>=0)
          s = s.Left(i);
        }
      Strng ss;
      ss.Set("%s%s.", TagPrefix, (const char*)s);
      BldTreeSelList(m_CopyTree.GetChildItem(h), ss(), Cnt, List);
      }
    h = m_CopyTree.GetNextSiblingItem(h);
    }
  }
Example #8
0
static int SplitRemoteBranchName(CString ref, CString &remote, CString &branch)
{
	if (ref.Left(13) == _T("refs/remotes/"))
		ref = ref.Mid(13);
	else if (ref.Left(8) == _T("remotes/"))
		ref = ref.Mid(8);

	STRING_VECTOR list;
	int result = g_Git.GetRemoteList(list);
	if (result != 0)
		return result;

	for (size_t i = 0; i < list.size(); ++i)
	{
		if (ref.Left(list[i].GetLength() + 1) == list[i] + _T("/"))
		{
			remote = list[i];
			branch = ref.Mid(list[i].GetLength() + 1);
			return 0;
		}
		if (ref == list[i])
		{
			remote = list[i];
			branch = _T("");
			return 0;
		}
	}

	return -1;
}
Example #9
0
CString CCommonAppUtils::GetAbsoluteUrlFromRelativeUrl(const CString& root, const CString& url)
{
    // is the URL a relative one?
    if (url.Left(2).Compare(L"^/") == 0)
    {
        // URL is relative to the repository root
        CString url1 = root + url.Mid(1);
        TCHAR buf[INTERNET_MAX_URL_LENGTH] = { 0 };
        DWORD len = url.GetLength();
        if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
            return CString(buf, len);
        return url1;
    }
    else if (url[0] == '/')
    {
        // URL is relative to the server's hostname
        CString sHost;
        // find the server's hostname
        int schemepos = root.Find(L"//");
        if (schemepos >= 0)
        {
            sHost = root.Left(root.Find('/', schemepos+3));
            CString url1 = sHost + url;
            TCHAR buf[INTERNET_MAX_URL_LENGTH] = { 0 };
            DWORD len = url.GetLength();
            if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
                return CString(buf, len);
            return url1;
        }
    }
    return url;
}
CString CPathUtils::GetAppParentDirectory(HMODULE hMod /* = nullptr */)
{
    CString path = GetAppDirectory(hMod);
    path = path.Left(path.ReverseFind('\\'));
    path = path.Left(path.ReverseFind('\\')+1);
    return path;
}
Example #11
0
bool GitAdminDir::HasAdminDir(const CString& path, bool bDir,CString *ProjectTopDir) const
{
	if (path.IsEmpty())
		return false;
	CString sDirName = path;
	if (!bDir)
	{
		// e.g "C:\"
		if (path.GetLength() <= 3)
			return false;
		sDirName = path.Left(path.ReverseFind(_T('\\')));
	}

	// a .git dir or anything inside it should be left out, only interested in working copy files -- Myagi
	{
	int n = 0;
	for (;;)
	{
		n = sDirName.Find(_T("\\.git"), n);
		if (n < 0)
		{
			break;
		}

		// check for actual .git dir (and not .gitignore or something else), continue search if false match
		n += 5;
		if (sDirName[n] == _T('\\') || sDirName[n] == 0)
		{
			return false;
		}
	}
	}

	for (;;)
	{
		if(CGit::GitPathFileExists(sDirName + _T("\\.git")))
		{
			if(ProjectTopDir)
			{
				*ProjectTopDir=sDirName;
				// Make sure to add the trailing slash to root paths such as 'C:'
				if (sDirName.GetLength() == 2 && sDirName[1] == _T(':'))
					(*ProjectTopDir) += _T("\\");
			}
			return true;
		}
		else if (IsBareRepo(sDirName))
			return false;

		int x = sDirName.ReverseFind(_T('\\'));
		if (x < 2)
			break;

		sDirName = sDirName.Left(x);
	}

	return false;

}
// (3) Totally changed
//==============================================================================
CDiskItem::CDiskItem( const CString &strFullName )
{
//   wchar_t cFullName[_MAX_PATH];
//   _tcscpy( cFullName, fullName ); // M If Unicode
	wchar_t drive[_MAX_DRIVE];
	wchar_t dir[_MAX_DIR];
	wchar_t fname[_MAX_FNAME];
	wchar_t ext[_MAX_EXT];

	CString strTmp = strFullName;	// (3) We copy the string because we can't change const &
	if( strTmp.Right(1) == "\\" )	// (3) Consider a folder as a file
		strTmp = strTmp.Left( strTmp.GetLength()-1 );

	_wsplitpath_s( strTmp/*(3)strFullName*/, drive, dir, fname, ext );
	// (3) m_strDrive = drive;
	// (3) m_strDir = dir;
	// (3) m_strName = CString(fname) + CString(ext);

// Support UNC
// I must do it because _splitpath doesn't work correctly with UNC!
	if( strFullName.Left( 2 ) == "\\\\" )	// If UNC path is specified
	// (3) Was if( m_strDir.Left( 2 ) == "\\\\" )	// If UNC...
	{
	// (3) In all places - strTmp instead of m_strDir

		int compEnd = strTmp.Find( _T("\\"), 2 );
		m_strComputer = strTmp.Left( compEnd+1 );

		int driveEnd = strTmp.Find( _T("\\"), compEnd+1 );
		if( driveEnd == -1 )	// (3) Slash not found
		{
			m_strDrive = strTmp.Mid( compEnd+1 );
			m_strDir   = "";	// (3)
			m_strName = "";		// (3)
		}
		else					// (3) Slash found
		{
			m_strDrive = strTmp.Mid( compEnd+1, driveEnd-compEnd );

			int dirEnd = strTmp.ReverseFind( '\\' );				// (3)
			if( dirEnd > driveEnd )									// (3)
				m_strDir = strTmp.Mid( driveEnd+1, dirEnd-driveEnd );// (3)

			if( strTmp.GetLength() > dirEnd )				// (3)
				m_strName = CString(fname) + CString(ext);	// (3)
			else
				m_strName = "";
		}
	}
	else	// (3) All in brackets added
	{
		m_strComputer = "";
		m_strDrive = drive;
		m_strDir = dir;
		m_strName = CString(fname) + CString(ext);
	}
}
Example #13
0
CString LimitHeadersLength( CString Headers )
{
	if (Headers.GetLength() > 4000)	//4000 - \r\n and some margin
	{
		Headers = Headers.Left(4000);
		Headers = Headers.Left(Headers.ReverseFind('\n') + 1);	//Remove last line
	}
	return Headers;
}
Example #14
0
void CHTMLDialogEx::TitleChange(BSTR Text)
{
    CString strText = Text;

    if (strText.Left(7) == "file://" || strText.Left(7) == "http://")
        strText.Empty();

    if (strText.IsEmpty())
        return;

    SetWindowText(strText);
}
/*-----------------------------------------------------------------------------
	Take a crack at modifying custom headers
-----------------------------------------------------------------------------*/
void CWinInetEvents::OnHttpAddRequestHeaders(HINTERNET hRequest, CString &headers, DWORD &dwModifiers)
{
    if( active )
    {
        if( !userAgent.IsEmpty() )
        {
            CString lcase = headers;
            lcase.MakeLower();
            int offset = lcase.Find(_T("user-agent"));
            if( offset >= 0 )
            {
                offset = lcase.Find(_T(":"), offset);
                if( offset >= 0 )
                {
                    int end = lcase.Find(_T('\n'), offset);
                    if( end >= -1 )
                    {
                        // insert it in the middle of the string
                        headers = headers.Left(offset + 2) + userAgent + headers.Mid(end);
                    }
                }
            }
        }
        else if( script_modifyUserAgent && !keepua )
        {
            // modify the user agent string if it was passed as a custom header (IE8)
            CString agent;
            agent.Format(_T("; PTST 2.%d"), build);
            if( headers.Find(agent) == -1 )
            {
                CString lcase = headers;
                lcase.MakeLower();
                int offset = lcase.Find(_T("user-agent"));
                if( offset >= 0 )
                {
                    int end = lcase.Find(_T('\n'), offset);
                    if( end >= -1 )
                    {
                        // now scan backwards for the end parenthesis
                        CString left = lcase.Left(end);
                        int end2 = left.ReverseFind(_T(')'));
                        if( end2 >= 0 )
                            end = end2;

                        // insert it in the middle of the string
                        headers = headers.Left(end) + agent + headers.Mid(end);
                    }
                }
            }
        }
    }
}
Example #16
0
BOOL PathManager::CopyDir(CString strSrcPath, CString strDstPath)
{ // 创建目标文件夹
	if (strSrcPath.Right(1) == "\\")
	{
		strSrcPath = strSrcPath.Left(strSrcPath.GetLength() - 1);
	}
	if (strDstPath.Right(1) == "\\")
	{
		strDstPath = strDstPath.Left(strDstPath.GetLength() - 1);
	}
	CreateDirectory(strDstPath,NULL);
	CFileFind finder;
	// 打开指定的文件夹进行搜索
	BOOL bWorking = finder.FindFile(strSrcPath + "\\" + "*.*"); 
	while(bWorking) 
	{
		// 从当前目录搜索文件
		bWorking = finder.FindNextFile();
		CString strFileName = finder.GetFileName(); 
		CString strSrc = strSrcPath + "\\" + strFileName;
		CString strDst = strDstPath + "\\" + strFileName;
		// 判断搜索到的是不是"."和".."目录

		if(!finder.IsDots())

		{

			// 判断搜索到的目录是否是文件夹

			if(finder.IsDirectory())

			{

				// 如果是文件夹的话,进行递归

				if(!CopyDir(strSrc, strDst)) 
				{
					return false;
				}
			}
			else
			{
				// 如果是文件,进行复制
				if(!CopyFile(strSrc, strDst, FALSE))
				{
					return false;
				} 
			} 
		}
	}       
	return true;
} 
Example #17
0
/////////////////////////////////////////////////////////////////////////////
// CZWEIII メッセージ ハンドラ
void CED5::OnDblclkList1() 
{
	// TODO: この位置にコントロール通知ハンドラ用のコードを追加してください
	CString s;	s=tied5[m_list.GetItemData(m_list.GetCurSel())];
	ret=s.Left(8); ret.TrimRight();
	ret2=m_list.GetCurSel();
	if(s.Left(2)=="★"){
		fnn=s.Mid(2);
	}else{
		fnn=s.Mid(9);
	}
	EndDialog(1567);
}
Example #18
0
void CLotteryDlg::_readInit()
{
	TCHAR path[MAX_PATH] = {0};
	CString strPath = _getCurPath() + _T("init.ini");
	GetPrivateProfileString(_T("Titile"), _T("title"), _T(""), path, MAX_PATH, strPath);
	CString str = path;
	m_uiInfo._title = str.GetBuffer();
	str.ReleaseBuffer();
	//读取已经中奖的人
	TCHAR *pBuf = new TCHAR[10240];
	memset(pBuf, 0, sizeof(TCHAR) * 10240);
	GetPrivateProfileString(_T("Procedure"), _T("winner"), _T(""), pBuf, 10240, strPath);
	std::wstring strwinner = pBuf;
	delete pBuf;
	pBuf = NULL;
	_parseWinnerPicPath(strwinner);
	//读取奖项设置
	m_TotalClass = GetPrivateProfileInt(_T("Adwards"), _T("total"), 3, strPath);
	m_NumFinished = GetPrivateProfileInt(_T("Procedure"), _T("finished"), 0, strPath);
	AwardInfo ai;
	CString tmp;
	int pos = 0;
	for (int i = m_TotalClass; i > 0; --i)
	{
		str.Format(_T("%d"), i);
		GetPrivateProfileString(_T("Adwards"), str, _T("0"), path, MAX_PATH, strPath);
		str = path;
		//几等奖品
		pos = str.Find(_T(' '));
		tmp = str.Left(pos);
		str = str.Right(str.GetLength() - pos);
		str.TrimLeft();
		ai._class = tmp.GetBuffer();
		tmp.ReleaseBuffer();
		//多少人的
		pos = str.Find(_T(' '));
		tmp = str.Left(pos-1);
		str = str.Right(str.GetLength() - pos);
		str.TrimLeft();
		ai._tnum = _wtoi(tmp.GetBuffer());
		tmp.ReleaseBuffer();
		//什么奖品
		str.Trim();
		ai._award = str.GetBuffer();
		str.ReleaseBuffer();

		m_AwardInfo.push_back(ai);
	}
	//读取信息后需要在做一下处理:比如说上次程序运行已经完成到什么阶段,现在应该接着运行
	_checkFinishedNum();
}
Example #19
0
const CString COmdFileFactor::GetCell(const PTCHAR& c, const int& n) const
{
    CString str;
    str.Format("%s", c);
    
    TCHAR c1;
    TCHAR c2;
    c1 = *(str.Left(1).GetBuffer(str.Left(1).GetLength()));
    c2 = *(str.Right(1).GetBuffer(str.Left(1).GetLength()));
    
    int x;
    x = (c1 - 'A'+1) + (c2 - 'A'+1) + 'Z'+1;//+25是因為這個部份是從AA開始算,所以要跳過A~Z
        
    return GetCell(x, n);
}
Example #20
0
void MYIniReadTools::GetKeyAndValue(CString &strKey,CString &strValue,CString &strComment,CString str)
{
	int nComment=str.Find(';',0);
	if (nComment!=-1)
	{
		if (str.Find('"',nComment)==-1)
		{
			strComment=str.Right(str.GetLength()-nComment-1);
			str=str.Left(nComment);
		}
	}
	int nEquale=str.Find('=',0);
	strKey=str.Left(nEquale);
	strValue=str.Right(str.GetLength()-nEquale-1);
}
void CEditPropExternalsValue::OnBnClickedBrowse()
{
    SVNRev rev = SVNRev::REV_HEAD;
    CAppUtils::BrowseRepository(m_URLCombo, this, rev, false, m_RepoRoot.GetSVNPathString(), m_URL.GetSVNPathString());

    // if possible, create a repository-root relative url
    CString strURLs;
    m_URLCombo.GetWindowText(strURLs);
    if (strURLs.IsEmpty())
        strURLs = m_URLCombo.GetString();
    strURLs.Replace('\\', '/');
    strURLs.Replace(L"%", L"%25");

    CString root = m_RepoRoot.GetSVNPathString();
    int rootlength = root.GetLength();
    if (strURLs.Left(rootlength).Compare(root)==0)
    {
        if ((strURLs.GetLength() > rootlength) && (strURLs.GetAt(rootlength) == '/'))
        {
            strURLs = L"^/" + strURLs.Mid(rootlength);
            strURLs.Replace(L"^//", L"^/");
            m_URLCombo.SetWindowText(strURLs);
        }
    }
}
Example #22
0
bool CMountPoints::IsVolumeMountPoint(CString volume, CString path)
{
	for (;;)
	{
		PointVolumeArray *pva;
		if (!m_volume.Lookup(volume, pva))
		{
			TRACE(_T("CMountPoints: Volume(%s) unknown!\r\n"), volume);	
			return false;
		}

		CString point;
		for (int i=0; i < pva->GetSize(); i++)
		{
			point= (*pva)[i].point;
			if (path.Left(point.GetLength()) == point)
				break;
		}
		if (i >= pva->GetSize())
			return false;

		if (path.GetLength() == point.GetLength())
			return true;

		volume= (*pva)[i].volume;
		path= path.Mid(point.GetLength());
	}
}
Example #23
0
void CAirportsManager::GetAirportCoordinates(const CString strAirport, CLatitude& tlat, CLongitude& tlong )
{
	int iAirportIndex = FindOrAddEntry(strAirport);

	CString strCorrd;
	if(iAirportIndex >= 0 )
	{
		CAirport * pAirport =  GetAirportList()->at(iAirportIndex);
		ASSERT(pAirport);
		if(pAirport)
			strCorrd = pAirport->m_sARPCoordinates;
	}
	//get lat long form str;
	if( strCorrd.CompareNoCase("") !=0 )
	{
		CString strLongitude;
		CString strLatitude;
		int nIndex = strCorrd.Find("-");
		strLongitude = strCorrd.Left(nIndex);
		tlong.SetValue(strLongitude);
		strLatitude  = strCorrd.Right(strCorrd.GetLength() - nIndex-1);
		tlat.SetValue(strLatitude);
	}

}
Example #24
0
void CAirportsManager::GetAirportsByFilter(CAIRPORTFILTER airportFilter, CAIRPORTLIST& list)
{
	CString sFilter = airportFilter.sIATACode;
	int nIdx = sFilter.Find('*');
	if(nIdx != -1)
	{
		sFilter = sFilter.Left(nIdx);
		for(unsigned i=0; i<m_vAirports.size(); i++) 
		{
			CAirport* pAP = m_vAirports[i];
			if(pAP->m_sIATACode.Left(sFilter.GetLength()).CompareNoCase(sFilter) == 0)
				list.push_back(pAP);
		}

	}
	else
	{
		for(unsigned i=0; i<m_vAirports.size(); i++) 
		{
			CAirport* pAP = m_vAirports[i];
			if(pAP->m_sIATACode.CompareNoCase(sFilter) == 0)
				list.push_back(pAP);
		}
	}


}
bool CFunctionCollection::CheckForOutdatedFunction(CString name) {
  if (name  == "f$play") {
    CParseErrors::Error("f$play got replaced\n"
      "by f$sitin, f$sitout, f$leave.\n");
    return true;
  }
  if (name  == "f$P") {
    CParseErrors::Error("f$P got replaced\n"
      "by f$prwin_number_of_opponents.\n");
    return true;
  }
  if (name  == "f$swag") {
    CParseErrors::Error("f$swag and its supporting functions got replaced\n"
      "by a single function f$betsize (raise-to-semantics)\n"
      "and OpenHoldem automatically cares about casino-specific adjustments\n"
      "if you provide the casinos swagtextmethod in the tablemap.\n");
    return true;
  } 
  if (name.Left(9) == "f$OpenPPL") {
    CParseErrors::Error("This is old-style translated OpenPPL.\n"
      "OpenHoldem supports now plain-text OpenPPL.\n"
      "The old technology is no longer compatible.\n"
      "Please have a look at the latest OpenPPL-manual.\n"
      "Things became far more easy.\n");
	  return true;
  }
  return false;
}
Example #26
0
CString opencv::SaveImage(const Mat& src, CString str)
{
	//写在一起了 供以后参考
	if (src.empty()) return L"";

	//获取时间
	if (L"" == str)
	{
		SYSTEMTIME st;
		CString strDate, strTime;
		GetLocalTime(&st);
		strDate.Format(_T("%4d-%d-%d_"), st.wYear, st.wMonth, st.wDay);
		strTime.Format(_T("%d-%d-%d"), st.wHour, st.wMinute, st.wSecond);
		str = strDate + strTime;
	}
	//获取路径
	CString AppPath;
	::GetModuleFileName(GetModuleHandle(NULL), AppPath.GetBuffer(300), 300);
	AppPath.ReleaseBuffer();
	AppPath = AppPath.Left(AppPath.ReverseFind('\\'));
	AppPath = AppPath + L"\\" + L"Image";
	CreateDirectory(AppPath, NULL);
	str = AppPath + L"\\" + str + L".bmp";

	//CString转成char*
	std::string pstr = (LPCSTR)CStringA(str);
	imwrite(pstr, src);
	return str;
}
Example #27
0
int CSpecialApp::SplitCString1(CString strIn, CSimpleArray<CString>& vec_String, TCHAR division) 
{ 
	vec_String.RemoveAll(); 
	if (!strIn.IsEmpty()) 
	{ 
		int nCount = 0; 
		int nPos = -1; 
		nPos = strIn.Find(division); 
		CString strTemp = strIn; 
		while (nPos != -1) 
		{ 
			CString strSubString = strTemp.Left(nPos);  
			strTemp = strTemp.Right(strTemp.GetLength() - nPos-1);  
			nPos = strTemp.Find(division); 
			nCount++; 
			vec_String.Add(strSubString); 
		} 

		if (nCount == vec_String.GetSize()) 
		{ 
			CString str; 
			int nSize = strIn.ReverseFind(division); 
			str = strIn.Right(strIn.GetLength()-nSize-1); 
			vec_String.Add(str); 
		} 
	} 

	return vec_String.GetSize(); 
} 
void CSymbolEngineMemorySymbols::Store(CString command) {
  assert(command.Left(6) == "me_st_");
  CString command_without_prefix = command.Mid(6); 
  write_log(preferences.debug_memorysymbols(), 
    "[CSymbolEngineMemorySymbols] command without prefix> %s\n", command_without_prefix);
  // Get the name of the symbol, up to the next underscore
  int position_of_first_underscore = command_without_prefix.Find('_');
  write_log(preferences.debug_memorysymbols(), 
    "[CSymbolEngineMemorySymbols] position of under-score: %i\n", 
    position_of_first_underscore);
  if (position_of_first_underscore <= 0) {
    // Missing right hand side expression, including under-score
    ErrorInvalidMemoryStoreCommand(command);
    return;
  }
  CString symbol_name = command_without_prefix.Left(position_of_first_underscore);
  write_log(preferences.debug_memorysymbols(), 
    "[CSymbolEngineMemorySymbols] symbol name: %s\n", symbol_name);
  // Get the right hand value after the underscore
  CString right_hand_side = command_without_prefix.Mid(position_of_first_underscore + 1);
  write_log(preferences.debug_memorysymbols(), 
    "[CSymbolEngineMemorySymbols] right hand side: %s\n", right_hand_side);
  if (right_hand_side == "") {
    // Empty right hand side expression after under-score
    ErrorInvalidMemoryStoreCommand(command);
    return;
  }
  double result = EvaluateRightHandExpression(right_hand_side);
  _memory_symbols[symbol_name] = result;
}
Example #29
0
CString CTreePropSheet::SplitPageTreePath(CString &strRest)
{
	int	nSeperatorPos = 0;
	while (TRUE)
	{
		nSeperatorPos = strRest.Find(_T("::"), nSeperatorPos);
		if (nSeperatorPos == -1)
		{
			CString	strItem(strRest);
			strRest.Empty();
			return strItem;
		}
		else if (nSeperatorPos>0)
		{
			// if there is an odd number of backslashes infront of the
			// seperator, than do not interpret it as separator
			int	nBackslashCount = 0;
			for (int nPos = nSeperatorPos-1; nPos >= 0 && strRest[nPos]==_T('\\'); --nPos, ++nBackslashCount);
			if (nBackslashCount%2 == 0)
				break;
			else
				++nSeperatorPos;
		}
	}

	CString	strItem(strRest.Left(nSeperatorPos));
	strItem.Replace(_T("\\::"), _T("::"));
	strItem.Replace(_T("\\\\"), _T("\\"));
	strRest = strRest.Mid(nSeperatorPos+2);
	return strItem;
}
//启动事件
bool CAttemperEngineSink::OnAttemperEngineStart(IUnknownEx * pIUnknownEx)
{
	//绑定参数
	m_pBindParameter=new tagBindParameter[m_pInitParameter->m_wMaxConnect];
	ZeroMemory(m_pBindParameter,sizeof(tagBindParameter)*m_pInitParameter->m_wMaxConnect);

	//设置时间
	ASSERT(m_pITimerEngine!=NULL);
	m_pITimerEngine->SetTimer(IDI_COLLECT_ONLINE_INFO,m_pInitParameter->m_wCollectTime*1000L,TIMES_INFINITY,0);

	//获取目录
	TCHAR szPath[MAX_PATH]=TEXT("");
	CString szFileName;
	GetModuleFileName(AfxGetInstanceHandle(),szPath,sizeof(szPath));
	szFileName=szPath;
	int nIndex = szFileName.ReverseFind(TEXT('\\'));
	szFileName = szFileName.Left(nIndex);
	szFileName += TEXT("\\PlazaOptionConfig.ini");

	//读取配置
	m_bShowServerStatus = (GetPrivateProfileInt(TEXT("ServerStatus"),TEXT("ShowServerStatus"),0,szFileName) != 0);

	//获取目录
	TCHAR szServerAddr[LEN_SERVER]=TEXT("");
	GetCurrentDirectory(sizeof(szPath),szPath);

	//读取配置
	TCHAR szVideoFileName[MAX_PATH]=TEXT("");
	_sntprintf(szVideoFileName,CountArray(szVideoFileName),TEXT("%s\\VideoOption.ini"),szPath);
	DWORD dwAddrLen=GetPrivateProfileString(TEXT("VideoOption"),TEXT("ServerAddr"), TEXT(""), szServerAddr,LEN_SERVER,szVideoFileName);
	return true;
}