Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
'Credit: Bernard Fomm
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Include "CommCtrl.inc"
%IDC_ListView = 400
Global hDlg, hListView,hListViewH As Dword, OrigLVProc, OrigLVHProc As Long
Function PBMain() As Long
Dialog New Pixels, 0, "gbSearch v1.0",300,300,400,220, %WS_OverlappedWindow To hDlg
Control Add ListView, hDlg, %IDC_ListView,"", 10,10,380,200 ', %LVS_NoColumnHeader
Control Handle hDlg, %IDC_ListView To hListView
ListView Set StyleXX hDlg, %IDC_ListView, %LVS_Ex_GridLines
ListView Insert Column hDlg, %IDC_ListView, 1, "Column1", 100, 0
ListView Insert Column hDlg, %IDC_ListView, 2, "Column2", 100, 0
ListView Insert Column hDlg, %IDC_ListView, 3, "Column3", 100, 0
LoadListViewData
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local hdnptr As HD_NOTIFY Ptr, hdiptr As HD_ITEM Ptr
Select Case Cb.Msg
Case %WM_InitDialog
hListViewH = GetWindow (hListView,%GW_CHILD)
OrigLVProc = SetWindowLong(hListView, %GWL_WndProc, CodePtr(NewLVProc)) 'subclass
OrigLVHProc = SetWindowLong(hListViewH, %GWL_WndProc, CodePtr(NewLVHProc)) 'subclass
Case %WM_Destroy
SetWindowLong hListView, %GWL_WNDPROC, OrigLVProc
SetWindowLong hListViewH, %GWL_WNDPROC, OrigLVHProc
End Select
End Function
Function NewLVProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Local hdnptr As HD_NOTIFY Ptr, hdiptr As HD_ITEM Ptr
Select Case Msg
Case %WM_Notify
hdnptr = lParam
hdiptr = @hdnptr.pitem
Select Case @hdnptr.hdr.code
Case %hdn_BeginTrackW : Function = %True : Exit Function
End Select
End Select
Function = CallWindowProc(OrigLVProc, hWnd, Msg, wParam, lParam)
End Function
Function NewLVHProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Local hdnptr As HD_NOTIFY Ptr, hdiptr As HD_ITEM Ptr
Select Case Msg
Case %WM_LButtonDblClk : Function = %True : Exit Function
Case %WM_SetCursor : Function = %True : Exit Function
End Select
Function = CallWindowProc(OrigLVHProc, hWnd, Msg, wParam, lParam)
End Function
Sub LoadListViewData
Local i As Long
For i = 1 To 10
ListView Insert Item hDlg, %IDC_ListView, 10,0, "Row " + Chr$(64+i)
ListView Set Text hDlg, %IDC_ListView, i, 2, "Col2 " + "Row " + Format$(i,"00")
ListView Set Text hDlg, %IDC_ListView, i, 3, "Col3 " + "Row " + Format$(i,"00")
Next i
End Sub
'gbs_01038
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm