本文整理汇总了C++中TSTR::Resize方法的典型用法代码示例。如果您正苦于以下问题:C++ TSTR::Resize方法的具体用法?C++ TSTR::Resize怎么用?C++ TSTR::Resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSTR
的用法示例。
在下文中一共展示了TSTR::Resize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeUnique
void ObjNameList::MakeUnique(TSTR &n)
{
// First make it less than 10 chars.
if( n.Length() > 10 )
n.Resize(10);
if( Contains(n) < 0 )
{
Append(n);
return;
}
// Make it unique and keep it 10 chars or less
for(int i = 0; i < 100000; ++i)
{
char buf[12];
sprintf(buf,"%d",i);
TSTR num(buf);
TSTR work = n;
int totlen = num.Length() + work.Length();
if(totlen > 10)
work.Resize(10 - (totlen - 10));
work = work + num;
if(Contains(work) < 0)
{
Append(work);
n = work;
return;
}
}
// Forget it!
}
示例2: PutAppData
void AppDataTest::PutAppData()
{
Animatable *anim = PickAnim();
if (!anim) return;
// XRef stuff 020416 --prs.
if (s_through_xref) {
RefTargetHandle rth = (RefTargetHandle)anim;
IXRefItem* xi = NULL;
while (rth != NULL && (xi = IXRefItem::GetInterface(*rth)) != NULL)
rth = xi->GetSrcItem();
if (rth != NULL)
anim = rth;
}
// Load the text out of the edit field into a buffer
int text_len = GetWindowTextLength(GetDlgItem(hPanel,IDC_APPDATA_EDIT))+1;
TSTR theText;
theText.Resize(text_len);
GetWindowText(
GetDlgItem(hPanel,IDC_APPDATA_EDIT),
theText.dataForWrite(), text_len);
MaxSDK::Util::MaxString m_string;
theText.ToMaxString(m_string);
const char* a_string = m_string.ToUTF8();
size_t len = strlen(a_string)+4; // 3 for UTF8 BOM, one for null
char* buf = (char*)MAX_malloc(len);
strcpy(buf, "\xef\xbb\xbf"); // UTF8 BOM
strcat(buf, a_string);
// Remove the chunk if it exists
anim->RemoveAppDataChunk(
APPDATA_TEST_CLASS_ID,
UTILITY_CLASS_ID,
spin->GetIVal());
// Add a chunk
anim->AddAppDataChunk(
APPDATA_TEST_CLASS_ID,
UTILITY_CLASS_ID,
spin->GetIVal(),
(DWORD)len, buf);
}
示例3: IGameExporterOptionsDlgProc
//.........这里部分代码省略.........
case IDOK:
{
// LRESULT 在 64 位机器上是 _int64
int ogreVerIdx = (int)SendDlgItemMessage(hWnd, IDC_OGREVERSION, CB_GETCURSEL, 0, 0);
if (ogreVerIdx != CB_ERR)
{
switch (ogreVerIdx)
{
case 0:
exp->meshVersion = TOGRE_LASTEST;
break;
case 1:
exp->meshVersion = TOGRE_1_8;
break;
case 2:
exp->meshVersion = TOGRE_1_7;
break;
case 3:
exp->meshVersion = TOGRE_1_4;
break;
case 4:
exp->meshVersion = TOGRE_1_0;
break;
default:
exp->meshVersion = TOGRE_1_8;
}
}
TSTR temp;
int len = 0;
len = (int)SendDlgItemMessage(hWnd, IDC_RESPREFIX, WM_GETTEXTLENGTH, 0, 0);
temp.Resize(len + 1);
SendDlgItemMessage(hWnd, IDC_RESPREFIX, WM_GETTEXT, len + 1, (LPARAM)temp.data());
#ifdef UNICODE
std::wstring temp_w = temp.data();
std::string temp_s;
temp_s.assign(temp_w.begin(), temp_w.end());
exp->resPrefix = temp_s;
#else
exp->resPrefix = temp;
#endif
len = (int)SendDlgItemMessage(hWnd, IDC_MATDIR, WM_GETTEXTLENGTH, 0, 0);
temp.Resize(len + 1);
SendDlgItemMessage(hWnd, IDC_MATDIR, WM_GETTEXT, len + 1, (LPARAM)temp.data());
#ifdef UNICODE
temp_w = temp.data();
temp_s.assign(temp_w.begin(), temp_w.end());
exp->materialOutputDir = temp_s;
#else
exp->materialOutputDir = temp;
#endif
len = (int)SendDlgItemMessage(hWnd, IDC_TEXDIR, WM_GETTEXTLENGTH, 0, 0);
temp.Resize(len + 1);
SendDlgItemMessage(hWnd, IDC_TEXDIR, WM_GETTEXT, len + 1, (LPARAM)temp.data());
#ifdef UNICODE
temp_w = temp.data();
temp_s.assign(temp_w.begin(), temp_w.end());
exp->texOutputDir = temp_s;
#else
exp->texOutputDir = temp;
#endif
示例4: RollupDialogProc
//.........这里部分代码省略.........
case CC_SPINNER_BUTTONDOWN:
{
int id = LOWORD(wParam);
switch (id)
{
case IDC_ANIMATION_SPIN:
case IDC_ACTION_SPIN2:
theHold.Begin();
return TRUE;
default:
return FALSE;
}
}
break;
case CC_SPINNER_BUTTONUP:
{
if (!HIWORD(wParam))
{
theHold.Cancel();
break;
}
int id = LOWORD(wParam);
switch (id)
{
case IDC_ANIMATION_SPIN:
case IDC_ACTION_SPIN2:
if (th->getCoreHelper())
th->getCoreHelper()->setState(th->animationIDSpin->GetIVal(), 0.0);
theHold.Accept(GetString(IDS_DS_PARAMCHG));
return TRUE;
default:
return FALSE;
}
}
case CC_SPINNER_CHANGE:
{
int animID;
int id = LOWORD(wParam);
TimeValue t = 0; // not really needed...yet
switch (id)
{
case IDC_ANIMATION_SPIN:
case IDC_ACTION_SPIN2:
if (!HIWORD(wParam))
theHold.Begin();
//actionID = th->actionIDSpin->GetIVal();
//th->animationIDSpin->SetValue(animID, FALSE);
//th->actionIDSpin->SetValue(actionID, FALSE);
animID = th->animationIDSpin->GetIVal();
if (th->getCoreHelper())
th->getCoreHelper()->setState(animID, 0.0);
if (!HIWORD(wParam))
theHold.Accept(GetString(IDS_DS_PARAMCHG));
return TRUE;
default:
return FALSE;
}
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_CAL_CFG_URL:
switch (HIWORD(wParam))
{
case EN_SETFOCUS:
DisableAccelerators();
break;
case EN_KILLFOCUS:
EnableAccelerators();
break;
case EN_CHANGE:
int len = (int)SendDlgItemMessage(hDlg, IDC_CAL_CFG_URL, WM_GETTEXTLENGTH, 0, 0);
TSTR temp;
temp.Resize(len + 1);
SendDlgItemMessage(hDlg, IDC_CAL_CFG_URL, WM_GETTEXT, len + 1, (LPARAM)temp.data());
#if MAX_PRODUCT_VERSION_MAJOR > 14
th->setURL(temp.ToUTF8().data());
#else
th->setURL((char *)temp);
#endif
break;
}
break;
}
return FALSE;
default:
return FALSE;
}
return FALSE;
}