Re: Simple win32lib question

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

> >How do [I] create a List Control using win32lib with the
> ability for users
> >to select more than one line? Ie, a multiselect listbox
>

>   LBS_EXTENDEDSEL =  #800,

>   LBS_MULTIPLESEL = 8,
> -- to create a multiple select listbox, use LBS_MULTIPLESEL
> -- Example:
>
>   Win  = create( Window, "Example", 0, Default, Default, 200,
> 200, 0 ),
>   Lstbox1 = create( List, "", Win, Win, 10, 10, 170, 100,
> LBS_MULTIPLESEL )
>
> -- LBS_MULTIPLESEL -> String selection is toggled each time
> the user clicks
> -- or double-clicks the string. Any number of strings can be selected.
>
> -- Brian
>

LBS_EXTENDEDSEL might be more what you're looking for.  It's more of a
standard, where you can select multiple items using shift, control, etc.

A little digging turned these up, which you'll need to use to retrieve the
values selected:
LBS_GETSELCOUNT = #190
LBS_GETSELITEMS = #191

The following functions return either a list of values, or the indices of
the selections:

global function getMultIndices( integer id )
    atom buffer, items, array
    sequence selections

    selections = {}

    items = sendMessage(id, LBS_GETSELCOUNT, 0 ,0)
    buffer = allocate_struct(items*4)
    items = sendMessage(id, LBS_GETSELITEMS, items, buffer)

    for i = items to 1 by -1 do
        selections = prepend(selections, peek4u( buffer + (i-1) * 4) + 1   )
    end for

    free(buffer)

    return selections
end function

global function getMultItems( integer id )

    sequence selections

    selections = getMultIndices( id )

    for i = 1 to length(selections) do
        selections[i] = getItem(id,selelctions[i])
    end for

    return selections
end function


Dave, how about adding this to win32lib?


Matt Lewis

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

Search



Quick Links

User menu

Not signed in.

Misc Menu