Example #1
0
void CEditableListCtrl::CommitEditCtrl()
{
	if (m_iEditCol != -1 && m_iEditRow != -1)
	{
		if (m_pctrlEdit && m_pctrlEdit->IsWindowVisible())
		{
			CString strItem;
			m_pctrlEdit->GetWindowText(strItem);
			strItem.TrimLeft();
			strItem.TrimRight();
			SetItemText(m_iEditRow, m_iEditCol, strItem);
//			m_iEditRow = -1;
//			m_iEditCol = -1;
		}
		else if (m_pctrlComboBox && m_pctrlComboBox->IsWindowVisible())
		{
			CString strItem;
			m_pctrlComboBox->GetLBText(m_pctrlComboBox->GetCurSel(), strItem);
			strItem.TrimLeft();
			strItem.TrimRight();
			SetItemText(m_iEditRow, m_iEditCol, strItem);
//			m_iEditRow = -1;
//			m_iEditCol = -1;
		}
	}
}
CConfigurationDBI *CProjectDBI::LookupConfigurationByAddress (const CString &strAddress)
{
    HRESULT hr;
    int iIndex;
    CString str = strAddress;

    hr = Load ();
    if (FAILED (hr))
    {
        throw hr;
    };

    //it is possible that the address passed here contains {} encapsulation.
    str.TrimLeft();
    str.TrimRight();
    str.TrimLeft(_T('{'));
    str.TrimRight(_T('}'));

    for (iIndex = 0; iIndex < m_Configurations.GetSize (); ++iIndex)
    {
        CConfigurationDBI *pConfigurationDBI;

        pConfigurationDBI = m_Configurations[iIndex];
        ASSERT (pConfigurationDBI != NULL);
        if (pConfigurationDBI == NULL)
            continue;

        if (str.CompareNoCase (pConfigurationDBI->GetMachineAddress ()) == 0)
        {
            return (pConfigurationDBI);
        };
    };

    return (NULL);
}
Example #3
0
/**
 * @brief Writes options values from UI to storage.
 */
void PropRegistry::WriteOptions()
{
    CMergeApp *app = static_cast<CMergeApp*>(AfxGetApp());
    CString sDefaultEditor = app->GetDefaultEditor();

    GetOptionsMgr()->SaveOption(OPT_USE_RECYCLE_BIN, m_bUseRecycleBin == TRUE);

    CString sExtEditor = m_strEditorPath;
    sExtEditor.TrimLeft();
    sExtEditor.TrimRight();
    if (sExtEditor.IsEmpty())
        sExtEditor = sDefaultEditor;
    GetOptionsMgr()->SaveOption(OPT_EXT_EDITOR_CMD, sExtEditor);

    CString sFilterPath = m_strUserFilterPath;
    sFilterPath.TrimLeft();
    sFilterPath.TrimRight();
    GetOptionsMgr()->SaveOption(OPT_FILTER_USERPATH, sFilterPath);

    bool useSysTemp = m_tempFolderType == 0;
    GetOptionsMgr()->SaveOption(OPT_USE_SYSTEM_TEMP_PATH, useSysTemp);

    CString tempFolder = m_tempFolder;
    tempFolder.TrimLeft();
    tempFolder.TrimRight();
    GetOptionsMgr()->SaveOption(OPT_CUSTOM_TEMP_PATH, tempFolder);
}
Example #4
0
bool COleDBConnectionProp::ReadProps(const CString strConnectionString)
{
	CString strConnection = strConnectionString;

	CString strToken;
	while( !(strToken = GetNextToken(strConnection,";")).IsEmpty())
	{
		CString strTok	 = GetNextToken(strToken,"=");
		strTok.TrimLeft(); strTok.TrimRight();
		CString strValue = GetNextToken(strToken,"");
		strValue.TrimLeft(); strValue.TrimRight();

		if(strTok.CompareNoCase(m_szDSNEntry) == 0)
			m_strDSN = strValue;
		else
		if(strTok.CompareNoCase(m_szServerNameEntry) == 0)
			m_strServerName = strValue;
		else
		if(strTok.CompareNoCase(m_szLoginNameEntry) == 0)
			m_strLoginName = strValue;
		else
		if(strTok.CompareNoCase(m_szDatabaseNameEntry) == 0)
			m_strDatabaseName = strValue;
		else
		if(strTok.CompareNoCase(m_szPasswordEntry) == 0)
			m_strPassword = strValue;
		else
		if(strTok.CompareNoCase(m_szTableEntry) == 0)
			m_strTableName = strValue;
	}

	return true;
}
Example #5
0
CString CNumSpinCtrl::FormatValue (double val)
{
    CString str;

    if (m_NumDecPlaces == -1) // no precision specified
    {
        str.Format (_T("%g"), val);
        return str;
    }

    CString fstr;

    /// Check which format to use ('e' or 'f')
    bool bExponential;
    fstr.Format (_T("%g"), val);
    if (fstr.Find (_T('e')) != -1)
    {
        fstr.Format (_T("%%.%de"), m_NumDecPlaces);
        bExponential = true;
    }
    else
    {
        fstr.Format (_T("%%.%df"), m_NumDecPlaces);
        bExponential = false;
    }

    /// Output the number with given format
    str.Format (fstr, val);

    /// Check for trailing zeros and remove them
    if (m_bTrimTrailingZeros)
    {
        if (bExponential)
        {
            // separate base and exponent
            CString strBase, strExponent;
            int e_pos = str.Find (_T('e'));
            strBase = str.Left (e_pos);
            strExponent = str.Right (str.GetLength () - e_pos);

            if (str.Find (m_DecSymbol) != -1) {
                strBase.TrimRight (_T('0'));
                strBase.TrimRight (m_DecSymbol); // if dot is all that's left
            }

            str = strBase + strExponent; //reconstruct
        }
        else
        {
            if (str.Find (m_DecSymbol) != -1) {
                str.TrimRight (_T('0'));
                str.TrimRight (m_DecSymbol); // if dot is all that's left
            }
        }
    }

    return str;
}
Example #6
0
CString XgnExtDataDlg::GetCurrentPath()
{
	CString sCurrent = CMainFrame::m_taiShanDoc ->m_CurrentWorkDirectory ;
	sCurrent.TrimRight ("\\");
	sCurrent.TrimRight ("/");
	sCurrent+="\\";
	return sCurrent;

}
BOOL CHMProject::ReadHuaMianList(CStdioFile *pfile)
{
    CString str;
    BOOL bl1,bl2;
    tagHMID hmid;
    tagHMID* phmid;
    int iret;

    //移动读指针到画面段落
    if (SeekSection(pfile,"HuaMian")==FALSE)
        return FALSE;
    try
    {
        //读取下一行字符串
        bl1=pfile->ReadString(str);
        if (!bl1) return FALSE;

        str.TrimLeft();
        str.TrimRight();
        //判断字符串是否是段落名
        bl2=HitTestSectionID(str);
        if (bl2) return FALSE;
        while ((!bl2)&&(bl1))
        {
            //读入画面名称和画面标志
            iret=sscanf(str,"%x=%[^;]33s",&hmid.dwflag,hmid.strHMName);//%[^=]s
            if (iret==2)
            {
                phmid=new tagHMID;
                if (phmid==NULL) return FALSE;
                ZeroMemory(phmid,sizeof(*phmid));
                strcpy(phmid->strHMName,hmid.strHMName);
                phmid->dwflag=hmid.dwflag;
                m_HMIDList.AddTail(phmid);
            }

            //读取下一行字符串
            bl1=pfile->ReadString(str);
            if (!bl1) break;

            str.TrimLeft();
            str.TrimRight();
            //判断字符串是否是段落名
            bl2=HitTestSectionID(str);
            if (bl2) break;
        }
        return TRUE;
    }
    catch(CFileException* e)
    {
        e->Delete();
        return FALSE;
    }

}
// 用于列信息的子函数
void CRecordUpDlg::ListTheInfo()
{
	// 采用时间降序排列,更贴心
	set.m_strSort.Format(_T("upTime desc"));
	if (!set.Open())
		MessageBox(_T("连接数据库时错误"), _T("提示"), MB_OK);
	m_list.DeleteAllItems();
	if(set.IsEOF())
	{
		m_sumNum = 0;
	}
	else
	{
		m_sumNum = 0;
		for(int i=0; !set.IsEOF(); i++,set.MoveNext())
		{
			CString cs;
			set.m_upMark.TrimRight();
			m_list.InsertItem(i, set.m_upMark);

			cs.Format(_T("%d-%d-%d %d:%d:%d"),
				set.m_upTime.GetYear(), set.m_upTime.GetMonth(), set.m_upTime.GetDay(),
				set.m_upTime.GetHour(), set.m_upTime.GetMinute(), set.m_upTime.GetSecond());
			m_list.SetItemText(i, 1, cs);

			set.m_code.TrimRight();
			m_list.SetItemText(i, 2, set.m_code);

			set.m_name.TrimRight();
			m_list.SetItemText(i, 3, set.m_name);

			set.m_specification.TrimRight();
			m_list.SetItemText(i, 4, set.m_specification);

			cs.Format(_T("%.2f"), set.m_upPrice);
			cs.TrimRight();
			m_list.SetItemText(i, 5, cs);

			cs.Format(_T("%d"), set.m_upNum);
			cs.TrimRight();
			m_list.SetItemText(i, 6, cs);

			cs.Format(_T("%d"), set.m_upCounts);
			cs.TrimRight();
			m_list.SetItemText(i, 7, cs);

			set.m_ID.TrimRight();
			m_list.SetItemText(i, 8, set.m_ID);

			m_sumNum++;
		}	
	}
	UpdateData(FALSE);
	set.Close();
}
Example #9
0
BOOL CPreStylePag::DeleteTextStyle(CString strTSName)
{
    CMObject obj, tsobj;
    long     i, nCount;
    CString  strtmp;

    //进行参数检查和初始化
    strTSName.TrimLeft();
    strTSName.TrimRight();
    strTSName.MakeUpper();
    if(strTSName.GetLength() <= 0) return FALSE;

    try
    {
        if(FindAcad() == FALSE)
        {
            return FALSE;
        }
        
        //SETUP-1: 获取ACAD文本样式列表
        obj = EDIBAcad::objAcadDoc.GetPropertyByName(
                                      _T("TextStyles"));
        
        //SETUP-2: 获取样式对象
		nCount = (long)obj.GetPropertyByName(_T("Count"));
		for( i = 0; i < nCount; i++)
		{
			tsobj = obj.Invoke(_T("Item"), 1, &_variant_t(i));
			strtmp = vtos(tsobj.GetPropertyByName(_T("Name")));
			strtmp.TrimLeft();
            strtmp.TrimRight();
			strtmp.MakeUpper();
			if(strtmp == strTSName)
			{
                //删除目标样式
                tsobj.Invoke0(_T("Delete"));
                return TRUE;
			}
		}
    }
	catch (_com_error &e)
	{
		CString strMsg;
		strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description());
		AfxMessageBox(strMsg);
	}
    catch(...)
    {
    }
    return FALSE;
}
Example #10
0
/**
 * Returns the .git-path (if .git is a file, read the repository path and return it)
 * adminDir always ends with "\"
 */
