c++ - 在 MFC C++ 中查找 Indexof

标签 c++ mfc

如何在 GetWindowsText 中找到 indexof

我只想从 box->fileExt->GetWindowsText(save);
获取扩展 例如我的输入是 .exe .txt .bmp

所以我想把它们分开。例如这样的事情:

.exe
.txt
.bmp

目前我的代码是这样的:

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

它不起作用。

最佳答案

您需要根据分隔符拆分字符串。您可以使用 CStringTokenize 方法来做到这一点:

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);
}

关于c++ - 在 MFC C++ 中查找 Indexof,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29359936/

相关文章:

c++ - MFC GDI +文字呈现问题

c++ - 在退出应用程序之前不调用 GdiplusShutdown 会有什么后果?

c#代码转成QT C++

c++ - 在 Bloodshed 中使用 C++ 使用 <iomanip> 进行格式化

c++ - 程序无法启动,因为您的计算机缺少 libgcc_s_dw2-1.dll。简单控制台

c++ - 在 C 或 C++ 中,如何区分在内存地址上设置的 0 和因为该地址未初始化而设置的 0?

c# - Shell命名空间扩展。 C#。 C++,MFC,AT-使用什么?

c++ - MFC中如何给组合框添加字符串

c++ - 使用 std::runtime_error 而不是 CException

c++ - 平衡石头