c++ - 将 vector 字符串的值传递给 C++ 中的 win32 函数 SetWindowText

标签 c++ winapi

如何将 vector 字符串的值传递给 C++ 中的 win32 函数 SetWindowText。

到目前为止,这是我的代码:

vector <string> filelist;
string path;
path = Text;
filelist = GetPath(path);
SetWindowText(EditShow,filelist);

最佳答案

您可以将它们全部连接成一个字符串并将其作为 C 字符串传递:

#include <sstream>   // for std::stringstream
#include <algorithm> // for std::copy
#include <iterator>  // for std::ostream_iterator

std::stringstream buffer;
std::copy(filelist.begin(), filelist.end(), 
          std::ostream_iterator<std::string>(buffer, "\n");
SetWindowText(EditShow,buffer.str().c_str());

关于c++ - 将 vector 字符串的值传递给 C++ 中的 win32 函数 SetWindowText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5309296/

相关文章:

c++ - 为什么编译 VCC .sln 在没有标准输出的情况下在后台运行?

c++ - 没有第二个操作数的三元运算符

c - 64 位 Windows : longjmp lands in a wrong place

windows - 获取文件系统目录条目的物理扇区

c++ - 删除抽象非虚拟 dtor C++

c++ - 如何检查函数的模板参数是否具有某种类型?

c++ - DirectX 9 设备。渲染时创建顶点和索引缓冲区。(2 个线程)

c - Windows 虚拟按键代码的所有标识符都以 VK_ 为前缀吗?

c++ - 在 C++ 中查找函数的地址

c++ - 无法从 gethostname 访问 IP 地址的内存