User Tools

Site Tools


adding_20tooltips_20to_20the_20status_20bar

Differences

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

Link to this comparison view

adding_20tooltips_20to_20the_20status_20bar [2018/03/31 13:19]
127.0.0.1 external edit
adding_20tooltips_20to_20the_20status_20bar [2018/04/16 14:27] (current)
richardrussell Added syntax highlighting
Line 1: Line 1:
 =====Adding tooltips to the status bar===== =====Adding tooltips to the status bar=====
  
-//by Richard Russell, January 2007//\\ \\  If your program uses the [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwing.html#​winlib|WINLIB library]] to create a **toolbar** then you can easily add //​tooltips//​ to the toolbar buttons using the **PROC_addtooltips** function provided. However if you use the same library to create a **status bar** no built-in method for adding tooltips to it is provided.\\ \\  Nevertheless it is actually quite easy to add tooltips to a status bar. You should first create the status bar in the usual way, using the **FN_createstatusbar** function, and divide it up into the wanted number of //parts//. Next you need a handle to a //tooltip control//; there are two ways of achieving that, depending on whether or not your program also uses a toolbar.\\ \\  If you have created a toolbar with tooltips then you can obtain a handle to its tooltip control as follows:\\ \\ +//by Richard Russell, January 2007//\\ \\  If your program uses the [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwing.html#​winlib|WINLIB library]] to create a **toolbar** then you can easily add //​tooltips//​ to the toolbar buttons using the **PROC_addtooltips** function provided. However if you use the same library to create a **status bar** no built-in method for adding tooltips to it is provided.\\ \\  Nevertheless it is actually quite easy to add tooltips to a status bar. You should first create the status bar in the usual way, using the **FN_createstatusbar** function, and divide it up into the wanted number of //parts//. Next you need a handle to a //tooltip control//; there are two ways of achieving that, depending on whether or not your program also uses a toolbar.\\ \\  If you have created a toolbar with tooltips then you can obtain a handle to its tooltip control as follows: 
 + 
 +<code bb4w> ​
         TB_GETTOOLTIPS = 1059         TB_GETTOOLTIPS = 1059
         SYS "​SendMessage",​ htoolbar%, TB_GETTOOLTIPS,​ 0, 0 TO htooltip%         SYS "​SendMessage",​ htoolbar%, TB_GETTOOLTIPS,​ 0, 0 TO htooltip%
-Here **htoolbar%** is the handle of the toolbar, as returned from **FN_createtoolbar**.\\ \\  If your program doesn'​t use a toolbar, you must install the **WINLIB5** (or **WINLIB5A**) library:\\ +</​code>​ 
 + 
 +Here **htoolbar%** is the handle of the toolbar, as returned from **FN_createtoolbar**.\\ \\  If your program doesn'​t use a toolbar, you must install the **WINLIB5** (or **WINLIB5A**) library: 
 + 
 +<code bb4w>
         INSTALL @lib$+"​WINLIB5"​         INSTALL @lib$+"​WINLIB5"​
-The tooltip control can now be created as follows:\\ +</​code>​ 
 + 
 +The tooltip control can now be created as follows: 
 + 
 +<code bb4w>
         TTS_ALWAYSTIP = 1         TTS_ALWAYSTIP = 1
         TTS_NOPREFIX = 2         TTS_NOPREFIX = 2
Line 14: Line 24:
         htooltip% = FN_createwindow("​tooltips_class32",​ "",​ 0, 0, 0, 0, 0, \         htooltip% = FN_createwindow("​tooltips_class32",​ "",​ 0, 0, 0, 0, 0, \
         \           ​WS_CHILD+WS_VISIBLE+TTS_ALWAYSTIP+TTS_NOPREFIX,​ 0)         \           ​WS_CHILD+WS_VISIBLE+TTS_ALWAYSTIP+TTS_NOPREFIX,​ 0)
-If instead your program uses the **WINLIB5A** library then the code must be adapted as follows:\\ +</​code>​ 
 + 
 +If instead your program uses the **WINLIB5A** library then the code must be adapted as follows: 
 + 
 +<code bb4w>
         TTS_ALWAYSTIP = 1         TTS_ALWAYSTIP = 1
         TTS_NOPREFIX = 2         TTS_NOPREFIX = 2
Line 22: Line 36:
         htooltip% = FN_createwindow(@hwnd%,​ "​tooltips_class32",​ "",​ 0, 0, 0, 0, 0, \         htooltip% = FN_createwindow(@hwnd%,​ "​tooltips_class32",​ "",​ 0, 0, 0, 0, 0, \
         \           ​WS_CHILD+WS_VISIBLE+TTS_ALWAYSTIP+TTS_NOPREFIX,​ 0)         \           ​WS_CHILD+WS_VISIBLE+TTS_ALWAYSTIP+TTS_NOPREFIX,​ 0)
-It is advisable to create only one tooltip control for your entire program.\\ \\  Next define a TOOLINFO data structure and initialise a couple of its members:\\ +</​code>​ 
 + 
 +It is advisable to create only one tooltip control for your entire program.\\ \\  Next define a TOOLINFO data structure and initialise a couple of its members: 
 + 
 +<code bb4w>
         DIM ti{cbSize%, uFlags%, hwnd%, uId%, rect{l%,​t%,​r%,​b%},​ hinst%, lpszText%}         DIM ti{cbSize%, uFlags%, hwnd%, uId%, rect{l%,​t%,​r%,​b%},​ hinst%, lpszText%}
         TTM_ADDTOOL = 1028         TTM_ADDTOOL = 1028
Line 30: Line 48:
         ti.uFlags% = TTF_SUBCLASS         ti.uFlags% = TTF_SUBCLASS
         ti.hwnd% = hstatusbar%         ti.hwnd% = hstatusbar%
-Here **hstatusbar%** is the handle of the status bar, as returned from **FN_createstatusbar**.\\ \\  Now we have everything we need to create the tooltips themselves. For each //part// of the status bar create a tooltip for it as follows:\\ +</​code>​ 
 + 
 +Here **hstatusbar%** is the handle of the status bar, as returned from **FN_createstatusbar**.\\ \\  Now we have everything we need to create the tooltips themselves. For each //part// of the status bar create a tooltip for it as follows: 
 + 
 +<code bb4w>
         tip$ = "Tool tip"​+CHR$0         tip$ = "Tool tip"​+CHR$0
         ti.lpszText% = !^tip$         ti.lpszText% = !^tip$
         SYS "​SendMessage",​ hstatusbar%,​ SB_GETRECT, part%, ^ti.rect.l%         SYS "​SendMessage",​ hstatusbar%,​ SB_GETRECT, part%, ^ti.rect.l%
         SYS "​SendMessage",​ htooltip%, TTM_ADDTOOL,​ 0, ti{}         SYS "​SendMessage",​ htooltip%, TTM_ADDTOOL,​ 0, ti{}
 +</​code>​
 +
 Here **part%** is the status bar part number, starting from 0 for the first (leftmost) part.\\ \\  Note particularly the important **CHR$0** concatenated to the end of the tooltip string (here "Tool tip"). Here **part%** is the status bar part number, starting from 0 for the first (leftmost) part.\\ \\  Note particularly the important **CHR$0** concatenated to the end of the tooltip string (here "Tool tip").
adding_20tooltips_20to_20the_20status_20bar.txt · Last modified: 2018/04/16 14:27 by richardrussell