Crypto-Notepad/Crypto Notepad/ExRichTextBox.cs

39 lines
1.3 KiB
C#
Raw Normal View History

2019-08-27 07:04:44 +00:00
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Crypto_Notepad
{
public class ExRichTextBox : RichTextBox
{
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
2019-08-27 08:35:02 +00:00
private const int WM_VSCROLL = 0x115;
private const int WM_MOUSEWHEEL = 0x20A;
2019-08-27 07:04:44 +00:00
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_MOUSEWHEEL)
{
int scrollLines = SystemInformation.MouseWheelScrollLines;
for (int i = 0; i < scrollLines; i++)
{
2019-08-30 09:21:55 +00:00
try
{
if ((int)m.WParam >= 0)
SendMessage(Handle, WM_VSCROLL, (IntPtr)0, IntPtr.Zero);
else
SendMessage(Handle, WM_VSCROLL, (IntPtr)1, IntPtr.Zero);
}
catch (OverflowException)
{
2019-08-27 07:04:44 +00:00
SendMessage(Handle, WM_VSCROLL, (IntPtr)1, IntPtr.Zero);
2019-08-30 09:21:55 +00:00
}
2019-08-27 07:04:44 +00:00
}
return;
}
base.WndProc(ref m);
}
2019-08-27 08:35:02 +00:00
2019-08-27 07:04:44 +00:00
}
}