User Tools

Site Tools


list_20view_20with_20header_20tooltips

Differences

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

Link to this comparison view

Next revision
Previous revision
list_20view_20with_20header_20tooltips [2018/03/31 13:19] – external edit 127.0.0.1list_20view_20with_20header_20tooltips [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 2: Line 2:
  
 //by Richard Russell, April 2011//\\ \\  The article [[/List%20View%20with%20tooltips|List View with tooltips]] shows how to add tooltips to the main body of a **List View** control. Occasionally you may instead want to add tooltips to the **column headers**; the program listed below shows one way of achieving that. Basically it differs from the other program only in using the Header Control handle **hwndHD%** rather than the List View handle **hwndLV%**, and in substituting the **LVM_SUBITEMHITTEST** and **LVM_GETITEMRECT** messages with the equivalents for the Header Control: **HDM_HITTEST** and **HDM_GETITEMRECT** respectively.\\ \\  It would be possible to combine the code from the two programs to provide tooltips for both the main body of the List View and the column headers. I will leave that as an exercise for the reader!\\ \\  //by Richard Russell, April 2011//\\ \\  The article [[/List%20View%20with%20tooltips|List View with tooltips]] shows how to add tooltips to the main body of a **List View** control. Occasionally you may instead want to add tooltips to the **column headers**; the program listed below shows one way of achieving that. Basically it differs from the other program only in using the Header Control handle **hwndHD%** rather than the List View handle **hwndLV%**, and in substituting the **LVM_SUBITEMHITTEST** and **LVM_GETITEMRECT** messages with the equivalents for the Header Control: **HDM_HITTEST** and **HDM_GETITEMRECT** respectively.\\ \\  It would be possible to combine the code from the two programs to provide tooltips for both the main body of the List View and the column headers. I will leave that as an exercise for the reader!\\ \\ 
 +<code bb4w>
         REM. List View with header tooltips, Richard Russell, 05-Apr-2011         REM. List View with header tooltips, Richard Russell, 05-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:
         GW_CHILD = 5         GW_CHILD = 5
Line 29: Line 30:
         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
Line 42: Line 43:
         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 62: Line 63:
         ti.hwnd% = hwndHD%         ti.hwnd% = hwndHD%
         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 78: Line 79:
           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 92: Line 93:
           ENDIF           ENDIF
         UNTIL FALSE         UNTIL FALSE
 +        
         DEF PROCtooltip(x%, y%)         DEF PROCtooltip(x%, y%)
         LOCAL tip$         LOCAL tip$
Line 110: Line 111:
         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_20header_20tooltips.1522502366.txt.gz · Last modified: 2024/01/05 00:17 (external edit)