Jump to content

WinQueryLboxSelectedItem

From EDM2
Revision as of 17:53, 9 April 2025 by Martini (talk | contribs) (Created page with "This macro returns the index of the selected item in the List Box (for single selection only). ==Syntax==  WinQueryLboxSelectedItem(hwndLbox) ==Parameters== ;hwndLbox (HWND) - Input : List box handle. ==Returns== ;lRetIndex (LONG) - returns :Index of the selected item. ==Remarks== This macro is defined as&colon. <Pre> #define WinQueryLBoxSelectedItem (hwndLbox)         ((LONG)WinSendMsg(hwndLbox,                           LM_Q...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This macro returns the index of the selected item in the List Box (for single selection only).

Syntax

 WinQueryLboxSelectedItem(hwndLbox)

Parameters

hwndLbox (HWND) - Input
List box handle.

Returns

lRetIndex (LONG) - returns
Index of the selected item.

Remarks

This macro is defined as&colon.

#define WinQueryLBoxSelectedItem (hwndLbox)
        ((LONG)WinSendMsg(hwndLbox,
                          LM_QUERYSELECTION,
                          MPFROMLONG(LIT_FIRST),
                          (MPARAM)NULL))

This macro requires the existence of a message queue.

Example Code

#define INCL_WINWINDOWMGR /* Or use INCL_WIN, INCL_PM, */
#include <os2.h>

HWND    hwndLbox;   /*  List box handle. */
LONG    lRetIndex;  /*  Index of the selected item. */

lRetIndex = WinQueryLboxSelectedItem(hwndLbox);

This example copies the text from the selected item in a list box to a buffer. Note that while WinQueryLboxSelectedItem returns a LONG value, WinQueryLboxItemText takes a SHORT parameter.

#define INCL_WINLISTBOXES
#define INCL_WINWINDOWMGR
#include <OS2.H>

HWND hwndLB;
LONG index;
char szTemp[256];

index = WinQueryLboxSelectedItem(hwndLB);

WinQueryLboxItemText(hwndLB,
                     (SHORT) index,
                     szTemp,
                     WinQueryLboxItemTextLength(hwndLB,index));

Related Messages

Related Functions