User Tools

Site Tools


adding_20an_20up-down_20control_20to_20the_20main_20window

Differences

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

Link to this comparison view

adding_20an_20up-down_20control_20to_20the_20main_20window [2018/03/31 13:19]
127.0.0.1 external edit
adding_20an_20up-down_20control_20to_20the_20main_20window [2018/04/17 14:56] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //by Richard Russell, May 2006//\\ \\  The BB4W help documentation describes how to add an **up-down control** to a dialogue box [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwing.html#​updown|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:\\ \\  //by Richard Russell, May 2006//\\ \\  The BB4W help documentation describes how to add an **up-down control** to a dialogue box [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwing.html#​updown|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:\\ \\ 
 +<code bb4w>
         INSTALL @lib$+"​WINLIB5"​         INSTALL @lib$+"​WINLIB5"​
 +</​code>​
 Next create the edit box to which the up-down control will be attached:\\ \\  Next create the edit box to which the up-down control will be attached:\\ \\ 
 +<code bb4w>
         WS_BORDER = &800000         WS_BORDER = &800000
         ES_NUMBER = &2000         ES_NUMBER = &2000
         hedit% = FN_editbox("",​ 50, 50, 80, 20, 0, WS_BORDER + ES_NUMBER)         hedit% = FN_editbox("",​ 50, 50, 80, 20, 0, WS_BORDER + ES_NUMBER)
 +</​code>​
 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:\\ \\  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:\\ \\ 
 +<code bb4w>
         UDS_SETBUDDYINT = 2         UDS_SETBUDDYINT = 2
         UDS_ALIGNRIGHT = 4         UDS_ALIGNRIGHT = 4
         hupdown% = FN_createwindow("​msctls_updown32",​ "",​ 0, 0, 0, 0, 0, \         hupdown% = FN_createwindow("​msctls_updown32",​ "",​ 0, 0, 0, 0, 0, \
         \          UDS_ALIGNRIGHT + UDS_SETBUDDYINT,​ 0)         \          UDS_ALIGNRIGHT + UDS_SETBUDDYINT,​ 0)
 +</​code>​
 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:\\ \\  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:\\ \\ 
 +<code bb4w>
         UDM_SETBUDDY = &469         UDM_SETBUDDY = &469
         UDM_SETRANGE = &465         UDM_SETRANGE = &465
Line 19: Line 26:
         SYS "​SendMessage",​ hupdown%, UDM_SETRANGE,​ 0, 50         SYS "​SendMessage",​ hupdown%, UDM_SETRANGE,​ 0, 50
         SYS "​SendMessage",​ hupdown%, UDM_SETPOS, 0, 20          SYS "​SendMessage",​ hupdown%, UDM_SETPOS, 0, 20 
 +</​code>​
 Now we can access the contents of the edit box in the usual way, as documented [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwing.html#​fneditbox|here]].\\ \\  Don't forget to delete both the edit box and the up-down control when you are finished:\\ \\  Now we can access the contents of the edit box in the usual way, as documented [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwing.html#​fneditbox|here]].\\ \\  Don't forget to delete both the edit box and the up-down control when you are finished:\\ \\ 
 +<code bb4w>
         PROC_closewindow(hupdown%)         PROC_closewindow(hupdown%)
         PROC_closewindow(hedit%)         PROC_closewindow(hedit%)
 +</​code>​
adding_20an_20up-down_20control_20to_20the_20main_20window.txt ยท Last modified: 2018/04/17 14:56 by tbest3112