|
-
Aug 13th, 2003, 07:27 AM
#1
Thread Starter
Hyperactive Member
Synchronize two Listviews scroll
I have two Listviews side-by-side and I want their scrolling behavior to be synchronized. I.E. When the user drags the vertical scroll bar up or down on one list view, I would like the other listview to do the same.
I have already hooked the two listviews and trapped the WM_VSCROLL messages, which are fine for when the user clicks the "Scroll Up" and "Scroll Down" arrows on the scroll bar. But what messages can I trap to detect when the user drags the scrollbar with the mouse?
Thanks
And I, for one, welcome our new insect overlords. I'd like to remind them as a trusted TV personality, I can be helpful in rounding up others to toil in their underground sugar caves.
-
Dec 5th, 2015, 08:35 AM
#2
Member
Re: Synchronize two Listviews scroll
Hey,
Did you find a solution for your issue?
I know it is almost 12 years ago!
-
Dec 23rd, 2015, 03:26 PM
#3
Re: Synchronize two Listviews scroll
Seems you need to check the LOWORD of wParam when receiving a Scroll message.
Quick test in VB.Net,....
Code:
Public Class ListViewEx
Inherits ListView
Private Const SB_THUMBTRACK As Int32 = 5
Private Const SB_ENDSCROLL As Int32 = 8
Private Const WM_VSCROLL As Int32 = &H115
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_VSCROLL
' see https://msdn.microsoft.com/en-us/library/windows/desktop/bb787577(v=vs.85).aspx
'
' wParam
' The LOWORD specifies a scroll bar value that indicates the user's scrolling request.
'
' get LOWORD from wParam
Dim lw = LOWORD(m.WParam)
' show result
Select Case lw
Case SB_THUMBTRACK
Debug.WriteLine("The user is dragging the scroll box. ")
Case SB_ENDSCROLL
Debug.WriteLine("Ends scroll.")
End Select
End Select
MyBase.WndProc(m)
End Sub
' Converted to VB from NativeMethods.cs,
' http://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/NativeMethods.cs,e1ab28ba69954959
Public Shared Function LOWORD(n As Integer) As Integer
Return n And &HFFFF
End Function
Public Shared Function LOWORD(n As IntPtr) As Integer
Return LOWORD(CInt(CLng(n)))
End Function
End Class
Last edited by Edgemeal; Dec 23rd, 2015 at 04:29 PM.
Reason: typos
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|