delete item within external listbox if match string

i wana delete item with string ds.exe if found in listbox i already get handle for it

HWND hMainWnd = FindWindow(NULL,"board");


HWND hListWnd = FindWindowEx(hMainWnd,NULL,"ListBox",NULL);

DWORD count = SendMessage(hListWnd,LB_GETTEXTLEN,0,0);


char* lpBuff = new char[count+1];

SendMessage(hListWnd,LB_GETTEXT,0,(LPARAM)lpBuff);


cout << "First item in ListBox " << lpBuff << endl;

SendMessage(hListWnd,LB_DELETESTRING,L"ds.exe",(LPARAM)lpBuff);


why can't delete the ds.exe item in list box
Did you ever bother to look at MSDN what LB_DELETESTRING does and what parameters it requires?
itry SendMessage(hListWnd,LB_DELETESTRING,(WPARAM)L"ds.exe",(LPARAM)lpBuff);

same result , and i can't understand how to match item with string ds.exe t be deleted ,
itry what i know ,other else i would solve this by myself , but ineed help that's it.

LB_DELETESTRING
Deletes a string in a list box.
Parameters
wParam
The zero-based index of the string to be deleted.
lParam
This parameter is not used.

https://msdn.microsoft.com/en-us/library/windows/desktop/bb775183(v=vs.85).aspx

To get the index you need to use LB_FINDSTRINGEXACT
To learn about Windows programming it's better to get a good book.
https://www.amazon.com/Programming-Windows%C2%AE-Fifth-Developer-Reference/dp/157231995X/ref=sr_1_2?s=books&ie=UTF8&qid=1505638496&sr=1-2&keywords=petzold
HWND hMainWnd = FindWindow(NULL,"board");


HWND hListWnd = FindWindowEx(hMainWnd,NULL,"ListBox",NULL);

DWORD count = SendMessage(hListWnd,LB_GETTEXTLEN,0,0);


char* lpBuff = new char[count+1];

SendMessage(hListWnd,LB_GETTEXT,0,(LPARAM)lpBuff);


//cout << "First item in ListBox " << lpBuff << endl;
DWORD ss=SendMessage(hListWnd,LB_FINDSTRINGEXACT,0,(LPARAM)"ds.exe");

cout << "First item in ListBox " << lpBuff << endl;

SendMessage(hListWnd,LB_DELETESTRING,0,(LPARAM)lpBuff);



i edit the code still not work ?
Last edited on
any help ?
Before you can tackle such a task you need to learn the basics. Get a copy of the book I mentioned earlier, study it and you should be able to do it.

If you are not willing to learn, you can post in the job section and if you offer some money probaly someone will do it for you.
all i need is one line of code why i need to read whole book to solve just small issue!!

if any one willing to help thanks in advance.
Topic archived. No new replies allowed.