User Tools

Site Tools


adding_20tooltips_20to_20a_20dialogue_20box

Differences

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

Link to this comparison view

adding_20tooltips_20to_20a_20dialogue_20box [2018/03/31 13:19]
127.0.0.1 external edit
adding_20tooltips_20to_20a_20dialogue_20box [2018/04/15 17:10] (current)
richardrussell Added syntax highlighting
Line 1: Line 1:
 =====Adding tooltips to a dialogue box===== =====Adding tooltips to a dialogue box=====
  
-//by Richard Russell and Howard Bolton, May 2006//\\ \\  Tooltips are small (usually light yellow) windows containing useful information,​ which pop up when you '​hover'​ the mouse over a particular control or region of the screen. This article describes how you can add tooltips to a dialogue box; there are other articles for adding tooltips to a [[/​Adding%20tooltips%20to%20the%20status%20bar|status bar]] and to the [[/​Tooltips%20on%20the%20main%20output%20window|main output window]] (the main Help documentation describes how to add tooltips to a [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwing.html#​addtooltips|toolbar]]).\\ \\  Firstly we create and display a dialogue box in the usual way (see the main help documentation [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwing.html#​winlib2|here]]). For the purpose of this example the dialogue box contains two editboxes, a combobox, a list box and two push buttons:\\ \\ +//by Richard Russell and Howard Bolton, May 2006//\\ \\  Tooltips are small (usually light yellow) windows containing useful information,​ which pop up when you '​hover'​ the mouse over a particular control or region of the screen. This article describes how you can add tooltips to a dialogue box; there are other articles for adding tooltips to a [[/​Adding%20tooltips%20to%20the%20status%20bar|status bar]] and to the [[/​Tooltips%20on%20the%20main%20output%20window|main output window]] (the main Help documentation describes how to add tooltips to a [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwing.html#​addtooltips|toolbar]]).\\ \\  Firstly we create and display a dialogue box in the usual way (see the main help documentation [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwing.html#​winlib2|here]]). For the purpose of this example the dialogue box contains two editboxes, a combobox, a list box and two push buttons: 
 + 
 +<code bb4w> ​
         INSTALL @lib$+"​WINLIB2"​         INSTALL @lib$+"​WINLIB2"​
         INSTALL @lib$+"​WINLIB5A"​         INSTALL @lib$+"​WINLIB5A"​
Line 24: Line 26:
  
         PROC_showdialog(dlg%)         PROC_showdialog(dlg%)
-Note the installation of the **WINLIB5A** library which is needed later.\\ \\  Next we perform any initialisation of the dialogue box required; in this case we enter some data into the combobox and the list box:\\ \\ +</​code>​ 
 + 
 +Note the installation of the **WINLIB5A** library which is needed later.\\ \\  Next we perform any initialisation of the dialogue box required; in this case we enter some data into the combobox and the list box: 
 + 
 +<code bb4w>
         CB_ADDSTRING = &143         CB_ADDSTRING = &143
         CB_SETCURSEL = &14E         CB_SETCURSEL = &14E
Line 39: Line 45:
         SYS "​SendDlgItemMessage",​!dlg%,​104,​LB_ADDSTRING,​0,"​Listbox item 2"         SYS "​SendDlgItemMessage",​!dlg%,​104,​LB_ADDSTRING,​0,"​Listbox item 2"
         SYS "​SendDlgItemMessage",​!dlg%,​104,​LB_ADDSTRING,​0,"​Listbox item 3"         SYS "​SendDlgItemMessage",​!dlg%,​104,​LB_ADDSTRING,​0,"​Listbox item 3"
-So far everything has been conventional. Now comes the code for creating the tooltips:\\ \\ +</​code>​ 
 + 
 +So far everything has been conventional. Now comes the code for creating the tooltips: 
 + 
 +<code bb4w>
         TTS_ALWAYSTIP = 1         TTS_ALWAYSTIP = 1
         TTS_NOPREFIX = 2         TTS_NOPREFIX = 2
Line 54: Line 64:
         PROC_CreateToolTip(!dlg%,​ htt%, 104, "This is a list box")         PROC_CreateToolTip(!dlg%,​ htt%, 104, "This is a list box")
         PROC_CreateToolTip(!dlg%,​ htt%, 1, "This is the default push button"​)         PROC_CreateToolTip(!dlg%,​ htt%, 1, "This is the default push button"​)
-        PROC_CreateToolTip(!dlg%,​ htt%, 2, "This is another push button"​) ​  +        PROC_CreateToolTip(!dlg%,​ htt%, 2, "This is another push button"​) 
-Finally we need the procedure to send the Tooltip text to each dialogue item. This procedure can be used for any dialogue box in your program by passing appropriate values for the handles to the dialogue box and the Tooltip (note the important addition of CHR$0 to each of the strings):\\ \\ +</​code>​ 
 +   
 +Finally we need the procedure to send the Tooltip text to each dialogue item. This procedure can be used for any dialogue box in your program by passing appropriate values for the handles to the dialogue box and the Tooltip (note the important addition of CHR$0 to each of the strings): 
 + 
 +<code bb4w>
         DEF PROC_CreateToolTip(hdlg%,​ htt%, id%, tip$)         DEF PROC_CreateToolTip(hdlg%,​ htt%, id%, tip$)
         TTF_IDISHWND = 1         TTF_IDISHWND = 1
Line 68: Line 82:
         SYS "​SendMessage",​ htt%, TTM_ADDTOOL,​ 0, ti{}         SYS "​SendMessage",​ htt%, TTM_ADDTOOL,​ 0, ti{}
         ENDPROC         ENDPROC
 +</​code>​
 +
 Now all you need to do is hover the mouse over the controls and see the effect. Now all you need to do is hover the mouse over the controls and see the effect.
adding_20tooltips_20to_20a_20dialogue_20box.txt · Last modified: 2018/04/15 17:10 by richardrussell