Example #1
0
void CFileDetailDialogName::RenameFile()
{
	if (CanRenameFile())
	{
		CString strNewFileName;
		GetDlgItem(IDC_FILENAME)->GetWindowText(strNewFileName);
		strNewFileName.Trim();
		if (strNewFileName.IsEmpty() || !IsValidEd2kString(strNewFileName))
			return;
		CPartFile* file = STATIC_DOWNCAST(CPartFile, (*m_paFiles)[0]);
		file->SetFollowTheMajority(false); // EastShare       - FollowTheMajority by AndCycle
		file->SetFileName(strNewFileName, true);
		file->UpdateDisplayedInfo();
		file->SavePartFile();
	}
}
Example #2
0
CString ExtractFileName(LPCTSTR lpszFullFileName)
{
	CString strPath = lpszFullFileName;
	strPath.Trim();

	if(!strPath.IsEmpty())
	{
		int iLen		= strPath.GetLength();
		int iLastSep	= strPath.ReverseFind(PATH_SEPARATOR_CHAR);

		if(iLastSep != -1)
			strPath		= strPath.Right(iLen - 1 - iLastSep);
	}
	
	return strPath;
}
Example #3
0
void CHistoryCombo::SetList(const STRING_VECTOR& list)
{
	Reset();
	for (size_t i = 0; i < list.size(); ++i)
	{
		CString combostring = list[i];
		combostring.Replace('\r', ' ');
		combostring.Replace('\n', ' ');
		if (m_bTrim)
			combostring.Trim();
		if (combostring.IsEmpty())
			continue;

		InsertEntry(combostring, i);
	}
}
Example #4
0
	void	AddEd2kLinksToDownload(CString strlink, int cat)
	{
		int curPos = 0;
		CString resToken = strlink.Tokenize(_T("\t\n\r"), curPos);
		while (resToken != _T(""))
		{
			if (resToken.Right(1) != _T("/"))
				resToken += _T("/");
			try
			{
				CED2KLink* pLink = CED2KLink::CreateLinkFromUrl(resToken.Trim());
				if (pLink)
				{
					
					if (pLink->GetKind() == CED2KLink::kFile)
					{
						/// CDlgAddTask::AddNewTask(pLink->GetFileLink(), cat);
						CDlgAddTask::AddNewTask(strlink, cat);
					}

					// added by VC-yavey on 2010-04-27 : 处理订阅 <begin>
					else if (pLink->GetKind() == CED2KLink::kRss)
					{
						ASSERT(pLink->GetRssLink() != NULL);
						CDlgAddTask::AddNewRssUrl(*pLink->GetRssLink());
					}
					// added by VC-yavey on 2010-04-27 : 处理订阅 <end>

					else
					{
						delete pLink;
						throw CString(_T("bad link"));
					}
					delete pLink;
				}
			}
			catch(CString error)
			{
				TCHAR szBuffer[200];
				_sntprintf(szBuffer, ARRSIZE(szBuffer), GetResString(IDS_ERR_INVALIDLINK), error);
				LogError(LOG_STATUSBAR, GetResString(IDS_ERR_LINKERROR), szBuffer);
			}
			resToken = strlink.Tokenize(_T("\t\n\r"), curPos);
		}

		//CDlgAddTask::AddNewTask(strlink, cat);
	}
Example #5
0
STDMETHODIMP CTangramNode::get_AxPlugIn(BSTR bstrPlugInName, IDispatch** pVal)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	CString strObjName = OLE2T(bstrPlugInName);
	strObjName.Trim();
	strObjName.MakeLower();
	IDispatch* pDisp = NULL;
	if(m_pRootObj->m_PlugInDispDictionary.Lookup(LPCTSTR(strObjName),(void*&)pDisp))
	{
		* pVal = pDisp;
		(* pVal)->AddRef();
	}
	else
		*pVal = NULL;
	return S_OK;
} 
Example #6
0
File: XUtil.hpp Project: Sumxx/XUI
		XResult Format( CString& path,BOOL slash/*=TRUE*/ )
		{
			path.Trim();
			TCHAR slashes[] = {Slash,Slash,0};
			TCHAR backslashes[] = {BackSlash,BackSlash,0};
			if (slash)
			{
				path.Replace(BackSlash,Slash);
				while (path.Replace(slashes,SlashStr));
			}
			else
			{
				path.Replace(Slash,BackSlash);
				while (path.Replace(backslashes,BackSlashStr));
			}
			return XResult_OK;
		}
CString CCheckForUpdatesDlg::GetWinINetError(DWORD err)
{
	CString readableError = CFormatMessageWrapper(err);
	if (readableError.IsEmpty())
	{
		for (const CString& module : { _T("wininet.dll"), _T("urlmon.dll") })
		{
			LPTSTR buffer;
			FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE, GetModuleHandle(module), err, 0, (LPTSTR)&buffer, 0, nullptr);
			readableError = buffer;
			LocalFree(buffer);
			if (!readableError.IsEmpty())
				break;
		}
	}
	return readableError.Trim();
}
Example #8
0
BOOL ShellRunExe(LPCTSTR lpszPath, LPCTSTR lpszParams, int iShow, HANDLE* phProcess, BOOL bWait, DWORD dwWaitTime)
{
	CString strPath = lpszPath;
	strPath.Trim();

	ASSERT(strPath.GetLength() > 4 && strPath.Right(4).CompareNoCase(EXE_FILE_EXTEND_NAME) == 0);

#ifdef _WIN32_WCE
	if(strPath.GetAt(0) != PATH_SEPARATOR_CHAR)
#else
	if(strPath.GetAt(1) != DISK_SYMBLE_CHAR)
#endif
	{
		CString strCurPath = ExtractModulePath();
		strPath = strCurPath + strPath;
	}

	SHELLEXECUTEINFO info = {0};

	info.cbSize			= sizeof(SHELLEXECUTEINFO);
	info.lpFile			= strPath;
	info.fMask			= SEE_MASK_FLAG_NO_UI;
	info.nShow			= iShow;
	info.lpParameters	= lpszParams;
	
	if(phProcess || bWait)
		info.fMask		|= SEE_MASK_NOCLOSEPROCESS;

	BOOL isOK = FALSE;

	if(::ShellExecuteEx(&info))
	{
		if(phProcess)
			*phProcess = info.hProcess;

		if(bWait)
		{
			isOK = (::WaitForSingleObject(info.hProcess, dwWaitTime) != WAIT_FAILED) ? TRUE : FALSE;
			::CloseHandle(info.hProcess);
		}
		else
			isOK = TRUE;
	}

	return isOK;
}
Example #9
0
CString CPathUtils::ParsePathInString(const CString& Str)
{
	CString sToken;
	int curPos = 0;
	sToken = Str.Tokenize(_T("'\t\r\n"), curPos);
	while (!sToken.IsEmpty())
	{
		if ((sToken.Find('/')>=0)||(sToken.Find('\\')>=0))
		{
			sToken.Trim(_T("'\""));
			return sToken;
		}
		sToken = Str.Tokenize(_T("'\t\r\n"), curPos);
	}
	sToken.Empty();
	return sToken;
}
Example #10
0
CString CHistoryCombo::GetString() const
{
	CString str;
	int sel;
	sel = GetCurSel();
	DWORD style=GetStyle();

	if (sel == CB_ERR ||(m_bURLHistory)||(m_bPathHistory) || (!(style&CBS_SIMPLE)))
	{
		GetWindowText(str);
		if (m_bTrim)
			str.Trim();
		return str;
	}

	return m_arEntries.GetAt(sel);
}
Example #11
0
static inline bool PPBOOL(LPCTSTR path, LPCTSTR section, LPCTSTR field, const bool defvalue)
{
	LPTSTR def = _T("T");
	if(! defvalue) def = _T("F");
	CString value = PPSTR(path, section, field, def);
	value.Trim();
	if(value.IsEmpty()) return false;
	CString lower = value.MakeLower();
	switch(lower[0]){
		case _T('1'):
		case _T('t'):
			return true;
		case _T('o'):
			return lower == _T("on");
	}
	return false;
}
Example #12
0
void CStroeSet::SaveMapping(CString &strList)
{
	strList.Empty();
	CString strTemp = "";
	int iCount = m_List.GetItemCount();
	for ( int i=0;i<iCount;i++)
	{
		strTemp = m_List.GetItemText(i,0);
		strTemp.Trim();
		if ( strTemp != "" )
		{
			strList += strTemp+",";
			strTemp = CStringToIntCString(m_List.GetItemText(i,1));
			strList +=strTemp+";";
		}		
	}
}
CCxStructTreeNode * CIfExpressEditorDlg::FindArryElementNode(const CString & strArrID,const CString & strArryIndex)
{
	CString strTmp = strArryIndex;
	strTmp.Trim();
	if (strTmp.Left(1)!="[")
		return NULL;

	if (strTmp.Right(1)!="]")
		return NULL;

	CCxStructTreeNode *pNodeArryRoot = NULL;
	pNodeArryRoot = theApp.m_pBarJianmoTree->m_wndGridTree.m_StructTree.Find(strArrID);
	if (pNodeArryRoot==NULL)
		return NULL;

	CString strCenterPart = strTmp.Mid(1,strTmp.GetLength()-2); // 数字和分隔符部分
	vector<string> vSplitNum;
	string strTmpStr = strCenterPart;
	string strDelim = ",";
	ZTools::split(strTmpStr,strDelim,&vSplitNum);

	CCxStructTreeNodeParam *pParamNode = reinterpret_cast<CCxStructTreeNodeParam*>(pNodeArryRoot);
	CxArrayND * pArrayND = reinterpret_cast < CxArrayND * > ( pParamNode->m_lpValueData );
	if (pArrayND==NULL)
		return NULL;

	int iDimCount = pArrayND->GetDimCount();
	if (iDimCount!=vSplitNum.size())
		return NULL;

	vector<int> vDim;
	for (int i=0;i<iDimCount;i++)
		vDim.push_back(pArrayND->GetDataCount(i));

	CCxStructTreeNode *pNodeFind = pNodeArryRoot;
	for (size_t i=0;i<vSplitNum.size();i++)
	{
		int iIndex = atoi(vSplitNum[i].c_str());
		if (iIndex >= vDim[i])
			return NULL;

		pNodeFind = pNodeFind->m_vChildren[iIndex];
	}

	return pNodeFind;
}
Example #14
0
void CStaticHyperLink::PositionWindow()
{
	if (!::IsWindow(GetSafeHwnd()) || !m_bAdjustToFit) 
		return;

	CRect WndRect, ClientRect;
	GetWindowRect(WndRect);
	GetClientRect(ClientRect);

	ClientToScreen(ClientRect);

	CWnd* pParent = GetParent();
	if (pParent)
	{
		pParent->ScreenToClient(WndRect);
		pParent->ScreenToClient(ClientRect);
	}

	CString strWndText;
	GetWindowText(strWndText.GetBuffer(MAX_PATH), MAX_PATH);
	strWndText.ReleaseBuffer();
	strWndText.Trim();

	CDC* pDC = GetDC();
	CSize Extent = pDC->GetTextExtent(strWndText, strWndText.GetLength());
	ReleaseDC(pDC);

	Extent.cx += WndRect.Width() - ClientRect.Width();
	Extent.cy += WndRect.Height() - ClientRect.Height(); 

	DWORD dwStyle = GetStyle();
	if (dwStyle & SS_CENTERIMAGE)
		WndRect.DeflateRect(0, (WndRect.Height() - Extent.cy)/2);
	else
		WndRect.bottom = WndRect.top + Extent.cy;

	if (dwStyle & SS_CENTER)   
		WndRect.DeflateRect((WndRect.Width() - Extent.cx)/2, 0);
	else if (dwStyle & SS_RIGHT) 
		WndRect.left  = WndRect.right - Extent.cx;
	else
		WndRect.right = WndRect.left + Extent.cx;

	SetWindowPos(NULL, WndRect.left, WndRect.top, WndRect.Width(), WndRect.Height(), SWP_NOZORDER);
}
Example #15
0
// Extracts a substring from the lpstr string
// Example: to extract the auto-type command, pass "auto-type:" in lpStart
CString ExtractParameterFromString(LPCTSTR lpstr, LPCTSTR lpStart,
	DWORD dwInstance)
{
	CString str;

	ASSERT(lpstr != NULL); if(lpstr == NULL) return str; // _T("")

	CString strSource = lpstr;
	strSource = strSource.MakeLower();
	TCHAR *lp = const_cast<TCHAR *>(lpstr);

	int nPos = -1, nSearchFrom = 0;

	// nPos = strSource.Find(lpStart, 0);
	while(dwInstance != DWORD_MAX)
	{
		nPos = strSource.Find(lpStart, nSearchFrom);

		if(nPos != -1) nSearchFrom = nPos + 1;
		else return str; // _T("")

		--dwInstance;
	}

	if(nPos != -1)
	{
		lp += _tcslen(lpStart);
		lp += nPos;

		while(1)
		{
			const TCHAR tch = *lp;

			if(tch == '\0') break;
			else if(tch == '\n') break;
			else if(tch == '\r') { }
			else str += tch;

			++lp;
		}
	}

	str = str.Trim();
	return str;
}
void CNewGameView::StartServer(bool bPublish)
{
	CString sName = "";
	CIniLoader::GetInstance()->ReadValue("General", "USERNAME", sName);

	BOOL trans;
	UINT nPort = GetDlgItemInt(IDC_SERVERPORT, &trans, FALSE);
	ASSERT(trans && nPort && nPort <= 65535);

	// Server starten
	if (!server.Start(nPort))
	{
		MessageBox(CLoc::GetString("SERVERERROR3"), CLoc::GetString("ERROR"), MB_ICONEXCLAMATION | MB_OK);
		SetCursor(::LoadCursor(NULL, IDC_ARROW));
		return;
	}

	// Client zu 127.0.0.1:nPort verbinden
	if (!client.Connect(INADDR_LOOPBACK, nPort, sName))
	{
		server.Stop();
		MessageBox(CLoc::GetString("SERVERERROR4"), CLoc::GetString("ERROR"), MB_ICONEXCLAMATION | MB_OK);
		SetCursor(::LoadCursor(NULL, IDC_ARROW));
		return;
	}

	// Veröffentlichung starten
	if (bPublish)
	{
		CString strDescription;
		m_description.GetWindowText(strDescription);
		strDescription.Trim();

		if (!serverPublisher.StartPublishing(7777, strDescription, nPort))
		{
			// Vorgang nicht abbrechen, nur Warnhinweis ausgeben
			MessageBox(CLoc::GetString("SERVERERROR5"), CLoc::GetString("WARNING"), MB_ICONWARNING | MB_OK);
		}
	}
	else
		serverPublisher.StopPublishing();

	// Umschalten zur Rassenauswahlansicht
	ShowChooseRaceView(true);
}
DWORD CGridDevListCtrl::GetServiceDisplay(CString serviceName)
{
	serviceName.Trim();
	serviceName.MakeLower();

	if (serviceName.IsEmpty() || serviceName == _T("(none)"))
		return SERVICE_DISPLAY_NODRIVER;

	int serviceCount = sizeof(g_ServiceMap) / sizeof(g_ServiceMap[0]);

	for (int serviceIndex = 0; serviceIndex < serviceCount; serviceIndex++)
	{
		if (serviceName == g_ServiceMap[serviceIndex].ServiceName)
			return g_ServiceMap[serviceIndex].DisplayType;
	}

	return SERVICE_DISPLAY_WARNING;
}
Example #18
0
void CPropPannel::OnEnChangeGiveuser()
{
	CString sGiveUser;
	m_ctlGiveUser.GetWindowText(sGiveUser);
	sGiveUser.Trim();
	if(sGiveUser=="")
	{
		m_ctlGiveCount.EnableWindow(FALSE);
		m_bnGive.EnableWindow(FALSE);
		UpdateData();
	}	
	else
	{
		m_ctlGiveCount.EnableWindow(TRUE);
		m_bnGive.EnableWindow(TRUE);
		OnEnChangeGivecount();
	}
}
Example #19
0
CString
XMLRestriction::CheckBoolean(CString p_value)
{
  p_value.Trim();
  if(!p_value.IsEmpty())
  {
    if(p_value.CompareNoCase("true") &&
       p_value.CompareNoCase("false") &&
       p_value.CompareNoCase("1") &&
       p_value.CompareNoCase("0"))
    {
      CString details("Not a boolean, but: ");
      details += p_value;
      return details;
    }
  }
  return "";
}
Example #20
0
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
void  CPagetestBase::LoadAdPatterns()
{
  TCHAR iniFile[MAX_PATH];
  iniFile[0] = 0;
  GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase), iniFile, _countof(iniFile));
  lstrcpy( PathFindFileName(iniFile), _T("adblock.txt") );

  CString fileName = CString(iniFile);
  HANDLE hFile = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);

  if( hFile != INVALID_HANDLE_VALUE )
  {
	  DWORD len = GetFileSize(hFile,NULL);
	  if( len )
	  {
		  LPBYTE szUrl = (LPBYTE)malloc(len + 1);
		  DWORD read;
		  if( ReadFile(hFile, szUrl, len, &read, 0) )
		  {
			  CString file((const char *)szUrl);
			  free(szUrl);
			  int pos = 0;
			  CString line = file.Tokenize(_T("\r\n"), pos);
			   while( pos >= 0 )
			   {
				   line.Trim();
				   adPatterns.AddTail(line);
				   // on to the next line
				   line = file.Tokenize(_T("\r\n"), pos);
			   }
		  }
		  else
		  {
			  // Free the memory allocated incase the file can't be read.
  			  free(szUrl);
		  }
	  }
	  CloseHandle(hFile);
  }
  else
  {
  	  ATLTRACE(_T("[Pagetest] - *** LoadAdPatterns: Error loading file. %s"), iniFile);
  }
}
Example #21
0
PWSversion::PWSversion()
  : m_nMajor(0), m_nMinor(0), m_nBuild(0), m_bModified(false)
{
  CString csFileVersion = WIDEN(STRFILEVER);
  m_SpecialBuild = SPECIAL_BUILD;

  m_builtOn = CString(__DATE__) + CString(L" ") + CString(__TIME__);

  CString resToken;
  int curPos = 0, index = 0;
  
  // Tokenize the file version to get the values in order
  // Revision is either a number or a number with '+',
  // so we need to get it from the file version string
  // which is of the form "MM, NN, BB, rev"
  resToken = csFileVersion.Tokenize(L",", curPos);
  while (resToken != L"" && curPos != -1) {
    resToken.Trim();
    if (resToken.IsEmpty())
      resToken = L"0";
    
    // Note: if token not numeric, returned value of _wtoi is zero
    switch (index) {
      case 0:
        m_nMajor = _wtoi(resToken);
        break;
      case 1:
        m_nMinor = _wtoi(resToken);
        break;
      case 2:
        m_nBuild = _wtoi(resToken);
        break;
      case 3:
        if (resToken.Right(1) == L"+")
          m_bModified = true;
        m_Revision = resToken;
        break;
      default:
        ASSERT(0);
    }
    index++;
    resToken = csFileVersion.Tokenize(L",", curPos);
  };
}
Example #22
0
void CProcessEnumerator::GetProcessEnum( CArray<CString, CString> * processArray )
{
	DWORD dwProcIds[1024] = {0}, cbNeeded = 0;

	if (EnumProcesses(dwProcIds, sizeof(dwProcIds), &cbNeeded))
	{
		for (int i = 0; i < (int)(cbNeeded / sizeof(DWORD)); i++)
		{
			if (dwProcIds[i] != NULL)
			{
				CString strFileName = _T("");

				HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcIds[i]);

				if (hProcess != NULL)
				{	
					HMODULE hMods[1024] = {0}; DWORD cbNeeded = 0;

					if (EnumProcessModules(hProcess, hMods, sizeof(hMods) / sizeof(DWORD), &cbNeeded))
					{
						if (GetModuleFileNameEx(hProcess, hMods[0], strFileName.GetBuffer(MAX_PATH), MAX_PATH))
						{
							strFileName.ReleaseBuffer(MAX_PATH);
							strFileName.Trim();
							INT nstrLength = strFileName.GetLength() - 1;
							strFileName = strFileName.Right(nstrLength - strFileName.ReverseFind(_T('\\')));

							if (processArray)
							{
								processArray->Add(strFileName);
							}
							else
							{
								ProcessEachName(strFileName);
							}
						}

					}

				} 
			}
		}
	}
}
void CHotGamePanel::OnListPopOpenDir()
{
	if (!AfxGetDbMgr()->GetBoolOpt(OPT_M_BROWSEDIR))
	{
		CString strNotify;
		strNotify.Format(TEXT("对不起,当前设置不允许浏览游戏目录。"));
		AfxMessageBoxEx(strNotify);
		return;
	}	

	size_t nSel = m_lstGame.GetNextItem(-1, LVIS_SELECTED);
	if (nSel == -1 || nSel >= m_GameInfo.size())
		return ;
	tagGameInfo* pGame = m_GameInfo[nSel];

	CString szWorkDir;
	if (pGame->RunType == 2)	//虚拟盘运行的,需要转换路径
	{
		szWorkDir = pGame->SvrPath;
		szWorkDir.Trim();
		tagVDiskInfo* pVDisk = AfxGetDbMgr()->FindVDiskInfo(pGame->VID);
		if (szWorkDir.GetLength() > 3 && pVDisk != NULL)
		{
			szWorkDir.SetAt(0, pVDisk->CliDrv);
		}
	}
	else
	{
		szWorkDir = pGame->CliPath;
	}

	if (szWorkDir.GetLength() && szWorkDir.Right(1) != TEXT("\\"))
		szWorkDir += TEXT("\\");

	if (PathFileExists(szWorkDir))
	{
		ShellExecute(m_hWnd, TEXT("open"), szWorkDir, TEXT(""), TEXT(""), SW_SHOWNORMAL);
	}
	else
	{
		szWorkDir.Insert(0, TEXT("目录不存在:"));
		AfxMessageBoxEx(szWorkDir);
	}
}
Example #24
0
void CPropPannel::OnGetPropInformation(_TAG_USERPROP* userProp)
{
	// 此处是从服务器传来的消息,与本地的数据有可能不一致

	if(userProp->nPropID==curPropID)
	{
		UpdateData();
		m_nHoldCount=userProp->nHoldCount;
		UpdateData(FALSE);
	}

	CBcfFile fMsg(CBcfFile::GetAppPath()+"ClientMessage.bcf");
	//需要修改本地金币
	CMainRoomEx *pWnd=(CMainRoomEx*)pParentWnd;
	CString stip;
	pWnd->m_PlaceUserInfo.i64Bank-=userProp->dwCost;//由ZXD修改
	TCHAR szNum[128];
	GetNumString(szNum, pWnd->m_PlaceUserInfo.i64Bank, Glb().m_nPowerOfGold,Glb().m_bUseSpace, Glb().m_strSpaceChar);
	CString strMessage = fMsg.GetKeyVal("PropPanelDlg","BuyToolsWithCoin","购买道具使用的是您银行中的金币,您现在银行中有 %s 金币。");
	stip.Format(strMessage, szNum);
	//stip.Format("购买道具使用的是您银行中的金币,您现在银行中有 %d 金币。",pWnd->m_PlaceUserInfo.dwBank);
	m_ctlTip.SetWindowText(stip);
	for(int i = 0; i < MAX_GAME_ROOM; i ++)
	{
		if(pWnd->m_RoomInfo[i].pGameRoomWnd != NULL)
		{
			pWnd->m_RoomInfo[i].pGameRoomWnd->PostMessage(WM_USER+151,userProp->dwCost,0);
			pWnd->m_RoomInfo[i].pRoomInfoWnd->PostMessage(WM_USER+151,userProp->dwCost,0);
//			((CGameRoomEx*)pWnd->m_RoomInfo[i].pGameRoomWnd)->InsertSystemMessageWithGame(stip);//
		}
	}
	if(m_nHoldCount>0)
	{
		m_bnUse.EnableWindow(TRUE);
		m_ctlGiveUser.EnableWindow(TRUE);
		CString rString;
		m_ctlGiveUser.GetWindowText(rString);
		if(rString.Trim()!="")
		{
			m_bnGive.EnableWindow(TRUE);
			m_ctlGiveCount.EnableWindow(TRUE);
		}
	}
}
Example #25
0
void CDirectDownloadDlg::OnOK()
{
	CString strLinks;
	GetDlgItem(IDC_ELINK)->GetWindowText(strLinks);

	int curPos = 0;
	CString strTok = strLinks.Tokenize(_T("\t\n\r"), curPos);
	while (!strTok.IsEmpty())
	{
		if (strTok.Right(1) != _T("/"))
			strTok += _T("/");
		try
		{
			CED2KLink* pLink = CED2KLink::CreateLinkFromUrl(strTok.Trim());
			if (pLink)
			{
				if (pLink->GetKind() == CED2KLink::kFile)
				{
					theApp.downloadqueue->AddFileLinkToDownload(pLink->GetFileLink(), 
						(thePrefs.GetCatCount()==0)?0 : m_cattabs.GetCurSel() );
				}
				else
				{
					delete pLink;
					throw CString(_T("bad link"));
				}
				delete pLink;
			}
		}
		catch(CString error)
		{
			TCHAR szBuffer[200];
			_sntprintf(szBuffer, ARRSIZE(szBuffer), GetResString(IDS_ERR_INVALIDLINK), error);
			CString strError;
			strError.Format(GetResString(IDS_ERR_LINKERROR), szBuffer);
			AfxMessageBox(strError);
			return;
		}
		strTok = strLinks.Tokenize(_T("\t\n\r"), curPos);
	}

	CResizableDialog::OnOK();
}
Example #26
0
unsigned int CHTTPSock::GetParamValues(const CString& sName, VCString& vsRet, const map<CString, VCString>& msvsParams, const CString& sFilter) {
	vsRet.clear();

	map<CString, VCString>::const_iterator it = msvsParams.find(sName);

	if (it != msvsParams.end()) {
		for (unsigned int a = 0; a < it->second.size(); a++) {
			CString sParam = it->second[a];
			sParam.Trim();

			for (size_t i = 0; i < sFilter.length(); i++) {
				sParam.Replace(CString(sFilter.at(i)), "");
			}
			vsRet.push_back(sParam);
		}
	}

	return vsRet.size();
}
//
//    GetApplicationName
//    ==================
//
//    Recover the application name from the specified registry key location and pre-parse it to 
//    remove invalid characters
//
CString	CApplicationInstanceList::GetApplicationName (HKEY hKey ,CString& subKeyName ,CString& valueName)
{
	CString applicationName = CReg::GetItemString(hKey, subKeyName, valueName);
	if (applicationName != "")
	{
		// Trim and remove invalid characters
		applicationName.Trim();
		applicationName.Replace("[" ,"");
		applicationName.Replace("]" ,"");
		applicationName.Replace("=" ,"");

		// Special case for Adobe products which can have leading text which will get in the way of
		// the actual product name
		if (applicationName.Left(19) == "Add or Remove Adobe")
			applicationName = applicationName.Mid(19);
	}

	return applicationName;
}
Example #28
0
	EModRet OnRaw(CString& sLine) override {
		//Handle 303 reply if m_Requests is not empty
		if (sLine.Token(1) == "303" && !m_ISONRequests.empty()) {
			VCString::iterator it = m_ISONRequests.begin();

			sLine.Trim();

			// Only append a space if this isn't an empty reply
			if (sLine.Right(1) != ":") {
				sLine += " ";
			}

			//add BNC nicks to the reply
			sLine += *it;
			m_ISONRequests.erase(it);
		}

		return CONTINUE;
	}
Example #29
0
void CPlayerToolBar::SetStatusTimer(CString str , UINT timer )
{
  if(m_timerstr == str) return;

  str.Trim();
  
  if(holdStatStr && !timer){
    m_timerqueryedstr = str;
  }else{
    m_timerstr = str;
    Invalidate();
  }
  if(timer){
    KillTimer(TIMER_STATERASER); 
    holdStatStr = TRUE;
    SetTimer(TIMER_STATERASER, timer , NULL);
  }

}
Example #30
0
// ----------------------------------------------------------------------------
//
bool ColorSelectField::setValue( LPCSTR value ) {
    CString key( value );
    RGBWAArray colors;

    int curPos = 0;
    while ( true ) {
        CString resToken = key.Tokenize( _T(","), curPos );
        if ( resToken.IsEmpty() )
            break;

        resToken.Trim();
        if ( resToken.GetLength() == 0 )
            continue;

        bool found = false;
        RGBWA rgb;
        ULONG value;
        unsigned red, green, blue;

        if ( sscanf_s( resToken, "#%lx", &value ) == 1 ) {
            found = true;
            rgb = RGBWA( value );
        }
        else if ( sscanf_s( resToken, "rgb(%u %u %u)", &red, &green, &blue ) == 3 ) {
            found = true;
            rgb = RGBWA( red, green, blue );
        }
        else 
            found = RGBWA::getColorByName( (LPCSTR)resToken, rgb );

        if ( ! found )
            throw FieldException( "Unknown color value '%s'", (LPCSTR)resToken );

        colors.push_back( rgb );
    }

    if ( colors.size() > 1 && !m_allow_multiple )
        throw FieldException( "Select a single color" );

    m_colors = colors;

    return InputField::setValue( value );
}