User Tools

Site Tools


list_20view_20with_20tooltips

Differences

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

Link to this comparison view

list_20view_20with_20tooltips [2018/03/31 13:19]
127.0.0.1 external edit
list_20view_20with_20tooltips [2018/04/15 19:12] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //by Richard Russell, April 2011//\\ \\  A **List View** control has built-in support for tooltips, but this feature requires your program to respond to the **LVN_EX_INFOTIP** notification,​ and in //BBC BASIC for Windows// that is only possible using assembler code.\\ \\  The program listed below uses an alternative technique that doesn'​t require assembler code. The position of the mouse cursor is constantly monitored, and when it moves over the List View control a tooltip is displayed. As shown, the displayed message depends only on what **item** (row) the mouse is hovering over, but it could easily be adapted so the message is specific to the **subitem** (column) as well.\\ \\  The code requires v4.70 of the Windows Common Controls, so won't work on versions of Windows prior to XP. It is also necessary to ensure that the **Use Windows XP visual styles** option is selected if the program is compiled.\\ \\  //by Richard Russell, April 2011//\\ \\  A **List View** control has built-in support for tooltips, but this feature requires your program to respond to the **LVN_EX_INFOTIP** notification,​ and in //BBC BASIC for Windows// that is only possible using assembler code.\\ \\  The program listed below uses an alternative technique that doesn'​t require assembler code. The position of the mouse cursor is constantly monitored, and when it moves over the List View control a tooltip is displayed. As shown, the displayed message depends only on what **item** (row) the mouse is hovering over, but it could easily be adapted so the message is specific to the **subitem** (column) as well.\\ \\  The code requires v4.70 of the Windows Common Controls, so won't work on versions of Windows prior to XP. It is also necessary to ensure that the **Use Windows XP visual styles** option is selected if the program is compiled.\\ \\ 
 +<code bb4w>
         REM. List View with tooltips, Richard Russell, 02-Apr-2011         REM. List View with tooltips, Richard Russell, 02-Apr-2011
 +        ​
         REM. Install libraries:         REM. Install libraries:
         INSTALL @lib$+"​WINLIB5"​         INSTALL @lib$+"​WINLIB5"​
 +        ​
         nColumns% = 5         nColumns% = 5
 +        ​
         REM!WC Windows constants:         REM!WC Windows constants:
         LVCF_FMT = 1         LVCF_FMT = 1
Line 27: Line 28:
         TTM_NEWTOOLRECT = &406         TTM_NEWTOOLRECT = &406
         TTM_UPDATETIPTEXT = &40C         TTM_UPDATETIPTEXT = &40C
 +        ​
         ON ERROR SYS "​MessageBox",​ @hwnd%, REPORT$, 0, 48 : PROCcleanup : QUIT         ON ERROR SYS "​MessageBox",​ @hwnd%, REPORT$, 0, 48 : PROCcleanup : QUIT
         ON CLOSE PROCcleanup : QUIT         ON CLOSE PROCcleanup : QUIT
 +        ​
         REM. Declare and initialise structures:         REM. Declare and initialise structures:
         DIM pt{x%,y%}, rc{l%,​t%,​r%,​b%}         DIM pt{x%,y%}, rc{l%,​t%,​r%,​b%}
Line 40: Line 41:
         lvc.mask% = LVCF_WIDTH OR LVCF_SUBITEM OR LVCF_FMT OR LVCF_TEXT         lvc.mask% = LVCF_WIDTH OR LVCF_SUBITEM OR LVCF_FMT OR LVCF_TEXT
         lvi.mask% = LVIF_TEXT OR LVIF_STATE OR LVIF_PARAM         lvi.mask% = LVIF_TEXT OR LVIF_STATE OR LVIF_PARAM
 +        ​
         REM. Create list view control:         REM. Create list view control:
         SYS "​InitCommonControls"​         SYS "​InitCommonControls"​
Line 58: Line 59:
         ti.hwnd% = hwndLV%         ti.hwnd% = hwndLV%
         SYS "​SendMessage",​ hwndTT%, TTM_ADDTOOL,​ 0, ti{}         SYS "​SendMessage",​ hwndTT%, TTM_ADDTOOL,​ 0, ti{}
 +        ​
         REM. Populate list view control:         REM. Populate list view control:
         FOR item% = 0 TO 10         FOR item% = 0 TO 10
Line 74: Line 75:
           NEXT col%           NEXT col%
         NEXT item%         NEXT item%
 +        ​
         REM. Polling loop, monitoring mouse position:         REM. Polling loop, monitoring mouse position:
         oldx% = -1         oldx% = -1
Line 88: Line 89:
           ENDIF           ENDIF
         UNTIL FALSE         UNTIL FALSE
 +        ​
         DEF PROCtooltip(x%,​ y%)         DEF PROCtooltip(x%,​ y%)
         LOCAL tip$         LOCAL tip$
Line 106: Line 107:
         ENDIF         ENDIF
         ENDPROC         ENDPROC
 +        ​
         DEF PROCcleanup         DEF PROCcleanup
         hwndLV% += 0 : IF hwndLV% PROC_closewindow(hwndLV%) : hwndLV% = 0         hwndLV% += 0 : IF hwndLV% PROC_closewindow(hwndLV%) : hwndLV% = 0
         ENDPROC         ENDPROC
 +</​code>​
list_20view_20with_20tooltips.txt ยท Last modified: 2018/04/15 19:12 by tbest3112