Listbox added nich
-
hi,
hab hier ne funktion um alle laufenden prozesse rauszufinden und in ne listbox reinzuschreiben.
nur funkt die nich *g*.
die funktion gibt mir die laufenden prozesse aus aber sie werden in meiner listbox nich angezeigt. kann mir jemand sagen warum?void enumProcs() { HANDLE tmp; LRESULT lResult; PROCESSENTRY32 procEntry; procEntry.dwSize = sizeof(PROCESSENTRY32); tmp = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if(Process32First(tmp, &procEntry) != false) { int count = 0; prozesses[count] = procEntry.szExeFile; MessageBox(NULL, procEntry.szExeFile, "Adding...", 0); lResult = SendMessage(listBox, LB_INSERTSTRING, 0, (LPARAM) procEntry.szExeFile); if(lResult == LB_ERR) MessageBox(NULL, "LB_ERR", "Error", 0); if(lResult == LB_ERRSPACE) MessageBox(NULL, "LB_ERRSPACE", "Error", 0); while(Process32Next(tmp, &procEntry) != false) { count++; prozesses[count] = procEntry.szExeFile; MessageBox(NULL, procEntry.szExeFile, "Adding...", 0); lResult = SendMessage(listBox, LB_INSERTSTRING, count, (LPARAM) procEntry.szExeFile); if(lResult == LB_ERR) MessageBox(NULL, "LB_ERR", "Error", 0); if(lResult == LB_ERRSPACE) MessageBox(NULL, "LB_ERRSPACE", "Error", 0); } } CloseHandle(tmp); }
thx
mfg
Black Sting
-
Sind die Handle zur Listbox gültig zum Zeitpunkt von SendMessage? (Debugger fragen)
MSDN schrieb:
The return value is the index of the position at which the string was inserted. If an error occurs, the return value is LB_ERR. If there is insufficient space to store the new string, the return value is LB_ERRSPACE.
Welchen Wert liefert Dein SendMessage zurück?
Versuch doch mal spaßeshalber, anstatt der Variable count einfach immer 1 anzugeben als 3. Parameter...
-
ah, jetzt funktionierts. ich schein die funktion zu früh aufgerufen zu haben...
(im WM_CREATE event). habs jetzt direkt nach der zuweisung der variablen listBox gemacht..
thx
mfg
Black Sting