Patches to riched20

Mark Lu excelblue at gmail.com
Sun Aug 27 18:47:39 CDT 2006


There are a few bugs in the riched20 dll in the current wine:

1. 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."

2. The following code does not set the selection:

        CHARRANGE cr;
        cr.cpMin = cr.cpMax = -1;
        SendMessage(h,EM_EXSETSEL,0,(LPARAM)&cr);

   In all versions of win32 (and rtf controls) that I've tried, those particular
   2 values set the selection to the very end of the text.

These are (already tested) patches for both. A good friend of mine
made this patch
to get his IRC client (http://www.excelex.net/zrc.zip) working in
wine. I am just
submitting them on his behalf because he is a very busy person.

Author: Hippocrates Sendoukas (aka Kilgore)
Submitter: Mark Lu (aka excelblue)

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

diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index bdab179..06f021c 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -90,6 +90,14 @@ void ME_SetSelection(ME_TextEditor *edit
     ME_ClearTempStyle(editor);
     return;
   }
+  if (from == -1 && to == -1)	/*-1,-1 means put the selection at the
end of the text */
+  {
+    editor->pCursors[1].pRun = editor->pCursors[0].pRun =
ME_FindItemBack(editor->pBuffer->pLast, diRun);
+    editor->pCursors[1].nOffset = editor->pCursors[0].nOffset = 0;
+    ME_InvalidateSelection(editor);
+    ME_ClearTempStyle(editor);
+    return;
+  }
   if (from == -1)
   {
     editor->pCursors[1] = editor->pCursors[0];
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;
   if(!editor->lpOleCallback)
-    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);
     DestroyMenu(menu);
   }
+  return TRUE;
 }

 ME_TextEditor *ME_MakeEditor(HWND hWnd) {
@@ -2318,7 +2319,11 @@ LRESULT WINAPI RichEditANSIWndProc(HWND
     ME_SelectWord(editor);
     break;
   case WM_CONTEXTMENU:
-    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 );
+    }
     break;
   case WM_PAINT:
     if (editor->bRedraw)
-- 
1.4.1.1



More information about the wine-patches mailing list