bool GitAdminDir::GetAdminDirPath(const CString &projectTopDir, CString &adminDir) const
{
	if (IsBareRepo(projectTopDir))
	{
		adminDir = projectTopDir;
		adminDir.TrimRight('\\');
		adminDir.Append(_T("\\"));
		return true;
	}

	CString sDotGitPath = projectTopDir + _T("\\") + g_GitAdminDir.GetAdminDirName();
	if (CTGitPath(sDotGitPath).IsDirectory())
	{
		sDotGitPath.TrimRight('\\');
		sDotGitPath.Append(_T("\\"));
		adminDir = sDotGitPath;
		return true;
	}
	else
	{
		FILE *pFile;
		_tfopen_s(&pFile, sDotGitPath, _T("r"));

		if (!pFile)
			return false;

		int size = 65536;
		std::unique_ptr<char[]> buffer(new char[size]);
		int length = (int)fread(buffer.get(), sizeof(char), size, pFile);
		fclose(pFile);
		CStringA gitPathA(buffer.get(), length);
		if (length < 8 || gitPathA.Left(8) != "gitdir: ")
			return false;
		CString gitPath = CUnicodeUtils::GetUnicode(gitPathA.Trim().Mid(8)); // 8 = len("gitdir: ")
		gitPath.Replace('/', '\\');
		gitPath.TrimRight('\\');
		gitPath.Append(_T("\\"));
		if (gitPath.GetLength() > 0 && gitPath[0] == _T('.'))
		{
			gitPath = projectTopDir + _T("\\") + gitPath;
			PathCanonicalize(adminDir.GetBuffer(MAX_PATH), gitPath.GetBuffer());
			adminDir.ReleaseBuffer();
			gitPath.ReleaseBuffer();
			return true;
		}
		adminDir = gitPath;
		return true;
	}
}
Example #11
0
// Reads a field ending with a comma, newline, or at maxlen
// Delimiting character is not appended
// CurPos is incremented to the next field
// Returns FALSE if the current field is blank
int CSVFile::getField (char *str, int maxlen)
{
	int i = 0;

    while (dataLine[curPos] != COMMA && i < maxlen && curPos < lineLength)
        str[i++] = dataLine[curPos++];

    if (dataLine[curPos] != COMMA && i == maxlen)
	{
        str[--i] = NULL;
		skipField (1);
	}
	else
	{
		str[i] = NULL;
		curPos++;
	}

	CString csStr = str;
	csStr.TrimLeft();
	csStr.TrimRight();
	strcpy( str, csStr );

    // returns count of characters in field
    return i;
}
Example #12
0
void CuDlgPropertyPageSqlExpressionInParams::OnButton2Param() 
{
	int nAnswer = IDCANCEL;
	CxDlgPropertySheetSqlExpressionWizard* pParent = (CxDlgPropertySheetSqlExpressionWizard*)GetParent();

	try
	{
		//
		// Select only mode:
		CxDlgPropertySheetSqlWizard sqlWizard (TRUE, this);
		sqlWizard.m_queryInfo = pParent->m_queryInfo;
		if (sqlWizard.DoModal() != IDCANCEL)
		{
			CString strStatement;
			sqlWizard.GetStatement (strStatement);
			strStatement.TrimLeft();
			strStatement.TrimRight();
			if (!strStatement.IsEmpty())
				m_cParam1.ReplaceSel(strStatement, TRUE);
		}
	}
	catch (CMemoryException* e)
	{
		theApp.OutOfMemoryMessage();
		e->Delete();
	}
	catch(...)
	{
		// _T("Cannot initialize the SQL assistant.");
		AfxMessageBox (IDS_MSG_SQL_ASSISTANT, MB_ICONEXCLAMATION|MB_OK);
	}
}
Example #13
0
static int InsertTabs(CString &str, int numTabs, const TCHAR* indent, bool& bracketed)
{
	CString tabs = indent ? indent : _T("");
	for(int i = 0; i < numTabs; i++)
		tabs += _T("\t");

	str.TrimRight();
	str = tabs + str;
	bool sol = true; int line = 0;
	bracketed = false;
	for (int i = 0; i < str.GetLength(); i++)
	{
		if (str[i] == _T('\n') || str[i] == _T('\r'))
		{
			while (i < str.GetLength()-1 && str[++i] == _T('\n'));
			if (i < str.GetLength())
			{
				str.Insert(i, tabs);
				i += tabs.GetLength();
			}
			sol = true;
			continue;
		}
		if (str[i] == _T('(') && sol)
			bracketed = true;
		if (!_istspace(str[i]) && sol)
			line++, sol = false;
	}
	return line;
}
void CBusEventHandlerDlg::OnBnClickedOk()
{
    CButton* pomButton       = NULL;
    CString omStrHandlerName = STR_EMPTY ;
    CString omStrControl     = STR_EMPTY ;
    INT nCheck               = 0;
    BOOL bIsEnable           = TRUE;
    // Get the selected handlers either for deleteting or adding and
    // add the name in the array
    for(int j=0; j<defBUSEV_HANDLER_NUMBER; j++)
    {
        pomButton = (CButton*)GetDlgItem(IDC_CHKB_BUSEV_CONNECT_HANDLER + j);
        if(pomButton != NULL )
        {
            nCheck      = pomButton->GetCheck();
            bIsEnable   = pomButton->IsWindowEnabled();
            pomButton->GetWindowText(omStrControl);
            omStrControl.TrimLeft();
            omStrControl.TrimRight();
            omStrControl.Replace(' ','_');
            omStrControl.Replace('-','_');
            omStrHandlerName = omStrControl;
            if(nCheck == 1 && bIsEnable != 0 )
            {
                m_omStrArrayBusEventHandler.Add(omStrHandlerName);
            }
        }
    }
    OnOK();
}
Example #15
0
/**
 * Returns the .git-path (if .git is a file, read the repository path and return it)
 * adminDir always ends with "\"
 */
