zattz
asked on
Add an item to a listbox in another running process
I have a running process (not my own) and I want to add an item to a listbox.
I have the handle of the listbox control, can somebody give me some code to add an item to it?
thanks
I have the handle of the listbox control, can somebody give me some code to add an item to it?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yep... one of the few exceptions where you can send(message) a string to a remote process without first allocating memory in the remote process. You can also just pass (-1) as the index if you want to append to the list (no need to get count)
Russell
Russell
>You can also just pass (-1) as the index if you want to append to the list (no need to get count)
Thanks, I wasn't aware of that :)
And I just see there's also LB_ADDSTRING.
So zattz, in fact if you already have the LB handle, all you really need is a line like:
SendMessage(hnd, LB_INSERTSTRING,-1,Integer (PChar('Te stString') ));
or
SendMessage(hnd, LB_ADDSTRING,0,Integer(PCh ar('TestSt ring')));
Thanks, I wasn't aware of that :)
And I just see there's also LB_ADDSTRING.
So zattz, in fact if you already have the LB handle, all you really need is a line like:
SendMessage(hnd, LB_INSERTSTRING,-1,Integer
or
SendMessage(hnd, LB_ADDSTRING,0,Integer(PCh
ASKER
Thanks Guys:)
Worked perfectly.
Except that I made a mistake and actually wanted to send to a combobox so I changed LB_ADDSTRING to CB_ADDSTRING
Worked perfectly.
Except that I made a mistake and actually wanted to send to a combobox so I changed LB_ADDSTRING to CB_ADDSTRING
SendMessage(hnd, LB_INSERTSTRING,Count,Inte