-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScrollSyncTextBox.cs
More file actions
40 lines (34 loc) · 1.11 KB
/
ScrollSyncTextBox.cs
File metadata and controls
40 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
namespace MarkdownThing
{
/// <summary>
/// Multiline TextBox that raises <see cref="Scroll"/> when the user scrolls vertically.
/// </summary>
internal class ScrollSyncTextBox : TextBox
{
private const int WmVScroll = 0x0115;
private const int WmMouseWheel = 0x020A;
public event EventHandler? Scroll;
public event EventHandler? SelectionChanged;
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg is WmVScroll or WmMouseWheel)
Scroll?.Invoke(this, EventArgs.Empty);
}
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
SelectionChanged?.Invoke(this, EventArgs.Empty);
}
protected override void OnMouseUp(MouseEventArgs mevent)
{
base.OnMouseUp(mevent);
SelectionChanged?.Invoke(this, EventArgs.Empty);
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
SelectionChanged?.Invoke(this, EventArgs.Empty);
}
}
}