Kbase 18752: SELECTION-LIST -- How To Get The Index Of The Selected Item
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  26/01/2005 |
|
Status: Unverified
GOAL:
How to use the Win32 API function called SendMessage to retrieve the index number of the selected item in a Selection-List.
FACT(s) (Environment):
Windows 32 Intel
Windows NT 32 Intel/Windows 2000
FIX:
This code assumes a Selection-List named SELECT-1.
&GLOBAL-DEFINE LB_GETCURSEL 392
DEFINE VARIABLE iRC AS INTEGER NO-UNDO.
DEFINE VARIABLE iEntry AS INTEGER NO-UNDO.
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.
/*
The following RUN statement will retrieve the zero (0) based number
of the selected item in the list (for single select lists) or the
first selected item in the list (for multi-select lists)
*/
RUN SendMessageA (INPUT SELECT-1:HWND,
INPUT {&LB_GETCURSEL},
INPUT 0,
INPUT 0,
OUTPUT iRC).
IF iRC = -1 THEN
MESSAGE "There Was No Selected Item In The List" VIEW-AS ALERT-BOX.
ELSE
ASSIGN iEntry = iRC + 1. /* Add 1 to conform to Progress'
one (1) based indexing */