We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now



arkady asked
Medium Priority
Last Modified: 2013-12-03
I have noticed that pressing and holding the left mouse button on a RICHEDIT control puts EVERYTHING in the application on hold.  Messages just don't go through.  The breakpoint set in the application's PreTranslateMessage() (I am using MFC) is never hit until you release the button.

I would like to do some custom processing while the left mouse button is held down.  I can't figure out how to overcome that "feature" of the RICHEDIT control.
Watch Question

Use a worker thread?

What messages are you expecting to get whilst the mouse button is down?

Do you not get mouse move message while holding down the left mouse button?


I would love to get a WM_MOUSEMOVE message, or a WM_TIMER message, but I don't get any messages at all.

I'm ultimatelly trying to implement custom scrolling when user makes a selection in a RICHEDIT control by dragging the mouse beyond the window limits.

I need custon scrolling because for certain (well justified, believe me) reasons the control is created without ES_AUTOVSCROLL and ES_AUTOHSCROLL styles, and that prevents standard scrolling performed by the RICHEDIT control itself.

I guess RICHEDIT control implements some kind of a hook, but I don't know much about it.

I assume that the rich edit control has its own message pump loop - and probably captures the mouse as well. If so, I don't know if it is possible to hook yourself into that loop somehow. I don't know enough about the internals of the rich edit control to suggest a way - I hope someone else can help you here
Send EM_SETEVENTMASK to Rich edit contol with LPARAM=0xFFFFFFFF.
Now you will receive EN_MSGFILTER notification message.
This message notifies a rich edit control's parent window of a keyboard or mouse event in the control.
So you can do your job in EN_MSGFILTER handler.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
ENM_MOUSEEVENTS (instead of 0xFFFFFFFF) as LPARAM in EN_SETEVENTMASK sends EN_MSGFILTER notifications for mouse events only.


Well, I did set the event mask as suggested, and, regretfully, it didn't really help me.
The RICHEDIT control still notifies me about two events only: WM_LBUTTONDOWN and WM_LBUTTONUP, and I'm interested in getting in between.
As noted before, I'm trying to do some custom processing WHILE the left button is held down, not only WHEN the WM_LBUTTONDOWN event occurs.
My handler receives WM_MOUSEMOVE as well. As I see it is what you need. Please check your code again.

I'm using ENM_MOUSEEVENTS mask.


Sorry for being so persistent, but are you sure you get WM_MOUSEMOVE between pressing and releasing the left button?


I created a trivial dialog-based app, and then created a RICHEDIT control in the dialog.  In OnInitDialog() I set event mask with ENM_MOUSEEVENTS.  At my request, ClassWizard in Visual C++ created an WM_NOTIFY handler, OnNotify(), whilh I implemented as follows:

BOOL CRichDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
   if (((NMHDR*)lParam)->code == EN_MSGFILTER)
      static BOOL bDown = FALSE;

      MSGFILTER* pMF = (MSGFILTER*)lParam;

      switch (pMF->msg)
         case WM_LBUTTONDOWN:
            bDown = TRUE;
         case WM_LBUTTONUP:
            bDown = FALSE;
         case WM_MOUSEMOVE:
            if (bDown)
               TRACE2("X = %d\tY = %d\n", LOWORD(pMF->lParam), HIWORD(pMF->lParam));
   return CDialog::OnNotify(wParam, lParam, pResult);

The TRACE2... statement is never executed.  However, remove  "if (bDown)", and it is executed for each mouse move.


... except, of course, when the left button is down...
I am sorry, you are right. Indeed, there are no WM_MOUSEMOVE messages when left button is pressed.

I see the only way. You can return nonzero value when pMF->msg==WM_LBUTTONDOWN. This prevents rich edit control from processing it. Of course, in this case the user will be unable to, say, select text in rich edit control, and you have to do  all this job manually. Eg, by posting several  WM_LBUTTONDOWN, WM_MOUSEMOVE, WM_LBUTTONUP to rich edit.


Yes, I understand about doing all that stuff myself...  I tried to avoid that, but...

Anyway, you did all you could.  I am a novice here, how would you like me to grade you?
You can just reject my answer.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.