Jump to content

WinQueryLboxItemTextLength

From EDM2

This macro returns the length of the text of the indexed item in the List Box.

Syntax

 WinQueryLboxItemTextLength(hwndLbox, index)

Parameters

hwndLbox (HWND) - Input
Listbox handle.
index (SHORT) - Input
Index of the item in the List Box.

Returns

sRetLen (SHORT) - returns
Text length of the indexed item.

Remarks

This macro is defined as&colon.

#define WinQueryLboxItemTextLength(hwndLbox, index)  \
        ((SHORT)WinSendMsg(hwndLbox,                  \
                           LM_QUERYITEMTEXTLENGTH,    \
                           MPFROMSHORT(index),       \
                           (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;  /*  Listbox handle. */
SHORT    index;    /*  Index of the item in the List Box. */
SHORT    sRetLen;  /*  Text length of the indexed item. */

sRetLen = WinQueryLboxItemTextLength(hwndLbox,
            index);

This example uses WinQueryLboxItemText to copy all of the list box items into a buffer.

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

LONG  cWindows;
char *szTemp;
HWND  hwndLB;
SHORT maxchar, index = 0;

cWindows = WinQueryLboxCount(hwndLB);

/* allocate a buffer for cWindows items. */

DosAllocMem((PPVOID)&szTemp,
            (ULONG)cWindows*256*sizeof(char),
             PAG_READ |
             PAG_WRITE |
             PAG_COMMIT);

/* loop through all of the items;  copying each */
/* one the buffer.                              */

while (index <= cWindows)
{
   maxchar = WinQueryLboxItemTextLength(hwndLB,index);
   WinQueryLboxItemText(hwndLB,
                        index++,
                        szTemp,
                        maxchar);
   szTemp+=maxchar; /* increment pointer by number */
                                    /* of bytes copied. */
}

Related Messages

Related Functions