Item Pairs

Hi all,
I have a selection list that uses item-pairs. I do not know how to get the item-pair number selected. eg item-pairs = 'a,1,ab,2,abc,3' The online help doesn't help much either!!
Cheers
Regards
 

nborshukov

New Member
Under Windows try this:

define input parameter sl-hndl as widget-handle no-undo.
define output parameter iSL as integer no-undo.

&GLOBAL-DEFINE LB_GETCURSEL 392
&GLOBAL-DEFINE LB_SETCURSEL 390

RUN SendMessageA (INPUT sl-hndl:HWND,
INPUT {&LB_GETCURSEL},
INPUT 0,
INPUT 0,
OUTPUT iSL).

PROCEDURE SendMessageA EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER hwnd AS LONG NO-UNDO.
DEFINE INPUT PARAMETER wmsg AS LONG NO-UNDO.
DEFINE INPUT PARAMETER wparam AS LONG NO-UNDO.
DEFINE INPUT PARAMETER lparam AS LONG NO-UNDO.
DEFINE RETURN PARAMETER rc AS LONG NO-UNDO.
END PROCEDURE.
 
When you are using list item pairs, the first value is the value displayed, the second value is the value returned. So your example would display three items

a
ab
abc

But as each item is selected, the SCREEN-VALUE of the selection list will return 1, 2 or 3.

So are you are asking how to get back to the displayed values? If so you can use something like the following. The displayed value always precedes the return value in the list. e.g. In the list "a,1,ab,2", the SCREEN-VALUE will be 1 or 2 and the displayed value is 1 less than the position of the SCREEN-VALUE in the list.

DEF VAR pos AS INT NO-UNDO.

pos = LOOKUP(SELECT-1:SCREEN-VALUE,SELECT-1:LIST-ITEM-PAIRS) - 1.

value = ENTRY(pos,SELECT-1:LIST-ITEM-PAIRS).
 
Top