User Tools

Site Tools


changing_20the_20step_20size_20of_20an_20up-down_20control

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

changing_20the_20step_20size_20of_20an_20up-down_20control [2018/03/31 13:19]
127.0.0.1 external edit
changing_20the_20step_20size_20of_20an_20up-down_20control [2018/04/17 14:55] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //by Richard Russell, July 2014//\\ \\  When you create an **up-down control** you can easily choose the minimum and maximum values, and the direction in which it changes (i.e. whether clicking on the up arrow increases or decreases the value). However you cannot choose the step size: each click always changes the value by either +1 or -1 (or zero if the limit has been reached).\\ \\  To modify the behaviour of the up-down control requires a small piece of assembler code. The simplest option is to change the step size to a value other than one; the code example below demonstrates setting it to five:​\\ ​ //by Richard Russell, July 2014//\\ \\  When you create an **up-down control** you can easily choose the minimum and maximum values, and the direction in which it changes (i.e. whether clicking on the up arrow increases or decreases the value). However you cannot choose the step size: each click always changes the value by either +1 or -1 (or zero if the limit has been reached).\\ \\  To modify the behaviour of the up-down control requires a small piece of assembler code. The simplest option is to change the step size to a value other than one; the code example below demonstrates setting it to five:​\\ ​
 +<code bb4w>
         REM!WC         REM!WC
         UDN_DELTAPOS = -722         UDN_DELTAPOS = -722
Line 43: Line 44:
         SYS "​SetWindowLong",​ hdlg%, -4, M%         SYS "​SetWindowLong",​ hdlg%, -4, M%
         ENDPROC         ENDPROC
 +</​code>​
 The procedure **PROCsetdelta** takes three parameters: the handle of the dialogue box, the ID of the up-down control and the desired step size.\\ \\  However this may not always be what you want. Suppose that the contents of the associated edit box are initially 1 rather than 0 (for example because the user has typed in that value). Now, when you click the up button, the value will change to 6, then 11, then 16 and so on. You might prefer that instead of **adding** (or subtracting) 5, the up-down control changes the value to the next **multiple** of 5, so that the first click will change it from 1 to 5 (rather than 6). That can be achieved using this slightly more complicated code:​\\ ​ The procedure **PROCsetdelta** takes three parameters: the handle of the dialogue box, the ID of the up-down control and the desired step size.\\ \\  However this may not always be what you want. Suppose that the contents of the associated edit box are initially 1 rather than 0 (for example because the user has typed in that value). Now, when you click the up button, the value will change to 6, then 11, then 16 and so on. You might prefer that instead of **adding** (or subtracting) 5, the up-down control changes the value to the next **multiple** of 5, so that the first click will change it from 1 to 5 (rather than 6). That can be achieved using this slightly more complicated code:​\\ ​
 +<code bb4w>
         REM!WC         REM!WC
         UDN_DELTAPOS = -722         UDN_DELTAPOS = -722
Line 88: Line 91:
         SYS "​SetWindowLong",​ hdlg%, -4, M%         SYS "​SetWindowLong",​ hdlg%, -4, M%
         ENDPROC         ENDPROC
 +</​code>​
changing_20the_20step_20size_20of_20an_20up-down_20control.txt ยท Last modified: 2018/04/17 14:55 by tbest3112