Patch to riched20 (resubmission)

Mark Lu excelblue at
Sun Aug 27 19:35:54 CDT 2006

If the rtf control is a child window AND it doesn't display its own context menu,
then the WM_CONTEXTMENU message should be passed to the parent window in the rtf
control's DefWindowProc. Here is what MSDN says on the subject:

    "If a window does not display a shortcut menu it should pass this message
    to the DefWindowProc function. If a window is a child window, DefWindowProc
    sends the message to the parent. Otherwise, DefWindowProc displays a default
    shortcut menu if the specified position is in the window's caption."

This (already tested) patch resolves the issue. A good friend of mine made this 
patch to get his IRC client ( working in wine. I 
am just submitting them on his behalf because he is a very busy person.

Author: Hippocrates Sendoukas (aka Kilgore) <hsendoukas at>
Submitter: Mark Lu (aka excelblue) <excelblue at>

PS: This is a resubmission due to slight problems in the first submission.

 dlls/riched20/editor.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 15d2654..f901760 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1077,13 +1077,13 @@ ME_KeyDown(ME_TextEditor *editor, WORD n
   return FALSE;
-static void ME_ShowContextMenu(ME_TextEditor *editor, int x, int y)
+static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y)
   CHARRANGE selrange;
   HMENU menu;
   int seltype = 0;
-    return;
+    return FALSE;
   ME_GetSelection(editor, (int *)&selrange.cpMin, (int *)&selrange.cpMax);
   if(selrange.cpMin == selrange.cpMax)
     seltype |= SEL_EMPTY;
@@ -1099,6 +1099,7 @@ static void ME_ShowContextMenu(ME_TextEd
     TrackPopupMenu(menu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, x, y, 0, GetParent(editor->hWnd), NULL);
+  return TRUE;
 ME_TextEditor *ME_MakeEditor(HWND hWnd) {
@@ -2318,7 +2319,11 @@ LRESULT WINAPI RichEditANSIWndProc(HWND 
-    ME_ShowContextMenu(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
+    if (!ME_ShowContextMenu(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)))
+    {
+      if (GetWindowLongW( hWnd, GWL_STYLE ) & WS_CHILD)
+        SendMessageW( GetParent(hWnd), msg, wParam, lParam );
+    }
   case WM_PAINT:
     if (editor->bRedraw)

More information about the wine-patches mailing list