Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Disable the CTRL+ mouse wheel scroll text resize

Disable the CTRL+ mouse wheel scroll text resize

Scheduled Pinned Locked Moved C#
helptutorial
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jay Shankar
    wrote on last edited by
    #1

    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.

    H 1 Reply Last reply
    0
    • J Jay Shankar

      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.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Extend the RichTextBox class and override WndProc. If you don't want to allow zooming at all, catch the EM_SETZOOM (0x04e1) and don't call base.WndProc. If you don't want the mouse to be able to set the zoom factor, then catch the WM_MOUSEWHEEL (0x020a) and use the static Control.ModiferKeys properties to easily determine if the Ctrl+MouseWheel is in effect. If it is, again, don't call base.WndProc. In all other cases, be sure to call base.WndProc passing a reference to the Message struct otherwise your control will not work at all and may not even be initialized correctly.

      Microsoft MVP, Visual C# My Articles

      J 1 Reply Last reply
      0
      • H Heath Stewart

        Extend the RichTextBox class and override WndProc. If you don't want to allow zooming at all, catch the EM_SETZOOM (0x04e1) and don't call base.WndProc. If you don't want the mouse to be able to set the zoom factor, then catch the WM_MOUSEWHEEL (0x020a) and use the static Control.ModiferKeys properties to easily determine if the Ctrl+MouseWheel is in effect. If it is, again, don't call base.WndProc. In all other cases, be sure to call base.WndProc passing a reference to the Message struct otherwise your control will not work at all and may not even be initialized correctly.

        Microsoft MVP, Visual C# My Articles

        J Offline
        J Offline
        Jay Shankar
        wrote on last edited by
        #3

        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.

        H 1 Reply Last reply
        0
        • J Jay Shankar

          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.

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          RichTextBox.ZoomFactor is also between 0.64 and 64.0 because it simply uses the EM_GETZOOM and EM_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

          J 1 Reply Last reply
          0
          • H Heath Stewart

            RichTextBox.ZoomFactor is also between 0.64 and 64.0 because it simply uses the EM_GETZOOM and EM_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

            J Offline
            J Offline
            Jay Shankar
            wrote on last edited by
            #5

            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.

            H 1 Reply Last reply
            0
            • J Jay Shankar

              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.

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              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 the EM_SETZOOM when using Ctrl + Mouse Wheel and instead handles that internally in much the same way the handler for EM_SETZOOM does.

              Microsoft MVP, Visual C# My Articles

              J 1 Reply Last reply
              0
              • H Heath Stewart

                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 the EM_SETZOOM when using Ctrl + Mouse Wheel and instead handles that internally in much the same way the handler for EM_SETZOOM does.

                Microsoft MVP, Visual C# My Articles

                J Offline
                J Offline
                Jay Shankar
                wrote on last edited by
                #7

                Hi Heath, Thanks a lot for sparing your valuable time to solve the problem. Warm Regards, Jay.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups