[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

RichEdit32 and WM_CONTEXTMENU

Posted on 1998-05-20
5
Medium Priority
?
946 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
[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
  • 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 300 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

656 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