From 0ff70fe612fbb306162b034c5c12ede5bc50a3d6 Mon Sep 17 00:00:00 2001 From: Sigmanor Date: Wed, 31 May 2017 22:10:09 +0300 Subject: [PATCH] Fixed #6 --- Crypto Notepad/CustomRichTextBox.cs | 39 +++++++++++++++++------------ Crypto Notepad/Form1.Designer.cs | 4 +-- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Crypto Notepad/CustomRichTextBox.cs b/Crypto Notepad/CustomRichTextBox.cs index b100a6d..14dfc61 100644 --- a/Crypto Notepad/CustomRichTextBox.cs +++ b/Crypto Notepad/CustomRichTextBox.cs @@ -53,22 +53,29 @@ protected override void OnHandleCreated(EventArgs e) } } - //protected override void WndProc(ref Message m) - //{ - // if (m.Msg == WM_MOUSEWHEEL) - // { - // int scrollLines = SystemInformation.MouseWheelScrollLines; - // for (int i = 0; i < scrollLines; i++) - // { - // if ((int)m.WParam > 0) // when wParam is greater than 0 - // SendMessage(this.Handle, WM_VSCROLL, (IntPtr)0, IntPtr.Zero); // scroll up - // else - // SendMessage(this.Handle, WM_VSCROLL, (IntPtr)1, IntPtr.Zero); // else scroll down - // } - // return; - // } - // base.WndProc(ref m); - //} + protected override void WndProc(ref Message m) + { + if (m.Msg == WM_MOUSEWHEEL) + { + int scrollLines = SystemInformation.MouseWheelScrollLines; + for (int i = 0; i < scrollLines; i++) + { + try + { + if ((int)m.WParam >= 0) // when wParam is greater than 0 + SendMessage(this.Handle, WM_VSCROLL, (IntPtr)0, IntPtr.Zero); // scroll up + else + SendMessage(this.Handle, WM_VSCROLL, (IntPtr)1, IntPtr.Zero); // scroll down + } + catch (OverflowException) + { + SendMessage(this.Handle, WM_VSCROLL, (IntPtr)1, IntPtr.Zero); // scroll down + } + } + return; + } + base.WndProc(ref m); + } /// /// Search and Highlight all text in RichTextBox Control diff --git a/Crypto Notepad/Form1.Designer.cs b/Crypto Notepad/Form1.Designer.cs index e3df925..a4ffb50 100644 --- a/Crypto Notepad/Form1.Designer.cs +++ b/Crypto Notepad/Form1.Designer.cs @@ -795,9 +795,9 @@ public void InitializeComponent() this.customRTB.ContextMenuStrip = this.contextMenuStrip1; this.customRTB.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.customRTB.ForeColor = System.Drawing.SystemColors.WindowText; - this.customRTB.Location = new System.Drawing.Point(6, 52); + this.customRTB.Location = new System.Drawing.Point(6, 47); this.customRTB.Name = "customRTB"; - this.customRTB.Size = new System.Drawing.Size(523, 247); + this.customRTB.Size = new System.Drawing.Size(529, 252); this.customRTB.TabIndex = 10; this.customRTB.Text = ""; this.customRTB.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.customRTB_LinkClicked);