by Richard Russell, May 2006

The BB4W help documentation describes how to add an up-down control to a dialogue box here but doesn't tell you how to add one to the main output window.

The code below illustrates the creation of an up-down control which is 'attached' to an edit box, which is the usual way in which one is used. First install the necessary library:

      INSTALL @lib$+"WINLIB5"
Next create the edit box to which the up-down control will be attached:

      WS_BORDER = &800000
      ES_NUMBER = &2000
      hedit% = FN_editbox("", 50, 50, 80, 20, 0, WS_BORDER + ES_NUMBER)
Here the edit box is positioned at 50,50 and has a size of 80x20 pixels. The style value specifies that the box has a border and that it is a numeric-entry box.

Now we can create the up-down control itself:

      hupdown% = FN_createwindow("msctls_updown32", "", 0, 0, 0, 0, 0, \
The style value specifies that the up-down control is right-aligned in the edit box and that the edit box value is automatically modified by the up-down control.

We must tell the up-down control to which edit box it is attached, over what range of values it operates, and what the initial value is:

      UDM_SETBUDDY = &469
      UDM_SETRANGE = &465
      UDM_SETPOS = &467
      SYS "SendMessage", hupdown%, UDM_SETBUDDY, hedit%, 0
      SYS "SendMessage", hupdown%, UDM_SETRANGE, 0, 50
      SYS "SendMessage", hupdown%, UDM_SETPOS, 0, 20 
Now we can access the contents of the edit box in the usual way, as documented here.

Don't forget to delete both the edit box and the up-down control when you are finished: