Date: 02-16-2022
Return to Index
created by gbSnippets
'By adding the LVS_Ex_InfoTip style to a ListView, the LVN_GetInfoTip
'notification will be sent to the dialog, in which you can
'set the tooltip for the item 0.
'Primary Code:
'set the style
ListView Set StyleXX hDlg, %IDC_ListView, %LVS_Ex_InfoTip '<--- enables builtin tooltips
'set the infotip text
Case %WM_Notify
Select Case Cb.NmId
Case %IDC_ListView
Select Case Cb.NmCode
Case %LVN_GetInfoTip
LVGIT = Cb.LParam
@LVGIT.cchTextMax = Len(text$) '<-- in example below, infotip text is in array
@LVGIT.pszText = StrPtr(text$) '<-- in example below, infotip text is in array
End Select
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "win32api.inc"
#Include "commctrl.inc"
#Resource "gbsnippets.pbr"
%IDC_ListView = 500
Global hDlg,hListView,hList As Dword, D() As String
Function PBMain() As Long
Dialog New Pixels, 0, "ListView Test",300,300,200,125,%WS_SysMenu, 0 To hDlg
Dim D(1) : D(0) = "one" : D(1) = "two"
CreateListView
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local LVGIT As NMLVGetInfoTip Ptr, temp$
Select Case Cb.Msg
Case %WM_Notify
Select Case Cb.NmId
Case %IDC_ListView
Select Case Cb.NmCode
Case %LVN_GetInfoTip
LVGIT = Cb.LParam
@LVGIT.cchTextMax = Len(D(@LVGIT.iItem))
@LVGIT.pszText = StrPtr(D(@LVGIT.iItem))
End Select
End Select
End Select
End Function
Sub CreateListview
Control Add ListView, hDlg, %IDC_ListView, "", 10,10,180,100, %WS_Visible Or %LVS_Icon
ListView Set StyleXX hDlg, %IDC_ListView, %LVS_Ex_InfoTip '<--- enables builtin tooltips
Control Handle hDlg, %IDC_ListView To hListView
ImageList New Icon 32,32,24,3 To hList
ImageList Add Icon hList, "x" 'image 1
ImageList Add Icon hList, "y" 'image 2
ListView Set ImageList hDlg, %IDC_ListView, hList, %lvsil_normal 'normal (large) imagelist for LVS_Icon mode
ListView Insert Column hDlg, %IDC_ListView, 1, "test1", 75, 0
ListView Insert Item hDlg, %IDC_ListView, 1, 1, "" 'row,image,text
ListView Insert Item hDlg, %IDC_ListView, 2, 2, "" 'row,image,text
End Sub
'gbs_00991
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm