Wednesday 24 December 2014

Disabling smooth scrolling on wordpad

I’ve always been annoyed by smooth scrolling, and if you’re reading this blog post, you’re probably annoyed too. Wordpad on windows has smooth scrolling on, and a quick browse through the settings turns up no option to disable this. Time to debug!

A quick browse through the modules list (windbg’s lm) shows up something interesting, msftedit.dll, which a quick googling shows that it allows applications to embed rich text text-boxes. This is the dll for the latest version of the rich text edit control, v4.1. Previous versions include riched20.dll and riched32.dll.

Since that is basically what wordpad is doing, could wordpad simply have embedded a rich text box in it’s window? Breaking on msftedit!RichEditWndProc shows that this is indeed the case, where scrolling the text box breaks on this routine, with WM_MOUSEWHEEL as the message parameter.

Rich edit boxes are not only used under wordpad, but all over the place. Examples include tortoisegit and windbg.

Digging a bit further, we see that the routine that starts the scrolling is the following:

0051ee3c 5ec19ed8 Msftedit!CDisplay::SmoothVScroll
0051ee60 5ec0d6de Msftedit!CMagellan::MagellanRollScroll+0x98
0051eea8 5ebb8f66 Msftedit!CTxtEdit::HandleMouseWheel+0xee
0051f028 5ebe38e5 Msftedit!CTxtEdit::TxSendMessage+0xe15
0051f918 76de62fa Msftedit!RichEditWndProc+0xa31

Fortunately for us, SmoothVScroll is open sourced in windows CE, which helps in analysis. But going through each of the methods starting from HandleMouseWheel, we see that there are a couple of places the call to SmoothVScroll can be skipped, depending on some flags. Unfortunately none give us the desired behaviour. Some flags control zooming, and others disable scrolling entirely.

The relevant header file defines SmoothVScroll ‘s as:

VOID    SmoothVScroll ( int direction, WORD cLines, int speedNum, int speedDenom, BOOL fMouseRoller );

We can see some speed arguments here. Patching speedNum to 1 and speedDenom to 50, to give a speed of 1/50 instead of the default 3/1, does give us instant scrolling behavour, But SmoothVScroll also has a kind of acceleration effect, where if we scroll longer using the mouse wheel the scrolling speed will accelerate. This can be rather annoying while editing text.

There is a way to skip the call to SmoothVScroll entirely, and without going into internal functions, by hooking RichEditWndProc and sending WM_VSCROLL when WM_MOUSEWHEEL is received. The former occurs when we press the up and down buttons on the scrollbar.

We can also scroll faster by sending it more than once.

I implemented the above hooks in rich edit scroll, which uses minhook, SetWindowsHookEx and friends. Run install.bat to run it on startup, and smooth scrolling will be gotten rid of for good.

Rich edit scroll allows configuring which applications to hook as well as scrolling speed. Hooking is opt-in due to exe protectors often checking whether LoadLibrary is hooked, which is sometimes necessary, in the case of windbg. That can cause them to stop working.

