Scroll two ExplorerListView together

The place for threads about TimoSoft ExplorerListView.
Post Reply
namalyaya@gmail.com
Cadet
Posts: 3
Joined: 27 Feb 2014, 13:11

Scroll two ExplorerListView together

Post by namalyaya@gmail.com » 27 Feb 2014, 13:20

Hello :geek: , I want to Scroll two ExplorerListView with together.
Can you explain, how do that. :(

User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: Unterföhring
Contact:

Re: Scroll two ExplorerListView together

Post by TiKu » 28 Feb 2014, 19:08

Hi,

Right now I don't have the time to create a sample project, but it should be easy. I'd subclass both controls and watch for WM_VSCROLL and WM_HSCROLL messages. Then I would duplicate these messages and send them to the slave control. To identify master and slave control, you could use GetCursorPos and WindowFromPoint and declare the control with the mouse cursor in it as the master control.

Hope this helps
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

namalyaya@gmail.com
Cadet
Posts: 3
Joined: 27 Feb 2014, 13:11

Re: Scroll two ExplorerListView together

Post by namalyaya@gmail.com » 08 Mar 2014, 08:19

Thanks :geek: Tiku Spend your time for answer :) . but I am not genius of Programming :cry: . So I haven't knowledge about sub class :? . do you can provide any similar post link which I can understand your solution. :D

User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: Unterföhring
Contact:

Re: Scroll two ExplorerListView together

Post by TiKu » 08 Mar 2014, 10:22

I'll put something together tomorrow.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

namalyaya@gmail.com
Cadet
Posts: 3
Joined: 27 Feb 2014, 13:11

Re: Scroll two ExplorerListView together

Post by namalyaya@gmail.com » 08 Mar 2014, 10:27

Thanks TiKu again. :D

User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: Unterföhring
Contact:

Re: Scroll two ExplorerListView together

Post by TiKu » 09 Mar 2014, 18:40

This seems to be more difficult than expected. The best solution I could find doesn't involve sub-classing at all. Instead it uses the AfterScroll event:

Code: Select all

Option Explicit


Private Sub Form_Load()
  Dim i As Long
  
  lv1.View = vDetails
  lv1.Columns.Add "Column 1", , 300
  For i = 1 To 100
    lv1.ListItems.Add "Item " & CStr(i)
  Next i
  lv2.View = vDetails
  lv2.Columns.Add "Column 1", , 300
  For i = 1 To 100
    lv2.ListItems.Add "Item " & CStr(i)
  Next i
End Sub

Private Sub lv1_AfterScroll(ByVal dx As Long, ByVal dy As Long)
  If lv1.Tag = "" Then
    If lv1.View = vDetails Then
      lv2.Tag = 1
      lv2.Scroll dx, dy * (lv2.ItemHeight + 2)
      lv2.Tag = ""
    End If
  End If
End Sub

Private Sub lv2_AfterScroll(ByVal dx As Long, ByVal dy As Long)
  If lv2.Tag = "" Then
    If lv2.View = vDetails Then
      lv1.Tag = 1
      lv1.Scroll dx, dy * (lv1.ItemHeight + 2)
      lv1.Tag = ""
    End If
  End If
End Sub
The problem with this approach is, that it doesn't synchronize all scroll events. For instance it won't catch the scrolling that is involved when selecting items by keyboard (arrow keys etc.)

Regards
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!

Post Reply