Solved

RichEdit32 and WM_CONTEXTMENU

Posted on 1998-05-20
5
905 Views
Last Modified: 2013-12-03
I am using a richedit control (richedit32.dll) and I want to get the WM_CONTEXTMENU message to the parent window.  Problem is, RE32 eats all the mouse messages.  So, I used the events notify to capture the wm_rbuttonup message, and used SendMessage to send wm_contextmenu (with cursor x,y position) to the parent window.  Here's the problem--> the wm_contextmenu message dissappears!!  It seems so simple, what am I missing??  I do this:

case EN_MSGFILTER:
      {
      UINT uID = (UINT) wParam;
      MSGFILTER *pmf = (MSGFILTER*) lParam;
 
      if (pmf->msg == WM_RBUTTONUP)
            {
            if ((void*)GetWindowLong(hWnd,GWL_WNDPROC) != (void*)TextWndProc)
                  MessageBeep(0); // never gets here!!
            //TextWndProc(hWnd,WM_CONTEXTMENU,0,pmf->lParam); // works!!
            SendMessage(hWnd,WM_CONTEXTMENU,0,pmf->lParam);  // does not!!
            }
      *pResult = 0;
      }            
      
I put a breakpoint on the wm_contextmenu case in the parent window proc, trace thru SendMessage, (which returns) and the breakpoint is never hit.  If I call the window procedure directly (commented out above) it works fine.  Where did my message go????
0
Comment
Question by:tkirby052098
  • 3
5 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1402952
Try using PostMessage instead of SendMessage.
0
 

Author Comment

by:tkirby052098
ID: 1402953
I tried PostMessage with the same results.
0
 
LVL 2

Accepted Solution

by:
tonp earned 100 total points
ID: 1402954
This is no doubt a multiple thread issue. Under Win32 a SendMessage can return before the message is processed if the Window is created in another thread. Use SendMessageTimeOut if you want the message to be processed before the call returns. However, this may not always be possible.
0
 

Author Comment

by:tkirby052098
ID: 1402955
It's possible that richedit32 sends msgfilter notifications from another thread, so then the SendMessage thread issue might pop up.  However, even though the call returns immediately, the other (main) thread should process the message (eventually), right?  But, it does not happen: the message never gets to the intended window procedure.
The work-around for this problem was to call the wm_contextmenu handler function directly from the msgfilter notification.  If there was a thread problem, it would have definitely caused a failure (running TrackPopupMenu from a sub-thread).  Stumped?
0
 

Author Comment

by:tkirby052098
ID: 1402956
Never did find out why this does not work....
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run Program using VBScript 3 64
Mixed results 10 84
Need a complete list of ASP.NET page load events 3 44
Problem to open text file 11 106
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 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

13 Experts available now in Live!

Get 1:1 Help Now