Solved

RICHEDIT and WM_LBUTTONDOWN

Posted on 1997-05-16
13
569 Views
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.
0
Comment
Question by:arkady
  • 6
  • 5
  • 2
13 Comments
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1397408
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
 

Author Comment

by:arkady
ID: 1397409
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
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1397410
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
 
LVL 15

Accepted Solution

by:
NickRepin earned 200 total points
ID: 1397411
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
 
LVL 15

Expert Comment

by:NickRepin
ID: 1397412
ENM_MOUSEEVENTS (instead of 0xFFFFFFFF) as LPARAM in EN_SETEVENTMASK sends EN_MSGFILTER notifications for mouse events only.
0
 

Author Comment

by:arkady
ID: 1397413
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 15

Expert Comment

by:NickRepin
ID: 1397414
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
 

Author Comment

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

0
 

Author Comment

by:arkady
ID: 1397416
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
 

Author Comment

by:arkady
ID: 1397417
... except, of course, when the left button is down...
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 1397418
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
 

Author Comment

by:arkady
ID: 1397419
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
 
LVL 15

Expert Comment

by:NickRepin
ID: 1397420
You can just reject my answer.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now