You create a value set by using the WC_VALUESET window class name in the ClassName parameter of WinCreateWindow call.
Before the value set is created, a temporary VSCDATA data structure is allocated so that the number of rows and columns of the value set can be specified.
Also, VS_* values are specified in the ulValueSetStyle variable so that the value set can be customized. The following sample code shows the creation of a value set:
VSCDATA vscData; /* VSCDATA data structure */
HWND hwndValueSet; /* Value set window handle */
ULONG ulValueSetStyle; /* Value set style variable */
/**********************************************************************/
/* Initialize the parameters in the data structure. */
/**********************************************************************/
vscData.cbSize = /* Size of value set equals size */
sizeof(VSCDATA); /* of VSCDATA */
vscData.usRowCount = 1; /* 1 row in the value set */
vscData.usColumnCount = 3; /* 3 columns in the value set */
/**********************************************************************/
/* Set the VS_* style flags to customize the value set. */
/**********************************************************************/
ulValueSetStyle =
VS_RGB | /* Use colors for items. */
VS_ITEMBORDER | /* Put border around each value */
/* set item. */
VS_BORDER; /* Put border around the entire */
/* value set */
/**********************************************************************/
/* Create the value set control window. */
/* The handle of the window is returned in hwndValueSet. */
/**********************************************************************/
hwndValueSet = WinCreateWindow(
hwndClient, /* Parent window handle */
WC_VALUESET, /* Value set class name */
(PSZ)NULL, /* No window text */
ulValueSetStyle, /* Value set styles */
(SHORT)10, /* X coordinate */
(SHORT)10, /* Y coordinate */
(SHORT)300, /* Window width */
(SHORT)200, /* Window height */
hwndClient, /* Owner window handle */
HWND_TOP, /* Z-order position */
ID_VALUESET, /* Value set window ID */
&vscData, /* Control data structure */
(PVOID)NULL); /* No presentation parameters */
/**********************************************************************/
/* Set the color value for each item in each row and column. */
/**********************************************************************/
WinSendMsg(hwndValueSet, /* Value set window handle */
VM_SETITEM, /* Message for setting items */
MPFROM2SHORT(1,1), /* Set item in row 1, column 1 */
MPFROMLONG(0x00FF0000)); /* to the color red. */
WinSendMsg(hwndValueSet, /* Value set window handle */
VM_SETITEM, /* Message for setting items */
MPFROM2SHORT(1,2), /* Set item in row 1, column 2 */
MPFROMLONG(0x0000FF00)); /* to the color green. */
WinSendMsg(hwndValueSet, /* Value set window handle */
VM_SETITEM, /* Message for setting items */
MPFROM2SHORT(1,3), /* Set item in row 1, column 3 */
MPFROMLONG(0x000000FF)); /* to the color blue. */
/**********************************************************************/
/* Set the default selection. */
/**********************************************************************/
WinSendMsg(hwndValueSet, /* Value set window handle */
VM_SELECTITEM, /* Message for selecting items */
MPFROM2SHORT(1,2), /* Item in row 1, column 2 */
NULL); /* Reserved value */
/**********************************************************************/
/* Since all items have been set in the control, */
/* make the control visible. */
/**********************************************************************/
WinShowWindow(hwndValueSet, /* Value set window handle */
TRUE); /* Make the window visible */