本文整理汇总了C++中CStdStringW::Left方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdStringW::Left方法的具体用法?C++ CStdStringW::Left怎么用?C++ CStdStringW::Left使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdStringW
的用法示例。
在下文中一共展示了CStdStringW::Left方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestTOCFields
void TestDocReader::TestTOCFields()
{
DocReader dr;
dr.OpenFile(TEST_TOC_DOC);
CStdStringW sGot = dr.GetMainDocumentText();
CStdStringW sExp = L"Table of Contents\rTable of Contents\t1\rNote\t4\rAppendix B – Calculation of font (FTC) and language (LID)\t178\r\r";
for (unsigned int i=0; i<(x64_int_cast)sGot.size(); i++)
{
switch (sGot[i])
{
case 19:
OutputDebugString(_T("<start>"));
break;
case 20:
OutputDebugString(_T("<result>"));
break;
case 21:
OutputDebugString(_T("<end>"));
break;
default:
{
CStdStringW s = sGot.Mid(i,1);
OutputDebugString(CStdString(s));
}
}
}
assertTest(sGot.Left(sExp.length()) == sExp);
}
示例2: TestExtractBodyTextOnly
void TestDocReader::TestExtractBodyTextOnly()
{
DocReader dr;
dr.OpenFile(TEST_REALLY_COMPLEX_DOC);
CStdStringW sDocText = dr.GetMainDocumentText();
assertTest(sDocText.Left(9) == L"Once upon");
assertTest(sDocText.Right(12) == L"ever after.\r");
assertMessage(sDocText.Find(L"Nested") != -1, _T("expected to get the nested table contents, but didnt"));
assertMessage(sDocText.Find(L"Four") != -1, _T("expected to get the table contents, but didnt"));
assertMessage(sDocText.Find(L"a comment") == -1, _T("didnt expect to get the comment contents, but did"));
assertMessage(sDocText.Find(L"header") == -1, _T("didnt expect to get the header contents, but did"));
assertMessage(sDocText.Find(L"footer") == -1, _T("didnt expect to get the footer contents, but did"));
assertMessage(sDocText.Find(L"text box") == -1, _T("didnt expect to get the text box contents, but did"));
assertMessage(sDocText.Find(L"MERGEFORMAT") == -1, _T("didnt expect to get the field code contents, but did"));
assertMessage(sDocText.Find(L"allsorts") != -1, _T("expected to get the field result contents, but didny"));
assertMessage(sDocText.Find(L"be footnote") == -1, _T("didnt expect to get the footnote, but did"));
assertMessage(sDocText.Find(L"Line Break\013") != -1, _T("expected char 11 as line break"));
assertMessage(sDocText.Find(L"Section Break\014") != -1, _T("expected char 12 as section break"));
// assertMessage(sDocText.Find(L"Symbol Char\050") != -1, _T("expected char 40 as symbol char"));
assertMessage(sDocText.Find(L"NonBreakSpace\240char") != -1, _T("expected char 160 as non breaking space"));
//assertMessage(sDocText.Find(L"EnDash\226") != -1, _T("expected char 150 as En dash"));
//assertMessage(sDocText.Find(L"EnDash\227") != -1, _T("expected char 150 as Em dash"));
// assertMessage(sDocText.Find(L"the \025 document") != -1, _T("expected char 21 as field char"));
assertMessage(sDocText.Find(L"One\007Two") != -1, _T("expected char 7 as cell char"));
}
示例3: RecalcLabelPosition
void CGUIEditControl::RecalcLabelPosition()
{
if (!m_label.font) return;
// ensure that our cursor is within our width
ValidateCursor();
CStdStringW text = GetDisplayedText();
m_textWidth = m_textLayout2.GetTextWidth(text + L'|');
m_textHeight = m_textLayout2.GetTextHeight(1);
float beforeCursorWidth = m_textLayout2.GetTextWidth(text.Left(m_cursorPos));
float afterCursorWidth = m_textLayout2.GetTextWidth(text.Left(m_cursorPos) + L'|');
float leftTextWidth = m_textLayout.GetTextWidth();
float maxTextWidth = m_width - m_label.offsetX*2;
if (leftTextWidth > 0)
maxTextWidth -= leftTextWidth + spaceWidth;
// if skinner forgot to set height :p
if (m_height == 0)
m_height = 2*m_label.font->GetTextHeight(1);
if (m_textWidth > maxTextWidth)
{ // we render taking up the full width, so make sure our cursor position is
// within the render window
if (m_textOffset + afterCursorWidth > maxTextWidth)
{
// move the position to the left (outside of the viewport)
m_textOffset = maxTextWidth - afterCursorWidth;
}
else if (m_textOffset + beforeCursorWidth < 0) // offscreen to the left
{
// otherwise use original position
m_textOffset = -beforeCursorWidth;
}
else if (m_textOffset + m_textWidth < maxTextWidth)
{ // we have more text than we're allowed, but we aren't filling all the space
m_textOffset = maxTextWidth - m_textWidth;
}
}
else
m_textOffset = 0;
}
示例4: TestTableChanges
void TestDocReader::TestTableChanges()
{
DocReader dr;
dr.OpenFile(TEST_TABLE_TC_DOC);
CStdStringW sGot = dr.GetMainDocumentText();
CStdStringW sExp = L"Some stuff before the table\r\rA\07e\07d\07d\07c\07B\07C";
assertTest(sGot.Left(sExp.length()) == sExp);
}
示例5: UpdateMenu
void CAcceleratorManager::UpdateMenu(HMENU menu)
{
int count = GetMenuItemCount(menu);
MENUITEMINFO info;
wchar_t ss[128];
ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info);
info.fMask = MIIM_ID | MIIM_SUBMENU;
for(int i = 0; i < count; i++) {
GetMenuItemInfo(menu, i, TRUE, &info);
if(info.hSubMenu != NULL) {
UpdateMenu(info.hSubMenu);
} else {
if(info.wID != -1) {
MENUITEMINFOW info2;
ZeroMemory(&info2, sizeof(info2));
info2.cbSize = sizeof(info2);
info2.fMask = MIIM_STRING;
info2.dwTypeData = ss;
info2.cch = 128;
GetMenuItemInfoW(menu, i, MF_BYPOSITION, &info2);
CStdStringW str = ss;
int index = str.Find('\t');
if(index != -1)
str = str.Left(index);
CMapWordToCCmdAccelOb::iterator it = m_mapAccelTable.find(info.wID);
if(it != m_mapAccelTable.end()) {
CCmdAccelOb *o = it->second;
if(o->m_Accels.begin() != o->m_Accels.end()) {
std::list<CAccelsOb*>::iterator j = o->m_Accels.begin();
CAccelsOb *accel = *j;
CStdString s;
accel->GetString(s);
str += "\t";
str += s;
}
}
if(str != ss)
ModifyMenuW(menu, i, MF_BYPOSITION | MF_STRING, info.wID, str);
}
}
}
}
示例6: CreateFileW
bool CWIN32Util::IsUsbDevice(const CStdStringW &strWdrive)
{
CStdStringW strWDevicePath;
strWDevicePath.Format(L"\\\\.\\%s",strWdrive.Left(2));
HANDLE deviceHandle = CreateFileW(
strWDevicePath.c_str(),
0, // no access to the drive
FILE_SHARE_READ | // share mode
FILE_SHARE_WRITE,
NULL, // default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL); // do not copy file attributes
if(deviceHandle == INVALID_HANDLE_VALUE)
return false;
// setup query
STORAGE_PROPERTY_QUERY query;
memset(&query, 0, sizeof(query));
query.PropertyId = StorageDeviceProperty;
query.QueryType = PropertyStandardQuery;
// issue query
DWORD bytes;
STORAGE_DEVICE_DESCRIPTOR devd;
STORAGE_BUS_TYPE busType = BusTypeUnknown;
if (DeviceIoControl(deviceHandle,
IOCTL_STORAGE_QUERY_PROPERTY,
&query, sizeof(query),
&devd, sizeof(devd),
&bytes, NULL))
{
busType = devd.BusType;
}
CloseHandle(deviceHandle);
return BusTypeUsb == busType;
}
示例7: GetLogicalDriveStringsW
void CWIN32Util::GetDrivesByType(VECSOURCES &localDrives, Drive_Types eDriveType, bool bonlywithmedia)
{
WCHAR* pcBuffer= NULL;
DWORD dwStrLength= GetLogicalDriveStringsW( 0, pcBuffer );
if( dwStrLength != 0 )
{
CMediaSource share;
dwStrLength+= 1;
pcBuffer= new WCHAR [dwStrLength];
GetLogicalDriveStringsW( dwStrLength, pcBuffer );
int iPos= 0;
WCHAR cVolumeName[100];
do{
int nResult = 0;
cVolumeName[0]= L'\0';
CStdStringW strWdrive = pcBuffer + iPos;
UINT uDriveType= GetDriveTypeW( strWdrive.c_str() );
// don't use GetVolumeInformation on fdd's as the floppy controller may be enabled in Bios but
// no floppy HW is attached which causes huge delays.
if(!strWdrive.Left(2).Equals(L"A:") && !strWdrive.Left(2).Equals(L"B:"))
nResult= GetVolumeInformationW( strWdrive.c_str() , cVolumeName, 100, 0, 0, 0, NULL, 25);
if(nResult == 0 && bonlywithmedia)
{
iPos += (wcslen( pcBuffer + iPos) + 1 );
continue;
}
share.strPath= share.strName= "";
bool bUseDCD= false;
if( uDriveType > DRIVE_UNKNOWN &&
(( eDriveType == ALL_DRIVES && (uDriveType == DRIVE_FIXED || uDriveType == DRIVE_REMOTE || uDriveType == DRIVE_CDROM || uDriveType == DRIVE_REMOVABLE )) ||
( eDriveType == LOCAL_DRIVES && (uDriveType == DRIVE_FIXED || uDriveType == DRIVE_REMOTE)) ||
( eDriveType == REMOVABLE_DRIVES && ( uDriveType == DRIVE_REMOVABLE )) ||
( eDriveType == DVD_DRIVES && ( uDriveType == DRIVE_CDROM ))))
{
//share.strPath = strWdrive;
g_charsetConverter.wToUTF8(strWdrive, share.strPath);
if( cVolumeName[0] != L'\0' )
g_charsetConverter.wToUTF8(cVolumeName, share.strName);
if( uDriveType == DRIVE_CDROM && nResult)
{
// Has to be the same as auto mounted devices
share.strStatus = share.strName;
share.strName = share.strPath;
share.m_iDriveType= CMediaSource::SOURCE_TYPE_LOCAL;
bUseDCD= true;
}
else
{
// Lets show it, like Windows explorer do... TODO: sorting should depend on driver letter
switch(uDriveType)
{
case DRIVE_CDROM:
share.strName.Format( "%s (%s)", share.strPath, g_localizeStrings.Get(218));
break;
case DRIVE_REMOVABLE:
if(share.strName.IsEmpty())
share.strName.Format( "%s (%s)", g_localizeStrings.Get(437), share.strPath);
break;
case DRIVE_UNKNOWN:
share.strName.Format( "%s (%s)", share.strPath, g_localizeStrings.Get(13205));
break;
default:
if(share.strName.empty())
share.strName = share.strPath;
else
share.strName.Format( "%s (%s)", share.strPath, share.strName);
break;
}
}
share.strName.Replace(":\\",":");
share.strPath.Replace(":\\",":");
share.m_ignore= true;
if( !bUseDCD )
{
share.m_iDriveType= (
( uDriveType == DRIVE_FIXED ) ? CMediaSource::SOURCE_TYPE_LOCAL :
( uDriveType == DRIVE_REMOTE ) ? CMediaSource::SOURCE_TYPE_REMOTE :
( uDriveType == DRIVE_CDROM ) ? CMediaSource::SOURCE_TYPE_DVD :
( uDriveType == DRIVE_REMOVABLE ) ? CMediaSource::SOURCE_TYPE_REMOVABLE :
CMediaSource::SOURCE_TYPE_UNKNOWN );
}
AddOrReplace(localDrives, share);
}
iPos += (wcslen( pcBuffer + iPos) + 1 );
} while( wcslen( pcBuffer + iPos ) > 0 );
delete[] pcBuffer;
}
}
示例8: GetLongPathName
DWORD GetLongPathName (CStdStringW strShortPath, CStdStringW &strLongPath)
{
int iFound = strShortPath.ReverseFind (L'\\');
if (iFound > 1)
{
// recurse to peel off components
//
if (GetLongPathName(strShortPath.Left (iFound), strLongPath) > 0)
{
strLongPath += L'\\';
if (strShortPath.Right(1) != L"\\")
{
HANDLE hFind;
if (g_bIsNT)
{
WIN32_FIND_DATAW findData;
// append the long component name to the path
//
if (INVALID_HANDLE_VALUE != (hFind = ::FindFirstFileW (strShortPath, &findData)))
{
strLongPath += findData.cFileName;
::FindClose (hFind);
}
else
{
// if FindFirstFile fails, return the error code
//
strLongPath.Empty();
return 0;
}
}
else
{
WIN32_FIND_DATAA findData;
// append the long component name to the path
//
if (INVALID_HANDLE_VALUE != (hFind = ::FindFirstFileA (CStdStringA (strShortPath), &findData)))
{
strLongPath += findData.cFileName;
::FindClose (hFind);
}
else
{
// if FindFirstFile fails, return the error code
//
strLongPath.Empty();
return 0;
}
}
}
}
}
else
{
strLongPath = strShortPath;
}
return strLongPath.GetLength();
}