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"
%IDC_ListViewL = 500 : %IDC_ListViewR = 501
Global hDlg,hLeft,hRight As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "ListView Test",300,300,230,200,%WS_OverlappedWindow, 0 To hDlg
CreateListViews
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local rcLeft, rcRight as Rect
Select Case Cb.Msg
Case %WM_Notify
Select Case Cb.NMCode
SendMessage(hLeft, %LVM_GetItemRect, 0, VarPtr(rcLeft)) 'rcLeft.nLeft = %LVIR_BOUNDS = 0
SendMessage(hRight, %LVM_GetItemRect, 0, VarPtr(rcRight)) 'rcRight.nLeft = %LVIR_BOUNDS = 0
If Cb.wParam = %IDC_ListViewL Then
SendMessage(hRight, %LVM_Scroll, 0, rcRight.nTop - rcLeft.nTop)
ElseIf Cb.WParam = %IDC_ListViewR Then
SendMessage(hLeft, %LVM_Scroll, 0, rcLeft.nTop - rcRight.nTop)
End If
End Select
End Select
End Function
Sub CreateListViews
Local i As Long
Control Add ListView, hDlg, %IDC_ListViewL, "", 10,10,100,180
Control Add ListView, hDlg, %IDC_ListViewR, "", 120,10,100,180
Control Handle hDlg, %IDC_ListViewL To hLeft
Control Handle hDlg, %IDC_ListViewR To hRight
ListView Insert Column hDlg, %IDC_ListViewL, 1, "Left", 80, 0
ListView Insert Column hDlg, %IDC_ListViewR, 1, "Right", 80, 0
For i = 1 To 1000
ListView Insert Item hDlg, %IDC_ListViewL, 1, 0, Str$(i)
ListView Insert Item hDlg, %IDC_ListViewR, 1, 0, Str$(i)
Next i
End Sub
'gbs_01131
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm