Solved

RichEdit32 and WM_CONTEXTMENU

Posted on 1998-05-20
5
916 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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