Disable the CTRL+ mouse wheel scroll text resize
-
Hi All, I want to disable text resize of texts of a rich text box when Ctrl + Mouse Wheel scroll is being proformed. Any idea!! Any clues!! How to fix it. Please suggest... Thanks in advance, Regards, Jay.
-
Hi All, I want to disable text resize of texts of a rich text box when Ctrl + Mouse Wheel scroll is being proformed. Any idea!! Any clues!! How to fix it. Please suggest... Thanks in advance, Regards, Jay.
Extend the
RichTextBox
class and overrideWndProc
. If you don't want to allow zooming at all, catch theEM_SETZOOM
(0x04e1) and don't callbase.WndProc
. If you don't want the mouse to be able to set the zoom factor, then catch theWM_MOUSEWHEEL
(0x020a) and use the staticControl.ModiferKeys
properties to easily determine if the Ctrl+MouseWheel is in effect. If it is, again, don't callbase.WndProc
. In all other cases, be sure to callbase.WndProc
passing a reference to theMessage
struct otherwise your control will not work at all and may not even be initialized correctly.Microsoft MVP, Visual C# My Articles
-
Extend the
RichTextBox
class and overrideWndProc
. If you don't want to allow zooming at all, catch theEM_SETZOOM
(0x04e1) and don't callbase.WndProc
. If you don't want the mouse to be able to set the zoom factor, then catch theWM_MOUSEWHEEL
(0x020a) and use the staticControl.ModiferKeys
properties to easily determine if the Ctrl+MouseWheel is in effect. If it is, again, don't callbase.WndProc
. In all other cases, be sure to callbase.WndProc
passing a reference to theMessage
struct otherwise your control will not work at all and may not even be initialized correctly.Microsoft MVP, Visual C# My Articles
Hi Heath, Thanx a lot, I could solve the problem by 1.Extending the RichTextBox class 2. Catching WM_MOUSEWHEEL (0x020a) and checking whether Control.ModiferKeys is Keys.Control 3. not calling base.WndProc in the above case (mentioned in 2). Where as I could not get the result by Catching EM_SETZOOM (0x04e1) and not calling base.WndProc. I am keen to know whether is it possible to solve the problem using EM_SETZOOM ? Please Comment. Thanks and Regards, Jay.
-
Hi Heath, Thanx a lot, I could solve the problem by 1.Extending the RichTextBox class 2. Catching WM_MOUSEWHEEL (0x020a) and checking whether Control.ModiferKeys is Keys.Control 3. not calling base.WndProc in the above case (mentioned in 2). Where as I could not get the result by Catching EM_SETZOOM (0x04e1) and not calling base.WndProc. I am keen to know whether is it possible to solve the problem using EM_SETZOOM ? Please Comment. Thanks and Regards, Jay.
RichTextBox.ZoomFactor
is also between 0.64 and 64.0 because it simply uses theEM_GETZOOM
andEM_SETZOOM
message which it sends to the underlying window handle, same as practically all the controls in Windows Forms.Microsoft MVP, Visual C# My Articles
-
RichTextBox.ZoomFactor
is also between 0.64 and 64.0 because it simply uses theEM_GETZOOM
andEM_SETZOOM
message which it sends to the underlying window handle, same as practically all the controls in Windows Forms.Microsoft MVP, Visual C# My Articles
Hi Heath, Thanks for the info. using EM_SETZOOM should give the same result.But it does not work I tried to catch the EM_SETZOOM using the following code Did I go wrong somewhere in implementation?. Please comment.
protected override void WndProc(ref System.Windows.Forms.Message m) { if (m.Msg == 0x04e1) //EM_SETZOOM { //Do not set the Zoom simply return return; } else { base.WndProc(ref m); } }
Where as catching WM_MOUSEWHEEL and asserting Control.ModifierKeys == Keys.Control solves the problem. Thanks and Regards, Jay. -
Hi Heath, Thanks for the info. using EM_SETZOOM should give the same result.But it does not work I tried to catch the EM_SETZOOM using the following code Did I go wrong somewhere in implementation?. Please comment.
protected override void WndProc(ref System.Windows.Forms.Message m) { if (m.Msg == 0x04e1) //EM_SETZOOM { //Do not set the Zoom simply return return; } else { base.WndProc(ref m); } }
Where as catching WM_MOUSEWHEEL and asserting Control.ModifierKeys == Keys.Control solves the problem. Thanks and Regards, Jay.I've tried a few things to and it's my educated guess that the Rich Edit control (which is encapsulated by the
RichTextBox
) doesn't use theEM_SETZOOM
when using Ctrl + Mouse Wheel and instead handles that internally in much the same way the handler forEM_SETZOOM
does.Microsoft MVP, Visual C# My Articles
-
I've tried a few things to and it's my educated guess that the Rich Edit control (which is encapsulated by the
RichTextBox
) doesn't use theEM_SETZOOM
when using Ctrl + Mouse Wheel and instead handles that internally in much the same way the handler forEM_SETZOOM
does.Microsoft MVP, Visual C# My Articles
Hi Heath, Thanks a lot for sparing your valuable time to solve the problem. Warm Regards, Jay.