- As @jkb metioned, use
std::wstring
;
- use
std::stringstream
.(or any other stream class)
In addition, there are other problems in your sample. If you don't want your output text to be one line and hard to read, you need to add the Exstyle of ES_MULTILINE | ES_AUTOVSCROLL
to your edit control, and use "\r\n"
to connect strings to Wrap text.
1). Sample:
HWND listProc = CreateWindowEx(0, L"Edit", L"", WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL| ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
0, 0, 100, 300, hWnd, NULL, NULL, NULL);
HANDLE procSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
std::wstring procList;
PROCESSENTRY32 procEntry;
procEntry.dwSize = sizeof(PROCESSENTRY32);
Process32First(procSnap, &procEntry);
procList += procEntry.szExeFile;
procList += L"\r\n";
while (Process32Next(procSnap, &procEntry))
{
procList += procEntry.szExeFile;
procList += L"\r\n";
}
SetWindowText(listProc, procList.c_str());
CloseHandle(procSnap);
2). Sample:
HWND listProc = CreateWindowEx(0, L"Edit", L"", WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL| ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
0, 0, 100, 300, process, NULL, NULL, NULL);
HANDLE procSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
std::wstringstream procList;
PROCESSENTRY32 procEntry;
procEntry.dwSize = sizeof(PROCESSENTRY32);
Process32First(procSnap, &procEntry);
procList += procEntry.szExeFile;
procList += L"\r\n";
while (Process32Next(procSnap, &procEntry))
{
procList << procEntry.szExeFile;
procList << L"\r\n";
}
SetWindowText(listProc, procList.str().c_str());
CloseHandle(procSnap);