bool GitAdminDir::GetAdminDirPath(const CString& projectTopDir, CString& adminDir, bool* isWorktree)
{
	CString wtAdminDir;
	if (!GetWorktreeAdminDirPath(projectTopDir, wtAdminDir))
		return false;

	CString pathToCommonDir = wtAdminDir + L"commondir";
	if (!PathFileExists(pathToCommonDir))
	{
		adminDir = wtAdminDir;
		if (isWorktree)
			*isWorktree = false;
		return true;
	}

	CAutoFILE pFile = _wfsopen(pathToCommonDir, L"rb", SH_DENYWR);
	if (!pFile)
		return false;

	int size = 65536;
	CStringA commonDirA;
	int length = (int)fread(commonDirA.GetBufferSetLength(size), sizeof(char), size, pFile);
	commonDirA.ReleaseBuffer(length);
	CString commonDir = CUnicodeUtils::GetUnicode(commonDirA);
	commonDir.TrimRight(L"\r\n");
	commonDir.Replace(L'/', L'\\');
	if (PathIsRelative(commonDir))
		adminDir = CPathUtils::BuildPathWithPathDelimiter(wtAdminDir + commonDir);
	else
		adminDir = CPathUtils::BuildPathWithPathDelimiter(commonDir);
	if (isWorktree)
		*isWorktree = true;
	return true;
}
Example #16
0
void CGroupingDlg::OnAdd() 
{
	CString strValue;
	m_wndGroup.GetWindowText( strValue );
	
	strValue.TrimLeft(); strValue.TrimRight();
	if ( strValue.IsEmpty() ) return;
	
	if ( ! m_pXML ) m_pXML = new CXMLElement;
	
	if ( m_wndGroup.FindStringExact( -1, strValue ) == CB_ERR ) CreateGroup( strValue, m_pXML );
	
	int nItem = m_wndList.InsertItem( LVIF_TEXT|LVIF_PARAM,
		m_wndList.GetItemCount(), NULL, 0, 0, 0, NULL );
	
	for ( int nDeselect = m_wndList.GetNextItem( -1, LVNI_SELECTED ) ;
		nDeselect != -1 ; nDeselect = m_wndList.GetNextItem( nDeselect, LVNI_SELECTED ) )
	{
		m_wndList.SetItemState( nDeselect, 0, LVIS_SELECTED );
	}
	
	m_wndList.SetItemState( nItem, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED );
	m_wndList.EnsureVisible( nItem, TRUE );
	
	m_pHitInfo.iItem	= nItem;
	m_pHitInfo.iSubItem	= 0;
	
	m_wndList.SetFocus();
	m_wndList.EditLabel( nItem );
}
Example #17
0
BOOL RenameDir(LPCTSTR pszSrc, LPCTSTR pszDest, BOOL bClearDestDir)
{
	if(bClearDestDir && ::FileExists(pszDest)) 
		RemoveAllDir(pszDest);

#ifndef _WIN32_WCE
	BOOL bRet = (_trename(pszSrc, pszDest) == NO_ERROR) ? TRUE : FALSE;
#else
	BOOL bRet = FHRenameFile(pszSrc, pszDest, TRUE);
#endif

	if(!bRet)
	{
		if(!::FileExists(pszDest))
			bRet = FHMoveFile(pszSrc, pszDest);
		else
		{
			CString strSrc = pszSrc;
			strSrc.TrimRight(_T("\\/ "));
			strSrc += _T("\\*.*");
			bRet = FHMoveFile(strSrc, pszDest);
			if(bRet)
				FHDeleteFile(pszSrc);
		}
	}

	if(!bRet)
		bRet = CycleRenameDir(pszSrc, pszDest);

	return bRet;
}
Example #18
0
void textelite_get(CString& cszText)
{
   std::string str(g_vecPrintfText.begin(), g_vecPrintfText.end());
   cszText = str.c_str();
   cszText.TrimLeft(_T("\r\n"));
   cszText.TrimRight();
}
Example #19
0
void CMediaFormats::GetFilter(CString& filter, CAtlArray<CString>& mask) const
{
    CString strTemp;

    filter += ResStr(IDS_AG_MEDIAFILES);
    mask.Add(_T(""));

    for (size_t i = 0; i < GetCount(); i++) {
        strTemp = GetAt(i).GetFilter() + _T(";");
        mask[0] += strTemp;
        filter  += strTemp;
    }
    mask[0].TrimRight(_T(';'));
    filter.TrimRight(_T(';'));
    filter += _T("|");

    for (size_t i = 0; i < GetCount(); i++) {
        const CMediaFormatCategory& mfc = GetAt(i);
        filter += mfc.GetDescription() + _T("|" + GetAt(i).GetFilter() + _T("|"));
        mask.Add(mfc.GetFilter());
    }

    filter += ResStr(IDS_AG_ALLFILES);
    mask.Add(_T("*.*"));

    filter += _T("|");
}
Example #20
0
void CMediaFormats::GetAudioFilter(CString& filter, CAtlArray<CString>& mask) const
{
    CString strTemp;

    filter += ResStr(IDS_AG_AUDIOFILES);
    mask.Add(_T(""));

    for (size_t i = 0; i < GetCount(); i++) {
        const CMediaFormatCategory& mfc = GetAt(i);
        if (!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) {
            continue;
        }
        strTemp  = GetAt(i).GetFilter() + _T(";");
        mask[0] += strTemp;
        filter  += strTemp;
    }

    mask[0].TrimRight(_T(';'));
    filter.TrimRight(_T(';'));
    filter += _T("|");

    for (size_t i = 0; i < GetCount(); i++) {
        const CMediaFormatCategory& mfc = GetAt(i);
        if (!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) {
            continue;
        }
        filter += mfc.GetDescription() + _T("|") + GetAt(i).GetFilter() + _T("|");
        mask.Add(mfc.GetFilter());
    }

    filter += ResStr(IDS_AG_ALLFILES);
    mask.Add(_T("*.*"));

    filter += _T("|");
}
Example #21
0
BOOL CListCtrlEx::OnToolTipText(UINT /*uID*/, NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/)
{
    BOOL bRet = TRUE;
#ifdef _TOOL_TIP_ENABLE
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
    TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
    UINT nID = pNMHDR->idFrom;
    if(!nID)
    	bRet = FALSE;

	if(bRet)
	{
		int nRow = ((nID-1) >> 10) & 0x3fffff ;
		int nCol = (nID-1) & 0x3ff;
		CString strTipText = GetItemText(nRow, nCol);
		strTipText.TrimRight();
		strTipText.TrimLeft();
#ifndef _UNICODE
		if (pNMHDR->code == TTN_NEEDTEXTA)
			lstrcpyn(pTTTA->szText, strTipText, 80);
		else
			_mbstowcsz(pTTTW->szText, strTipText, 80);
#else
		if(pNMHDR->code == TTN_NEEDTEXTA)
			_wcstombsz(pTTTA->szText, strTipText, 80);
		else
			lstrcpyn(pTTTW->szText, strTipText, 80);
#endif
	}
    
	*pResult = 0;
#endif

    return bRet;
}
BOOL CVersionChecker::UndertakeRequest(CString& strPost)
{
	m_pRequest.SetURL( _T("http://update.trillinux.org/version/beta.php?") + strPost );
	//Remember to set the update server for final releases.
	
	if ( ! m_pRequest.Execute( FALSE ) ) return FALSE;
	
	int nStatusCode = m_pRequest.GetStatusCode();
	if ( nStatusCode < 200 || nStatusCode > 299 ) return FALSE;
	
	CString strResponse = m_pRequest.GetResponseString();
	CString strHack = theApp.GetProfileString( _T("VersionCheck"), _T("TestResponse"), _T("") );
	if ( strHack.GetLength() ) strResponse = strHack;
	
	for ( strResponse += '&' ; strResponse.GetLength() ; )
	{
		CString strItem	= strResponse.SpanExcluding( _T("&") );
		strResponse		= strResponse.Mid( strItem.GetLength() + 1 );
		
		CString strKey = strItem.SpanExcluding( _T("=") );
		if ( strKey.GetLength() == strItem.GetLength() ) continue;
		strItem = CTransfer::URLDecode( strItem.Mid( strKey.GetLength() + 1 ) );

		strItem.TrimLeft();
		strItem.TrimRight();
		
		m_pResponse.SetAt( strKey, strItem );
	}
	
	return TRUE;
}
void CGroupSelectDlg::OnUpdate() 
{
	// TODO: Add your control notification handler code here
	int item;
	int i = m_list.GetSelectedCount();
	if(i>0)
	{
		POSITION pos = m_list.GetFirstSelectedItemPosition();
		item = m_list.GetNextSelectedItem(pos);
	}
	else
		return;
	
	CGroupUrlDlg dlg;
	dlg.m_strName = m_list.GetItemText(item, 0);
	dlg.m_strUrl = m_list.GetItemText(item,1);
	dlg.m_bState = m_list.GetCheck(item);
	dlg.m_dwProperty = m_list.GetItemData(item);
	if(dlg.DoModal() == IDOK)
	{
		CString str = dlg.m_strName;
		str.TrimLeft();
		str.TrimRight();
		if(str.IsEmpty())
			GetUnqBlankName(str);
		m_list.SetItemText(item, 0, str);
		dlg.m_strUrl.TrimLeft();
		m_list.SetItemText(item, 1, dlg.m_strUrl);
		m_list.SetCheck(item, dlg.m_bState);
		m_list.SetItemData(item,dlg.m_dwProperty);
	}	
}
Example #24
0
void CPreStylePag::QueryAcadTextStyleCombo()
{
    //查询ACAD中已有的可用的文字样式
    CMObject obj, sobj;
    CString  strStyleName;
    CComboBox *lpStyle;
    long i, nCount;
	try
	{
        lpStyle = (CComboBox *)GetDlgItem(IDC_COMBO_STYLE);
        obj = EDIBAcad::objAcadDoc.GetPropertyByName(_T("TextStyles"));
		nCount =(long)obj.GetPropertyByName(_T("Count"));

		for(i = 0; i < nCount; i++)
		{
			sobj = obj.Invoke(_T("Item"), 1, &_variant_t(i));
			strStyleName = vtos(sobj.GetPropertyByName(_T("Name")));
			strStyleName.TrimLeft();
            strStyleName.TrimRight();
            if(strStyleName.GetLength() <= 0) continue;

            lpStyle->AddString(strStyleName);
		}
	}
	catch (_com_error &e)
	{
		CString strMsg;
		strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description());
		AfxMessageBox(strMsg);
	}
	catch(...)
	{
	}
}
Example #25
0
int CuDlgMain::GetInstallationParam(int nSchema)
{
	int nInstallation = -1;
	CRect r1, r2, re;
	CComboBoxEx* pComboDatabase = (nSchema == 1)? &m_cComboDatabase1: &m_cComboDatabase2;
	CEdit*       pEditFile  = (nSchema == 1)? &m_cEditFile1: &m_cEditFile2;
	if (pEditFile->IsWindowVisible())
	{
		CString strFile;
		pEditFile->GetWindowText(strFile);
		strFile.TrimLeft();
		strFile.TrimRight();
		if (strFile.IsEmpty())
			return -1;
		if (_taccess(strFile, 0) == -1)
			return -1;
		nInstallation = IsInstallationFile(strFile);
	}
	else
	{
		int nSel = pComboDatabase->GetCurSel();
		if (nSel != CB_ERR)
		{
			CaDatabase* pDatabase = (CaDatabase*)pComboDatabase->GetItemDataPtr(nSel);
			if (pDatabase)
			{
				CString strDb = pDatabase->GetItem();
				nInstallation = strDb.IsEmpty()? 1: 0;
			}
		}
	}
	return nInstallation;
}
void CCeWatchDlg::OnPasteItems ()
{
    if (m_bHistoryFocus)
    {
        m_HistoryListCtrl.Paste();
        return;
    }

    HGLOBAL memoryHandle;
    LPCTSTR memoryBlock;
    CString strNames;

    if (!::OpenClipboard (m_hWnd))
        return;

    memoryHandle = ::GetClipboardData (CF_TEXT);
    if (memoryHandle == NULL)
    {
        ::CloseClipboard ();
        return;
    };

    memoryBlock = (LPCTSTR)::GlobalLock (memoryHandle);
    if (memoryBlock == NULL)
    {
        ::CloseClipboard ();
        return;
    };

    strNames = memoryBlock;

    ::GlobalUnlock (memoryHandle);
    ::CloseClipboard ();

    while (!strNames.IsEmpty ())
    {
        int iPos;
        CString strName;
        CCeWatchElement *pInsertedElement=NULL;

        iPos = strNames.Find (_T ('\n'));
        if (iPos == -1)
        {
            strName = strNames;
            strNames = _T ("");
        }
        else
        {
            strName = strNames.Left (iPos);
            strNames = strNames.Mid (iPos + 1);
        };

        strName.TrimLeft ();
        strName.TrimRight ();

        if (!strName.IsEmpty ())
            m_VarList.InsertExpressionWithStructInfo(strName, pInsertedElement);
    };
}
void CCalendarDlg2::SetTextForDay(SYSTEMTIME* sysTime)
{
    static BOOL bFirst=1;
    static CString sDovesok;
    static COleDateTime dtCurrent;
    if(!bFirst && dtCurrent.GetStatus()!=COleDateTime::invalid) {
        CString sThisDayNKey=Format(sKey,dtCurrent.GetDay(),dtCurrent.GetMonth(),dtCurrent.GetYear());
        CString sCurDay;
        m_eText.GetWindowText(sCurDay);
        sCurDay.TrimLeft();
        sCurDay.TrimRight();
        if(sCurDay!="") {
            sCurDay.Replace("\r\n","\n");
            if(sDovesok!="") {
                sCurDay+=Format("[?CDATA{%s}?DATAC:)]",sDovesok);
            }
            if(!bINewLine) {
                sCurDay.Replace("\n","<br>");
            }
            CString sContent=CString("\n")+sCurDay+"\n";
            while(sContent!="") {
                CString sLine=sContent.SpanExcluding("\n");
                if(sLine!="") {
                    aItems.Add(sThisDayNKey+sLine);
                    if(sContent.GetLength()>sLine.GetLength()) {
                        sContent=sContent.Mid(sLine.GetLength()+1);
                    } else {
                        sContent="";
                    }
                }
                sContent.TrimLeft();
            }
        }
        sDovesok="";
    }
    bFirst=0;
    if(sysTime) {
        COleDateTime dtTime=COleDateTime(sysTime->wYear,sysTime->wMonth,sysTime->wDay,0,0,0);
        char szTmp[256]= {0};
        GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,sysTime,0,szTmp,sizeof(szTmp));
        GetDlgItem(IDC_STATIC3)->SetWindowText(Format("%s: %s",_l("Current date"),szTmp));
        CString sThisDayNKey=Format(sKey,dtTime.GetDay(),dtTime.GetMonth(),dtTime.GetYear());
        dtCurrent=dtTime;
        CString sDayNote;
        for(int i=aItems.GetSize()-1; i>=0; i--) {
            if(aItems[i].Find(sThisDayNKey)==0) {
                if(sDayNote!="") {
                    sDayNote+="\r\n";
                }
                sDayNote+=aItems[i].Mid(sThisDayNKey.GetLength());
                aItems.RemoveAt(i);
            }
        }
        sDovesok=CDataXMLSaver::GetInstringPart("[?CDATA{","}?DATAC:)]",sDayNote);
        sDayNote.Replace(Format("[?CDATA{%s}?DATAC:)]",sDovesok),"");
        sDayNote.Replace("<br>","\r\n");
        m_eText.SetWindowText(sDayNote);
    }
}
Example #28
0
BOOL COutWnd::bAddString(CStringArray& omStrArray)
{
    BOOL bReturn     = TRUE;
    INT  nTotalCount = (COMMANINT)omStrArray.GetSize();
    INT  nReturnAdd  = 0;
    //   vResetContent();
    MDIActivate();
    omStrArray.Add(" ");
    INT nCount; //nCount declared outside
    for( nCount=0; nCount<nTotalCount; nCount++)
    {
        nReturnAdd = m_omListBox.AddString(omStrArray.GetAt(nCount));
        if(nReturnAdd<0)
        {
            bReturn = FALSE;
        }
    }
    // Set horizontal extent of the list box to max string availaable
    // so that user can scroll
    CSize   sz(0,0);
    CString omStrText   = "";
    CDC*  pDC = m_omListBox.GetDC();
    //Check for valid dc and then set the horizontal extent
    if( pDC != nullptr)
    {
        TEXTMETRIC   tm;
        pDC->GetTextMetrics(&tm);

        //Select the new font object to calculte the extent
        //because font is set for window not for CDC
        CFont* pOldFont = pDC->SelectObject(&m_omNewFont);
        INT nTotalItem =  m_omListBox.GetCount();
        INT nDx = 0;
        for (nCount = 0; nCount < nTotalItem; nCount++)
        {
            m_omListBox.GetText( nCount, omStrText );
            // remove space
            omStrText.TrimRight();
            sz = pDC->GetTextExtent(omStrText);
            //Add avg char width for avoiding any wrapping up
            sz.cx += tm.tmAveCharWidth;
            if (sz.cx > nDx)
            {
                nDx = sz.cx;
            }
        }
        //release the new font
        pDC->SelectObject(pOldFont);
        m_omListBox.ReleaseDC(pDC);
        // Set the horizontal extent so every character of all strings
        // can be scrolled to.
        m_omListBox.SetHorizontalExtent(nDx);
    }
    else
    {
        bReturn = FALSE;
    }
    return bReturn;
}
Example #29
0
void CFilePath::Trim(CString &sString)
{
    if (_istspace(GetFirstChar(sString)))
        sString.TrimLeft();

    if (_istspace(GetLastChar(sString)))
        sString.TrimRight();
}
Example #30
0
void CTGitPath::SetBackslashPath(const CString& sPath) const
{
	CString path = sPath;
	path.Replace('/', '\\');
	path.TrimRight('\\');
	SanitizeRootPath(path, false);
	m_sBackslashPath = path;
}