Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting two scrollbars to mirror eachother

340 views
Skip to first unread message

MrNobody

unread,
Jul 26, 2005, 10:20:05 AM7/26/05
to
I have two large text boxes side by side which when loaded with text will
usually get a horizontal scrollbar automatically.

I would like to set it up so that when I scroll a bit to one direction on
one textbox, the other textbox scrolls in the same direction with the same
amount...

how to do this?

MrNobody

unread,
Jul 26, 2005, 10:51:04 AM7/26/05
to
Update, I had to change from TextBox to ListView now for column support, but
I still have the same problem- how can I get two ListView's scrollbars to
mirror eachother?

There aren't even any properties/methods on ListView to get at the
scrollbars...

Nicholas Paldino [.NET/C# MVP]

unread,
Jul 26, 2005, 10:59:20 AM7/26/05
to
MrNobody,

Basically, when you scroll one list view, you can send the LVM_SCROLL
message to the other to make that one scroll as well. You can detect when
one list view scrolls by overriding the WndProc method and looking for the
WM_VSCROLL (vertical scroll) message, I believe.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"MrNobody" <MrNo...@discussions.microsoft.com> wrote in message
news:16DE67B2-D4EC-4AC3...@microsoft.com...

MrNobody

unread,
Jul 26, 2005, 11:32:37 AM7/26/05
to
Thanks for your reply!

Ok I know how to extend the control and override the WndProc method but how
do I compare the Msg property to 'WM_VSCROLL' ? When I do:

if (m.Msg == WM_VSCROLL)

I get a compiler error, it does not know what WM_VSCROLL is...

also, onced I capture this how do I send this as a command to the other
ListView's scrollbar?


Thanks!

Nicholas Paldino [.NET/C# MVP]

unread,
Jul 26, 2005, 11:42:22 AM7/26/05
to
MrNobody,

You can get the value for WM_VSCROLL from the C++ header file WinUser.h
(it should have been installed if you installed Visual C++, or you can
google it).

As for sending the message to the other listview, you can declare the
SendMessage function to be called through the P/Invoke layer (you can get
the definition from http://www.pinvoke.net).


--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"MrNobody" <MrNo...@discussions.microsoft.com> wrote in message

news:127B44A8-7E27-420E...@microsoft.com...

MrNobody

unread,
Jul 26, 2005, 4:08:04 PM7/26/05
to
Nicholas,

thanks again for your help!

OK this is starting to get a little bit over my head... (the sending message
part) What do you mean by declaring a SendMessage through a p/invoke layer? I
am totally unfamilar with what the web site is referencing...

"Nicholas Paldino [.NET/C# MVP]" wrote:

> MrNobody,
>

0 new messages