A spin button is created as a public window class by using WinCreateWindow, with a class style of WC_SPINBUTTON and a window style of WS_VISIBLE. These are joined with any of the spin button style flags by using a logical OR (|). The spin button style flags let you specify:
The placement and width of the spin button component are specified as parameters in WinCreateWindow.
The upper and lower limits of numeric fields, the value array pointer for arrays of strings, and the initial value in the spin field are all set by messages sent from the application to the component.
You can destroy the spin button component window using WinDestroyWindow when finished. The component handle that was returned when the spin button was created is the input parameter to WinDestroyWindow. The following sample code shows an example of how to create a spin button.
ULONG ulSpinStyle; /* Spin Button style */HWND hwndSpin; /* Spin Button window handle */ /**********************************************************************/ /* Set the SPBS_* style flags. */ /**********************************************************************/ ulSpinStyle = SPBS_MASTER | /* Spin button has its own */ /* buttons, */ SPBS_NUMERICONLY | /* and it only holds numbers */ SPBS_JUSTRIGHT | /* that are right justified, */ SPBS_FASTSPIN; /* and it spins faster as */ /* the arrows are held down */ /**********************************************************************/ /* Create the Spin Button control window. */ /* The handle of the window is returned in hwndSpin. */ /**********************************************************************/ hwndSpin = WinCreateWindow ( hwndClient, /* Parent window handle */ WC_SPINBUTTON, /* Spin Button window class name */ (PSZ)NULL, /* No window text */ ulSpinStyle, /* Spin Button styles variable */ (LONG)10, /* X coordinate */ (LONG)10, /* Y coordinate */ (LONG)150, /* Window width */ (LONG)50, /* Window height */ hwndClient, /* Owner window handle */ HWND_TOP, /* Sibling window handle */ ID_SPINBUTTON, /* Spin Button control window ID */ (PVOID)NULL, /* No control data structure */ (PVOID)NULL); /* No presentation parameters */ /**********************************************************************/ /* Set the limits of the Spin Button control, since it has a style */ /* of SPBS_NUMERICONLY. */ /**********************************************************************/ WinSendMsg (hwndSpin, /* Spin Button window handle */ SPBM_SETLIMITS, /* Set limits message */ (MPARAM)1000, /* Spin Button maximum setting */ (MPARAM)0); /* Spin Button minimum setting */ /**********************************************************************/ /* Set the initial value of the Spin Button. */ /**********************************************************************/ WinSendMsg (hwndSpin, /* Spin Button window handle */ SPBM_SETCURRENTVALUE, /* Set current value message */ (MPARAM)100, /* Spin Button initial value */ (MPARAM)NULL); /* Reserved value */ /**********************************************************************/ /* Because all items have been set, make the control visible. */ /**********************************************************************/ WinShowWindow (hwndSpin, /* Spin Button window handle */ TRUE); /* Make the window visible */