Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "win32api.inc"
Global hDlg, hContextListView As DWord
%IDMC_ListViewOne = 920 : %IDMC_ListViewTwo = 921
Function PBMain() As Long
Dialog New Pixels, 0, "ListView Test",300,300,245,95,%WS_SysMenu, 0 To hDlg
Control Add ListView, hDlg, 100, "", 10,10,175,75 '225
'columns hdlg, id&, col, "test", width, format
ListView Insert Column hDlg, 100, 1, "test1", 75, 0
ListView Insert Column hDlg, 100, 2, "test2", 75, 0
'rows hdlg, id&, row, image, "text"
ListView Insert Item hDlg, 100, 1, 1, "one" 'row 1, col1
ListView Insert Item hDlg, 100, 2, 2, "two" 'row 2, col1
'context menu
Menu New Popup To hContextListView
Menu Add String, hContextListView, "One", %IDMC_ListViewOne, %MF_Enabled
Menu Add String, hContextListView, "Twot", %IDMC_ListViewTwo, %MF_Enabled
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local x, y, iReturn As Long
Select Case CB.Msg
Case %WM_ContextMenu
x = Lo(Integer,CB.lParam) : y = Hi(Integer, CB.lParam)
iReturn = GetDlgCtrlID (CB.wParam) 'get control ID
Select Case iReturn
Case 100 '%IDC_ListView
TrackPopupMenu hContextListView, %TPM_LEFTALIGN, x, y, 0, CB.Hndl, ByVal 0
End Select
End Select
End Function
'gbs_00530
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm