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;
}
Example #2
0
LRESULT CMainDlg::OnExport(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	CFileDialog fd(FALSE, 0, 0, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "X files (*.x)\0*.x\0Obj files (*.obj)\0*.obj\0\x33\x64s files (*.3ds)\0*.3ds\0My files (*.my)\0*.my\0VBO files (*.vbo)\0*.vbo\0Android3D files (*.a3d)\0*.a3d\0FBX files (*.fbx)\0*.fbx\0\0");
	if(fd.DoModal(this->m_hWnd)!= IDCANCEL)
	{
		void (TriFile::*Export[])(float, string, string)={NULL, &TriFile::ExportX, &TriFile::ExportObj, &TriFile::Export3ds, &TriFile::ExportMy, &TriFile::ExportVbo, &TriFile::ExportA3D, &TriFile::ExportFBX};
		CString ext[] = {"",".x", ".obj", ".3ds", ".my", ".vbo", ".a3d", ".fbx"};
		int extl[] = {0, 2, 4, 4, 3, 4, 4, 4};
		CString efile = fd.m_szFileTitle;
		CString efilepath = fd.m_szFileName;
		CString msg;
		msg.Format("Export to %s file completed!", ext[fd.m_ofn.nFilterIndex].Right(extl[fd.m_ofn.nFilterIndex]-1));
		int lf = efile.GetLength();
		efilepath.Delete(efilepath.GetLength() - lf, lf);
		if(!efile.Right(extl[fd.m_ofn.nFilterIndex]).Compare(ext[fd.m_ofn.nFilterIndex]))
		{
			efile.Delete(lf - extl[fd.m_ofn.nFilterIndex], extl[fd.m_ofn.nFilterIndex]);
		}
		file->textures = textures;
		ExportTextures(efilepath);
		(file->*Export[fd.m_ofn.nFilterIndex])((float)((m_Scale.GetPos()/20.0) + 0.05), (LPCSTR)efile, (LPCSTR)efilepath);
		MessageBox(msg, "Information", MB_ICONINFORMATION|MB_OK);
	}
	return 0;
}
Example #3
0
char CRegisterDlg::GetFatherPath(CString& strFullPath)
{
	char bToken;
	if(!strFullPath.Find("HKEY_CLASSES_ROOT"))	//判断主键
	{

		bToken=MHKEY_CLASSES_ROOT;
		strFullPath.Delete(0,sizeof("HKEY_CLASSES_ROOT"));
	}else if(!strFullPath.Find("HKEY_CURRENT_USER"))
	{
		bToken=MHKEY_CURRENT_USER;
		strFullPath.Delete(0,sizeof("HKEY_CURRENT_USER"));

	}else if(!strFullPath.Find("HKEY_LOCAL_MACHINE"))
	{
		bToken=MHKEY_LOCAL_MACHINE;
		strFullPath.Delete(0,sizeof("HKEY_LOCAL_MACHINE"));

	}else if(!strFullPath.Find("HKEY_USERS"))
	{
		bToken=MHKEY_USERS;
		strFullPath.Delete(0,sizeof("HKEY_USERS"));

	}else if(!strFullPath.Find("HKEY_CURRENT_CONFIG"))
	{
		bToken=MHKEY_CURRENT_CONFIG;
		strFullPath.Delete(0,sizeof("HKEY_CURRENT_CONFIG"));

	}
	return bToken;
}
Example #4
0
CTGitPath CTGitPathList::GetCommonRoot() const
{
	if (IsEmpty())
		return CTGitPath();

	if (GetCount() == 1)
		return m_paths[0];

	// first entry is common root for itself
	// (add trailing '\\' to detect partial matches of the last path element)
	CString root = m_paths[0].GetWinPathString() + _T('\\');
	int rootLength = root.GetLength();

	// determine common path string prefix
	for (auto it = m_paths.cbegin() + 1; it != m_paths.cend(); ++it)
	{
		CString path = it->GetWinPathString() + _T('\\');

		int newLength = CStringUtils::GetMatchingLength(root, path);
		if (newLength != rootLength)
		{
			root.Delete(newLength, rootLength);
			rootLength = newLength;
		}
	}

	// remove the last (partial) path element
	if (rootLength > 0)
		root.Delete(root.ReverseFind(_T('\\')), rootLength);

	// done
	return CTGitPath(root);
}
bool MyUPnP::GetDescription()
{
	if(!Valid())return false;
	CString post, host, addr;
	int port = 0;
	addr = NGetAddressFromUrl(m_description, post, host, port);
	if(addr.IsEmpty())return false;
	CString request = CString(_T("GET ")) + post + _T(" HTTP/1.1\r\nHOST: ") + host + _T("\r\nACCEPT-LANGUAGE: en\r\n\r\n");
	CString response;
	if (!SOAP_action(addr, (uint16)port, request, response)) return false;
	CString result;
	if (!parseHTTPResponse(response, result)) return false;

	m_friendlyname = getProperty(result, _T("friendlyName"));
	m_modelname = getProperty(result, _T("modelName"));
	m_baseurl = getProperty(result, _T("URLBase"));
	if(m_baseurl.IsEmpty())m_baseurl = CString(_T("http://")) + host + _T("/");
	if(m_baseurl[m_baseurl.GetLength() - 1]!='/')m_baseurl += _T("/");
	
	CString serviceType = _T("<serviceType>") + m_name + _T("</serviceType>");
	int pos = result.Find(serviceType);
	if (pos >= 0) {
		result.Delete(0, pos + serviceType.GetLength());
		pos = result.Find(_T("</service>"));
		if (pos >= 0) {
			result = result.Mid(0, pos);
			m_controlurl = getProperty(result, _T("controlURL"));
			if (!m_controlurl.IsEmpty() && m_controlurl[0] == '/') {
				m_controlurl = m_baseurl + m_controlurl.Mid(1);
			}
		}
	}

	return isComplete();
}
Example #6
0
void CCaliData::EraseZeroPlus(CString& str)  
{  
	int strLen = str.GetLength();
	int pos= str.Find(_T("E+")); 
	if (pos+5==strLen) //X.XXXe+000
		str.Delete(pos+2);
} 
Example #7
0
// 从XML设置是否发送指定的DUI消息的属性
HRESULT CControlBase::OnAttributeSendDuiMsg(const CString& strValue, BOOL bLoading)
{
	if (strValue.IsEmpty()) return E_FAIL;

	// 解析需要发送的DUI消息列表
	CStringArray asDuiMsg;
	CString strDuiMsg = strValue;
	int nPos = -1;
	while((nPos = strDuiMsg.Find(_T("|"))) != -1)
	{
		CString strTemp = strDuiMsg.Left(nPos);
		strDuiMsg.Delete(0, nPos+1);
		asDuiMsg.Add(strTemp);
	}
	if(!strDuiMsg.IsEmpty())
	{
		asDuiMsg.Add(strDuiMsg);
	}

	for(int i=0; i<asDuiMsg.GetSize(); i++)
	{
		OnControlSetDuiMsg(asDuiMsg[i]);
	}

	return bLoading?S_FALSE:S_OK;
}
Example #8
0
CString CGetEnvPath::CombinationPath(const CString& strLeft, 
    const CString& strMiddle, 
    const CString& strRight)
{
    CString strResult;
    const int nCount = 3;
    const CString* pStr[nCount] = 
        { &strLeft, &strMiddle, &strRight};

    for (int i = 0; i < nCount; i++)
    {
        const CString& str = *pStr[i];

        if (strResult.GetLength() <= 0)
            strResult += str;
        else
        {
            if (str.GetLength() <= 0)
                continue;

            if (strResult[strResult.GetLength() - 1] == TEXT('\\'))
                strResult.Delete(strResult.GetLength() - 1);

            if (str[0] != TEXT('\\'))
            {
                strResult += TEXT('\\');
            }

            strResult += str;
        }
    }

    return strResult;
}
Example #9
0
bool CPinInfoWnd::OnActivate()
{
	DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_TABSTOP;

	CPoint p(10, 10);

	m_pin_static.Create(_T("Pin:"), dwStyle, CRect(p + CPoint(0, 3), CSize(30, m_fontheight)), this);
	m_pin_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CPoint(30, 0), CSize(450, 200)), this, IDC_PP_COMBO1);
	BeginEnumPins(m_pBF, pEP, pPin) {
		CPinInfo pi;
		if(FAILED(pPin->QueryPinInfo(&pi))) {
			continue;
		}
		CString str = CString(pi.achName);
		if(!str.Find(_T("Apple"))) {
			str.Delete(0,1);
		}
		CString dir = _T("[?] ");
		if(pi.dir == PINDIR_INPUT) {
			dir = _T("[IN] ");
		} else if(pi.dir == PINDIR_OUTPUT) {
			dir = _T("[OUT] ");
		}
		m_pin_combo.SetItemDataPtr(m_pin_combo.AddString(dir + str), pPin);
	}
Example #10
0
CString CsRemoveMeta(CString *psString)
{
	CString str = _T(""), strLower;
	LPCTSTR lpRemove = NULL;

	ASSERT(psString != NULL); if(psString == NULL) return str;

	str = *psString;
	strLower = str; strLower = strLower.MakeLower();

	for(int i = 0; i < 2; ++i)
	{
		if(i == 0) lpRemove = _T("auto-type:");
		else if(i == 1) lpRemove = _T("auto-type-window:");

		int nPos = strLower.Find(lpRemove, 0);
		if(nPos != -1)
		{
			if(nPos != 0)
				if(strLower.GetAt(nPos - 1) == _T('\n')) nPos -= 1;
			if(nPos != 0)
				if(strLower.GetAt(nPos - 1) == _T('\r')) nPos -= 1;

			int nCount = strLower.Find(_T('\n'), (int)(nPos + _tcslen(lpRemove) - 1));
			if(nCount == -1) nCount = strLower.GetLength() - nPos;
			else nCount -= nPos - 1;

			strLower.Delete(nPos, nCount);
			str.Delete(nPos, nCount);
		}
	}

	return str;
}
Example #11
0
BOOL CWizardEncWpa::OnInitDialog() 
{
	CNGWizardPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	CNGWizard* pWizardSheet = (CNGWizard*)m_pParentSheet;
	CString strRadiusServer;
	char m_cRadiusServer[4];

//	memcpy(strRadiusServer, pWizardSheet->m_pWizardLogin->m_cRadiusServer, sizeof(strRadiusServer));
	strRadiusServer = pWizardSheet->m_pWizardLogin->m_cRadiusServer;
	
	if (strRadiusServer.IsEmpty() == false)
	{
		for(int i = 0; i < 4; i++)
		{
			CString StrTemp;

			int pos = strRadiusServer.Find('.',0);
			if ( pos != -1 )
				StrTemp = strRadiusServer.Left(pos);
			else
				StrTemp = strRadiusServer;

			int tt;
			tt = atoi(StrTemp);
			m_cRadiusServer[i] = (char)tt;
			strRadiusServer.Delete(0,pos+1);
		}
		m_ctrlRadiusServer.SetAddress(m_cRadiusServer[0],
									  m_cRadiusServer[1],
									  m_cRadiusServer[2],
									  m_cRadiusServer[3]);
	}

	switch(pWizardSheet->m_pWizardLogin->m_iEncryption)
	{
	case ENCRYPTION_TKIP:
		m_iWzEncryptionWpa = TKIP;
		break;
	case ENCRYPTION_AES_CCM:
		m_iWzEncryptionWpa = AES;
		break;
	case ENCRYPTION_DISABLED:
	case ENCRYPTION_WEP:
	case ENCRYPTION_AES_OCB:
	case ENCRYPTION_CKIP:
	case ENCRYPTION_AUTO:
		m_iWzEncryptionWpa = TKIP;
		break;
	}

	UpdateData(false);
	
	((CEdit*)GetDlgItem(IDC_EDIT_WZKEY_WPA))->SetLimitText(64);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Example #12
0
void CEquivManager::Read(void) {
    struct_stat NewStat;
    base_stat((const char *) m_Filename.GetBuffer(), &NewStat);
    if (GetSize() && (m_Stat.st_mtime == NewStat.st_mtime))
        return;

    m_LoadMutex.Lock();
    m_Stat = NewStat;
    RemoveAll();
    (* (CTSStringTable *) this) = m_PersistentTable;
    CLocalFile File(m_Filename);
    if (File.OpenReadBinary()) {
        CVector<CString> Lines;
        File.ReadLines(&Lines);
        CString Line;
        for (register int i=0; i<(int) Lines.GetSize(); i++) {
            Line = Lines[i];
            //// _L_DEBUG(6, cout << "CEquivManager::Read() - parsing " << Line << endl);
            if (!Line.GetLength()) continue;
            if (Line[0] == '#') {
                Line.Delete(0, 1);
                if ((Line.Pos('<')>=0)&&(Line.Pos('>')> Line.Pos('<'))) m_EmailVector += Line;
            } else {
                CVector<CString> Tokens;
                CString::StrToVector(Line, ',', &Tokens);
                if ((Tokens.GetSize() == 2)&&(Tokens[0].GetLength())&&(Tokens[1].GetLength())) {
                    // complex equivalences
                    CVector<CString> TokensLeft;
                    CString::StrToVector(Tokens[0], '+', &TokensLeft);
                    CVector<CString> TokensRight;
                    CString::StrToVector(Tokens[1], '+', &TokensRight);
                    if ((int) TokensLeft.GetSize() > 1) {
                        if (TokensLeft.GetSize() > TokensRight.GetSize()) {
                            cout << "Dropping malformed equivalence at " << Tokens[0] << "=" << Tokens[1] << endl;
                        } else {
                            for (int ii=1; ii<(int)TokensLeft.GetSize(); ii++) {
                                CString TL(TokensLeft[0]);
                                TL+=TokensLeft[ii];
                                CString TR(TokensRight[0]);
                                TR+=TokensRight[ii];
                                CTSStringTable::Set(TL, TR);
                            }
                        }
                    } else {
                        CTSStringTable::Set(Tokens[0], Tokens[1]);
                    }
                }
            }
        }
    }
    m_LoadMutex.UnLock();
}
Example #13
0
void CCaliData::EraseZeroMinus(CString& str)  
{  
	int strLen = str.GetLength();
	int pos = str.Find(_T("E-00"));
	if (pos!=-1)
	{
		str.Delete(pos+2, 2);
		return;
	}
	pos = str.Find(_T("E-0"));
	if (pos!=-1)
	{
		str.Delete(pos+2);
		return;
	}
	//int pos= str.Find(_T("E-")); 
	//if (pos+5==strLen){ // E-000
	//	int next_pos = str.Find(_T("E-0"));
	//	if (next_pos!=-1)
	//		str.Delete(next_pos); 
		
} 
Example #14
0
static bool toString(const CustomColors& custom, CString& out)
{
	TCHAR tmp[32];
	out.Empty();

	for (int i=0; i<16; ++i)
	{
		out += _itot(custom.colors[i], tmp, 10);
		out += _T(",");
	}
	out.Delete(out.GetLength()-1);

	return true;
}
static CString NGetAddressFromUrl(const CString& str, CString& post, CString& host, int& port)
{
	CString s = str;

	post = _T("");
	host = post;
	port = 0;
	int pos = s.Find(_T("://"));
	if (!pos) return CString();
	s.Delete(0, pos + 3);

	pos = s.Find('/');
	if (!pos) {
		host = s;
		s = _T("");
	} else {
		host = s.Mid(0, pos);
		s.Delete(0, pos);
	}

	if (s.IsEmpty()) {
		post = _T("");
	} else {
		post = s;
	}

	pos = 0;
	CString addr = host.Tokenize(_T(":"), pos);
	s = host.Tokenize(_T(":"), pos);
	if (s.IsEmpty()) {
		port = 80;
	} else {
		port = _tstoi(s);
	}

	return addr;
}
int CXmlDocument::ValidateTag(CString &strTag, CString &strResult)
{
	strResult = "";

	if (strTag.IsEmpty())
		return -1;

    TCHAR ch;
	TCHAR chPrevious = '0';
	
	int nResult = 0;
	int nCount = 0;

	// determine tag type
    while(nCount <strTag.GetLength())
    {
        // get next character
		ch = strTag[nCount++];

		// skip comments '<!' and declaration '<?'
        if ((chPrevious == '<' && ch == '!') || 
			(chPrevious == '<' && ch == '?'))
		{
            return -1;
		}
        else
		// is it an end-tag '</' ?
        if(chPrevious =='<' && ch == '/') 
        {
            nResult = 1;
        }
        else
		// is it a start-end-tag '<..../>' ?
        if(chPrevious =='/' && ch == '>') 
        {
            nResult = 2;
			// remove last character
			strResult.Delete(strResult.GetLength()-1, 1);
        }
        else 
		if(ch != '<' && ch != '>')
		{
			// add character
            strResult += ch;
        }
        chPrevious = ch;
    }
	return nResult;
}
bool parseHTTPResponse(const CString& response, CString& result)
{
	int pos = 0;

	CString status = response.Tokenize(_T("\r\n"), pos);

	result = response;
	result.Delete(0, pos);

	pos = 0;
	status.Tokenize(_T(" "), pos);
	status = status.Tokenize(_T(" "), pos);
	if (status.IsEmpty() || status[0]!='2') return false;
	return true;
}
Example #18
0
CString CWorkThread::GetOutputName()
{
	CString szFlvPath = m_szOutputPath;
	CString szFlvName;
	m_qiyiFile.GetFileTitle(szFlvName);
	INT nLen = szFlvName.GetLength();
	szFlvName.Delete(nLen-4, 4);
	szFlvName.Append(_T(".FLV"));

	nLen = szFlvPath.GetLength();
	if (nLen > 3)
	{
		szFlvPath.Append(_T("\\"));
	}
	szFlvPath += szFlvName;
	return szFlvPath;
}
//////////////////////////////////////////////////////////////////////////////
// audio device handle functions 
CString GetHardwareId(LPCTSTR lpszPnpId)
{
	CString strPnpIds = (LPCTSTR)(lpszPnpId + 4); // skip _T("\\?\");
	int nFind = strPnpIds.Find(_T("#"));
	if (nFind != -1) {
		nFind = strPnpIds.Find(_T("#"), nFind + 1);
		if (nFind != -1)
			strPnpIds.Delete(nFind, strPnpIds.GetLength() - nFind);
		else
			strPnpIds.Empty();
	}
	else {
		strPnpIds.Empty();
	}

	return strPnpIds;
}
CString CXmlElement::GetValue(CString attribute)
{
	CString ret = m_strAttributes;;
	int pos = m_strAttributes.Find(attribute + "=");
	if (pos>=0)
	{
		ret.Delete(0,pos+attribute.GetLength()+2);
		int n=ret.Find("\"");
		if (n>=0)
			ret = ret.Left(n);
	}
	else 
		ret = "";
	
	return ret;

	
}
Example #21
0
static bool toString(const PrintTemplate& pt, CString& out)
{
	out = _T("1*"); // the '1' indicates version

	for (int i=0; i<5; ++i)
	{
		CString t;
		if (toString(pt.headings[i], t) == false)
			return false;
		if (t.Find(_T('*')) >= 0)
			return false;
		t += _T('*');
		out += t;
	}
	out.Delete(out.GetLength()-1);

	return true;
}
	int XMLWriter::WriteValue(CString name, CString value)
	{
		if (!has_params.empty()) {
			bool param = has_params.back();
			if (!param) {
				has_params.pop_back();
				has_params.push_back(true);
			}
		}

		#pragma region Escape Special Characters
		// NOTE: http://www.w3.org/TR/html4/sgml/entities.html#h-24.4.1
		for (int i=value.GetLength()-1; i>=0; i--) {
			CString replacement;
			switch(value[i]) {
				case _T('&'):
					replacement = _T("&amp;");
					break;
				case _T('<'):
					replacement = _T("&lt;");
					break;
				case _T('>'):
					replacement = _T("&gt;");
					break;
			}
			if(replacement.IsEmpty())
				continue;
			value.Delete(i);
			value.Insert(i, replacement);
		}
		#pragma endregion

		// escape quotes
		for (int i=value.GetLength()-1; i>=0; i--) {
			if (value[i] == L'\"') {
				value.Insert(i, _T("\\"));
			}
		}

		ret += _T(" ")+name+_T("=\"") + value + _T("\"");
		return 0;
	}
Example #23
0
// URL导航
void CDuiWkeView::Navigate(CString strUrl)
{
	if(m_pWebView)
	{
		if(strUrl.Find(_T("file://")) == 0)
		{
			CString strFile = strUrl;
			strFile.Delete(0, 7);
			if(strFile.Find(_T(":")) == -1)
			{
				strFile = DuiSystem::GetSkinPath() + strFile;
			}
			m_pWebView->loadFile(strFile);
		}else
		{
			m_pWebView->loadURL(strUrl);
		}
		m_render.render(m_pWebView);
	}
}
Example #24
0
/** 
 * @brief Convert user-given extension list to valid regular expression.
 * @param [in] Extension list/mask to convert to regular expression.
 * @return Regular expression that matches extension list.
 */
CString FileFilterHelper::ParseExtensions(CString extensions) const
{
	CString strParsed;
	CString strPattern;
	BOOL bFilterAdded = FALSE;
	static const TCHAR pszSeps[] = _T(" ;|,:");

	extensions += _T(";"); // Add one separator char to end
	int pos = extensions.FindOneOf(pszSeps);
	
	while (pos >= 0)
	{
		CString token = extensions.Left(pos); // Get first extension
		extensions.Delete(0, pos + 1); // Remove extension + separator
		
		// Only "*." or "*.something" allowed, other ignored
		if (token.GetLength() >= 2 && token[0] == '*' && token[1] == '.')
		{
			bFilterAdded = TRUE;
			strPattern += _T(".*\\.");
			strPattern += token.Mid(2);
			strPattern += _T("$");
		}
		else
			bFilterAdded = FALSE;

		pos = extensions.FindOneOf(pszSeps); 
		if (bFilterAdded && pos >= 0)
			strPattern += _T("|");
	}

	if (strPattern.IsEmpty())
		strParsed = _T(".*"); // Match everything
	else
	{
		strParsed = _T("^");
		strPattern.MakeLower();
		strParsed = strPattern; //+ _T("$");
	}
	return strParsed;
}
Example #25
0
bool CDolo8264COM::SearchLayer1(CString &str_url)
{

	CString cs_webContent;
	vector<string> astr;  //下载链接集合
	// http://u.8264.com/home-space-uid-104370-do-album-id-1496-page-1.html#comment
	// http://u.8264.com/home-space-uid-104370-do-album-view-me-from-space.html
	int t1 = str_url.Find(_T("album-id"));
	if(t1 >-1)
	{
		str_url.Delete(t1,str_url.GetLength() - t1);
		str_url+=_T("album-view-me-from-space.html");
	}

	DownloadUrlPage(str_url,cs_webContent);	
	regex reg("[a-zA-z]+://[^\\s]*.html\"  class=\"xi2\"");  	//图片模式
	smatch m1; 

	string s = cs_webContent.GetBuffer();	
	string::const_iterator it = s.begin(); 
	string::const_iterator end=s.end();
	while(regex_search(it,end,m1,reg))
	{
/*		int size = m1[0].length();*/
		string msg(m1[0].first,m1[0].second);	
		msg.erase(msg.size()-14,msg.size());
		astr.push_back(msg);
		it = m1[0].second; 
		msg.empty();
		myidle();
	}
	s.empty();
	for(unsigned int i=0; i<astr.size();i++)
	{
		CString strMfc=astr[i].c_str();
		SearchLayer3(strMfc);
	}
	astr.empty();
	return true;
}
void WZDlgDownload::OnBnClickedButtonPath()
{
	UpdateData(TRUE);

	if (!i8desk::IsRunOnServer())
		AfxMessageBox(_T("请在服务器上设置该功能!"));

	CString selPath;
	if( theApp.GetShellManager()->BrowseForFolder(selPath, this, DownPath_, _T("选择三层下载目录:")) )
	{
		if( selPath.IsEmpty() )
			return ;

		if( selPath.Right(1) == _T("\\") )
			selPath.Delete(selPath.GetLength()-1);

		selPath += _T("\\");
		selPath.Trim();

		DownPath_ = selPath;
	}

	UpdateData(FALSE);
}
Example #27
0
//下载像册信息
// http://u.8264.com/home-space-uid-16752722-do-album-id-1766.html
// http://u.8264.com/home-space-uid-16752722-do-album-id-1766-page-4.html#comment
bool CDolo8264COM::SearchLayer3(CString &str_url)
{
	CString cs_webContent;
	CString cs_tmp;
	int photo_num=0;		//像册数量
	int i_tmp;
	vector<string> astr;  //下载链接集合
	int m_page= 1;			//设置页面数
	CString cs_album_name;	//用户目录
	CString cs_sub_album;	//像册目录

	if(str_url.Find(_T("#comment")) < 0)
	{
		str_url.Delete(str_url.GetLength()-5,5);
		str_url+=_T("-page-1.html#comment");
	}
	else
		str_url.SetAt(str_url.GetLength()-14,_T('1'));

	//获得页面
	bool en_P=false;
	bool en_G=false;
	do 
	{
		cs_webContent.Empty();
		DownloadUrlPage(str_url,cs_webContent);	

		i_tmp = cs_webContent.Find(_T("张图片"),0);
		if(i_tmp>-1)
		{
			cs_tmp = cs_webContent.Left(i_tmp);
			cs_tmp = cs_tmp.Right(4);
			cs_tmp.TrimLeft(_T(" ")); 
			cs_tmp.TrimRight( _T(" "));
			if((atoi(cs_tmp)==0)||(cs_tmp.IsEmpty()))
			{
				return false;
			}
			else
				photo_num = atoi(cs_tmp);
		}
		//获得像册的题目
		if(en_P == false)
		{
			int i=cs_webContent.Find(_T("keywords\" content=\""),0);
			if(i>-1)
			{
				cs_sub_album= cs_webContent.Right(cs_webContent.GetLength() -i -19);
				cs_sub_album = cs_sub_album.Left(cs_sub_album.Find(_T("\"")));
				en_P = true;
			}
		}
		//获得用户题目cs_album_name
		if(en_G == false)
		{
			int i=cs_webContent.Find(_T("<h2 class=\"xs2\">"),0);
			if(i>-1)
			{
				i=cs_webContent.Find(_T("html"),i);
				cs_album_name= cs_webContent.Right(cs_webContent.GetLength() -i -6);
				cs_album_name = cs_album_name.Left(cs_album_name.Find(_T("<"),0));
				en_G = true;
			}
		}
		checkDirname(cs_album_name);
		checkDirname(cs_sub_album);
		CreateDirectory(_T("8264com\\")+cs_album_name,NULL);
		CreateDirectory(_T("8264com\\")+cs_album_name+_T("\\")+cs_sub_album,NULL);

		regex reg("html\"><img src=\"[a-zA-z]+://[^\\s]*thumb.jpg");  	//图片模式
		smatch m1; 

		string s = cs_webContent.GetBuffer();	
		string::const_iterator it = s.begin(); 
		string::const_iterator end=s.end();

		while(regex_search(it,end,m1,reg))
		{
/*			int size = m1[0].length();*/
			string msg(m1[0].first,m1[0].second);	
			msg.erase(0,16);
			msg.erase(msg.size()-10,msg.size());
			//astr.push_back(msg);
			
			s_dolo.cs_url=msg.c_str();
			s_dolo.cs_LocalFullPath=_T("8264com\\")+cs_album_name+_T("\\")+cs_sub_album;
			s_dolo.cs_ReferHead=_T("");
			v_doloST.push_back(s_dolo);

			it = m1[0].second; 
			msg.empty();
			myidle();
		}
		s.empty();

		str_url.Delete(str_url.Find(_T("page")),str_url.GetLength()-str_url.Find(_T("page")) );
		str_url.Insert(str_url.GetLength(), _T("page-"));
		CString tc;
		m_page++;
		tc.Format(_T("%d"),m_page);
		str_url.Insert(str_url.GetLength(), tc);
		str_url.Insert(str_url.GetLength(), _T(".html#comment"));	
		tc.Empty();
	} while (photo_num/20 +2 >m_page);
	


	// 	CString cs_album_name;	//主目录名字
	// 	int photo_num;		//像册数量
	// 	CString cs_sub_album;  //子相册名字
//	checkDirname(cs_album_name);


// 	st_lp.urlGroup=astr;
// 	st_lp.strFileURLInServer.IsEmpty();
// 	st_lp.strFileLocalFullPath=_T("8264com\\")+cs_album_name+_T("\\")+cs_sub_album;
// 	st_lp.strReferHead=_T("");					//_T("Referer: http://mm.taobao.com");
// 	st_lp.hWnd=(HWND)this;
// 	m_pMyThread=AfxBeginThread(Download1,(LPVOID)&st_lp);//&st_lp[n]);
// 	astr.empty();
	return true;
}
Example #28
0
CString CThread::ParseArchiverCmdLine()
{
	WORD wPos = 0;
	WORD wResPos = 0;
	WORD wLen = m_sArchiverCmdLine.Length();

	TCHAR res[MAX_PATH] = {0};

	while (wPos < wLen)
	{
		if (m_sArchiverCmdLine[wPos] != TEXT('%'))
		{
			res[wResPos] = m_sArchiverCmdLine[wPos];
			wPos++;
			wResPos++;
		}
		else if (m_sArchiverCmdLine[wPos] == TEXT('%') && 
			wPos + 1 < wLen && m_sArchiverCmdLine[wPos + 1] == TEXT('%'))
		{
			// Двойной процент ('%%') считаем за один, не макрос
			res[wResPos] = TEXT('%');
			wPos += 2;
			wResPos++;
		}
		else if (m_sArchiverCmdLine[wPos] == TEXT('%'))
		{
			CString sMacro;

			wPos++;
			WORD wMacroStart = wPos;

			while (wPos < wLen)
			{
				if (m_sArchiverCmdLine[wPos] != TEXT('%'))
					wPos++;
                else if (m_sArchiverCmdLine[wPos] == TEXT('%'))
				{	   
					sMacro = m_sArchiverCmdLine.SubStr(wMacroStart, wPos - wMacroStart).ToLowerNew();
					CString sMacroValue;

					while (true)
					{
						if ((sMacro[0] >= TEXT('a') && sMacro[0] <= TEXT('z')) || (sMacro[0] >= TEXT('A') && sMacro[0] <= TEXT('Z')))
						{
							break;
						}
						else
						{
							sMacroValue += sMacro[0];
							sMacro.Delete(0, 1);
						}
					}							

					if (sMacro == TEXT("compress"))
					{
						CString sCompress = FormatC(TEXT("compress%d"), m_TaskInfo.bArchCompress);
						sMacroValue += GetMacroValue(sCompress);

						lstrcat(res, sMacroValue.C());
						wResPos = lstrlen(res);
						wPos++;
					}
					else if (sMacro == TEXT("sfx") && m_TaskInfo.bArchSFX)
					{
						sMacroValue += GetMacroValue(TEXT("sfx"));

						lstrcat(res, sMacroValue.C());
						wResPos = lstrlen(res);
						wPos++;
					}
					else if (sMacro == TEXT("lock") && m_TaskInfo.bArchLock)
					{
						sMacroValue += GetMacroValue(TEXT("lock"));

						lstrcat(res, sMacroValue.C());
						wResPos = lstrlen(res);
						wPos++;
					}
					else if (sMacro == TEXT("taskcmd"))
					{
						sMacroValue += m_TaskInfo.sArchTaskCmd;

						lstrcat(res, sMacroValue.C());
						wResPos = lstrlen(res);
						wPos++;
					}
					else if (sMacro == TEXT("filelist"))
					{
						sMacroValue += TEXT("\"");
						sMacroValue += m_sFileList;
						sMacroValue += TEXT("\"");

						lstrcat(res, sMacroValue.C());
						wResPos = lstrlen(res);
						wPos++;
					}
					else if (sMacro == TEXT("archive"))
					{
						sMacroValue += TEXT("\"");
						sMacroValue += m_sDestFolder;
						sMacroValue += TEXT("\"");

						lstrcat(res, sMacroValue.C());
						wResPos = lstrlen(res);
						wPos++;
					}
					else 
						wPos++;

					break;
				}
			}
		}
	}

	return res;
}
Example #29
0
/*
================
SpinFloatString
================
*/
void SpinFloatString( CString &str, bool up ) {
	int i, dotIndex = -1, digitIndex = -1;

	for ( i = 0; str[i]; i++ ) {
		if ( str[i] == '.' ) {
			if ( dotIndex == -1 ) {
				dotIndex = i;
			}
		}
		else if ( str[i] != '0' ) {
			if ( digitIndex == -1 ) {
				digitIndex = i;
			}
		}
	}
	if ( digitIndex == -1 ) {
		str.SetString( "1" );
		return;
	}

	if ( dotIndex != -1 ) {
		str.Delete( dotIndex, 1 );
		if ( digitIndex > dotIndex ) {
			digitIndex--;
		}
	}
	else {
		dotIndex = i;
	}

	if ( up ) {
		if ( str[digitIndex] == '9' ) {
			str.SetAt( digitIndex, '0' );
			if ( digitIndex == 0 ) {
				str.Insert( 0, '1' );
				dotIndex++;
			}
			else {
				str.SetAt( digitIndex-1, '1' );
			}
		}
		else {
			str.SetAt( digitIndex, str[digitIndex] + 1 );
		}
	}
	else {
		if ( str[digitIndex] == '1' ) {
			if ( str[digitIndex+1] == '\0' ) {
				str.SetAt( digitIndex, '0' );
				str.AppendChar( '9' );
			}
			else if ( str[digitIndex+1] == '0' ) {
				str.SetAt( digitIndex, '0' );
				str.SetAt( digitIndex+1, '9' );
			}
			else {
				str.SetAt( digitIndex+1, str[digitIndex+1] - 1 );
			}
		}
		else {
			str.SetAt( digitIndex, str[digitIndex] - 1 );
		}
	}
	if ( dotIndex < str.GetLength() ) {
		str.Insert( dotIndex, '.' );
		// remove trailing zeros
		for ( i = str.GetLength()-1; i >= 0; i-- ) {
			if ( str[i] != '0' && str[i] != '.' ) {
				break;
			}
		}
		if ( i < str.GetLength() - 1 ) {
			str.Delete( i+1, str.GetLength() - i );
		}
	}
	for ( i = 0; str[i]; i++ ) {
		if ( str[i] == '.' ) {
			if ( i > 1 ) {
				str.Delete( 0, i-1 );
			}
			break;
		}
		if ( str[i] != '0' ) {
			if ( i > 0 ) {
				str.Delete( 0, i );
			}
			break;
		}
	}
}
Example #30
0
// 消息处理
LRESULT CControlBase::OnMessage(UINT uID, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if(m_bTaskMsg)
	{
		// 如果设置了任务方式发消息的属性,则添加一个任务消息
		CString strControlName = GetName();
		CString strAction = GetAction();
		CDlgBase* pParentDlg = GetParentDialog();
		DuiSystem::Instance()->AddDuiActionTask(uID, uMsg, wParam, lParam, strControlName, strAction, pParentDlg);
		return 0;
	}

	if(m_strAction.Find(_T("dlg:")) == 0)	// 动作:打开一个对话框,有内存泄漏,改为通过DuiSystem创建和管理
	{
		if(uMsg == MSG_BUTTON_UP)	// 鼠标放开事件才处理
		{
			CString strXmlFile = m_strAction;
			strXmlFile.Delete(0, 4);
			DuiSystem::ShowDuiDialog(strXmlFile, GetParentDialog());
		}
	}else
	if(m_strAction.Find(_T("popup:")) == 0)	// 动作:打开一个Popup对话框
	{
		if(uMsg == MSG_BUTTON_UP)	// 鼠标放开事件才处理
		{
			/*UINT nIDTemplate = 0;
			CDlgBase* pParentDlg = GetParentDialog();
			if(pParentDlg != NULL)
			{
				nIDTemplate = pParentDlg->GetIDTemplate();
			}
			CDlgPopup* pPopup = new CDlgPopup;
			pPopup->SetParent(this);
			CString strXmlFile = m_strAction;
			strXmlFile.Delete(0, 6);
			pPopup->SetXmlFile(_T("xml:") +strXmlFile );
			CRect rc = pControlBase->GetRect();
			rc.OffsetRect(-95, rc.Height());
			ClientToScreen(&rc);
			pPopup->Create(this, rc, WM_SKIN);
			pPopup->ShowWindow(SW_SHOW);*/
		}
	}else
	if(m_strAction.Find(_T("menu:")) == 0)	// 动作:打开一个菜单
	{
		CDuiMenu *pDuiMenu = new CDuiMenu(DuiSystem::GetDefaultFont(), 12);	// 可以考虑改为通过DuiSystem创建和管理
		pDuiMenu->SetAutoClose(FALSE);
		pDuiMenu->SetParent(this);
		CPoint point;
		CRect rc = GetRect();
		// 计算菜单的显示位置
		if(m_posMenu.nCount >= 2)
		{
			// 使用设置的菜单位置
			int nMenuX = PositionItem2Value(m_posMenu.Left, rc.left, rc.right);
			int nMenuY = PositionItem2Value(m_posMenu.Top, rc.top, rc.bottom);
			point.SetPoint(nMenuX, nMenuY);
		}else
		{
			// 如果没有设置位置信息,则默认按照控件底部开始显示,水平方向中间对齐
			point.SetPoint(rc.left + rc.Width() / 2, rc.bottom);
		}
		CDlgBase* pParentDlg = GetParentDialog();
		if(pParentDlg != NULL)
		{
			pParentDlg->ClientToScreen(&point);
		}
		CString strXmlFile = m_strAction;
		strXmlFile.Delete(0, 5);
		if(pDuiMenu->LoadXmlFile(strXmlFile, pParentDlg, point, WM_DUI_MENU))
		{
			if(m_posMenu.nCount >= 4)
			{
				// 如果菜单pos有4个值,第三个值为负数表示菜单向左侧显示,第四个值为负数表示菜单向上显示
				CRect rcMenu;
				pDuiMenu->GetWindowRect(&rcMenu);
				int nOffsetX = 0;
				int nOffsetY = 0;
				if(m_posMenu.Right.bMinus)
				{
					nOffsetX = -rcMenu.Width();
				}
				if(m_posMenu.Bottom.bMinus)
				{
					nOffsetY = -rcMenu.Height();
				}
				rcMenu.OffsetRect(nOffsetX, nOffsetY);
				pDuiMenu->MoveWindow(rcMenu);
			}
			pDuiMenu->ShowWindow(SW_SHOW);
			pDuiMenu->SetAutoClose(TRUE);
		}
	}else
	if(m_strAction.Find(_T("link:")) == 0)	// 动作:打开一个页面链接
	{
		if(uMsg == MSG_BUTTON_UP)	// 鼠标放开事件才处理
		{
			CString strLink = m_strAction;
			strLink.Delete(0, 5);
			if(!strLink.IsEmpty())
			{
				ShellExecute(NULL, TEXT("open"), strLink, NULL,NULL,SW_NORMAL);
			}
		}
	}else
	if(m_strAction.Find(_T("run:")) == 0)	// 动作:执行一个进程
	{
		if(uMsg == MSG_BUTTON_UP)	// 鼠标放开事件才处理
		{
			CString strProcess = m_strAction;
			strProcess.Delete(0, 4);
			strProcess.MakeLower();
			if(!strProcess.IsEmpty())
			{
				strProcess.MakeLower();
				BOOL bForceAdmin = FALSE;
				if(strProcess.Find(_T("admin@")) == 0)
				{
					bForceAdmin = TRUE;
					strProcess.Delete(0, 6);
				}
				BOOL bWaitProcess = FALSE;
				if(strProcess.Find(_T("&")) == (strProcess.GetLength()-1))
				{
					bWaitProcess = TRUE;
					strProcess.Delete(strProcess.GetLength()-1, 1);
				}
				if(strProcess.Find(_T(".exe")) == -1)
				{
					strProcess = DuiSystem::Instance()->GetString(strProcess);
				}
				if(strProcess.Find(_T("{platpath}")) == 0)
				{
					strProcess.Delete(0, 10);
					strProcess = DuiSystem::GetExePath() + strProcess;
				}
				CString strCmdLine = _T("");
				int nPos = strProcess.Find(_T("|"));
				if(nPos != -1)
				{
					strCmdLine = strProcess;
					strCmdLine.Delete(0, nPos+1);
					strProcess = strProcess.Left(nPos);
				}
				DuiSystem::PathCanonicalize(strProcess);	// 路径标准化
				DuiSystem::ExecuteProcess(strProcess, strCmdLine, bForceAdmin, bWaitProcess);
			}
		}
	}else
	if(m_strAction.Find(ACTION_CLOSE_WINDOW) == 0)	// 动作:关闭指定的窗口
	{
		if(uMsg == MSG_BUTTON_UP)	// 鼠标放开事件才处理
		{
			CString strWndName = m_strAction;
			strWndName.Delete(0, 13);
			if(!strWndName.IsEmpty())
			{
				CDlgBase* pDlg = DuiSystem::Instance()->GetDuiDialog(strWndName);
				if(pDlg != NULL)
				{
					//pDlg->DoClose();
					pDlg->PostMessage(WM_QUIT, 0, 0);
				}
			}
		}
	}else
	{
		// 首先判断如果是几个默认按钮,则直接做相应的处理
		CDlgBase* pParentDlg = GetParentDialog();
		if(IsThisObject(BT_OK, NAME_BT_OK))
		{
			if((MSG_BUTTON_UP == uMsg) && (pParentDlg != NULL)) { pParentDlg->DoOK(); }
		}else
		if(IsThisObject(BT_CANCEL, NAME_BT_CANCEL))
		{
			if((MSG_BUTTON_UP == uMsg) && (pParentDlg != NULL)) { pParentDlg->DoCancel(); }
		}else
		if(IsThisObject(BT_YES, NAME_BT_YES))
		{
			if((MSG_BUTTON_UP == uMsg) && (pParentDlg != NULL)) { pParentDlg->DoYes(); }
		}else
		if(IsThisObject(BT_NO, NAME_BT_NO))
		{
			if((MSG_BUTTON_UP == uMsg) && (pParentDlg != NULL)) { pParentDlg->DoNo(); }
		}else
		{
			// 调用控件的DUI事件处理对象
			return CallDuiHandler(uMsg, wParam, lParam);
		}
	}

	return 0;
}