The next step is to be able to retrieve the data represented by a value set item. To do this, variables are specified for combined row and column index values, item attributes, and item information. Then the VM_QUERYSELECTEDITEM, VM_QUERYITEMATTR, and VM_QUERYITEM messages are used to retrieve the index values, attributes, and data. The following sample code shows how data for selected value set items is retrieved:
ULONG ulIdx; /* Combined row and column */
/* index value */
USHORT usItemAttr; /* Item attributes */
ULONG ulItemData; /* Item data */
/**********************************************************************/
/* Get the row and column index values of the item selected by the */
/* user. These values are returned in the ulIdx parameter. */
/**********************************************************************/
ulIdx = (ULONG)WinSendMsg(
hwndValueSet, /* Value set window handle */
VM_QUERYSELECTEDITEM, /* Message for querying */
/* the selected item */
NULL, NULL); /* Reserved values */
/**********************************************************************/
/* Determine the type of item that was selected. This message is */
/* only to determine how to interpret item data when a value set */
/* contains different types of items. */
/**********************************************************************/
usItemAttr = (USHORT)WinSendMsg(
hwndValueSet, /* Value set window handle */
VM_QUERYITEMATTR, /* Message for querying item attribute */
MPFROMLONG(ulIdx), /* Row and column of selected item */
NULL); /* Reserved value */
/**********************************************************************/
/* Get the information about the selected (non-textual) item. */
/* If you are dealing with text, you need to allocate a buffer */
/* for the text string. */
/**********************************************************************/
ulItemData = (ULONG)WinSendMsg(
hwndValueSet, /* Value set window handle */
VM_QUERYITEM, /* Message for querying an item */
MPFROMLONG(ulIdx), /* Row and column of selected item */
NULL); /* Set to NULL because the item is not */
/* a text item */