RE: Multi-list behavior under win32lib

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

Hi "jjnick at cvn.com",
you have discovered a bug - sort of. The main problem is that getIndex() was
only designed to be used on single-selection listboxes. It works fine it
those cases. I know how to "fix" it to work with multi-select lists but the
problem I have is 'What do I return?' If multiple items are selected then
the obvious choice is a sequence of indexes. But this might break some code
that assigns the return value to an atom or integer.  What do you guys think
I ought to do?

My preference is to return a sequence of indexes when the list is a
multiple-select type and an integer otherwise. An empty list would indicate
that nothing is selected.


Here is the Microsoft documentation on the LB_GETCURSEL message, which is
currently being used in Win32lib. Please note the *Remarks* when used with
multi-selection lists.

-------------------------------------
*LB_GETCURSEL*
Send an LB_GETCURSEL message to retrieve the index of the currently selected
item, if any, in a single-selection list box.

To send this message, call the SendMessage function with the following
parameters.

SendMessage(
  (HWND) hWnd,              // handle to destination window
  LB_GETCURSEL,             // message to send
  (WPARAM) wParam,          // not used; must be zero
  (LPARAM) lParam          // not used; must be zero
);

*Parameters*
This message has no parameters.

*Return Values*
In a single-selection list box, the return value is the zero-based index of
the currently selected item. If there is no selection, the return value is
LB_ERR.

*Remarks*
Do not send this message to a multiple-selection list box.

To retrieve the indexes of the selected items in a multiple-selection list
box, use the LB_GETSELITEMS message. To determine whether the item that has
the focus rectangle in a multiple selection list box is selected, use the
LB_GETSEL message.

If sent to a multiple-selection list box, LB_GETCURSEL returns the index of
the item that has the focus rectangle. If no items are selected, it returns
zero.


-------------------------------------

cheers,
Derek Parnell

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

Search



Quick Links

User menu

Not signed in.

Misc Menu