Example #1
0
void CStatusLabel::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC dc;
	dc.Attach(lpDrawItemStruct->hDC);
		CString str;
		GetWindowText(str);
		CRect r;
		GetClientRect(&r);
		CFont* old = dc.SelectObject(&m_font);
		dc.SetTextColor(0xffffff);
		dc.SetBkColor(0);
		CSize size = dc.GetTextExtent(str);
		CPoint p = CPoint(m_fRightAlign ? r.Width() - size.cx : 0, (r.Height()-size.cy)/2);

		if(m_fAddEllipses)
		while(size.cx > r.Width()-3 && str.GetLength() > 3)
		{
			str = str.Left(str.GetLength()-4) + _T("...");
			size = dc.GetTextExtent(str);
		}

		dc.TextOut(p.x, p.y, str);
		dc.ExcludeClipRect(CRect(p, size));
		dc.SelectObject(&old);
		dc.FillSolidRect(&r, 0);
	dc.Detach();
}
Example #2
0
void CGLFont::Printfc3d(CString strText,HFONT hFont,float z)
{	HDC hdc = wglGetCurrentDC(); //设备场景
	HFONT hOldFont=(HFONT)::SelectObject(hdc,hFont);//将字体选入场景
	UCHAR * pChar=(UCHAR*)strText.GetBuffer(strText.GetLength());//定义字符串长度
	int   nListNum;                                 //显示列表
	DWORD dwChar;                                   //字符指针
	GLYPHMETRICSFLOAT pgmf[1];                      //轮廓字体字符集的信息
	glPushMatrix();                                 //压入堆栈
	for(int i = 0; i < strText.GetLength(); i++)
	{ if(IsDBCSLeadByte((BYTE)pChar[i]))            //是否双字节(汉字)
		{ dwChar=(DWORD)((pChar[i]<<8)|pChar[i+1]); //取当前字符,双字节转换
		  i++;
		}
	  else	dwChar = pChar[i];                      //取当前字符
	  nListNum = glGenLists(1);                     //创建列表
	  wglUseFontOutlines( hdc,						//拥有字体的HDC
						  dwChar,					//转化为显示列表的第一个字符
						  1,						//转化为显示列表的字符数
						  nListNum,					//显示列表的开始
						  0.0f, 
						  z,						//Z轴负方向的厚度
						  WGL_FONT_POLYGONS,		//绘制字体方式
						  pgmf						//指向存放信息的数组,为count个
						);
	  glCallList(nListNum);                         //绘制显示列表
	  glDeleteLists(nListNum, 1);                   //删除列表
	}	
	glPopMatrix();                                  //弹出堆栈
	strText.ReleaseBuffer();                        //清除字符串
	::SelectObject(hdc,hOldFont);                   //恢复字体
}
Example #3
0
void CCommonAppUtils::SetWindowTitle( HWND hWnd, const CString& urlorpath, const CString& dialogname )
{
#define MAX_PATH_LENGTH 80
    ASSERT(dialogname.GetLength() < MAX_PATH_LENGTH);
    WCHAR pathbuf[MAX_PATH] = {0};
    if (urlorpath.GetLength() >= MAX_PATH)
    {
        std::wstring str = (LPCTSTR)urlorpath;
        std::wregex rx(L"^(\\w+:|(?:\\\\|/+))((?:\\\\|/+)[^\\\\/]+(?:\\\\|/)[^\\\\/]+(?:\\\\|/)).*((?:\\\\|/)[^\\\\/]+(?:\\\\|/)[^\\\\/]+)$");
        std::wstring replacement = L"$1$2...$3";
        std::wstring str2 = std::regex_replace(str, rx, replacement);
        if (str2.size() >= MAX_PATH)
            str2 = str2.substr(0, MAX_PATH-2);
        PathCompactPathEx(pathbuf, str2.c_str(), MAX_PATH_LENGTH-dialogname.GetLength(), 0);
    }
    else
        PathCompactPathEx(pathbuf, urlorpath, MAX_PATH_LENGTH-dialogname.GetLength(), 0);
    CString title;
    switch (DWORD(CRegStdDWORD(L"Software\\TortoiseSVN\\DialogTitles", 0)))
    {
    case 0: // url/path - dialogname - appname
        title  = pathbuf;
        title += L" - " + dialogname + L" - " + CString(MAKEINTRESOURCE(IDS_APPNAME));
        break;
    case 1: // dialogname - url/path - appname
        title = dialogname + L" - " + pathbuf + L" - " + CString(MAKEINTRESOURCE(IDS_APPNAME));
        break;
    }
    SetWindowText(hWnd, title);
}
Example #4
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(); 
} 
Example #5
0
bool CMountPoints::IsMountPoint(CString path)
{
	if (path.GetLength() < 3 || path[1] != _T(':') || path[2] != _T('\\'))
	{
		// Don't know how to make out mount points on UNC paths ###
		return false;
	}

	ASSERT(path.GetLength() >= 3);
	ASSERT(path[1] == _T(':'));
	ASSERT(path[2] == _T('\\'));

	if (!m_va.IsSupported())
		return false;

	if (path.Right(1) != _T('\\'))
		path+= _T("\\");

	path.MakeLower();

	CString volume= m_drive[path[0] - _T('a')];
	path= path.Mid(3);

	return IsVolumeMountPoint(volume, path);
}
Example #6
0
CString GetNextToken(CString& csInput, int& iStartPos)
{
   int iEndPos = -1;

   for (int i=iStartPos; i<csInput.GetLength(); ++i)
   {
      if (csInput[i] == _T('\\'))
         ++i; // ignore next
      else if (csInput[i] == _T(';'))
      {
         iEndPos = i;
         break;
      }
   }

   if (iEndPos == -1) // no ';' found
      iEndPos = csInput.GetLength();

   int iLength = iEndPos - iStartPos;

   CString csReturn(((LPCTSTR)csInput) + iStartPos, iLength);

   for (int i=0; i<csReturn.GetLength(); ++i)
   {
      if (csReturn[i] == _T('\\'))
         csReturn.Delete(i); // loop does continue with the one after the next character
      else if (csReturn[i] == _T(';'))
         break;
   }

   iStartPos = iEndPos + 1;
   return csReturn;
}
Example #7
0
bool CBrowseRefsDlg::PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind)
{
	CString origRef;
	pComboBox->GetLBText(pComboBox->GetCurSel(), origRef);
	CString resultRef = PickRef(false,origRef,pickRef_Kind);
	if(resultRef.IsEmpty())
		return false;
	if(wcsncmp(resultRef,L"refs/",5)==0)
		resultRef = resultRef.Mid(5);
//	if(wcsncmp(resultRef,L"heads/",6)==0)
//		resultRef = resultRef.Mid(6);

	//Find closest match of choice in combobox
	int ixFound = -1;
	int matchLength = 0;
	CString comboRefName;
	for(int i = 0; i < pComboBox->GetCount(); ++i)
	{
		pComboBox->GetLBText(i, comboRefName);
		if(comboRefName.Find(L'/') < 0 && !comboRefName.IsEmpty())
			comboRefName.Insert(0,L"heads/"); // If combo contains single level ref name, it is usualy from 'heads/'
		if(matchLength < comboRefName.GetLength() && resultRef.Right(comboRefName.GetLength()) == comboRefName)
		{
			matchLength = comboRefName.GetLength();
			ixFound = i;
		}
	}
	if(ixFound >= 0)
		pComboBox->SetCurSel(ixFound);
	else
		ASSERT(FALSE);//No match found. So either pickRef_Kind is wrong or the combobox does not contain the ref specified in the picker (which it should unless the repo has changed before creating the CBrowseRef dialog)

	return true;
}
LONG CBenubirdAutoProxy::ConvertToPDF(LPCTSTR files)
{
	OutputDebugString(_T("------------------------------------- convert AutoProxy"));

	AFX_MANAGE_STATE(AfxGetAppModuleState());

	CStringList lFileList;
	CString lFiles = files;
	int lPos;
	CString lFile;

	//a tricky solution: if #part1 is true the #part2 is not executed
	while (((lPos = lFiles.Find(_T("####"))) != -1 /*#Part1*/) || ((lPos = lFiles.GetLength()) /*#Part2*/)) 
	{
		lFile = lFiles.Left(lPos);
		if (!lFile.IsEmpty())
			lFileList.AddTail(lFile);
		lFiles = lFiles.Right(lFiles.GetLength() - lPos - 4);
	}

	CConvertToPDFDlg lConvertToPDFDlg(&lFileList);
	lConvertToPDFDlg.DoModal();

	return 0;
}
Example #9
0
BOOL CNetClient::OnAllVideoTypes()
{
	//CMainFrame *pWnd=(CMainFrame*)AfxGetMainWnd();
	//CTypeManager typeMgr(&pWnd->m_adoConnection);
	CTypeManager typeMgr(&g_pWnd->m_adoConnection);
	CList<CType,CType> lstType;
	typeMgr.GetAllType(&lstType);
	
	CType type;
	CString strData;
    //发送的字符串的格式:"战争片,1,喜剧片,2,古装片,3 "
    for (int i=0;i<lstType.GetCount();i++)
    {
	    type=lstType.GetAt(lstType.FindIndex(i));
		strData+=type.strTypeName;
		strData+=",";
		CString strID;
		strID.Format("%d,",type.nTypeID);
		strData+=strID;
    }

	//首先发送数据长度,然后发送数据
	int nLen=strData.GetLength();
	LPSTR pData=(LPSTR)malloc(nLen+1);
	memset(pData,0,nLen+1);
	strcpy(pData,strData);
	SendData(VODNETCMD_TYPES_RET,pData,strData.GetLength());
	free(pData);
	return TRUE;
}
Example #10
0
CString GetSIPURI(CString str, bool isSimple, bool isLocal)
{
	CString rab = str;
	rab.MakeLower();
	int pos = rab.Find(_T("sip:"));
	if (pos==-1)
	{
		str=_T("sip:")+str;
	}
	if (!isLocal) {
		pos = str.Find(_T("@"));
		if (accountSettings.accountId && pos==-1) {
			str.Append(_T("@")+accountSettings.account.domain);
		}
	}
	if (str.GetAt(str.GetLength()-1)=='>')
	{
		str = str.Left(str.GetLength()-1);
		if (!isSimple) {
			if (!isLocal || !accountSettings.accountId) {
				AddTransportSuffix(str);
			}
		}
		str += _T(">");
	} else {
		if (!isSimple) {
			if (!isLocal || !accountSettings.accountId) {
				AddTransportSuffix(str);
			}
		}
		str = _T("<") + str + _T(">");
	}
	return str;
}
Example #11
0
bool SwapLTALTC(CString &sFilename)
{
	// If it's too short, it's not an option
	if (sFilename.GetLength() < 4)
		return false;

	// Point at the end of the string
	char *pBuffer = sFilename.LockBuffer();
	char *pLastChar = &pBuffer[sFilename.GetLength() - 1];

	bool bResult = true;

	// Make sure it's LT? for the extension
	if ((pLastChar[-3] != '.') ||
		(toupper(pLastChar[-2]) != 'L') ||
		(toupper(pLastChar[-1]) != 'T'))
	{
		bResult = false;
	}
	// Switch it
	else if (toupper(*pLastChar) == 'A')
		*pLastChar = 'C';
	else if (toupper(*pLastChar) == 'C')
		*pLastChar = 'A';
	else
		bResult = false;

	sFilename.UnlockBuffer();
	return bResult;
}
Example #12
0
bool XgnExtDataDlg::IsValidData(int nID)
{
	return true;
#ifdef Client_Xgn
	FileExtendData ext;
	IndicatorInfo data;
	bool b = ext.GetIndicatorInfo( data, nID);
	if(b == false)
		return false;
	CString s = CMainFrame::m_taiShanDoc ->m_strSerial ;
	if(s.IsEmpty ())
		return false;

	CString s2 = "";
	for(int i = 0;i<s.GetLength ();i++)
	{
		if(s[i]>='0' &&s[i]<='9')
			s2+=s[i];
		if(s2.GetLength ()>=7)
			break;
	}

	if(s2.GetLength ()<7)
		for( i = 0;i<s.GetLength ()-7;i++)
		{
			s2+='1';
		}
	if(data .m_nFileID != atoi(s2))
		return false;
#endif
	return true;
}
bool CFormulaParser::VerifyFunctionHeader(CString function_header) {
  // Check correct start of function header 
  // and especially throw warnings on old-style and Shanky-style PPL.
  // Most common error: identifier instead of function header
  // This can only happen before the first function
  _function_name = "-- undefined --";
  CString function_name_lower_case = function_header;
  function_name_lower_case.MakeLower();
  if (function_name_lower_case.Left(6) == "custom") {
    CParseErrors::Error("Superfluous keyword custom.\n"
      "OpenPPL 7.0 is somewhat different than old-style OpenPPL and Shanky-PPL.\n"
      "Please have a look at the manual for all the differences.\n"
      "It really matters!\n");
    return false;
  } else if ((function_name_lower_case.Left(7) == "preflop")
	    || (function_name_lower_case.Left(4) == "flop")
	    || (function_name_lower_case.Left(4) == "turn")
	    || (function_name_lower_case.Left(5) == "river")) {
    CParseErrors::Error("Shanky-style betrounds.\n"
      "OpenHoldem-style function expected.\n"
      "Example: ##f$preflop##\n");
    return false;
  } else if (function_name_lower_case.Left(3) == "new") {
    CParseErrors::Error("Old-style OpenPPL function.\n"
      "OpenHoldem-style ##f$function## expected.\n");
    return false;
  } else if ((function_name_lower_case.Left(2) == "//")
      || (function_name_lower_case.Left(2) == "/*")) {
    CParseErrors::Error("Top-level comment outside function.\n"
      "Technically a formula-file is a set of functions\n"
      "and every comment belongs to such a function.\n"
      "A top-level comment outside of a function would get lost.\n"
      "Please put it for example into \"##notes##\".\n");
    return false;
  } else if (function_name_lower_case.Left(2) != "##") {
    CParseErrors::Error("Shanky-style option settings?\n"
      "Options are not supported, because OpenPPL does not provide a default bot.\n"
      "They need to be removed.\n"
      "Expecting a ##f$function## or ##listXYZ## instead.\n");
    return false;
  }
  // Leading ## found
  if (function_name_lower_case.Right(2) != "##") {
    CParseErrors::Error("Malformed function-header. Trailing ## expected.\n");
    return false;
  }
  // New header verified
  _function_name = function_header;
  // Get rid pf ## at both ends
  int length = _function_name.GetLength();
  assert(length >= 4);
  _function_name = _function_name.Left(length - 2);
  _function_name = _function_name.Right(length - 4);
  if (_function_name.GetLength() <= 0) {
    CParseErrors::Error("Empty function or list name.\n"
      "Expecting a ##f$function## here.\n");
    return false;
  }
  return VerifyFunctionNamingConventions(_function_name);
}
Example #14
0
BOOL RC4::Crypt(CString &data)
{
    int a, b, nSize = data.GetLength();
	TCHAR ch;

    for(int i = 0; i < data.GetLength(); i++ )
    {
		x = ( x + 1 ) & 0xFF; a = m[x];
        y = ( y + a ) & 0xFF;
        m[x] = b = m[y];
        m[y] = a;

        ch = data[i];
        ch ^= m[( a + b ) & 0xFF];
		data.SetAt(i, ch);
    }

	// cover bin data to ASCII string

	TCHAR *pASCII = new TCHAR [nSize * sizeof(TCHAR) * 2 + 1];
    if (!pASCII)
		return FALSE;
	
    for (int l=0;  l < nSize;  l++)
        wsprintf((TCHAR *)&(pASCII)[l*2], "%02X", data[l]);
    
	data = pASCII;
	delete pASCII;
	return TRUE;
}
Example #15
0
bool	CCxImageCtrl::ShowSaveFileDialog()
{
	CFileDialog		saveImageDialog(FALSE,NULL,_T("ScreenCapture"),OFN_EXPLORER|OFN_OVERWRITEPROMPT,_T("Jpg Files (*.jpg)|*.jpg|Bmp Files(*.bmp)|*.bmp|"),this);

	int iRetVal = saveImageDialog.DoModal();
	if(iRetVal==IDOK)

	{
		CString strFileExt = saveImageDialog.GetFileExt();
		CString strFilePath = saveImageDialog.GetPathName();

		if(saveImageDialog.m_ofn.nFilterIndex==1)

		{
			if(strFileExt.GetLength()==0)
				strFilePath	+=	_T(".jpg");
			
			return Save(strFilePath, CXIMAGE_FORMAT_JPG);

		}
		else if(saveImageDialog.m_ofn.nFilterIndex==2)
		{
			if(strFileExt.GetLength()==0)
				strFilePath	+=	_T(".bmp");
			
			return Save(strFilePath, CXIMAGE_FORMAT_BMP);
		}
	}

	return false;
}
Example #16
0
void CSharedDirsTreeCtrl::FilterTreeAddSubDirectories(CDirectoryItem* pDirectory, CStringList& liDirs, int nLevel){
	// just some sanity check against too deep shared dirs
	// shouldnt be needed, but never trust the filesystem or a recursive function ;)
	if (nLevel > 14){
		ASSERT( false );
		return;
	}
	POSITION pos = liDirs.GetHeadPosition();
	CString strDirectoryPath = pDirectory->m_strFullPath;
	strDirectoryPath.MakeLower();
	while (pos){
		CString strCurrent = thePrefs.shareddir_list.GetNext(pos);
		CString strCurrentLow = strCurrent;
		strCurrentLow.MakeLower();
		if ( (strDirectoryPath.IsEmpty() || strCurrentLow.Find(strDirectoryPath + _T("\\"), 0) == 0) && strCurrentLow != strDirectoryPath){
			if (!FilterTreeIsSubDirectory(strCurrentLow, strDirectoryPath, liDirs)){
				CString strName = strCurrent;
				if (strName.Right(1) == "\\"){
					strName = strName.Left(strName.GetLength()-1);
				}
				strName = strName.Right(strName.GetLength() - (strName.ReverseFind('\\')+1));
				CDirectoryItem* pNewItem = new CDirectoryItem(strCurrent);
				pNewItem->m_htItem = InsertItem(TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE, strName, 5, 5, 0, 0, (LPARAM)pNewItem, pDirectory->m_htItem, TVI_LAST);
				pDirectory->liSubDirectories.AddTail(pNewItem);
				FilterTreeAddSubDirectories(pNewItem, liDirs, nLevel+1);
		
			}
		}
	}
}
Example #17
0
BOOL CPPgSecurity::PreTranslateMessage(MSG* pMsg) 
{
	if (pMsg->message == WM_KEYDOWN){

		if (pMsg->wParam == VK_ESCAPE)
			return FALSE;

		if( m_pacIPFilterURL && m_pacIPFilterURL->IsBound() && ((pMsg->wParam == VK_DELETE) && (pMsg->hwnd == GetDlgItem(IDC_UPDATEURL)->m_hWnd) && (GetAsyncKeyState(VK_MENU)<0 || GetAsyncKeyState(VK_CONTROL)<0)) )
			m_pacIPFilterURL->Clear();

		if (pMsg->wParam == VK_RETURN){
			if (pMsg->hwnd == GetDlgItem(IDC_UPDATEURL)->m_hWnd){
				if (m_pacIPFilterURL && m_pacIPFilterURL->IsBound() ){
					CString strText;
					GetDlgItem(IDC_UPDATEURL)->GetWindowText(strText);
					if (!strText.IsEmpty()){
						GetDlgItem(IDC_UPDATEURL)->SetWindowText(_T("")); // this seems to be the only chance to let the dropdown list to disapear
						GetDlgItem(IDC_UPDATEURL)->SetWindowText(strText);
						((CEdit*)GetDlgItem(IDC_UPDATEURL))->SetSel(strText.GetLength(), strText.GetLength());
					}
				}
				return TRUE;
			}
		}
	}
   
	return CPropertyPage::PreTranslateMessage(pMsg);
}
Example #18
0
//抽奖信息的绘制
void CLotteryDlg::_drawLotteryInfo(CDC* pDC)
{
	pDC->SetBkMode(TRANSPARENT);
	CFont* pOldFont = pDC->SelectObject(&m_TitleFont);
	pDC->SetTextColor(RGB(255, 255, 255));
	//绘制标题
	CString str = L"天极传媒.上海2013迎春年会抽奖仪式---lgy";
	str.SetString(m_uiInfo._title.c_str());
	CSize size = pDC->GetTextExtent(str);
	pDC->TextOut(m_ClientRect.CenterPoint().x - size.cx/2, m_ClientRect.top + m_ClientRect.Height() / 8, str, str.GetLength());
	pDC->SelectObject(pOldFont);

	if (m_bRollTimer)
	{
		pDC->SetTextColor(RGB(255,255,0));
		pOldFont = pDC->SelectObject(&m_NormalFont);
		str = L"正在抽取";
		int xPos = m_ClientRect.left + m_leftWidth;
		int yPos = m_ClientRect.bottom - m_ClientRect.Height()/10;

		pDC->TextOut(xPos, yPos - 5, str, str.GetLength());
		xPos += pDC->GetTextExtent(str+L"123").cx;
		pDC->SelectObject(pOldFont);

		pOldFont = pDC->SelectObject(&m_KeyFont);
		str.SetString(m_uiInfo._curClass.c_str());//奖项
		pDC->TextOut(xPos, yPos, str, str.GetLength());

		str.SetString(m_uiInfo._curAward.c_str());//奖品
		str = L"奖品 : " + str;
		pDC->TextOut(m_ClientRect.CenterPoint().x, yPos, str, str.GetLength());
		pDC->SelectObject(pOldFont);
	}

}
Example #19
0
/*
 * CreatePackage(BYTE Type,CString stxt)
 * Creates one package in the buffe. (Se below) 
 *
 * [SizeHeader|Type|...String..\0]
 */
