本文整理汇总了C++中CString::CompareNoCase方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::CompareNoCase方法的具体用法?C++ CString::CompareNoCase怎么用?C++ CString::CompareNoCase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::CompareNoCase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Serialize
void CGenericDoc::Serialize(CArchive& ar)
{
TRACE("CGenericDoc::Serialize called\n");
BOOL bCanSerialize = TRUE;
if(ar.IsLoading()) {
#ifdef XP_WIN32
// Determine name of actual document.
CFile *pFile = ar.GetFile();
CString csFile;
if(pFile) {
csFile = pFile->GetFilePath();
}
// Determine if this is the same file that was passed into the
// OnOpenDocument function.
// If so, then we can not read our OLE format.
bCanSerialize = (csFile.CompareNoCase(m_csOpenDocumentFile) != 0);
// However, if they're both empty, then we need to allow this.
if(csFile.IsEmpty() && m_csOpenDocumentFile.IsEmpty()) {
bCanSerialize = TRUE;
}
TRACE("%d = !(%s==%s)\n", bCanSerialize, (const char *)csFile, (const char *)m_csOpenDocumentFile);
#else
// 16 bit can not turn a file handle into a file name.
// If our document name is set, then say we can't serialize.
bCanSerialize = !(m_bOpenDocumentFileSet && !m_csOpenDocumentFile.IsEmpty());
TRACE("%d = !(%d && !%d)\n", m_bOpenDocumentFileSet, !m_csOpenDocumentFile.IsEmpty());
#endif
}
// We can only serialize if we're not looking at a local file which we've opened up.
if(bCanSerialize) {
// Fleshed out for OLE server work.
// The below is the common implementation that should work across the
// board for all versions of the navigator.
// All it does is either read in or write out a URL.
if(GetContext() && GetContext()->IsDestroyed() == FALSE) {
if (ar.IsStoring())
{
TRACE("Storing\n");
// Just shove our current URL into the file.
// Get the current history entry.
History_entry *pHist = SHIST_GetCurrent(&(GetContext()->GetContext()->hist));
if(pHist != NULL && pHist->address != NULL) {
CString csAddress = pHist->address;
ar << csAddress;
TRACE("URL is %s\n", (const char *)csAddress);
}
else {
TRACE("no history!\n");
CString csEmpty;
ar << csEmpty;
}
}
else
{
TRACE("Reading\n");
// Pretty much just read this in as internet shortcut
// format and load it.
CString csLoadMe;
ar >> csLoadMe;
// Do it.
TRACE("URL is %s\n", (const char *)csLoadMe);
GetContext()->NormalGetUrl(csLoadMe);
}
}
else {
TRACE("no context!\n");
if (ar.IsStoring())
{
TRACE("Storing\n");
// Hope that ephemeral data were cached, otherwise, no real
// harm done.
ar << m_csEphemeralHistoryAddress;
}
else
{
TRACE("Reading\n");
CString csDontcare;
ar >> csDontcare;
}
}
// Next in line should be a string identifying the client which wrote
// out the information.
// ALL NUMBERS TO BE CONVERTED TO NETWORK BYTE ORDER, SO WORKS ACROSS PLATFORMS.
CString csNetscapeVersion;
if(ar.IsStoring()) {
// Write out our document version number.
// This is initially 2.0
ar << theApp.ResolveAppVersion();
TRACE("App version is %s\n", (const char *)theApp.ResolveAppVersion());
// Write out any other information for a particular version here,
// prepended by the amount of total bytes to be written.
// Hold all integer values (all XP values) to a size that will
//.........这里部分代码省略.........
示例2: get_size
// Return the size of an element (if it only contains data and/or struct elements) checking
// the size of struct children if necessary. If any children are DATA elements with calc'd
// size (or FOR or IF) then -1 is returned.
long get_size(const CXmlTree::CElt &ee, int first /*=0*/, int last /*=999999999*/)
{
long retval = 0;
CXmlTree::CElt child;
int ii;
int bits_used = 0; // Bits used by all consec. bitfields so far (0 if previous elt not a bitfield)
int last_size; // Storage unit size of previous element if a bitfield (1,2,4, or 8) or 0
bool last_down; // Direction for previous bitfield (must be same dirn to be put in same stg unit)
for (child = ee.GetChild(first), ii = first; !child.IsEmpty() && ii < last; ++child, ++ii)
{
CString elt_type = child.GetName();
if (elt_type != "data" && bits_used > 0)
{
// End of bit-field stg unit
ASSERT(last_size == 1 || last_size == 2 || last_size == 4 || last_size == 8);
retval += last_size;
bits_used = 0;
}
if (elt_type == "data")
{
CString ss = child.GetAttr("type");
int data_bits = 0; // bits used in this element (or zero if not a bit-field)
int data_size;
bool data_down;
// Check for bit-field (type is "int")
if (ss.CompareNoCase("int") == 0)
{
data_bits = atoi(child.GetAttr("bits"));
if (data_bits > 0)
{
data_size = atoi(child.GetAttr("len"));
data_down = child.GetAttr("direction") == "down";
}
}
if (bits_used > 0 &&
(data_bits == 0 || // not bit-field
data_size != last_size || // diff size
data_down != last_down || // diff dirn
bits_used + data_bits > data_size*8) // overflow stg unit
)
{
// Previous elt was end of the bit-field stg unit
ASSERT(last_size == 1 || last_size == 2 || last_size == 4 || last_size == 8);
retval += last_size;
bits_used = 0;
}
if (data_bits > 0)
{
// Save info about current bit-field
bits_used += data_bits;
last_size = data_size;
last_down = data_down;
}
else if (ss.CompareNoCase("char") == 0)
{
// Work out the size of a character (normally 1 unless Unicode)
ss = child.GetAttr("format");
if (ss.CompareNoCase("unicode") == 0)
retval += 2;
else
retval += 1;
}
else if (ss.CompareNoCase("date") == 0)
{
// Work out the size of the date field depending on the format
ss = child.GetAttr("format");
if (ss.CompareNoCase("c") == 0)
retval += 4;
else if (ss.CompareNoCase("c51") == 0)
retval += 4;
else if (ss.CompareNoCase("c7") == 0)
retval += 4;
else if (ss.CompareNoCase("cmin") == 0)
retval += 4;
else if (ss.CompareNoCase("c64") == 0)
retval += 8;
else if (ss.CompareNoCase("ole") == 0)
retval += 8;
else if (ss.CompareNoCase("systemtime") == 0)
retval += 16;
else if (ss.CompareNoCase("filetime") == 0)
retval += 8;
else if (ss.CompareNoCase("msdos") == 0)
retval += 4;
else
{
ASSERT(0);
return -1;
}
}
else
{
//.........这里部分代码省略.........
示例3: HookFromOptionNode
//////////////////////////////////////////////////////////////////////////
//
// 위의 AdjustOption 에서 HOOK 노드를 만날경우 이 함수를 호출해서 적용한다.
//
//////////////////////////////////////////////////////////////////////////
BOOL CATCodeMgr::HookFromOptionNode(COptionNode* pNode)
{
BOOL bRetVal = FALSE;
try
{
// 후킹할 주소
COptionNode* pAddrNode = pNode->GetChild(0);
if(pAddrNode==NULL) throw -1;
CHookPoint* pHookPoint = CHookPoint::CreateInstance(pAddrNode->GetValue());
if(pHookPoint==NULL)
{
//MessageBox(m_hContainerWnd, _T("다음의 주소를 후킹하는데 실패했습니다 : ") + pAddrNode->GetValue(), _T("Hook error"), MB_OK);
//continue;
throw -2;
}
m_listHookPoint.push_back(pHookPoint);
// 이 주소에 대한 후킹 명령들 수집
int cnt2 = pNode->GetChildCount();
for(int j=1; j<cnt2; j++)
{
COptionNode* pNode2 = pNode->GetChild(j);
CString strHookValue = pNode2->GetValue();
// 번역 명령
if(strHookValue.CompareNoCase(_T("TRANS"))==0)
{
int cnt3 = pNode2->GetChildCount();
if(cnt3 < 2) continue;
// 인자
//COptionNode* pDistNode = pNode2->GetChild(0);
//if(pDistNode==NULL)
CString strArgScript = pNode2->GetChild(0)->GetValue();
CString strContextName = pNode2->GetChild(1)->GetValue();
CTransCommand* pTransCmd = pHookPoint->AddTransCmd(strArgScript, strContextName);
// 번역 옵션들 수집
for(int k=2; k<cnt3; k++)
{
COptionNode* pNode3 = pNode2->GetChild(k);
CString strTransOption = pNode3->GetValue().MakeUpper();
// 번역방식
if(strTransOption == _T("NOP"))
{
pTransCmd->SetTransMethod(0);
}
else if(strTransOption == _T("PTRCHEAT"))
{
pTransCmd->SetTransMethod(1);
}
else if(strTransOption == _T("OVERWRITE"))
{
pTransCmd->SetTransMethod(2);
if(pNode3->GetChild(_T("IGNORE")) != NULL)
{
pTransCmd->SetIgnoreBufLen(TRUE);
}
}
else if(strTransOption == _T("SOW"))
{
pTransCmd->SetTransMethod(3);
}
// 멀티바이트 / 유니코드 지정
else if(strTransOption == _T("ANSI"))
{
pTransCmd->SetUnicode(FALSE);
}
else if(strTransOption == _T("UNICODE"))
{
pTransCmd->SetUnicode(TRUE);
}
// 모든 일치하는 텍스트 번역
else if(strTransOption == _T("ALLSAMETEXT"))
{
pTransCmd->SetAllSameText(TRUE);
}
// CLIPKOR 옵션
else if(strTransOption == _T("CLIPKOR"))
{
pTransCmd->SetClipKor(TRUE);
}
// CLIPJPN 옵션
else if(strTransOption == _T("CLIPJPN"))
{
pTransCmd->SetClipJpn(TRUE);
}
//.........这里部分代码省略.........
示例4: CompareItems
int CIniEx::CompareItems( CString str1, CString str2 )
{
return str1.CompareNoCase(str2);
}
示例5: OnCbnSelchangeLevelsetcombo
void CUserAcessSetDlg::OnCbnSelchangeLevelsetcombo()
{
if(m_nCurRow==0)
return;
if(m_nCurCol==0)
return;
CString strValue;
strValue=m_FlexGrid.get_TextMatrix(m_nCurRow,m_nCurCol);
CString strSelect;
int nIdext=m_userLeveSetBox.GetCurSel();
if(nIdext>=0)
{
m_userLeveSetBox.GetLBText(nIdext,strSelect);
if(strSelect.CompareNoCase(strValue)==0)
{
return;
}
else
{
int nNewValue=nIdext;
m_FlexGrid.put_TextMatrix(m_nCurRow,m_nCurCol,strSelect);
CString strField;
if(m_nCurCol==6)
strField="mainscreen_level";
if(m_nCurCol==7)
strField="parameter_level";
if(m_nCurCol==8)
strField="outputtable_level";
if(m_nCurCol==9)
strField="graphic_level";
//if(m_nCurCol==10)
// strField="building_level";
if(m_nCurCol==10)
strField="burnhex_level";
if(m_nCurCol==11)
strField="loadconfig_level";
if(m_nCurCol==12)
strField="allscreen_level";
CString strSerial=m_FlexGrid.get_TextMatrix(m_nCurRow,2);
strSerial.TrimLeft();
strSerial.TrimRight();
int nSerial=_wtol(strSerial);
try
{
CppSQLite3DB SqliteDBBuilding;
SqliteDBBuilding.open((UTF8MBSTR)g_strCurBuildingDatabasefilePath);
CString strSql;
strSql.Format(_T("update user_level set "+strField+" = %i where serial_number = %i and username ='%s' and MainBuilding_Name='%s' and Building_Name='%s'"),nNewValue,nSerial,m_strUserName,m_strMainBuilding,m_strSubNetName);
SqliteDBBuilding.execDML((UTF8MBSTR)strSql);
SqliteDBBuilding.closedb();
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
}
}
if(m_nCurCol==12)
{
if(nIdext==0)//enable
{
for(int k=0;k<=12;k++)
{
if (m_nCurRow%2==0)
{
m_FlexGrid.put_Row(m_nCurRow);m_FlexGrid.put_Col(k);m_FlexGrid.put_CellBackColor(COLOR_CELL);
}
else
{
m_FlexGrid.put_Row(m_nCurRow);m_FlexGrid.put_Col(k);m_FlexGrid.put_CellBackColor(RGB(255,255,240));
}
}
}
else//unenable
{
for(int k=0;k<12;k++)
{
m_FlexGrid.put_Row(m_nCurRow);m_FlexGrid.put_Col(k);m_FlexGrid.put_CellBackColor(RGB(215,215,215));
}
}
}
//ReloadUserLevelDB();
}
示例6: if
/*-----------------------------------------------------------------------------
Dynamically configure the location and server for an EC2 instance
-----------------------------------------------------------------------------*/
void CurlBlastDlg::GetEC2Config()
{
log.Trace(_T("GetEC2Config"));
CString server, location, locationKey;
CString userData;
if( GetUrlText(_T("http://169.254.169.254/latest/user-data"), userData) )
{
int pos = 0;
do {
CString token = userData.Tokenize(_T(" &"), pos).Trim();
if( token.GetLength() )
{
int split = token.Find(_T('='), 0);
if( split > 0 )
{
CString key = token.Left(split).Trim();
CString value = token.Mid(split + 1).Trim();
if( key.GetLength() )
{
if( !key.CompareNoCase(_T("wpt_server")) && value.GetLength() )
server = CString(_T("http://")) + value + _T("/work/");
else if( !key.CompareNoCase(_T("wpt_location")) && value.GetLength() )
location = value;
else if( !key.CompareNoCase(_T("wpt_key")) )
locationKey = value;
else if( !key.CompareNoCase(_T("wpt_timeout")) && value.GetLength() )
timeout = _ttol(value);
else if( !key.CompareNoCase(_T("wpt_keep_DNS")) && value.GetLength() )
keepDNS = _ttol(value);
}
}
}
} while(pos > 0);
}
if( location.IsEmpty() )
{
// build the location name automatically from the availability zone
CString zone;
if( GetUrlText(_T("http://169.254.169.254/latest/meta-data/placement/availability-zone"), zone) )
{
int pos = zone.Find('-');
if( pos )
{
pos = zone.Find('-', pos + 1);
if( pos )
{
// figure out the browser version
TCHAR buff[1024];
CRegKey key;
CString ieVer;
if( SUCCEEDED(key.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Internet Explorer"), KEY_READ)) )
{
DWORD len = _countof(buff);
if( SUCCEEDED(key.QueryStringValue(_T("Version"), buff, &len)) )
{
ieVer = buff;
ieVer.Trim();
ULONG ver = _ttol(ieVer);
ieVer.Format(_T("%d"), ver);
location = CString(_T("ec2-")) + zone.Left(pos).Trim() + CString(_T("-IE")) + ieVer;
}
}
}
}
}
}
CString instance;
GetUrlText(_T("http://169.254.169.254/latest/meta-data/instance-id"), instance);
instance = instance.Trim();
log.Trace(_T("EC2 server: %s"), (LPCTSTR)server);
log.Trace(_T("EC2 location: %s"), (LPCTSTR)location);
log.Trace(_T("EC2 locationKey: %s"), (LPCTSTR)locationKey);
log.Trace(_T("EC2 Instance ID: %s"), (LPCTSTR)instance);
if( !server.IsEmpty() )
urlManager.SetHttp(server);
if( !location.IsEmpty() )
urlManager.SetHttpLocation(location);
if( !locationKey.IsEmpty() )
urlManager.SetHttpKey(locationKey);
if( !instance.IsEmpty() )
urlManager.SetHttpEC2Instance(instance);
// force EC2 to use the current OS user account
useCurrentAccount = 1;
}
示例7: OnInitDialog
BOOL CEditPropMergeLogTemplate::OnInitDialog()
{
CResizableStandAloneDialog::OnInitDialog();
CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
ExtendFrameIntoClientArea(IDC_DWM);
m_aeroControls.SubclassControl(this, IDC_PROPRECURSIVE);
m_aeroControls.SubclassOkCancelHelp(this);
SetDlgItemText(IDC_TITLEHINT, CString(MAKEINTRESOURCE(IDS_EDITPROPS_MERGETITLEHINT)));
SetDlgItemText(IDC_TITLEHINTREVERSE, CString(MAKEINTRESOURCE(IDS_EDITPROPS_MERGETITLEHINTREVERSE)));
SetDlgItemText(IDC_MSGHINT, CString(MAKEINTRESOURCE(IDS_EDITPROPS_MERGEMSGHINT)));
for (auto it = m_properties.begin(); it != m_properties.end(); ++it)
{
if (it->second.isinherited)
continue;
if (it->first.compare(PROJECTPROPNAME_MERGELOGTEMPLATETITLE) == 0)
{
CString sTitle = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
sTitle.Replace(L"\n", L"\r\n");
SetDlgItemText(IDC_TITLE, sTitle);
}
else if (it->first.compare(PROJECTPROPNAME_MERGELOGTEMPLATEREVERSETITLE) == 0)
{
CString sRevTitle = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
sRevTitle.Replace(L"\n", L"\r\n");
SetDlgItemText(IDC_TITLEREVERSE, sRevTitle);
}
else if (it->first.compare(PROJECTPROPNAME_MERGELOGTEMPLATEMSG) == 0)
{
CString sMsg = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
sMsg.Replace(L"\n", L"\r\n");
SetDlgItemText(IDC_MSG, sMsg);
}
else if (it->first.compare(PROJECTPROPNAME_MERGELOGTEMPLATETITLEBOTTOM) == 0)
{
CString val = CUnicodeUtils::StdGetUnicode(it->second.value).c_str();
CheckDlgButton(IDC_TITLEBOTTOM, ((val.CompareNoCase(L"true") == 0) || (val.CompareNoCase(L"yes") == 0)));
}
}
CString sWindowTitle;
GetWindowText(sWindowTitle);
CAppUtils::SetWindowTitle(m_hWnd, m_pathList.GetCommonRoot().GetUIPathString(), sWindowTitle);
GetDlgItem(IDC_PROPRECURSIVE)->EnableWindow(m_bFolder || m_bMultiple);
GetDlgItem(IDC_PROPRECURSIVE)->ShowWindow(m_bRevProps ? SW_HIDE : SW_SHOW);
AdjustControlSize(IDC_PROPRECURSIVE);
AdjustControlSize(IDC_TITLEBOTTOM);
AddAnchor(IDC_TITLEHINT, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_TITLE, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_TITLEHINTREVERSE, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_TITLEREVERSE, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_MSGHINT, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_MSG, TOP_LEFT, BOTTOM_RIGHT);
AddAnchor(IDC_DWM, BOTTOM_LEFT);
AddAnchor(IDC_TITLEBOTTOM, BOTTOM_LEFT, BOTTOM_RIGHT);
AddAnchor(IDC_PROPRECURSIVE, BOTTOM_LEFT, BOTTOM_RIGHT);
AddAnchor(IDOK, BOTTOM_RIGHT);
AddAnchor(IDCANCEL, BOTTOM_RIGHT);
AddAnchor(IDHELP, BOTTOM_RIGHT);
EnableSaveRestore(L"EditPropMergeLogTemplate");
GetDlgItem(IDC_TITLE)->SetFocus();
return FALSE;
}
示例8:
// Process as a HTTPMessage (Discovery)
bool
WebServiceServer::ProcessGet(HTTPMessage* p_message)
{
CString absPath = p_message->GetAbsolutePath();
CrackedURL& crack = p_message->GetCrackedURL();
bool hasWsdlParam = crack.HasParameter("wsdl");
// The following situations are processed as requesting the WSDL
// 1: URL/servicename.wsdl
// 2: URL/servicename<postfix>?wsdl
// 3: URL/servicename?wsdl
CString wsdlBase = m_absPath + m_name;
CString wsdlPath = wsdlBase + ".wsdl";
CString basePage = m_absPath + m_name + m_servicePostfix;
CString baseWsdl = basePage + "?wsdl";
if((wsdlPath.CompareNoCase(absPath) == 0) ||
(wsdlBase.CompareNoCase(absPath) == 0 && hasWsdlParam) ||
(basePage.CompareNoCase(absPath) == 0 && hasWsdlParam) ||
(baseWsdl.CompareNoCase(absPath) == 0 && hasWsdlParam) )
{
p_message->Reset();
CString wsdlFileInWebroot = m_wsdl->GetWSDLFilename();
p_message->GetFileBuffer()->SetFileName(wsdlFileInWebroot);
p_message->SetContentType("text/xml");
m_httpServer->SendResponse(p_message);
return true;
}
// 4: URL/servicename.aspcxx
// 5: URL/Servicename<postfix>
// ASPCXX = ASP for C++
if(basePage.CompareNoCase(absPath) == 0)
{
p_message->Reset();
CString pagina = m_wsdl->GetServicePage();
p_message->AddBody((void*)pagina.GetString(),pagina.GetLength());
p_message->SetContentType("text/html");
m_httpServer->SendResponse(p_message);
return true;
}
// 6: URL/servicename.<operation>.html
if(absPath.Right(5).CompareNoCase(".html") == 0)
{
// Knock of the ".html"
absPath = absPath.Left(absPath.GetLength() - 5);
// Knock of the basepath
if(absPath.Left(m_absPath.GetLength()).CompareNoCase(m_absPath) == 0)
{
absPath = absPath.Mid(m_absPath.GetLength());
// Knock of the servicename
if(absPath.Left(m_name.GetLength()).CompareNoCase(m_name) == 0)
{
absPath = absPath.Mid(m_name.GetLength());
// Knock of the period
if(absPath.GetAt(0) == '.')
{
absPath = absPath.Mid(1);
// Naming convention applies
p_message->Reset();
CString pagina = m_wsdl->GetOperationPage(absPath,m_httpServer->GetHostname());
if(!pagina.IsEmpty())
{
p_message->AddBody((void*)pagina.GetString(),pagina.GetLength());
p_message->SetContentType("text/html");
m_httpServer->SendResponse(p_message);
return true;
}
}
}
}
}
// Preset an error
p_message->SetStatus(HTTP_STATUS_BAD_REQUEST);
// Maybe luck in the next handler
return false;
}
示例9: OnNavigate
BOOL CKscMainDlg::OnNavigate(const CString& strNavigate)
{
BOOL retval = FALSE;
int nTabIndex = -1;
if (!strNavigate.CompareNoCase(KCLEARNS_ONEKEY) ||
!strNavigate.CompareNoCase(BKSFNS_SYSOPT_CLR_ONEKEY))
{
nTabIndex = 0;
}
else if (!strNavigate.CompareNoCase(KCLEARNS_TRASHCLEANER) ||
!strNavigate.CompareNoCase(BKSFNS_SYSOPT_CLR_RUBBISH))
{
nTabIndex = 1;
}
else if (!strNavigate.CompareNoCase(KCLEARNS_TRACKCLEANER) ||
!strNavigate.CompareNoCase(BKSFNS_SYSOPT_CLR_HENJI))
{
nTabIndex = 2;
}
else if (!strNavigate.CompareNoCase(KCLEARNS_REGCLEANER) ||
!strNavigate.CompareNoCase(BKSFNS_SYSOPT_CLR_REG))
{
nTabIndex = 3;
}
else if (!strNavigate.CompareNoCase(KCLEARNS_BIGCLEANER) ||
!strNavigate.CompareNoCase(BKSFNS_SYSOPT_BIG_FILE))
{
nTabIndex = 4;
}
else if (!strNavigate.CompareNoCase(KCLEARNS_SYSTEMSLIM) ||
!strNavigate.CompareNoCase(BKSFNS_SYSOPT_CLR_SHOUSHEN))
{
nTabIndex = 5;
}
else if (!strNavigate.CompareNoCase(L"clrrubscan"))
{
nTabIndex = 1;
m_bExamNeedScan = TRUE;
}
if (-1 == nTabIndex)
goto clean0;
retval = SetTabCurSel(IDC_TAB_MAIN, nTabIndex);
clean0:
return retval;
}
示例10: OnOpenDocument
BOOL CHandoutDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
/* open file */
CFile File;
if( File.Open( lpszPathName, CFile::modeRead ) == FALSE )
{
AfxMessageBox( "Cannot open handout file", MB_ICONERROR );
return FALSE;
}
/* load the file into a buffer */
//determine file size
char* pszBuffer = NULL;
DWORD dwLength = File.GetLength();
if( dwLength == 0 )
{
AfxMessageBox( "File is empty", MB_ICONERROR );
return FALSE;
}
//allocate a buffer
pszBuffer = new char[dwLength+1];
if( pszBuffer == NULL )
{
AfxMessageBox( "Cannot allocate buffer", MB_ICONERROR );
return FALSE;
}
//load the whole file
if( File.Read( pszBuffer, dwLength ) < dwLength )
{
delete[] pszBuffer;
AfxMessageBox( "Unexpected end of file", MB_ICONERROR );
return FALSE;
}
//add a terminator at the end of the string
pszBuffer[dwLength] = '\0';
/* parse the file */
CParseBuffer Buffer(pszBuffer);
delete[] pszBuffer;
//read in the rest of the file
Buffer.IgnoreLineFeeds();
while( Buffer.IsEmpty() == FALSE )
{
CString strSectionType = Buffer.ExtractUnquotedString();
CString strSection = Buffer.ExtractSurroundedString( '{', '}' );
if( Buffer.IsUnderflow() == FALSE && Buffer.IsParseError() == FALSE )
{
if( strSectionType.CompareNoCase( "Handout" ) == 0 ) ParseHandoutSection(strSection); else
AfxMessageBox( CString("Warning Unknown section type: ") + strSectionType );
}
else
{
AfxMessageBox( "Invalid file format", MB_ICONERROR );
return FALSE;
}
}
return TRUE;
}
示例11: GetSubFileNames
void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CString load_ext_list, CAtlArray<SubFile>& ret)
{
ret.RemoveAll();
fn.Replace('\\', '/');
bool fWeb = false;
{
//int i = fn.Find(_T("://"));
int i = fn.Find(_T("http://"));
if(i > 0) {fn = _T("http") + fn.Mid(i); fWeb = true;}
}
int l = fn.GetLength(), l2 = l;
l2 = fn.ReverseFind('.');
l = fn.ReverseFind('/') + 1;
if(l2 < l) l2 = l;
CString orgpath = fn.Left(l);
CString title = fn.Mid(l, l2-l);
CString filename = title + _T(".nooneexpectsthespanishinquisition");
ExtSupport ext_support;
if (!ext_support.init(load_ext_list))
{
XY_LOG_INFO(_T("unexpected error"));
return;
}
if(!fWeb)
{
WIN32_FIND_DATA wfd;
for(size_t k = 0; k < paths.GetCount(); k++)
{
CString path = paths[k];
path.Replace('\\', '/');
l = path.GetLength();
if(l > 0 && path[l-1] != '/') path += '/';
if(path.Find(':') == -1 && path.Find(_T("\\\\")) != 0) path = orgpath + path;
path.Replace(_T("/./"), _T("/"));
path.Replace('/', '\\');
CAtlList<CString> sl;
bool fEmpty = true;
HANDLE hFile = FindFirstFile(path + title + _T(".*"), &wfd);
if(hFile != INVALID_HANDLE_VALUE)
{
do
{
if(filename.CompareNoCase(wfd.cFileName) != 0)
{
fEmpty = false;
sl.AddTail(wfd.cFileName);
}
}
while(FindNextFile(hFile, &wfd));
FindClose(hFile);
}
if(fEmpty) continue;
POSITION pos = sl.GetHeadPosition();
while(pos)
{
const CString& fn = sl.GetNext(pos);
int l = fn.ReverseFind('.');
CString ext = fn.Mid(l+1);
int ext_order = ext_support.ext_support_order(ext);
if (ext_order>-1)
{
SubFile f;
f.full_file_name = path + fn;
int l2 = fn.Find('.');
if (l2==l)
{
f.extra_name = "";
}
else
{
f.extra_name = fn.Mid(l2+1, l-l2-1);
}
f.ext_order = ext_order;
f.path_order = k;
ret.Add(f);
}
}
}
}
else if(l > 7)
{
CWebTextFile wtf; // :)
if(wtf.Open(orgpath + title + WEBSUBEXT))
//.........这里部分代码省略.........
示例12: FilterTreeReloadTree
void CSharedDirsTreeCtrl::FilterTreeReloadTree(){
m_bCreatingTree = true;
// store current selection
CDirectoryItem* pOldSelectedItem = NULL;
if (GetSelectedFilter() != NULL){
pOldSelectedItem = GetSelectedFilter()->CloneContent();
}
// create the tree substructure of directories we want to show
POSITION pos = m_pRootDirectoryItem->liSubDirectories.GetHeadPosition();
while (pos != NULL){
CDirectoryItem* pCurrent = m_pRootDirectoryItem->liSubDirectories.GetNext(pos);
// clear old items
DeleteChildItems(pCurrent);
switch( pCurrent->m_eItemType ){
case SDI_ALL:
break;
case SDI_INCOMING:{
CString strMainIncDir = thePrefs.GetIncomingDir();
if (strMainIncDir.Right(1) == "\\"){
strMainIncDir = strMainIncDir.Left(strMainIncDir.GetLength()-1);
}
if (thePrefs.GetCatCount() > 1){
m_strliCatIncomingDirs.RemoveAll();
for (int i = 0; i < thePrefs.GetCatCount(); i++){
Category_Struct* pCatStruct = thePrefs.GetCategory(i);
if (pCatStruct != NULL){
CString strCatIncomingPath = pCatStruct->incomingpath;
if (strCatIncomingPath.Right(1) == "\\"){
strCatIncomingPath = strCatIncomingPath.Left(strCatIncomingPath.GetLength()-1);
}
if (!strCatIncomingPath.IsEmpty() && strCatIncomingPath.CompareNoCase(strMainIncDir) != 0
&& m_strliCatIncomingDirs.Find(strCatIncomingPath) == NULL)
{
m_strliCatIncomingDirs.AddTail(strCatIncomingPath);
CString strName = strCatIncomingPath;
if (strName.Right(1) == "\\"){
strName = strName.Left(strName.GetLength()-1);
}
strName = strName.Right(strName.GetLength() - (strName.ReverseFind('\\')+1));
CDirectoryItem* pCatInc = new CDirectoryItem(strCatIncomingPath, 0, SDI_CATINCOMING);
pCatInc->m_htItem = InsertItem(TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE, strName, 5, 5, 0, 0, (LPARAM)pCatInc, pCurrent->m_htItem, TVI_LAST);
pCurrent->liSubDirectories.AddTail(pCatInc);
}
}
}
}
break;
}
case SDI_TEMP:
if (thePrefs.GetCatCount() > 1){
for (int i = 0; i < thePrefs.GetCatCount(); i++){
Category_Struct* pCatStruct = thePrefs.GetCategory(i);
if (pCatStruct != NULL){
//temp dir
CDirectoryItem* pCatTemp = new CDirectoryItem(CString(""), 0, SDI_TEMP, i);
pCatTemp->m_htItem = InsertItem(TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE, CString(pCatStruct->title), 3, 3, 0, 0, (LPARAM)pCatTemp, pCurrent->m_htItem, TVI_LAST);
pCurrent->liSubDirectories.AddTail(pCatTemp);
}
}
}
break;
case SDI_DIRECTORY:
// add subdirectories
FilterTreeAddSubDirectories(pCurrent, m_strliSharedDirs);
break;
default:
ASSERT( false );
}
}
// restore selection
HTREEITEM htOldSection;
if (pOldSelectedItem != NULL && (htOldSection = m_pRootDirectoryItem->FindItem(pOldSelectedItem)) != NULL){
Select(htOldSection, TVGN_CARET);
EnsureVisible(htOldSection);
}
else if( GetSelectedItem() == NULL && !m_pRootDirectoryItem->liSubDirectories.IsEmpty()){
Select(m_pRootDirectoryItem->liSubDirectories.GetHead()->m_htItem, TVGN_CARET);
}
delete pOldSelectedItem;
m_bCreatingTree = false;
}
示例13: Reload
void CSharedDirsTreeCtrl::Reload(bool bForce){
bool bChanged = false;
if (!bForce){
// check for changes in shared dirs
if (thePrefs.shareddir_list.GetCount() == m_strliSharedDirs.GetCount()){
POSITION pos = m_strliSharedDirs.GetHeadPosition();
POSITION pos2 = thePrefs.shareddir_list.GetHeadPosition();
while (pos != NULL && pos2 != NULL){
CString str1 = m_strliSharedDirs.GetNext(pos);
CString str2 = thePrefs.shareddir_list.GetNext(pos2);
if (str1.Right(1) == "\\"){
str1 = str1.Left(str1.GetLength()-1);
}
if (str2.Right(1) == "\\"){
str2 = str2.Left(str2.GetLength()-1);
}
if (str1.CompareNoCase(str2) != 0){
bChanged = true;
break;
}
}
}
else
bChanged = true;
// check for changes in categories incoming dirs
CString strMainIncDir = thePrefs.GetIncomingDir();
if (strMainIncDir.Right(1) == _T("\\"))
strMainIncDir = strMainIncDir.Left(strMainIncDir.GetLength()-1);
CStringList strliFound;
for (int i = 0; i < thePrefs.GetCatCount(); i++){
Category_Struct* pCatStruct = thePrefs.GetCategory(i);
if (pCatStruct != NULL){
CString strCatIncomingPath = pCatStruct->incomingpath;
if (strCatIncomingPath.Right(1) == _T("\\"))
strCatIncomingPath = strCatIncomingPath.Left(strCatIncomingPath.GetLength()-1);
if (!strCatIncomingPath.IsEmpty() && strCatIncomingPath.CompareNoCase(strMainIncDir) != 0
&& strliFound.Find(strCatIncomingPath) == NULL)
{
POSITION pos = m_strliCatIncomingDirs.Find(strCatIncomingPath);
if (pos != NULL){
strliFound.AddTail(strCatIncomingPath);
}
else{
bChanged = true;
break;
}
}
}
}
if (strliFound.GetCount() != m_strliCatIncomingDirs.GetCount())
bChanged = true;
}
if (bChanged || bForce){
FetchSharedDirsList();
FilterTreeReloadTree();
Expand(m_pRootUnsharedDirectries->m_htItem, TVE_COLLAPSE); // collapsing is enough to sync for the filtetree, as all items are recreated on every expanding
}
}
示例14: parseOrbitDownloadsList
void parseOrbitDownloadsList(const CString& sDldList, OrbitDownloadsArray& arrDownloads)
{
CString sMsg;
if (sDldList.IsEmpty())
return;
CCsvParser cpParser;
cpParser.Init(sDldList, "\"", ",");
CString sContent;
while (cpParser.ParseNextRecord()) {
int nFieldNumber = -1;
CString sValue;
TOrbitDownload tOrbitDownload;
while (cpParser.GetNextField(sValue)) {
++nFieldNumber;
if (nFieldNumber == 0) {
tOrbitDownload.sPath = sValue;
}
if (nFieldNumber == 1) {
tOrbitDownload.sFile = sValue;
}
if (nFieldNumber == 2) {
sValue.Trim();
UINT64 uFileSize;
if (sscanf_s((const char*)sValue, "%I64u", &uFileSize) != 1) {
sMsg = LS (L_CANT_PARSE_ORBIT_DOWNLOAD_LIST);
throw std::runtime_error((LPCTSTR)sMsg);
}
char szCompletedSize[16] = {0,};
sprintf_s(szCompletedSize, 16, "%I64u", uFileSize);
if (sValue.CompareNoCase(szCompletedSize) != 0) {
sMsg = LS (L_CANT_PARSE_ORBIT_DOWNLOAD_LIST);
throw std::runtime_error((LPCTSTR)sMsg);
}
tOrbitDownload.uFileSize = uFileSize;
}
if (nFieldNumber == 4) {
tOrbitDownload.sUrl = sValue;
}
if (nFieldNumber == 10) {
sValue.Trim();
if (!sValue.IsEmpty())
tOrbitDownload.bIsComplete = true;
}
}
if (nFieldNumber < 10) {
sMsg = LS (L_CANT_PARSE_ORBIT_DOWNLOAD_LIST);
throw std::runtime_error((LPCTSTR)sMsg);
}
if (tOrbitDownload.bIsComplete)
arrDownloads.Add(tOrbitDownload);
}
int nFieldNumber = -1;
CString sValue;
TOrbitDownload tOrbitDownload;
while (cpParser.GetNextField(sValue)) {
++nFieldNumber;
if (nFieldNumber == 0) {
tOrbitDownload.sPath = sValue;
}
if (nFieldNumber == 1) {
tOrbitDownload.sFile = sValue;
}
if (nFieldNumber == 2) {
sValue.Trim();
UINT64 uFileSize;
if (sscanf_s((const char*)sValue, "%I64u", &uFileSize) != 1) {
sMsg = LS (L_CANT_PARSE_ORBIT_DOWNLOAD_LIST);
throw std::runtime_error((LPCTSTR)sMsg);
}
char szCompletedSize[16] = {0,};
sprintf_s(szCompletedSize, 16, "%I64u", uFileSize);
if (sValue.CompareNoCase(szCompletedSize) != 0) {
sMsg = LS (L_CANT_PARSE_ORBIT_DOWNLOAD_LIST);
throw std::runtime_error((LPCTSTR)sMsg);
}
tOrbitDownload.uFileSize = uFileSize;
}
if (nFieldNumber == 4) {
tOrbitDownload.sUrl = sValue;
}
if (nFieldNumber == 10) {
sValue.Trim();
if (!sValue.IsEmpty())
//.........这里部分代码省略.........
示例15: CheckEqualOrSubDir
BOOL CheckEqualOrSubDir(LPCTSTR szFirstDir,LPCTSTR szSecondDir,BOOL &bEqualDir, BOOL &bSubDir)
{
bEqualDir = FALSE;
bSubDir = FALSE;
WCHAR szFirstShortDir[MAX_PATH];
WCHAR szSecondShortDir[MAX_PATH];
memset(szFirstShortDir,0,sizeof(szFirstShortDir));
memset(szSecondShortDir,0,sizeof(szSecondShortDir));
if( FALSE == GetShortPathName(szFirstDir,szFirstShortDir,sizeof(szFirstShortDir)) )
{
TRACE(L"\nGetShortPathName %s error in CheckEqualOrSubDir",szFirstDir);
}
if( FALSE == GetShortPathName(szSecondDir,szSecondShortDir,sizeof(szSecondShortDir)) )
{
TRACE(L"\nGetShortPathName %s error in CheckEqualOrSubDir",szSecondDir);
}
CString strFirstDir;
strFirstDir = szFirstShortDir;
CString strSecondDir;
strSecondDir = szSecondShortDir;
strFirstDir.TrimRight(L'\\');
strFirstDir = strFirstDir + "\\";
strSecondDir.TrimRight(L'\\');
strSecondDir = strSecondDir + "\\";
if(strFirstDir.GetLength() < strSecondDir.GetLength() )
{
bEqualDir = FALSE;
bSubDir = FALSE;
return TRUE;
}
else if(strFirstDir.GetLength() == strSecondDir.GetLength() )
{
if( 0 == strFirstDir.CompareNoCase(strSecondDir) )
{
bEqualDir = TRUE;
bSubDir = FALSE;
return TRUE;
}
else
{
bEqualDir = FALSE;
bSubDir = FALSE;
return TRUE;
}
}
else if(strFirstDir.GetLength() > strSecondDir.GetLength())
{
if( 0 == strFirstDir.Left(strSecondDir.GetLength()).CompareNoCase(strSecondDir) )
{
bEqualDir = FALSE;
bSubDir = TRUE;
return TRUE;
}
else
{
bEqualDir = FALSE;
bSubDir = FALSE;
return TRUE;
}
}
return TRUE;
}