Results 1 to 4 of 4

Thread: [RESOLVED] RichEdit Control: using MouseWheel

  1. #1

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Resolved [RESOLVED] RichEdit Control: using MouseWheel

    I'm trying to add line numbers to rows in a RichEdit Control. To do that, I have to know when the scrollbar scrolls up and down, so I can align the line numbers accordingly. I have captured all arrow keys and subclassed the WM_VSCROLL message (which is triggered when you click the scrollbar). Leaves one problem: the mousewheel.

    By subclassing the WM_MOUSEWHEEL message I can refill the line numbers when the mouse is scrolled. The problem, however, is that the WM_MOUSEWHEEL message is sent before the actual scrolling has been done. So my code refills the line numbers to the unchanged situation, and only then the contents of the RichEdit box are being scrolled. So my line numbers are always 'one scroll behind'.

    Is there any message I can intercept that tells me when the contents have actually been scrolled? When the mousewheel has finished scrolling? And if not, is there a way to turn of smooth scrolling in Rich Edit controls?

    Thanks for your help.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: RichEdit Control: using MouseWheel

    There could be a way to hack around it.

    Have you tried intercepting the EN_UPDATE message? I assume it would be sent even when the mouse is moved over the control, but you could try using GETFIRSTVISIBLELINE and see if it changes, if it has, then you can redraw them from there.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Re: RichEdit Control: using MouseWheel

    Thanks for the tip; I looked at the MSDN page you provided, and there also seems to be a message EN_VSCROLL, which triggers when the page is scrolled by any means (be it mousewheel, arrows, scrollbar). That's exactly what I need here, but I can't get it to work. MSDN says you have to call EM_SETEVENTMASK in order to receive that message, but it doesn't seem to do anything. I also tried capturing EN_UPDATE, but got the same problem.

    I included a small test program. You can see that WM_VSCROLL is being captured when you click the scrollbar, but EN_VSCROLL is never.
    Attached Files Attached Files
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  4. #4

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Re: RichEdit Control: using MouseWheel

    Never mind, I found it out with the code sample in this thread. I was listening to the wrong message, should have used WM_COMMAND.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width