Solved

RichEdit32 and WM_CONTEXTMENU

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

16 Experts available now in Live!

Get 1:1 Help Now