RICHEDIT and WM_LBUTTONDOWN

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.
arkadyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RONSLOWCommented:
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?

0
arkadyAuthor Commented:
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.
0
RONSLOWCommented:
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
0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

NickRepinCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NickRepinCommented:
ENM_MOUSEEVENTS (instead of 0xFFFFFFFF) as LPARAM in EN_SETEVENTMASK sends EN_MSGFILTER notifications for mouse events only.
0
arkadyAuthor Commented:
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.
0
NickRepinCommented:
Why  WM_LBUTTONDOWN and WM_LBUTTONUP only?!
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.
0
arkadyAuthor Commented:
Sorry for being so persistent, but are you sure you get WM_MOUSEMOVE between pressing and releasing the left button?

0
arkadyAuthor Commented:
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;
            break;
         case WM_LBUTTONUP:
            bDown = FALSE;
            break;
         case WM_MOUSEMOVE:
            if (bDown)
               TRACE2("X = %d\tY = %d\n", LOWORD(pMF->lParam), HIWORD(pMF->lParam));
            break;
         default:
            break;
      }
   }
      
   return CDialog::OnNotify(wParam, lParam, pResult);
}

The TRACE2... statement is never executed.  However, remove  "if (bDown)", and it is executed for each mouse move.
0
arkadyAuthor Commented:
... except, of course, when the left button is down...
0
NickRepinCommented:
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.

0
arkadyAuthor Commented:
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?
0
NickRepinCommented:
You can just reject my answer.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.