BOOL CIOCPBuffer::CreatePackage(BYTE Type,CString stxt)
{
	UINT nBufLen = stxt.GetLength();	
	if(nBufLen<(MAXIMUMPACKAGESIZE-MINIMUMPACKAGESIZE-1)&&nBufLen>0)
	{
		// Perpare Package. 
		// Empty the Buffer..
		EmptyUsed();
		
		// Add one to the size header for the null termination byte.  
		nBufLen++;

		// Add one to the size header for the Type byte. .  
		nBufLen++;

		// Add The Header
		AddData(nBufLen);
		
		// Add the Type. 
		AddData(Type);
		
		// Add the string. 
		int length=stxt.GetLength();
		AddData((PBYTE) stxt.GetBuffer(length),length);


		// Null Teriminate (for Strings) 
		BYTE nullTerm='\0';
		AddData(nullTerm);
		return TRUE;
	}
	return FALSE;
}
Example #20
0
void CDataPool::OnSaveCommand(const CString& szName, BOOL bSaveRoot/* = FALSE*/)
{
	if( szName.GetLength() == 0 ) return;
	
	CString useName = szName;

	if (bSaveRoot)
	{
		useName = GetRootWindowName(szName);
	}
	CString testXML;
	CEGUI::Window* pWindow = WindowManager::getSingleton().getWindow(useName.GetString());

	//先刷新窗口定义
	GetRightEventList()->UpdateWindowEventDefine();

	WriteXMLHead(testXML, useName);
	WriteXMLContent(testXML,pWindow,"\t");
	WriteXMLEnd(testXML, useName);

	CFileDialog dlg(FALSE, useName, useName, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Layout文件(*.layout.xml)|*.layout.xml||", AfxGetMainWnd());
	if(IDOK == dlg.DoModal())
	{
		//layout文件
		CString szFileName = dlg.GetFileName();
		CString szFullPath = dlg.GetPathName();
		//CString szLayoutXml = szFullPath + "\\" + useName;
		//szLayoutXml += ".layout.xml";
		FILE* pfileb =fopen(szFullPath.GetString() , "w");
		fwrite(testXML.GetString(), testXML.GetLength(),1, pfileb);
		fclose(pfileb);

		//lua文件
		testXML = "";
		szFullPath.Replace(szFileName,"");
		szFileName.Replace(".layout.xml","");
		CString szLua = szFullPath + "\\" + szFileName;
		szLua += ".lua";
		GenLuaText(testXML,useName,szFileName);

		//判断是否存在文件,提示用户
		pfileb = fopen(szLua, "r");
		if (pfileb)
		{
			CString szMsg = "脚本文件:\n";
			szMsg += szLua;
			szMsg += "\n已经存在,是否覆盖??";
			if( MessageBox(NULL, szMsg, "提示", MB_YESNO) == IDNO )
			{
				fclose(pfileb);
				return;
			}
		}
		pfileb = fopen(szLua, "w");
		fwrite(testXML.GetString(), testXML.GetLength(),1, pfileb);
		fclose(pfileb);
	}
	

}
Example #21
0
// unicode hex to char;v_str char[65535]
int ctrmthreaddirecttcp::trmunicodehex2char(CString v_cs,char* v_str)
{
	int t_len=0;
	if(((v_cs.GetLength())%2)==1)
	{
		v_cs=_T("0")+v_cs;
	}
	t_len=v_cs.GetLength();
	WideCharToMultiByte(CP_OEMCP,0,(LPCTSTR)v_cs,-1,v_str,t_len,0,false); 
	for(int v_i=0;v_i<t_len;v_i++)
	{
		if((*(v_str+v_i)>='a')&&(*(v_str+v_i)<='f'))
		{
			*(v_str+v_i)=*(v_str+v_i)-'a'+10;
		}
		else if((*(v_str+v_i)>='0')&&(*(v_str+v_i)<='9'))
		{
			*(v_str+v_i)=*(v_str+v_i)-'0';
		}
		else
		{
			assert(0);
		}
	}
	for(int v_i=0;v_i<(t_len/2);v_i++)
	{
		*(v_str+v_i)=((*(v_str+2*v_i))<<4)+*(v_str+2*v_i+1);
	}
	t_len/=2;
	return t_len;
}
Example #22
0
void AssignSound()
{
  CString strBasePath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
  AddSlash(strBasePath);
  CString strPath = strBasePath;
  strPath += "sound\\";

  CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Sound files (*.wav,*.mp3)|*.wav;*.mp3||", g_pParentWnd);
  dlgFile.m_ofn.lpstrInitialDir = strPath;
  if (dlgFile.DoModal() == IDOK)
  {
	  SendMessage(hwndEnt[EntKeyField], WM_SETTEXT, 0, (LPARAM)"noise");	
    CString str = dlgFile.GetPathName().GetBuffer(0);
    str.MakeLower();
    strBasePath.MakeLower();
    QE_ConvertDOSToUnixName(str.GetBuffer(0), str.GetBuffer(0));
    QE_ConvertDOSToUnixName(strBasePath.GetBuffer(0), strBasePath.GetBuffer(0));
    int n = str.Find(strBasePath);
    if (n == 0)
    {
      str = str.Right(str.GetLength() - strBasePath.GetLength());
    }

	  SendMessage(hwndEnt[EntValueField], WM_SETTEXT, 0, (LPARAM)str.GetBuffer(0));	
    AddProp();
    g_pParentWnd->GetXYWnd()->SetFocus();
  }
}
Example #23
0
int
ODBCStringsMatrix::CutToSmallStrings(char* szString, CStringArray& arrSmallStrings)
	{
	int nLoop	= 0;
	int	nStart	= 0;
	arrSmallStrings.RemoveAll();

	while( szString[nLoop] != '\0' )
		{
		if( szString[nLoop] == ' ' )
			{
			char	cOld	= szString[nLoop];
			szString[nLoop]	= '\0';
			CString sValue	= (LPCTSTR)&szString[nStart];
			szString[nLoop]	= cOld;

			if( sValue.GetLength() )
				arrSmallStrings.Add(sValue);
			nStart			= nLoop + 1;
			}

		nLoop ++;
		}

	CString sValue	= (LPCTSTR)&szString[nStart];
	sValue.Remove(' ');
	if( sValue.GetLength() )
		arrSmallStrings.Add(sValue);

	return (long)arrSmallStrings.GetCount();
	}
Example #24
0
void CDialog2::BuildOutputFileName()
{
	UpdateData(true);
	if( m_input.IsEmpty() )
	{
		m_output = "";
		UpdateData(false);
		return;
	}
	
	CString path= (usedefpath && !m_defpath.IsEmpty()) ? m_defpath : CWindow::GetPath(m_input); 
	CString name= CWindow::GetFileNameNoExt( m_output.IsEmpty() ? m_input : m_output );
	CString ext = CWindow::GetExtName(m_input);
	CString newext = (run_type==DECRYPT) ? "" : (format==MCS) ? "mcs" : "des";
	
	if( path.GetAt( path.GetLength()-1 ) != '\\' )
		path += "\\";
	if( run_type==DECRYPT )
		if( ext.GetLength()>4 && ext.GetAt(ext.GetLength()-4)=='.' )
			ext = ext.Left( ext.GetLength()-4 );
		else
			ext = "";
		
		m_output = path + name;
		if( ext.GetLength() )
			m_output += "." + ext;
		if( newext.GetLength() )
			m_output += "." + newext;
	UpdateData(false);


}
Example #25
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 #26
0
BOOL CDxMaskEdit::CopyToClipboard(const CString& strText)
{
    if (!OpenClipboard(NULL))
        return FALSE;

    ::EmptyClipboard();

    int nLen = (strText.GetLength() + 1) * sizeof(TCHAR);

    HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, nLen);

    if (hglbCopy == NULL)
    {
        ::CloseClipboard();
        return FALSE;
    }

    LPTSTR lptstrCopy = (TCHAR*)GlobalLock(hglbCopy);
    _tcscpy_s(lptstrCopy, strText.GetLength() + 1, (LPCTSTR)strText);
    GlobalUnlock(hglbCopy);

#ifndef _UNICODE
    ::SetClipboardData(CF_TEXT, hglbCopy);
#else
    ::SetClipboardData(CF_UNICODETEXT, hglbCopy);
#endif

    if (!::CloseClipboard())
        return FALSE;

    return TRUE;
}
Example #27
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;
}
Example #28
0
void CKeyboardEdit::DisplayKeyboardString()
{
  CString strKbd;

  // modifiers
  if (m_bCtrlPressed)
    strKbd = "Ctrl";
  if (m_bAltPressed) {
    if (strKbd.GetLength () > 0)
      strKbd += '+';
    strKbd += "Alt";
  }
  if (m_bShiftPressed) {
    if (strKbd.GetLength () > 0)
      strKbd += '+';
    strKbd += "Shift";
  }
  // virtual key
  LPCTSTR szVirtKey = mapVirtKeysStringFromWORD(m_wVirtKey);
  if (szVirtKey != NULL) {
    if (strKbd.GetLength () > 0)
      strKbd += '+';
    strKbd += szVirtKey;
  }
  SetWindowText (strKbd);
}
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 #30
0
CString CTreeFileCtrl::ItemToPath(HTREEITEM hItem)
{
  CString sPath;
  
  //Create the full string of the tree item
  HTREEITEM hParent = hItem;
  while (hParent)
  {
    CString sItem = GetItemText(hParent);
    int nLength = sItem.GetLength();
    ASSERT(nLength);
    hParent = GetParentItem(hParent);

    if (sItem.GetAt(nLength-1) == _T('\\'))
      sPath = sItem + sPath;
    else
    {
      if (sPath.GetLength())
        sPath = sItem + _T('\\') + sPath;
      else
        sPath = sItem;
    }
  }

  //Add the root folder if there is one
  if (m_sRootFolder.GetLength())
    sPath = m_sRootFolder + _T('\\') + sPath;

  return sPath;
}