Reputation: 107
How can I find the indexof
in GetWindowsText
?
I just want to get extensions from box->fileExt->GetWindowsText(save);
For example my input is .exe .txt .bmp
So I want to get them separately. For example something like that:
.exe
.txt
.bmp
Currently my code is this:
for (int i = 0; i < files; i++)
{
box->testBox1.AddString(save);
fileExtensions.Add(save)`enter code here`;
CString check;
box->fileExt.GetWindowText(check);
CString store = check;
check.Find(' ') == save;
break;
continue;
if (fileExtensions[fileCounter] == store)
{
box->textBox2.AddString(fileExtensions[fileCounter]);
fileCounter++;
}
}//end for
It does not work.
Upvotes: 0
Views: 450
Reputation: 6566
You need to split string based on separator character(s). You can use Tokenize
method of CString
to do that:
CString sExtensions(_T(".exe .txt .bmp"));
CString sExt;
int nCurPos = 0;
CString sSeparators(_T(" ;"));
CStringArray Extensions;
sExt = sExtensions.Tokenize(sSeparators, nCurPos);
while (!sExt.IsEmpty())
{
Extensions.Add(sExt);
sExt = sExtensions.Tokenize(sSeparators, nCurPos);
}
Upvotes: 1