Re: Matt re:setListviewIndex

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

----- Original Message ----- 
From: "Tony Steward" <figjam at nlc.net.au>

> Hi Matt or anyone who can help,
> Matt sent me the routine below so I could set the index of a listview, 
> which works well thanks thankyou. At the moment when you set one index that 
> index is made visible and highlighted. If you then set a second index both 
> are highlighted. I would prefer that when an index is set that the previous 
> selection be cleared. Is this possible.

You're correct.  That code only changes the status of the item you've
specified, but doesn't 'unselect' the currently selected item(s).  I'm not
certain when I sent that to you, but in my copy of .55, I've modified setIndex
(did it on 1/26/01):

I added integers:
integer msg,
-- added for listview:
    start, check, ix, count

and added an elsif clause that cycles through the listview and
deselects/selects as appropriate.  It might be faster for larger listviews to
merely get the selected group of items and deselect those, then selecting your
list.

elsif window_type[id] = ListView then

    if atom( index ) then
        index = { index }
    end if

    start = 0

    result = struct_LVITEM( LVIF_STATE, start, 0, 0,
        LVIS_SELECTED, 0, 0, 0 )

    store( result, LVITEM_stateMask, LVIS_SELECTED )
    count = sendMessage( id, LVM_GETITEMCOUNT, 0, 0)
    while count do

        ix = getLVItemlParam( id, start )
        if find( ix, index ) then
            store( result, LVITEM_state, LVIS_SELECTED )
        else
            store( result, LVITEM_state, 0 )
        end if

        VOID = sendMessage( id, LVM_SETITEMSTATE, start, result )
        start += 1
        count -= 1
    end while

    -- release the structure from memory
    ix = new_memset()
    manage_mem( ix, result )
    release_mem( ix )
    return


=====
Matt Lewis
http://www14.brinkster.com/matthewlewis

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

Search



Quick Links

User menu

Not signed in.

Misc Menu