tkirby052098
asked on
RichEdit32 and WM_CONTEXTMENU
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_WNDPR OC) != (void*)TextWndProc)
MessageBeep(0); // never gets here!!
//TextWndProc(hWnd,WM_CONT EXTMENU,0, pmf->lPara m); // works!!
SendMessage(hWnd,WM_CONTEX TMENU,0,pm f->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????
case EN_MSGFILTER:
{
UINT uID = (UINT) wParam;
MSGFILTER *pmf = (MSGFILTER*) lParam;
if (pmf->msg == WM_RBUTTONUP)
{
if ((void*)GetWindowLong(hWnd
MessageBeep(0); // never gets here!!
//TextWndProc(hWnd,WM_CONT
SendMessage(hWnd,WM_CONTEX
}
*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????
Try using PostMessage instead of SendMessage.
ASKER
I tried PostMessage with the same results.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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?
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?
ASKER
Never did find out why this does not work....