本文整理汇总了C++中CString::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::Empty方法的具体用法?C++ CString::Empty怎么用?C++ CString::Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::Empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitInstance
BOOL CPeraProcessDesignerApp::InitInstance()
{
ZTools::InitZToolsLog();
if ( !m_CmdLine.Parse() )
{
MessageBox( NULL, "解析命令行失败!", g_lpszAppTitle, MB_OK | MB_TOPMOST );
return FALSE;
}
m_hMetux = CreateMutex(NULL,TRUE,"PeraProcessDesigner.exe");
if (m_hMetux)
{
if (ERROR_ALREADY_EXISTS== GetLastError())
{
HWND hwndPeraProcessDesignerCopied = FindPeraProcessDesignerMainWindow();
//当有互斥,但是没找到窗口时,认为之前的进程还在启动中,简单处理,直接退出
if ( hwndPeraProcessDesignerCopied)
{
if ( !m_CmdLine.GetValue( NULL ).IsEmpty() )
{
#define WS_OPENWS_SENDMSG
#ifdef WS_OPENWS_SENDMSG
DWORD dwProcessId = 0;
GetWindowThreadProcessId(hwndPeraProcessDesignerCopied, &dwProcessId);
if ( GetTopModalWindow( dwProcessId ) == NULL )
{
CSharedMemory Mem;
CString sMemData = g_lpszDoubleOpenWsMemStr;
Mem.Init( g_lpszDoubleOpenWsMemName, sMemData.GetLength()+MAX_PATH );
SendCopyData( hwndPeraProcessDesignerCopied, CPMSG_WORKSPACE_MAKESUREINFO, (LPVOID)NULL, 0 );
sMemData.Empty();
sMemData = (LPCTSTR)Mem.GetData();
if ( sMemData.CompareNoCase( g_lpszDoubleOpenWsMemStr ) == 0 )
{
MessageBox( NULL, "建模环境处于活动状态,请先保存模型后重试!", g_lpszAppTitle, MB_OK | MB_TOPMOST );
}
else
{
CString sCmdLine = ::GetCommandLine();
SendCopyData( hwndPeraProcessDesignerCopied, CPMSG_WORKSPACE_OPENWS, (LPVOID)(LPCTSTR)sCmdLine, sCmdLine.GetLength()+1 );
}
}
else
{
MessageBox( NULL, "建模环境处于活动状态,请先保存模型后重试!", g_lpszAppTitle, MB_OK | MB_TOPMOST );
}
#else
MessageBox( hwndPeraProcessDesignerCopied, "建模环境已打开,请在建模环境中打开本文件!", g_lpszAppTitle, MB_OK | MB_TOPMOST );
#endif
}
if (IsIconic(hwndPeraProcessDesignerCopied))
ShowWindow(hwndPeraProcessDesignerCopied,SW_RESTORE);
SetForegroundWindow(hwndPeraProcessDesignerCopied);
ZTools::WriteZToolsFormatLog("将已经运行的建模窗口激活,并前端显示...");
}
CloseHandle(m_hMetux);
m_hMetux = NULL;
ZTools::WriteZToolsFormatLog("已经存在一个建模客户端,本运行实例将退出...");
return FALSE;
}
}
m_LoginData.m_strRealName = m_CmdLine.GetValue( "realName" );
m_LoginData.m_strUser = m_CmdLine.GetValue( "userName" );
m_LoginData.m_strTicket = m_CmdLine.GetValue( "ticket-proxy" );
WriteShareMemoryLoginInfo();
CCrashHandler ch;
ch.SetProcessExceptionHandlers();
ch.SetThreadExceptionHandlers();
//如果PeraTaskService进程不存在,自动启动
StartPeraTaskService();
//_CrtSetBreakAlloc(1300);
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
//hModule = ::LoadLibrary("C:\\Users\\kunmiao-li\\Desktop\\TestBuild\\PeraLicMgr\\Release\\PeraLicMgr.dll");
//#ifndef _DEBUG
if (!InitLicense("PeraWorkSpace"))
return FALSE;
// if(!m_FlexNetMgr.CheckOutLicense("PeraWorkSpace"))
// {
// return FALSE;
// }
//.........这里部分代码省略.........
示例2: RegistryLookup
bool CTrueType::RegistryLookup(LPCTSTR pszTarget, TTF_DATA_TYPE TargetType, CString& strResult, TTF_DATA_TYPE ResultType)
{
strResult.Empty();
CString strTarget = pszTarget;
if (strTarget.IsEmpty())
return false;
OSVERSIONINFO osvi;
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
::GetVersionEx(&osvi);
bool bNT = (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT);
CRegKey regkey;
if (regkey.Open(HKEY_LOCAL_MACHINE, (bNT ? REGKEY_NTFONT : REGKEY_FONT)) != ERROR_SUCCESS)
return false;
char strDisplayName[MAX_PATH];
DWORD dwDisplayNameLength = sizeof(strDisplayName)-1;
char strFileName[MAX_PATH];
DWORD dwFileNameLength = sizeof(strFileName)-1;
bool bFound = false;
if (TargetType == TTF_DisplayName)
{
CString strTrueType = " (TrueType)";
if (strTarget.Find(strTrueType) < 0)
strTarget += strTrueType;
strcpy(strDisplayName, strTarget);
bFound = (regkey.QueryStringValue(strDisplayName, strFileName, &dwFileNameLength) == ERROR_SUCCESS);
}
else
{
DWORD dwType = 0;
DWORD dwIndex = 0;
while (::RegEnumValue(regkey, dwIndex, strDisplayName, &dwDisplayNameLength, NULL, &dwType, (BYTE*)strFileName, &dwFileNameLength) == ERROR_SUCCESS)
{
dwIndex++;
dwDisplayNameLength = sizeof(strDisplayName)-1;
dwFileNameLength = sizeof(strFileName)-1;
if (dwType != REG_SZ)
continue;
CString strValue;
if (TargetType == TTF_FileName)
strValue = strFileName;
else
if (TargetType == TTF_FaceName)
{
// Because GetFaceNameFromFileName() can be slow, assume that this is not a match
// unless the first 2 characters of the target FaceName match the DisplayName
if (strTarget[0] != strDisplayName[0] || strTarget[1] != strDisplayName[1])
continue;
GetFaceNameFromFileName(strFileName, strValue);
}
bFound = (strTarget.CompareNoCase(strValue) == 0);
if (bFound)
break;
}
}
if (!bFound)
return false;
if (ResultType == TTF_DisplayName)
strResult = strDisplayName;
else
if (ResultType == TTF_FileName)
strResult = strFileName;
else
if (ResultType == TTF_FaceName)
GetFaceNameFromFileName(strFileName, strResult);
return true;
}
示例3: ExportXML
//.........这里部分代码省略.........
CTrigger * t;
if (GetTriggerMap ().Lookup (strName, t))
{
Save_Header_XML (ar, "triggers", false);
Save_One_Trigger_XML (ar, t);
Save_Footer_XML (ar, "triggers");
} // end of item existing
}
break;
case 1: // alias
{
CAlias * t;
if (GetAliasMap ().Lookup (strName, t))
{
Save_Header_XML (ar, "aliases", false);
Save_One_Alias_XML (ar, t);
Save_Footer_XML (ar, "aliases");
} // end of item existing
}
break;
case 2: // timer
{
CTimer * t;
if (GetTimerMap ().Lookup (strName, t))
{
Save_Header_XML (ar, "timers", false);
Save_One_Timer_XML (ar, t);
Save_Footer_XML (ar, "timers");
} // end of item existing
}
break;
case 3: // macro
{
for (int i = 0; i < NUMITEMS (strMacroDescriptions); i++)
{
if (strMacroDescriptions [i].CompareNoCase (strName) == 0)
{
Save_Header_XML (ar, "macros", false);
Save_One_Macro_XML (ar, i);
Save_Footer_XML (ar, "macros");
} // end of item existing
} // end of finding which one
}
break;
case 4: // variable
{
CVariable * t;
if (GetVariableMap ().Lookup (strName, t))
{
Save_Header_XML (ar, "variables", false);
Save_One_Variable_XML (ar, t);
Save_Footer_XML (ar, "variables");
} // end of item existing
}
break;
case 5: // keypad
{
for (int i = 0; i < NUMITEMS (strKeypadNames); i++)
{
if (strKeypadNames [i].CompareNoCase (strName) == 0)
{
Save_Header_XML (ar, "keypad", false);
Save_One_Keypad_XML (ar, i);
Save_Footer_XML (ar, "keypad");
} // end of item existing
} // end of finding which one
}
break;
} // end of switch
ar.Close();
int nLength = f.GetLength ();
p = (char *) f.Detach ();
strResult = CString (p, nLength);
free (p); // remove memory allocated in CMemFile
p = NULL;
} // end of try block
catch (CException* e)
{
if (p)
free (p); // remove memory allocated in CMemFile
e->Delete();
strResult.Empty ();
} // end of catch
return strResult.AllocSysString();
} // end of CMUSHclientDoc::ExportXML
示例4: RunScript
DWORD CHooks::RunScript(CString cmd, LPCTSTR currentDir, CString& error, bool bWait, bool bShow)
{
DWORD exitcode = 0;
SECURITY_ATTRIBUTES sa;
SecureZeroMemory(&sa, sizeof(sa));
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
CAutoFile hOut ;
CAutoFile hRedir;
CAutoFile hErr;
// clear the error string
error.Empty();
// Create Temp File for redirection
TCHAR szTempPath[MAX_PATH] = {0};
TCHAR szOutput[MAX_PATH] = {0};
TCHAR szErr[MAX_PATH] = {0};
GetTortoiseGitTempPath(_countof(szTempPath), szTempPath);
GetTempFileName(szTempPath, _T("git"), 0, szErr);
// setup redirection handles
// output handle must be WRITE mode, share READ
// redirect handle must be READ mode, share WRITE
hErr = CreateFile(szErr, GENERIC_WRITE, FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, 0);
if (!hErr)
{
error = CFormatMessageWrapper();
return (DWORD)-1;
}
hRedir = CreateFile(szErr, GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
if (!hRedir)
{
error = CFormatMessageWrapper();
return (DWORD)-1;
}
GetTempFileName(szTempPath, _T("git"), 0, szOutput);
hOut = CreateFile(szOutput, GENERIC_WRITE, FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, 0);
if (!hOut)
{
error = CFormatMessageWrapper();
return (DWORD)-1;
}
// setup startup info, set std out/err handles
// hide window
STARTUPINFO si;
SecureZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
si.hStdOutput = hOut;
si.hStdError = hErr;
si.wShowWindow = bShow ? SW_SHOW : SW_HIDE;
PROCESS_INFORMATION pi;
SecureZeroMemory(&pi, sizeof(pi));
if (!CreateProcess(nullptr, cmd.GetBuffer(), nullptr, nullptr, TRUE, 0, nullptr, currentDir, &si, &pi))
{
const DWORD err = GetLastError(); // preserve the CreateProcess error
error = CFormatMessageWrapper(err);
SetLastError(err);
cmd.ReleaseBuffer();
return (DWORD)-1;
}
cmd.ReleaseBuffer();
CloseHandle(pi.hThread);
// wait for process to finish, capture redirection and
// send it to the parent window/console
if (bWait)
{
DWORD dw;
char buf[256] = { 0 };
do
{
while (ReadFile(hRedir, &buf, sizeof(buf)-1, &dw, NULL))
{
if (dw == 0)
break;
error += CString(CStringA(buf,dw));
}
Sleep(150);
} while (WaitForSingleObject(pi.hProcess, 0) != WAIT_OBJECT_0);
// perform any final flushing
while (ReadFile(hRedir, &buf, sizeof(buf)-1, &dw, NULL))
{
if (dw == 0)
break;
error += CString(CStringA(buf, dw));
}
//.........这里部分代码省略.........
示例5: WriteReportData
void CCompareResultsDlg::WriteReportData()
{
CompareData::iterator cd_iter;
CString buffer;
if (!m_OnlyInCurrent.empty()) {
buffer.Format(IDS_COMPAREENTRIES1, m_scFilename1);
m_pRpt->WriteLine((LPCWSTR)buffer);
for (cd_iter = m_OnlyInCurrent.begin(); cd_iter != m_OnlyInCurrent.end();
cd_iter++) {
const st_CompareData &st_data = *cd_iter;
buffer.Format(IDS_COMPARESTATS, st_data.group.c_str(), st_data.title.c_str(), st_data.user.c_str());
m_pRpt->WriteLine((LPCWSTR)buffer);
}
m_pRpt->WriteLine();
}
if (!m_OnlyInComp.empty()) {
buffer.Format(IDS_COMPAREENTRIES2, m_scFilename2);
m_pRpt->WriteLine((LPCWSTR)buffer);
for (cd_iter = m_OnlyInComp.begin(); cd_iter != m_OnlyInComp.end();
cd_iter++) {
const st_CompareData &st_data = *cd_iter;
buffer.Format(IDS_COMPARESTATS, st_data.group.c_str(), st_data.title.c_str(), st_data.user.c_str());
m_pRpt->WriteLine((LPCWSTR)buffer);
}
m_pRpt->WriteLine();
}
if (!m_Conflicts.empty()) {
buffer.Format(IDS_COMPAREBOTHDIFF);
m_pRpt->WriteLine((LPCWSTR)buffer);
const CString csx_password(MAKEINTRESOURCE(IDS_COMPPASSWORD));
const CString csx_notes(MAKEINTRESOURCE(IDS_COMPNOTES));
const CString csx_url(MAKEINTRESOURCE(IDS_COMPURL));
const CString csx_autotype(MAKEINTRESOURCE(IDS_COMPAUTOTYPE));
const CString csx_ctime(MAKEINTRESOURCE(IDS_COMPCTIME));
const CString csx_pmtime(MAKEINTRESOURCE(IDS_COMPPMTIME));
const CString csx_atime(MAKEINTRESOURCE(IDS_COMPATIME));
const CString csx_xtime(MAKEINTRESOURCE(IDS_COMPXTIME));
const CString csx_xtimeint(MAKEINTRESOURCE(IDS_COMPXTIME_INT));
const CString csx_rmtime(MAKEINTRESOURCE(IDS_COMPRMTIME));
const CString csx_pwhistory(MAKEINTRESOURCE(IDS_COMPPWHISTORY));
const CString csx_policy(MAKEINTRESOURCE(IDS_COMPPWPOLICY));
const CString csx_runcmd(MAKEINTRESOURCE(IDS_COMPRUNCOMMAND));
const CString csx_dca(MAKEINTRESOURCE(IDS_COMPDCA));
const CString csx_shiftdca(MAKEINTRESOURCE(IDS_COMPSHIFTDCA));
const CString csx_email(MAKEINTRESOURCE(IDS_COMPEMAIL));
const CString csx_protected(MAKEINTRESOURCE(IDS_COMPPROTECTED));
const CString csx_symbols(MAKEINTRESOURCE(IDS_COMPSYMBOLS));
const CString csx_policyname(MAKEINTRESOURCE(IDS_COMPPOLICYNAME));
const CString csx_kbshortcut(MAKEINTRESOURCE(IDS_KBSHORTCUT));
for (cd_iter = m_Conflicts.begin(); cd_iter != m_Conflicts.end();
cd_iter++) {
const st_CompareData &st_data = *cd_iter;
buffer.Format(IDS_COMPARESTATS2, st_data.group.c_str(), st_data.title.c_str(), st_data.user.c_str());
m_pRpt->WriteLine(std::wstring(buffer));
buffer.Empty();
// Non-time fields
if (st_data.bsDiffs.test(CItemData::PASSWORD)) buffer += csx_password;
if (st_data.bsDiffs.test(CItemData::NOTES)) buffer += csx_notes;
if (st_data.bsDiffs.test(CItemData::URL)) buffer += csx_url;
if (st_data.bsDiffs.test(CItemData::AUTOTYPE)) buffer += csx_autotype;
if (st_data.bsDiffs.test(CItemData::PWHIST)) buffer += csx_pwhistory;
if (st_data.bsDiffs.test(CItemData::POLICY)) buffer += csx_policy;
if (st_data.bsDiffs.test(CItemData::RUNCMD)) buffer += csx_runcmd;
if (st_data.bsDiffs.test(CItemData::DCA)) buffer += csx_dca;
if (st_data.bsDiffs.test(CItemData::SHIFTDCA)) buffer += csx_shiftdca;
if (st_data.bsDiffs.test(CItemData::EMAIL)) buffer += csx_email;
if (st_data.bsDiffs.test(CItemData::PROTECTED)) buffer += csx_protected;
if (st_data.bsDiffs.test(CItemData::SYMBOLS)) buffer += csx_symbols;
if (st_data.bsDiffs.test(CItemData::POLICYNAME)) buffer += csx_policyname;
if (st_data.bsDiffs.test(CItemData::KBSHORTCUT)) buffer += csx_kbshortcut;
// Time fields
if (st_data.bsDiffs.test(CItemData::CTIME)) buffer += csx_ctime;
if (st_data.bsDiffs.test(CItemData::PMTIME)) buffer += csx_pmtime;
if (st_data.bsDiffs.test(CItemData::ATIME)) buffer += csx_atime;
if (st_data.bsDiffs.test(CItemData::XTIME)) buffer += csx_xtime;
if (st_data.bsDiffs.test(CItemData::RMTIME)) buffer += csx_rmtime;
if (st_data.bsDiffs.test(CItemData::XTIME_INT)) buffer += csx_xtimeint;
m_pRpt->WriteLine((LPCWSTR)buffer);
}
m_pRpt->WriteLine();
}
}
示例6: SafeGetSimpleList
int GitRev::SafeGetSimpleList(CGit *git)
{
if(InterlockedExchange(&m_IsUpdateing,TRUE) == FALSE)
{
m_SimpleFileList.clear();
git->CheckAndInitDll();
GIT_COMMIT commit;
GIT_COMMIT_LIST list;
GIT_HASH parent;
memset(&commit,0,sizeof(GIT_COMMIT));
CAutoLocker lock(g_Git.m_critGitDllSec);
try
{
if(git_get_commit_from_hash(&commit, this->m_CommitHash.m_hash))
return -1;
}
catch (char *)
{
return -1;
}
int i=0;
bool isRoot = this->m_ParentHash.empty();
git_get_commit_first_parent(&commit,&list);
while(git_get_commit_next_parent(&list,parent) == 0 || isRoot)
{
GIT_FILE file=0;
int count=0;
try
{
if(isRoot)
git_root_diff(git->GetGitSimpleListDiff(), commit.m_hash, &file, &count, 0);
else
git_diff(git->GetGitSimpleListDiff(), parent, commit.m_hash, &file, &count, 0);
}
catch (char *)
{
return -1;
}
isRoot = false;
CTGitPath path;
CString strnewname;
CString stroldname;
for (int j = 0; j < count; ++j)
{
path.Reset();
char *newname;
char *oldname;
strnewname.Empty();
stroldname.Empty();
int mode,IsBin,inc,dec;
try
{
git_get_diff_file(git->GetGitSimpleListDiff(), file, j, &newname, &oldname, &mode, &IsBin, &inc, &dec);
}
catch (char *)
{
return -1;
}
git->StringAppend(&strnewname, (BYTE*)newname, CP_UTF8);
m_SimpleFileList.push_back(strnewname);
}
git_diff_flush(git->GetGitSimpleListDiff());
++i;
}
InterlockedExchange(&m_IsUpdateing,FALSE);
InterlockedExchange(&m_IsSimpleListReady, TRUE);
git_free_commit(&commit);
}
return 0;
}
示例7: FormatText
///////////////////////////////////////////////////////////////////////////////
// FormatText
int CXHTMLStatic::FormatText(HDC hdc,
LPCTSTR lpszText,
RECT * pRect,
int nInitialXOffset)
{
TRACE(_T("in CXHTMLStatic::FormatText: nInitialXOffset=%d <%-20.20s>\n"),
nInitialXOffset, lpszText);
//TRACERECT(*pRect);
int xStart, /*yStart,*/ nWord, xNext, xLast, nLeftMargin;
TCHAR *pText = (TCHAR *) lpszText;
SIZE size;
xNext = nInitialXOffset;
nLeftMargin = nInitialXOffset;
xLast = 0;
if (pRect->top >= (pRect->bottom-1))
return 0;
// set initial size
TCHAR * szTest = _T("abcdefgABCDEFG");
GetTextExtentPoint32(hdc, szTest, _tcslen(szTest), &size);
// prepare for next line - clear out the error term
SetTextJustification(hdc, 0, 0);
CString strOut = _T("");
BOOL bReturnSeen = FALSE;
TEXTMETRIC tm;
::GetTextMetrics(hdc, &tm);
do // for each text line
{
nWord = 0; // initialize number of spaces in line
// skip to first non-space in line
while (/**pText != _T('\0') && */*pText == _T(' '))
{
if (xNext)
strOut += *pText;
pText++;
}
for(;;) // process each word
{
CString strWord;
TCHAR *saved_pText = pText;
strWord = GetNextWord(&pText, &bReturnSeen);
CString strTrial;
strTrial = strOut + strWord;
// after each word, calculate extents
nWord++;
GetTextExtentPoint32(hdc, strTrial, strTrial.GetLength(), &size);
BOOL bOverflow = (size.cx >= (pRect->right - xNext - 2));
// don't get too close to margin,
// in case of italic text
if (bOverflow)
{
if (strOut.IsEmpty())
{
bOverflow = FALSE;
strOut = strWord;
}
}
else
{
strOut += strWord;
}
if (bReturnSeen || bOverflow || (*pText == _T('\0')))
{
if (strOut.IsEmpty())
break;
if (bOverflow)
pText = saved_pText;
nWord--; // discount last space at end of line
// if end of text and no space characters, set pEnd to end
GetTextExtentPoint32(hdc, strOut, strOut.GetLength(), &size);
xStart = pRect->left;
xStart += xNext;
xNext = 0;
xLast = xStart + size.cx;
// display the text
if ((m_yStart <= (pRect->bottom-size.cy)))// && (!IsBlank(strOut)))
{
TextOut(hdc, xStart, m_yStart, strOut, strOut.GetLength());
//.........这里部分代码省略.........
示例8: Write
bool SgmlElement::Write(CFileOutput *pOutput, int iLevel) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if (pOutput == NULL)
return false;
CString csTabString;
if (iLevel != -1) {
for (int i = 0; i < iLevel; ++i)
csTabString += " ";
}
CString csSgmlString;
CString writeString;
writeString.Format(_T("%s<%s"), csTabString, m_csName);
for (int i = 0; i < m_aAttributes.GetSize(); ++i) {
Attribute *pAttribute = m_aAttributes[i];
if (pAttribute != NULL) {
writeString += _T(" ");
writeString += pAttribute->GetName();
writeString += _T("=\"");
StringManipulation::TransformForSgml(pAttribute->GetValue(), csSgmlString);
writeString += csSgmlString;
writeString += _T("\"");
}
}
writeString += _T(">");
pOutput->Append(writeString);
if (!m_csParameter.IsEmpty()) {
writeString.Empty();
StringManipulation::TransformForSgml(m_csParameter.GetStringBuffer(), csSgmlString);
if (m_bUseOneLine) {
writeString.Format(_T("%s"), csSgmlString);
csTabString.Empty();
} else {
writeString.Format(_T("\n%s\n"), csSgmlString);
}
pOutput->Append(writeString);
}
if (!m_aElements.IsEmpty()) {
pOutput->Append(_T("\n"));
for (int i = 0; i < m_aElements.GetSize(); ++i) {
SgmlElement *pElement = m_aElements[i];
if (pElement != NULL) {
if (iLevel != -1)
pElement->Write(pOutput, iLevel + 1);
else
pElement->Write(pOutput, iLevel);
}
}
} else // use only one line
csTabString.Empty();
CString csEndTag;
csEndTag.Format(_T("%s</%s>\n"), csTabString, m_csName);
pOutput->Append(csEndTag);
return true;
}
示例9: Receive
//--------------------------------------------------------------------------------
int CTextSocket::Receive(CString& sText)
{
// if we have something queued then just return it
if(m_buffer.GetCount() > 0)
{
POSITION pos = m_buffer.GetHeadPosition();
if(pos == NULL)
return 0;
sText = m_buffer.GetAt(pos);
m_buffer.RemoveAt(pos);
return sText.GetLength();
}
sText.Empty();
DWORD nStart = ::GetTickCount();
for(;;)
{
int nLen = CSmallSocket::Receive(sText.GetBuffer(1024), 1024);
sText.ReleaseBuffer(nLen == -1 ? 0 : nLen);
if(nLen == 0)
return 0;
if(nLen == SOCKET_ERROR)
{
DWORD nNow = ::GetTickCount();
// check for tickcount wrap around - happens every 49.7 days
// of continuous running - see GetTickCount
if(nNow < nStart)
{
nStart = ::GetTickCount();
continue;
}
// see if we've timed out
if((nStart + GetTimeOut()) <= nNow)
return 0;
if(::WSAGetLastError() == WSAEWOULDBLOCK)
{
::Sleep(100);
continue;
}
else
return SOCKET_ERROR;
}
for(int i = 0; i < sText.GetLength(); i++)
{
TCHAR cCur = sText[i];
switch(cCur)
{
case '\r':
m_buffer.AddTail(m_sCurLine);
m_sCurLine.Empty();
break;
case '\n':
break;
default:
m_sCurLine += cCur;
break;
}
}
sText.Empty();
return 0;
}
}
示例10: GetVariableValue
int GetVariableValue(int index ,CString &ret_cstring,CString &ret_unit,CString &Auto_M,int &digital_value)
{
CStringArray temparray;
CString temp1;
if(index >= BAC_VARIABLE_ITEM_COUNT)
{
ret_cstring.Empty();
ret_unit.Empty();
Auto_M.Empty();
return -1;
}
int i = index;
if(m_Variable_data.at(i).auto_manual == 1)
{
Auto_M = _T("M");
}
else
{
Auto_M.Empty();
}
if(m_Variable_data.at(i).digital_analog == BAC_UNITS_DIGITAL)
{
if(m_Variable_data.at(i).range>30)
{
ret_cstring.Empty();
return -1;
}
else
{
if((m_Variable_data.at(i).range < 23) &&(m_Variable_data.at(i).range !=0))
temp1 = Digital_Units_Array[m_Variable_data.at(i).range];
else if((m_Variable_data.at(i).range >=23) && (m_Variable_data.at(i).range <= 30))
{
if(receive_customer_unit)
temp1 = temp_unit_no_index[m_Variable_data.at(i).range - 23];
}
else
{
ret_cstring.Empty();
return -1;
}
SplitCStringA(temparray,temp1,_T("/"));
if((temparray.GetSize()==2))
{
if(m_Variable_data.at(i).control == 0)
{
digital_value = 0;
ret_cstring = temparray.GetAt(0);
return 1;
}
else
{
digital_value = 1;
ret_cstring = temparray.GetAt(1);
}
}
}
}
else
{
if(m_Variable_data.at(i).range == 20) //如果是时间;
{
ret_unit = Variable_Analog_Units_Array[m_Variable_data.at(i).range];
char temp_char[50];
int time_seconds = m_Variable_data.at(i).value / 1000;
intervaltotext(temp_char,time_seconds,0,0);
MultiByteToWideChar( CP_ACP, 0, temp_char, strlen(temp_char) + 1,
ret_cstring.GetBuffer(MAX_PATH), MAX_PATH );
ret_cstring.ReleaseBuffer();
digital_value = 2;
}
else if((m_Variable_data.at(i).range<=sizeof(Variable_Analog_Units_Array)/sizeof(Variable_Analog_Units_Array[0])) && (m_Variable_data.at(i).range != 0))
{
ret_unit = Variable_Analog_Units_Array[m_Variable_data.at(i).range];
CString cstemp_value;
float temp_float_value;
temp_float_value = ((float)m_Variable_data.at(i).value) / 1000;
ret_cstring.Format(_T("%.3f"),temp_float_value);
digital_value = 2;
}
else
{
ret_cstring.Empty();
return -1;
}
}
return 1;
}
示例11: CreateGIBInputFile
BOOL CGIB::CreateGIBInputFile(CFile& file, CPlayer* pPlayer, CHandHoldings* pHand, CHandHoldings* pDummyHand, CString& strContents) const
{
// format the input
CString strInput;
CEasyBDoc* pDoc = pDOC;
// indicate player
strInput.Format("%c\n",PositionToChar(pPlayer->GetPosition()));
strContents += strInput;
file.Write((LPCTSTR)strInput, strInput.GetLength());
// indicate hand
strInput = pHand->GetInitialHand().GetGIBFormatHoldingsString();
strInput += '\n';
strContents += strInput;
file.Write((LPCTSTR)strInput, strInput.GetLength());
// indicate dealer
strInput.Format("%c\n",PositionToChar(pDoc->GetDealer()));
strContents += strInput;
file.Write((LPCTSTR)strInput, strInput.GetLength());
// indicate vulnerability
strInput = "n\n"; // TEMP
strContents += strInput;
file.Write((LPCTSTR)strInput, strInput.GetLength());
// indicate auction
strInput.Empty();
int numBids = pDoc->GetNumBidsMade();
for(int i=0;i<numBids;i++)
{
strInput += BidToBriefString(pDoc->GetBidByIndex(i));
if (i < numBids)
strInput += ' ';
}
strInput += '\n';
strContents += strInput;
file.Write((LPCTSTR)strInput, strInput.GetLength());
// indicate opening lead
int nLeadCard = pDoc->GetPlayRecord(0);
strInput.Format("%s\n",CardToShortString(nLeadCard));
strContents += strInput;
file.Write((LPCTSTR)strInput, strInput.GetLength());
// indicate dummy's (ORIGINAL) hand
strInput = pDummyHand->GetInitialHand().GetGIBFormatHoldingsString();
strInput += '\n';
strContents += strInput;
file.Write((LPCTSTR)strInput, strInput.GetLength());
// and enter any plays so far
strInput.Empty();
int numCardsPlayed = pDoc->GetNumCardsPlayedInGame();
for(i=1;i<numCardsPlayed;i++)
{
strInput += CardToShortString(pDoc->GetPlayRecord(i));
strInput += ' ';
if (((i % 3) == 0) || (i == numCardsPlayed-1))
{
// flush the line
strInput += '\n';
file.Write((LPCTSTR)strInput, strInput.GetLength());
strInput.Empty();
}
}
// end the file with a # sign
strInput = "#\n";
strContents += strInput;
file.Write((LPCTSTR)strInput, strInput.GetLength());
// done
return TRUE;
}
示例12: DownloadImage
bool CWebCDCovers::DownloadImage(CString strLetter, CString strName, CString strFilename, RESOURCEHOST* pHost, HWND hwndProgress, HWND hwndStatus, CString& strLocalFilename)
{
// get the html page for the image source
*m_pbCancelDownload = false;
WCC_GETIMAGEREQUEST* pfn_wccRequest = (WCC_GETIMAGEREQUEST*) GetProcAddress (pHost->hInst, "GetImageRequest");
WCC_GETIMAGEURL* pfn_wccImgURL = (WCC_GETIMAGEURL*) GetProcAddress (pHost->hInst, "GetImageURL");
char szUrl[300], szHeaders[300], szData[300];
int nMethod;
pfn_wccRequest (strFilename.GetBuffer (0), strLetter.GetBuffer (0), "", szUrl, &nMethod, szHeaders, szData);
CString strHTML = (*szUrl == 0) ? strFilename.GetBuffer (0) :
CHttpRequest::DownloadBuffer (szUrl, nMethod, szHeaders, szData,
m_pbCancelDownload, m_dwDownloadId, m_nError);
// MCH 29/08/04
// Send version info to the DLL
strcpy (szData, ((CCdCoverCreator2App*) AfxGetApp ())->GetVersion ().GetBuffer (-1));
// get the URL of the image
CString strURL;
if (!pfn_wccImgURL (strHTML.GetBuffer (0), strURL.GetBuffer (500), &nMethod, szHeaders, szData))
return false;
strURL.ReleaseBuffer ();
// generate a local temporary file name
strLocalFilename = ((CCdCoverCreator2App*) AfxGetApp ())->GetImageCacheDir () + strURL.Mid (strURL.ReverseFind ('/') + 1);
if (strLocalFilename.Find (".php?") >= 0)
{
// MCH 15/09/04
// www.darktown.to sends again JPGs, but via a PHP script. Filename provided as HTTP header which is not available here
strLocalFilename = ((CCdCoverCreator2App*) AfxGetApp ())->GetImageCacheDir ();
strLocalFilename.AppendFormat ("dld%d.jpg", GetTickCount ());
}
// get the jpeg image
*m_pbCancelDownload = false;
CHttpRequest::DownloadFile (strURL, nMethod, szHeaders, szData, strLocalFilename,
m_pbCancelDownload, m_dwDownloadId, m_nError, 0, hwndProgress, hwndStatus);
if (m_nError)
return false;
// MCH 29/08/04
// if the download is a zip file, extract the image
if (strLocalFilename.Right (4).MakeLower () == ".zip")
{
CString strPath = strLocalFilename.Left (strLocalFilename.ReverseFind ('\\'));
CString strZipFile = strLocalFilename;
// set up and open a zip archive, get the image files inside the zip file
CZipArchive zip;
zip.Open (strZipFile);
CZipWordArray ar;
zip.FindMatches ("*.jp*g", ar);
strLocalFilename.Empty ();
// extract the image files
for (int i = 0; i < ar.GetSize (); i++)
{
// set the local file name
CZipFileHeader info;
zip.GetFileInfo (info, i);
if (!strLocalFilename.IsEmpty ())
strLocalFilename += ";";
strLocalFilename += strPath + "\\" + info.GetFileName ();
// extract the file
zip.ExtractFile (ar.GetAt (i), strPath, false);
}
zip.Close ();
// delete the zip file
::DeleteFile (strZipFile);
}
return true;
}
示例13: ClearUpGlobalData
void ClearUpGlobalData()
{
int i;
option_filename.Empty();
trainset_filename.Empty();
validset_filename.Empty();
classifier_filename.Empty();
ada_log_filename.Empty();
cascade_filename.Empty();
FFS_WeakClassifiers_filename.Empty();
FFS_log_filename = "rate_FFS.txt";
FileUsage_log_filename.Empty();
Bootstrap_database_filename.Empty();
Backup_directory_name.Empty();
TestSet_filename.Empty();
sx = sy = 0;
train_method = 0;
linear_classifier = 0;
bootstrap_level = 0;
max_bootstrap_level = 0;
bootstrap_resizeratio.clear();
bootstrap_increment.clear();
first_feature = 0;
max_files = 0;
goal_method = 0;
node_det_goal = 0.0;
node_fp_goal = 0.0;
asym_ratio = 0.0;
max_nodes = 0;
nof.clear();
delete[] trainset; trainset = NULL;
delete[] validset; validset = NULL;
totalcount = validcount = 0;
delete cascade; cascade = NULL;
delete[] weights; weights = NULL;
for(i=0;i<totalfeatures;i++)
{
delete[] table[i]; table[i] = NULL;
}
totalfeatures = 0;
delete[] table; table = NULL;
delete[] classifiers; classifiers = NULL;
delete[] features; features = NULL;
delete[] labels; labels = NULL;
delete[] fileused; fileused = NULL;
bootstrap_size = 0;
delete[] bootstrap_filenames; bootstrap_filenames = NULL;
}
示例14: ProcessThread
//This method gets called by its static counterpart, and is the actual thread logic
DWORD WINAPI Kinect::ProcessThread()
{
//numEvents is the number of events, handleEvents is an Array of all the events being handled.
const int numEvents = 4;
HANDLE handleEvents[numEvents] = { treadNuiProcessStop, nextColorFrameEvent, nextDepthFrameEvent, nextSkeletonEvent };
std::stringstream ss;
int eventIdx, colorFrameFPS = 0, depthFrameFPS = 0;
DWORD t, lastColorFPSTime, lastDepthFPSTime;
CString TextFPS;
// Initializes the static text fields for FPS text.
CStatic * MFC_ecFPSCOLOR, * MFC_ecFPSDEPTH;
//Initialize the Image vieuwer on the GUI. Because this class does not inherit anything relatied to MFC, we need CWnd::GetDlgItem instead of just GetDlgItem.
// (By the way: because the main is a CWnd and 'GetDlgItem()' means the same thing as 'this->GetDlgItem()', main.cpp actually uses the same method.)
MFC_ecFPSCOLOR = (CStatic *) cWnd.GetDlgItem(1013);
MFC_ecFPSDEPTH = (CStatic *) cWnd.GetDlgItem(1014);
lastColorFPSTime = timeGetTime( );
lastDepthFPSTime = timeGetTime( );
//blank the skeleton display when started.
lastSkeletonFoundTime = 0;
bool continueProcess = true;
while ( continueProcess )
{
// wait for any of the events
eventIdx = WaitForMultipleObjects( numEvents, handleEvents, FALSE, 100);
// timed out, continue
if ( eventIdx == WAIT_TIMEOUT)
{
continue;
}
// stop event was signalled
if ( WAIT_OBJECT_0 == eventIdx )
{
continueProcess = false;
break;
}
// Wait for each object individually with a 0 timeout to make sure to
// process all signalled objects if multiple objects were signalled
// this loop iteration
// In situations where perfect correspondance between color/depth/skeleton
// is essential, a priority queue should be used to service the item
// which has been updated the longest ago Copyright Microsoft.
if ( WAIT_OBJECT_0 == WaitForSingleObject( nextColorFrameEvent, 0) )
{
if( gotColorAlert() )
{
++colorFrameFPS;
}
}
if ( WAIT_OBJECT_0 == WaitForSingleObject( nextDepthFrameEvent, 0) )
{
if( gotDepthAlert() )
{
++depthFrameFPS;
}
}
if (WAIT_OBJECT_0 == WaitForSingleObject( nextSkeletonEvent, 0))
{
if (gotSkeletonAlert() )
{
}
}
// fps counter for the color stream.
// compare first frametime with the current time, if more then 1000 passed,
// one second passed.
t = timeGetTime();
if((t - lastColorFPSTime) > 1000)
{
ss<<colorFrameFPS;
TextFPS= ss.str().c_str();
MFC_ecFPSCOLOR->SetWindowText(TextFPS);
colorFrameFPS = 0;
lastColorFPSTime = timeGetTime();
// Reset both the CString text and the stringstream, so you don't get any crazy value's.
TextFPS.Empty();
ss.str("");
ss<<depthFrameFPS;
TextFPS = ss.str().c_str();
MFC_ecFPSDEPTH->SetWindowText(TextFPS);
depthFrameFPS = 0;
// Reset both the CString text and the stringstream, so you don't get any crazy value's.
TextFPS.Empty();
//.........这里部分代码省略.........
示例15: DrawItem
//.........这里部分代码省略.........
Sbuffer.Format(_T("(%s)"), GetResString(IDS_UNKNOWN));
else
Sbuffer = client->GetUserName();
//EastShare Start - added by AndCycle, IP to Country
CString tempStr;
tempStr.Format(_T("%s%s"), client->GetCountryName(), Sbuffer);
Sbuffer = tempStr;
if(CGlobalVariable::ip2country->ShowCountryFlag()){
cur_rec.left+=20;
POINT point2= {cur_rec.left,cur_rec.top+1};
CGlobalVariable::ip2country->GetFlagImageList()->DrawIndirect(dc, client->GetCountryFlagIndex(), point2, CSize(18,16), CPoint(0,0), ILD_NORMAL);
}
//EastShare End - added by AndCycle, IP to Country
cur_rec.left +=20;
dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT);
cur_rec.left -=20;
//EastShare Start - added by AndCycle, IP to Country
if(CGlobalVariable::ip2country->ShowCountryFlag()){
cur_rec.left-=20;
}
//EastShare End - added by AndCycle, IP to Country
break;
}
case 1:{
Sbuffer = client->GetUploadStateDisplayString();
break;
}
case 2:{
if(client->credits)
Sbuffer = CastItoXBytes(client->credits->GetUploadedTotal(), false, false);
else
Sbuffer.Empty();
break;
}
case 3:{
Sbuffer = client->GetDownloadStateDisplayString();
break;
}
case 4:{
if(client->credits)
Sbuffer = CastItoXBytes(client->credits->GetDownloadedTotal(), false, false);
else
Sbuffer.Empty();
break;
}
case 5:{
Sbuffer = client->GetClientSoftVer();
if (Sbuffer.IsEmpty())
Sbuffer = GetResString(IDS_UNKNOWN);
break;
}
case 6:{
if(client->socket){
if(client->socket->IsConnected()){
Sbuffer = GetResString(IDS_YES);
break;
}
}
Sbuffer = GetResString(IDS_NO);
break;
}
case 7:
Sbuffer = md4str(client->GetUserHash());
break;
}
if( iColumn != 0)
dc.DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT);
cur_rec.left += GetColumnWidth(iColumn);
}
}
// draw rectangle around selected item(s)
if (lpDrawItemStruct->itemState & ODS_SELECTED)
{
RECT outline_rec = lpDrawItemStruct->rcItem;
outline_rec.top--;
outline_rec.bottom++;
dc.FrameRect(&outline_rec, &CBrush(GetBkColor()));
outline_rec.top++;
outline_rec.bottom--;
outline_rec.left++;
outline_rec.right--;
if(bCtrlFocused)
dc.FrameRect(&outline_rec, &CBrush(m_crFocusLine));
else
dc.FrameRect(&outline_rec, &CBrush(m_crNoFocusLine));
}
if (m_crWindowTextBk == CLR_NONE)
dc.SetBkMode(iOldBkMode);
dc.SelectObject(pOldFont);
dc.SetTextColor(crOldTextColor);
}