Win32lib list selection

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

Greetings!

How to select 1st item (or any other) in lists.  I tried and tried and
then decided that it was not yet supported in Win32lib.  So I went
searching and found the following two constants and wrote the following
procedure (with ample reference to exisiting Win32lib procedures and
with help of Borland's Win32 Help).

constant
   LB_SETCURSEL        = #186,     -- list box: set index of selected item
   CB_SETCURSEL        = #14E,     -- combo box: set index of selected item

global procedure setItem( atom id, integer item )

    -- set list box to highlight (select) the item with index item.  This
is a
    -- zero-based list.  Using -1 deselects all items.

    integer hwnd, msg
    atom dummy

    -- get the list's handle
    hwnd = window_handle[ id ]

    -- get the message, based on control type
    if      window_class[ id ] = LB then msg = LB_SETCURSEL
    elsif   window_class[ id ] = CB then msg = CB_SETCURSEL
    end if

    -- send the message
    dummy = c_func( xSendMessage, { hwnd, msg, item, 0 } )

end procedure

PS.  Dear David Cuny,  please add this to your list functions so I
don't have to keep editing!  And on that note, might it be better to
name each successive (and eagerly awaited) version of Win32lib.ew
differently, say WinLib13, WinLib14, etc?  I now have at least 5 copies
and I only started using them in earnest with version 0.10.  They are
very hard to keep track of, and I hate to go back through all my little
programs checking for compatability each time a new version comes out.

Thanks!
John Cannon

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

Search



Quick Links

User menu

Not signed in.

Misc Menu