Date: 02-16-2022
Return to Index
created by gbSnippets
'Credit: Kev Peel
'See this post at http://www.powerbasic.com/support/pbforums/showthread.php?t=12896
'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, OrigLeft, OrigRight, sbUpdating As Long
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
Select Case Cb.Msg
Case %WM_InitDialog
OrigLeft = SetWindowLong(hLeft,%GWL_WNDPROC, CodePTR(NewProc))
OrigRight = SetWindowLong(hRight,%GWL_WNDPROC, CodePTr(NewProc))
Case %WM_Destroy
SetWindowLong hLeft, %GWL_WNDPROC, OrigLeft
SetWindowLong hRight, %GWL_WNDPROC, OrigRight
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 100
ListView Insert Item hDlg, %IDC_ListViewL, 1, 0, Str$(i)
ListView Insert Item hDlg, %IDC_ListViewR, 1, 0, Str$(i)
Next i
End Sub
Function NewProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Static sbUpdating As Byte
Select Case Msg
Case %WM_MouseFirst To %WM_MouseLast, %WM_KEYFIRST To %WM_KEYLAST, %WM_VScroll, %WM_HScroll
If (sbUpdating = %False) Then
sbUpdating = %True
SendMessage IIF(hWnd=hLeft,hRight,hLeft), Msg, wParam, lParam
sbUpdating = %False
End If
End Select
Function = CallWindowProc (IIF(hWnd=hLeft,OrigRight,OrigLeft), hWnd, Msg, wParam, lParam)
End Function
'gbs_01126
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm