Created
September 23, 2010 15:34
-
-
Save jkingry/593809 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/3322741/synchronizing-multiline-textbox-positions-in-c/3779949#3779949 | |
namespace Kingry.StackOverFlow.Question_3779949 | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Forms; | |
class TextBoxSynchronizedScroll : TextBox | |
{ | |
public const int WM_VSCROLL = 0x115; | |
List<TextBoxSynchronizedScroll> peers = new List<TextBoxSynchronizedScroll>(); | |
public void AddPeer(TextBoxSynchronizedScroll peer) | |
{ | |
this.peers.Add(peer); | |
} | |
private void DirectWndProc(ref Message m) | |
{ | |
base.WndProc(ref m); | |
} | |
protected override void WndProc(ref Message m) | |
{ | |
if (m.Msg == WM_VSCROLL) | |
{ | |
foreach (var peer in this.peers) | |
{ | |
var peerMessage = Message.Create(peer.Handle, m.Msg, m.WParam, m.LParam); | |
peer.DirectWndProc(ref peerMessage); | |
} | |
} | |
base.WndProc(ref m); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment