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));


[Back] [Next]