本文整理汇总了C++中CString::SetString方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::SetString方法的具体用法?C++ CString::SetString怎么用?C++ CString::SetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::SetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCreate
int ControllerProperty::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (BaseProperty::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
DebuggingProcessProp * process = (DebuggingProcessProp *)this->target;
CString strMode;
if (process->traceMode == DebuggingProcessProp::MODE_TRACE_GRAPH)
strMode.SetString(L"display data");
else
strMode.SetString(L"raw data");
CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("Trace Type"), strMode.GetBuffer(), _T("Specifies the trace type of the track bar"));
pProp->AddOption(_T("display data"));
pProp->AddOption(_T("raw data"));
pProp->AllowEdit(FALSE);
this->AddProperty(pProp);
//pProp = new CMFCPropertyGridProperty( _T("Threshold"), (_variant_t) process->threshold, _T("Specifies the threshold for the channel circular buffer"));
//this->AddProperty(pProp);
return 0;
}
示例2: _drawLotteryInfo
//抽奖信息的绘制
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);
}
}
示例3: _readTheRandPartnerPic
void CLotteryDlg::_readTheRandPartnerPic()
{
CString strFilePath;
CPaintDC hDC(this);
m_PicWidth = 0;
m_PicHeight = 0;
int index = 0;
//一次读取生成的随机数对应的编号中的字符串
for (std::set<size_t>::iterator iter = m_RandNo.begin(); iter != m_RandNo.end(); ++iter)
{
strFilePath.SetString(m_PartnerPicPath[*iter].c_str());//设置读取的文件路径中的字符串
if (!_loadPic(strFilePath, &m_PartnerPicInfo[index]))
{
AfxMessageBox(_T("加载图片:") + strFilePath + _T("出错"));
continue;
}
m_PartnerPicInfo[index]._width = MulDiv(m_PartnerPicInfo[index]._cx, GetDeviceCaps(hDC, LOGPIXELSX), 2540);
m_PartnerPicInfo[index]._height = MulDiv(m_PartnerPicInfo[index]._cy, GetDeviceCaps(hDC, LOGPIXELSY), 2540);
m_PicWidth += m_PartnerPicInfo[index]._width;
if (m_PicHeight < m_PartnerPicInfo[index]._height)
m_PicHeight = m_PartnerPicInfo[index]._height;
index++;
}
m_PicWidth /= sizeof(m_PartnerPicInfo)/sizeof(m_PartnerPicInfo[0]);
_calcMargin();
}
示例4: _CheckDiskFreeSpace
BOOL CVulEngine::_CheckDiskFreeSpace()
{
CString strDisk = _T("C:\\");
TCHAR szPath[MAX_PATH+1] = {0};
if( SHGetSpecialFolderPath(NULL, szPath, CSIDL_WINDOWS, FALSE) )
{
strDisk.SetString(szPath, 3);
}
ULARGE_INTEGER lpuse = {0};
ULARGE_INTEGER lptotal = {0};
ULARGE_INTEGER lpfree = {0};
GetDiskFreeSpaceEx(strDisk,&lpuse,&lptotal,&lpfree);
const int MEGA = 1024 * 1024;
const int SPACE_LIMIT = MEGA * 100;
if(lpfree.QuadPart<SPACE_LIMIT)
{
LPCTSTR szBtnClean = BkString::Get(IDS_VULFIX_5000);
LPCTSTR szBtnCancel = BkString::Get(IDS_MSGBOX_CANCEL);
LPCTSTR szMsgPrompt = BkString::Get(IDS_VULFIX_5001);
CBkSafeMsgBox dlg;
dlg.AddButton( szBtnClean, IDYES);
dlg.AddButton( szBtnCancel, IDCANCEL);
UINT nRet = dlg.ShowMsg(szMsgPrompt, NULL, MB_BK_CUSTOM_BUTTON|MB_ICONQUESTION, NULL);
if(nRet==IDYES)
{
// C:\WINDOWS\\system32\\cleanmgr.exe
LPCTSTR szCmd = _T("cleanmgr.exe");
::ShellExecute(NULL,_T("open"), szCmd, NULL, NULL, SW_SHOW);
return FALSE;
}
}
return TRUE;
}
示例5: RemoveLine
void CAddTaskLinksEdit::RemoveLine(LPCTSTR lpszText)
{
if (NULL == lpszText
|| lpszText[0] == _T('\0'))
return;
CString strOldText;
GetWindowText(strOldText);
CONST TCHAR * pszURL = strOldText;
CString url;
CString result = _T("");
INT len = _tcslen(pszURL), i = 0, j = 0;
for(i = 0, j = _tcscspn(pszURL + i, _T("\r\n")); i < len; i += j + 1, j = _tcscspn(pszURL + i, _T("\r\n")))
{
if(j > 10)
{
url.SetString(pszURL + i, j);
url = url.Trim();
if(url != _T("") && url != lpszText)
result = result + url + _T("\r\n");
}
}
SetWindowText(result);
}
示例6: _TransOfficeDir
BOOL _TransOfficeDir( LPCTSTR lpszSpecialFolder, CString& strPath )
{
LPCTSTR szDot = _tcschr(lpszSpecialFolder, _T('.'));
if(!szDot) return FALSE;
++szDot;
INT nOfficeVersion = _tcstol(szDot, NULL, 10);
for(int i=0; i<sizeof(_office_versions)/sizeof(_office_versions[0]); ++i)
{
if(nOfficeVersion!=_office_versions[i].nVerPub)
continue;
int nVerInternal = _office_versions[i].nVerInternal;
///> 检测是否针对visio的特殊路径
CString strSpecialFolder = lpszSpecialFolder;
strSpecialFolder.MakeLower();
if ( -1 != strSpecialFolder.Find( _T("visio") ) )
{
return _TransVisioDir( nVerInternal, strPath );
}
CString strSubKey;
CString strName;
strName.SetString(lpszSpecialFolder, (int)(szDot-lpszSpecialFolder-1));
strSubKey.Format(_T("SOFTWARE\\Microsoft\\Office\\%d.0\\Common\\InstallRoot"), nVerInternal);
return ReadRegString(HKEY_LOCAL_MACHINE, strSubKey, _T("Path"), strPath);
}
return FALSE;
}
示例7: SplitDownloadUrl
// 分析出下载的 hostname, query path, 以及下载的文件名
BOOL SplitDownloadUrl( LPCTSTR szUrl, CString &strHostname, CString &strPath, CString &strFilename )
{
static LPCTSTR strProtocolHttp = _T("http://");
static LPCTSTR strProtocolHttps = _T("https://");
LPCTSTR p = NULL;
if( _tcsnicmp(szUrl, strProtocolHttp, _tcslen(strProtocolHttp))==0 )
p = szUrl + _tcslen( strProtocolHttp );
else if( _tcsnicmp(szUrl, strProtocolHttps, _tcslen(strProtocolHttps))==0 )
p = szUrl + _tcslen( strProtocolHttps );
if(p)
{
LPCTSTR pslash = _tcschr(p, _T('/'));
if( pslash )
{
LPCTSTR pslashRight = _tcsrchr(pslash, _T('/') );
if(pslashRight)
{
strHostname.SetString( p, (int)(pslash-p) );
strPath = pslash;
strFilename = pslashRight+1;
return TRUE;
}
}
}
return FALSE;
}
示例8:
/*static*/ void CRtsSettingsWizDlg::UpdateScrlToolTip(CWnd* pParentWnd, CToolTipCtrl* pToolTips, UINT idFrom)
{
// Grab the string with that res ID
CString csTip;
if (! pToolTips) return;
// If the string resource DNE
if (! csTip.LoadString(idFrom))
{
csTip.SetString(_T(""));
}
else
{
// Remove up to first new line
int iOffset = csTip.Find(_T("\n"));
if (iOffset < 0)
{
csTip.SetString(_T(""));
}
else
{
iOffset = csTip.GetLength() - (iOffset + 1);
csTip.SetString( csTip.Right(iOffset) );
// Remove after second new line
iOffset = csTip.Find(_T("\n"));
if (iOffset >= 0)
{
csTip.SetString( csTip.Left(iOffset) );
}
}
}
// Now add in the current value
char cCurValue[500];
_itot(((CSliderCtrl*)pParentWnd->GetDlgItem(idFrom))->GetPos(), cCurValue, 10);
csTip += _T(" (");
csTip += cCurValue;
csTip += _T(")");
// Now insert the new text
pToolTips->UpdateTipText(csTip, pParentWnd->GetDlgItem(idFrom));
pToolTips->Update();
}
示例9: FindSubCommand
CString CSZCommandLine::FindSubCommand(LPCTSTR lpszCmdLine, LPCWSTR* lppszSubCmdLine)
{
if (lppszSubCmdLine)
*lppszSubCmdLine = lpszCmdLine;
if (!lpszCmdLine)
return _T("");
// trim white space
while (*lpszCmdLine)
{
if (!IsWhiteSpace(*lpszCmdLine))
break;
++lpszCmdLine;
}
// find first word
LPCWSTR lpNextWord = lpszCmdLine;
while (*lpNextWord)
{
if (!IsAlpha(*lpNextWord))
break;
++lpNextWord;
}
// no word
if (lpNextWord == lpszCmdLine)
return _T("");
// get subcommand
CString strSubCommand;
strSubCommand.SetString(lpszCmdLine, int(lpNextWord - lpszCmdLine));
// trim white space
while (*lpNextWord)
{
if (!IsWhiteSpace(*lpNextWord))
break;
++lpNextWord;
}
// return command line for sub command
if (lppszSubCmdLine)
*lppszSubCmdLine = lpNextWord;
return strSubCommand;
}
示例10: ExpandFilePath
void ExpandFilePath( CString &strPath )
{
int nOffset = strPath.Find( '\\' );
if( nOffset > 0 ) // 替换之前的路径
{
CString strSpecial;
strSpecial.SetString(strPath, nOffset);
ParseSpecialFolder( strSpecial );
strPath.Format( _T("%s\\%s"),strSpecial, strPath.Mid( nOffset + 1 ));
}
else //
ParseSpecialFolder( strPath );
}
示例11: GetSelectedText
void CEditView::GetSelectedText( CString &strResult ) const
/*********************************************************/
{
DWORD dwSelStart;
DWORD dwSelEnd;
::SendMessage( m_hWnd, EM_GETSEL, (WPARAM)&dwSelStart, (LPARAM)&dwSelEnd );
if( dwSelEnd > dwSelStart ) {
LPCTSTR lpszBuffer = LockBuffer();
strResult.SetString( lpszBuffer + dwSelStart, dwSelEnd - dwSelStart );
UnlockBuffer();
} else {
strResult.Empty();
}
}
示例12: _TransClsid
BOOL _TransClsid( LPCTSTR lpszClsid, CString &strPath )
{
CString strFilename;
if( GetCLSIDFilename(lpszClsid, strFilename) )
{
LPTSTR lpszFileName = PathFindFileName(strFilename);
if(lpszFileName)
{
strPath.SetString(strFilename, (int)(lpszFileName-(LPCTSTR)strFilename) );
return TRUE;
}
}
return FALSE;
}
示例13: AsynchDialogueListenerThread
/* Low priority task checks if there's a message to be received from CONSIS and then sleeps for 200 msec */
DWORD WINAPI AsynchDialogueListenerThread(CPharmaRobot10Dlg* pdialog)
{
int MessageLength, MessagePSize = 114, MessageISize = 67, lisRobotItem;
char buffer[MAX_CONSIS_MESSAGE_SIZE];
size_t retsize, convertedChars = 0;;
pConsisRequestMessage * ppRequestMessage;
PConsisPmsResponseMessage PResponseToConsis;
iConsisRequestMessage * piRequestMessage;
IConsisPmsResponseMessage IResponseToConsis;
wchar_t description[256], wcstring[256];
for (;;) //Run forever
{
//Perform Message checking only if CONSIS is connected
if (pdialog->Consis.ConnectionStarted == TRUE)
{
//Try to catch the Mutex for CONSIS Access
//Protect with Mutex the CONSIS resource
CSingleLock singleLock(&(pdialog->m_Mutex));
// Attempt to lock the shared resource
if (singleLock.Lock(INFINITE))
{
//log locking success
}
//clear buffer
memset(buffer, 0, MAX_CONSIS_MESSAGE_SIZE);
MessageLength = sizeof(buffer);
pdialog->Consis.ReceiveConsisMessage(buffer, &MessageLength, 0 ); //no timeout
//Check if we received a 'p' request and handle it
if (buffer[0] == 'p')
{//handle a 'p' message here
mbstowcs_s(&convertedChars, wcstring, sizeof(pConsisRequestMessage) + 1, buffer, _TRUNCATE);
wcstring[sizeof(pConsisRequestMessage)] = L'\0';
pdialog->m_listBoxMain.AddString(wcstring);
ppRequestMessage = (pConsisRequestMessage *)buffer;
//Extract Article ID
wchar_t articleID[31];
articleID[30] = '\0';
mbstowcs_s(&retsize, articleID, sizeof(ppRequestMessage->ArticleId) + 1, ppRequestMessage->ArticleId, _TRUNCATE);
//Clean leading zeroes
CString cleanArticleID;
cleanArticleID.SetString(articleID);
cleanArticleID.TrimLeft(L' ');
cleanArticleID.TrimLeft(L'0');
wsprintf(articleID,cleanArticleID.GetString());
//clean the message to CONSIS
memset ((void*)&PResponseToConsis, '0',sizeof(PResponseToConsis));
memset (&(PResponseToConsis.ArticleName),' ',sizeof(PResponseToConsis.ArticleName));
//Get Description from Yarpa SQL
if (pdialog->GetItemDescFromBarcode(articleID, description))
{//Got a description
char DescriptionInChar[40];
wcstombs(DescriptionInChar, description, 39);
sprintf(PResponseToConsis.ArticleName,DescriptionInChar);
}
else
{
sprintf(PResponseToConsis.ArticleName, "Name Missing");
}
PResponseToConsis.RecordType = 'P';
memcpy(&(PResponseToConsis.ArticleId), ppRequestMessage->ArticleId, sizeof(PResponseToConsis.ArticleId));
mbstowcs_s(&convertedChars, wcstring, sizeof(PResponseToConsis) + 1, (char*)&PResponseToConsis, _TRUNCATE);
wcstring[sizeof(PResponseToConsis)] = L'\0';
pdialog->m_listBoxMain.AddString(wcstring);
//Send a response to CONSIS
pdialog->Consis.SendConsisMessage((char*)&PResponseToConsis, MessagePSize);
}
//Check if we received an 'i' request and handle it
if (buffer[0] == 'i')
{//handle an 'i' message here
mbstowcs_s(&convertedChars, wcstring, sizeof(iConsisRequestMessage) + 1, buffer, _TRUNCATE);
wcstring[sizeof(iConsisRequestMessage)] = L'\0';
pdialog->m_listBoxMain.AddString(wcstring);
piRequestMessage = (iConsisRequestMessage *)buffer;
//Extract Article ID
wchar_t articleID[31];
articleID[30] = '\0';
mbstowcs_s(&retsize, articleID, sizeof(piRequestMessage->ArticleId) + 1, piRequestMessage->ArticleId, _TRUNCATE);
//Clean leading zeroes
CString cleanArticleID;
cleanArticleID.SetString(articleID);
cleanArticleID.TrimLeft(L'0');
cleanArticleID.TrimLeft(L' ');
wsprintf(articleID,cleanArticleID.GetString());
//.........这里部分代码省略.........
示例14: Analyze
BOOL CSZCommandLine::Analyze(LPCTSTR lpszCmdLine)
{
BOOL bResult = FALSE;
int nParamNamePos = 0;
int nParamValuePos = 0;
int nSubCommandPos = 0;
CString strParamName;
CString strSubCommand;
BOOL bInQuotation = FALSE;
EM_CMDLINE_STATUS nStatus = em_Cmd_New_Arg;
m_mapParams.RemoveAll();
if (!lpszCmdLine)
goto Exit0;
for (int nPos = 0; 0 == nPos || lpszCmdLine[nPos - 1]; ++nPos)
{
TCHAR ch = lpszCmdLine[nPos];
switch (nStatus)
{
case em_Cmd_New_Arg:
bInQuotation = FALSE;
// no break;
case em_Cmd_White_Space:
if (IsWhiteSpace(ch))
{
nStatus = em_Cmd_White_Space;
}
else if (IsArgNamePrefix(ch))
{
nStatus = em_Cmd_Arg_Name_Prefix;
}
else if (IsAlpha(ch))
{ // skip sub command
nSubCommandPos = nPos;
nStatus = em_Cmd_Sub_Command;
}
else if (IsQuotation(ch))
{
bInQuotation = TRUE;
nStatus = em_Cmd_White_Space;
}
else
{
goto Exit0;
}
break;
case em_Cmd_Sub_Command:
if (IsWhiteSpace(ch))
{
strSubCommand.SetString(lpszCmdLine + nSubCommandPos, nPos - nSubCommandPos);
AppendSubCommand(strSubCommand);
nStatus = em_Cmd_New_Arg;
}
else if (IsAlpha(ch))
{ // skip sub command
nStatus = em_Cmd_Sub_Command;
}
else if (IsQuotation(ch))
{
strSubCommand.SetString(lpszCmdLine + nSubCommandPos, nPos - nSubCommandPos);
AppendSubCommand(strSubCommand);
nStatus = em_Cmd_New_Arg;
}
else
{
goto Exit0;
}
break;
case em_Cmd_Arg_Name_Prefix:
if (IsWhiteSpace(ch))
{
goto Exit0;
}
else if (IsArgNamePrefix(ch))
{ // Á¬ÐøµÄǰ׺
nStatus = em_Cmd_Arg_Name_Prefix;
}
else
{
nParamNamePos = nPos;
nStatus = em_Cmd_Arg_Name;
}
break;
case em_Cmd_Arg_Name:
if (IsWhiteSpace(ch))
//.........这里部分代码省略.........
示例15: SpinFloatString
/*
================
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;
}
}
}