Resurrected: How to select multiple in list

new topic     » topic index » view thread      » older message » newer message

Happy days. Been struggling to programmatically select multiple items in 
a List control. Had found out about LBS_EXTENDEDSEL but still kept 
getting an error, however the archive came to the rescue with the 
following setMany procedure. 

Questions for Derek I guess.  
Is this now part of win32lib under another name, or is it still the way 
to do it ? 
Is there also a way of selecting a range of items in a list (e.g. from 4 
to 9), or all items ?

Thanks
Rangi
 
Derek Parnell wrote:
> Hi Aku,
> here is a solution that might help. I've added a new routine to select
> multiple items. The Win32lib setIndex() will only set one item in a list
> box.
> 
> ---------------
> include Win32Lib.ew
> without warning
> 
> --  Window Window1
> global constant Window1 = create( Window, "Window1", 0, Default, 
> Default,
> 400, 300, 0 )
> global constant List2 = create( List, "List2", Window1, 44, 20, 150, 
> 120,
> LBS_MULTIPLESEL )
> addItem(List2, "1")
> addItem(List2, "2")
> addItem(List2, "3")
> addItem(List2, "4")
> addItem(List2, "5")
> addItem(List2, "6")
> addItem(List2, "7")
> addItem(List2, "8")
> addItem(List2, "9")
> global constant PushButton3 = create( PushButton, "PushButton3", 
> Window1,
> 44, 156, 90, 30, 0 )
> global constant PushButton4 = create( PushButton, "PushButton4", 
> Window1,
> 152, 160, 90, 30, 0 )
> 
> --- HERE IS THE NEW ROUTINE --
> constant LB_SETSEL = #0185
> -- Sets one or more items on or off in a multiple-selection list box.
> -- If onoff is 1, the item is highlighted, if 0 it is deselected.
> procedure setMany(integer id, sequence idx, integer onoff)
>     atom VOID
>     idx -= 1
>     for i = 1 to length(idx) do
>         VOID = sendMessage( id, LB_SETSEL, onoff, idx[i] )
>     end for
> end procedure
> --------END OF IT ----------------
> 
> procedure PushButton3_onClick ()
>   -- Set the 3rd and 5th item on.
>   setMany(List2, {3, 5}, 1)
> end procedure
> onClick[PushButton3]=routine_id("PushButton3_onClick")
> 
> procedure PushButton4_onClick ()
>   -- Set the 3rd and 5th item off.
>   setMany(List2, {3, 5}, 0)
> end procedure
> onClick[PushButton4]=routine_id("PushButton4_onClick")
> 
> WinMain( Window1, Normal )
> -------------
> best of luck,
> Derek
> 
> ----- Original Message -----
> From: "Aku" <aku at inbox.as>
> To: "EUforum" <EUforum at topica.com>
> Sent: Saturday, December 22, 2001 4:17 PM
> Subject: Re[2]: How to select multiple in list

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu