Solved

RICHEDIT and WM_LBUTTONDOWN

Posted on 1997-05-16
13
581 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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
 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Changing the installation path of this MSI 5 120
String manipulation in Visual Basic 7 90
How do ASP.NET and MVC work together? 4 78
Graph API & MS Apps 1 83
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…

752 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