12 comments:

  1. Something else must be going on though as well. Because I'm pretty sure the problem of perpetual smooth-scroll in WordPad happens only for people with Logitech mice using the SetPoint software. Otherwise, how could you explain the following?

    My home computer runs Windows 7 x64 Professional, I use a Logitech M570 trackball with official Logitech drivers and SetPoint software (v6.65). Smooth scrolling is turned off in both Windows' mouse settings and the SetPoint control panel, yet WordPad (and *only* WordPad) still smooth-scroll in an annoying, broken way (limiting scroll speed to the lines-per-second setting, which is *NOT* how smooth scroll works in other applications).

    My work computer runs Windows 7 x64 Enterprise, I use a Logitech M570 trackball *without* any Logitech software. Smooth scrolling is turned off in Windows' mouse settings, and indeed there is no smooth scrolling in WordPad.

    SetPoint seems to intercept all mouse actions before forwarding them again, in order to provide the button redefinition functionality, etc. Somewhere along this forwarding process, it breaks something about the mouse wheel actions. I'm sure most, if not all, people complaining about WordPad smooth-scrolling in the web are using SetPoint or some similar software. Note that a particularly irritating thing about this is that killing the SetPoint process or even uninstalling the software is not enough to remove the problem–it seems to be hooked in somewhere deeper. Only a reboot after uninstalling SetPoint will restore the non-smooth-scrolling state.

    ReplyDelete
    Replies
    1. Simons Codes: Disabling Smooth Scrolling On Wordpad >>>>> Download Now

      >>>>> Download Full

      Simons Codes: Disabling Smooth Scrolling On Wordpad >>>>> Download LINK

      >>>>> Download Now

      Simons Codes: Disabling Smooth Scrolling On Wordpad >>>>> Download Full

      >>>>> Download LINK FK

      Delete
  2. I don't think this is limited to logitech (my mouse isn't, and smooth scrolling is enabled), see code refs in post. I've no idea how smooth scrolling could be disabled depending on mice, the code indicates it's enabled no matter what mouse you're using.

    Have you tried rich edit hook yet? I've just uploaded a release. It should hopefully work.

    ReplyDelete
    Replies
    1. I gave it a go, unfortunately it doesn't seem to work. Is there anything I'd need to do besides running it? I get the tray icon with the 'Exit' option, but nothing else happens. I also copied in the .ini file which isn't in the release package, but it didn't make a difference.

      Also, scratch the last paragraph in my earlier comment; I got my systems mixed up. Uninstalling SetPoint didn't actually do the trick, not even after a reboot. I still think it has to be a third-party software triggering the problem though, because I can't imagine what else it could be that is different between my home and office desktops. Maybe some software, Logitech or not, changed some obscure registry value or patched a system file?

      That you don't use Logitech hardware or software is good to know. Just to be sure though, are we talking about the same symptom? Re-reading the article, you mention SmoothVScroll having an acceleration effect, and I don't have that. In fact, the lack of acceleration effect is pretty much the reason why this smooth scrolling bothers me so, in contrast to e.g. the one in Firefox. My scrolling speed in Windows is set to 3 lines, which is fine for all the other applications that respect the disabled smooth scroll settings. However when I turn my mouse wheel quickly in Wordpad, scrolling will be limited to a certain speed related to that setting (although I don't know what the exact relation is). The effect this has is that a quick turn of the mouse wheel can send WordPad into several seconds of automatic scrolling. Worse, if I'm at the end of a document and give the mouse wheel a spin down, then scroll up again, the window will immediately scroll back down to the bottom again, as long as it takes to "process" all the clicks of the wheel I sent originally.

      Delete
    2. Well, this is embarrassing. I was right about the "third-party software" bit, but that's about as far as it goes. I decided to look more closely at the differences between my two systems, so I checked the running processes on my office computer. One of the usability helpers I installed there is called KatMouse, and I use it to have the focus of wheel scrolling be on the window the mouse is pointing at, and not the one that has keyboard focus. It's almost essential for working with multiple monitors, but so transparent that I completely forgot I actually had a software running that specifically modifies my mouse wheel behaviour! Turns out that, although undocumented, the tool has the side effect of getting rid of WordPad's smooth scroll as well. As soon as I quit the tool, my office WordPad behaves as annoyingly as my home WordPad.

      I still wonder why your hook tool doesn't work for me – am I too thick to understand how to run it correctly, or could it be because of some differences in our system's libraries?

      Delete
    3. The idea is to copy it to %appdata% then run the hook exe in order, nothing complicated. It's supposed to disable smooth scrolling completely, including the acceleration and all. I keep smooth scrolling in firefox disabled, btw, as it's the animation that I find rather annoying. If it works the scrolling speed should be constant.

      I did test it on a win 7 enterprise vm though, strange it doesn't work on your system.

      Delete
    4. Got it – I just downloaded the .ini file to %Appdata% directly from Github without opening it to check. Turns out it had LF line breaks, and everything works after converting those to CR LF. Thanks!

      Delete
    5. That's still rather weird, when I checked mine they were just \n line breaks, but anyway glad you have it working :)

      Delete
  3. > I implemented the above hooks in rich edit scroll, which uses minhook, SetWindowsHookEx and friends. Run install.bat to run it on startup, and smooth scrolling will be gotten rid of for good.

    I tried this, but it seems that the file "rich_edit_scroll.exe" is not included when downloading rich_edit_scroll-master.zip.

    Thanks for any help -- I have been trying to get rid of Smooth Scrolling in WordPad for so many years, so it really would be great if this worked!

    Thanks,
    David

    ReplyDelete
  4. Don't download the repo, download it from the releases tab (rich_edit_scroll.zip). That one has the executable.

    ReplyDelete
  5. @simonzack

    When rich_edit_scroll.exe is running, I'm unable to Ctrl + Scroll to Zoom In/Out of the WordPad window. Can you look into this?

    Thanks

    ReplyDelete
  6. Simons Codes: Disabling Smooth Scrolling On Wordpad >>>>> Download Now

    >>>>> Download Full

    Simons Codes: Disabling Smooth Scrolling On Wordpad >>>>> Download LINK

    >>>>> Download Now

    Simons Codes: Disabling Smooth Scrolling On Wordpad >>>>> Download Full

    >>>>> Download LINK 2v

    ReplyDelete