Just an addition here. When I override the WndProc and use SendMessage
to send the info along, using Spy++ I can see that the
SB_ThumbPosition and the SB_ThumbTrack messages are being received by
the second ListView, but it's not processing them for some reason.
SlantyOD@hotmail.com (SlantyOD) wrote in message news:<42289057.0312151356.672de061@posting.google. com>...[color=blue]
> Hi All,
>
> I'm trying to tie two ListViews together so that when the user scrolls
> one, the other stays 'in sync'. Since there are no OnScroll events,
> and the scroll bar position is unavailable, I've been forced to create
> my own ListView class and override WndProc. In this I've caught all
> instances of WH_VScroll and WH_HScroll, and then I can pass this info
> onto the second ListView by using the User32.dll method SendMessage.
> This all works beautifully if the user clicks on teh arrow buttons,
> but doesn't work if the user decides to click and drag the bar along
> the scrollbar. I've determined that the problem is in handling the
> SB_ThumbTrack and SB_ThumbPosition values. But beyond that I'm
> stumped. I don't suppose anybody knows anything about this? I've
> posted my Class below, I'm just setting the Associated ListView
> manually when I create the class for now. I've edited out somestuff,
> but left in the code for determining the HIWORD and LOWORD values
> which may or may not be important. I'm pretty much way in over my head
> on this one =).
>
> CHeers,
> SlantyOD
>
> using System;
> using System.Collections;
> using System.ComponentModel;
> using System.Drawing;
> using System.Data;
> using System.Windows.Forms;
> using System.Runtime.InteropServices;
>
>
> namespace myNameSpace
> {
> public class MyListView : System.Windows.Forms.ListView
> {
> public ListView AssociatedListView;
> private System.ComponentModel.Container components = null;
> [DllImport("User32.dll")]
> private static extern bool SendMessage(IntPtr hwnd, UInt32 msg, UInt32
> wParam, UInt32 lParam);
>
> public MyListView()
> {
> InitializeComponent();
> }
>
> protected override void Dispose( bool disposing )
> {
> if( disposing )
> {
> if( components != null )
> {
> components.Dispose();
> }
> base.Dispose( disposing );
> }
>
>
> private void InitializeComponent()
> {
> components = new System.ComponentModel.Container();
> }
>
> private const int WM_HSCROLL = 0x114;
> private const int WM_VSCROLL = 0x115;
> protected override void WndProc(ref Message msg)
> {
>
> // Look for the WM_VSCROLL or the WM_HSCROLL messages.
> if (msg.Msg == WM_HSCROLL)
> {
> int myInt = msg.WParam.ToInt32();
> int IntLow = myInt & 0xffff;
> long IntHigh = ((long)myInt & 0xffff0000) >> 16;
> SendMessage(this.AssociatedListView.Handle,
> (int)WM_HSCROLL, (uint)msg.WParam.ToInt64(),
> (uint)msg.LParam.ToInt64());
> }
> // Pass message to default handler.
> base.WndProc(ref msg);
> }
> }[/color]