Board index » delphi » Moving TListBox items to another TListBox

Moving TListBox items to another TListBox

I have a dialog box set up with two listboxes.  They are multiple
selection listboxes.  How can I get all selected items and transfer
them from one to the other?  I think I would use SendDlgItemMsg with
the GETSELITEMS param.  I can't get this to work however.  I'm not sure
what the "buffer" should be set up as.  It says far pointer to a
"buffer"
large enough to hold all returned integers.  Would that be a pointer to
an array of integers?  Then do I use the returned integers to read then
delete the items from one list, then add them to the other?

Any help is appreciated!
Joe

 

Re:Moving TListBox items to another TListBox


In article <3230A2EF....@wcnet.org>, Jkonecny_...@wcnet.org says...

Quote

>I have a dialog box set up with two listboxes.  They are multiple
>selection listboxes.  How can I get all selected items and transfer
>them from one to the other?  I think I would use SendDlgItemMsg with
>the GETSELITEMS param.  I can't get this to work however.  I'm not sure
>what the "buffer" should be set up as.  It says far pointer to a
>"buffer"
>large enough to hold all returned integers.  Would that be a pointer to
>an array of integers?  Then do I use the returned integers to read then
>delete the items from one list, then add them to the other?

>Any help is appreciated!
>Joe

>> You got the idea ok. You have an array of integers which show the
>> lines selected by the user. Use this to GetString from ListBox1  and
>> then AddString to ListBox2. After, and *only* after all the adds,
>> delete entries from listbox1, starting from high index number *down*
>> to lowest. This is because every DeleteString is going to cause a new
>> index number for your old selected items.
>> Hopefully you are using AllocMultiSel and FreeMultiSel functions for
>> the MultiSelRec array? (see TmultiSelRec definition ).

>> Martin

Other Threads