richedit: Store mouse captured state rather than calling GetCapture.

Windowless richedit control will not be able to call GetCapture without
a handle to the host window (and there is no ITextHost_TxGetCapture
method), but there is a ITextHost_TxSetCapture method available for
setting and releasing the capture on the mouse.  This means that the
richedit control will need to keep track of whether it has captured the
mouse or not to implement windowless richedit controls.
This commit is contained in:
Dylan Smith 2009-01-11 02:59:20 -05:00 committed by Alexandre Julliard
parent ee19ec056a
commit f885d40d67
2 changed files with 10 additions and 4 deletions

View File

@ -2530,7 +2530,7 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
} }
ScreenToClient(editor->hWnd, &pt); ScreenToClient(editor->hWnd, &pt);
if (editor->nSelectionType == stLine && GetCapture() == editor->hWnd) { if (editor->nSelectionType == stLine && editor->bMouseCaptured) {
SetCursor(hLeft); SetCursor(hLeft);
return TRUE; return TRUE;
} }
@ -2670,6 +2670,7 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd, BOOL bEmulateVersion10)
ed->mode = TM_RICHTEXT | TM_MULTILEVELUNDO | TM_MULTICODEPAGE; ed->mode = TM_RICHTEXT | TM_MULTILEVELUNDO | TM_MULTICODEPAGE;
ed->AutoURLDetect_bEnable = FALSE; ed->AutoURLDetect_bEnable = FALSE;
ed->bHaveFocus = FALSE; ed->bHaveFocus = FALSE;
ed->bMouseCaptured = FALSE;
for (i=0; i<HFONT_CACHE_SIZE; i++) for (i=0; i<HFONT_CACHE_SIZE; i++)
{ {
ed->pFontCache[i].nRefs = 0; ed->pFontCache[i].nRefs = 0;
@ -3874,6 +3875,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam), ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam),
ME_CalculateClickCount(editor, msg, wParam, lParam)); ME_CalculateClickCount(editor, msg, wParam, lParam));
SetCapture(editor->hWnd); SetCapture(editor->hWnd);
editor->bMouseCaptured = TRUE;
ME_LinkNotify(editor,msg,wParam,lParam); ME_LinkNotify(editor,msg,wParam,lParam);
if (!ME_SetCursor(editor)) goto do_default; if (!ME_SetCursor(editor)) goto do_default;
break; break;
@ -3882,16 +3884,18 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
if ((editor->nEventMask & ENM_MOUSEEVENTS) && if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
!ME_FilterEvent(editor, msg, &wParam, &lParam)) !ME_FilterEvent(editor, msg, &wParam, &lParam))
return 0; return 0;
if (GetCapture() == editor->hWnd) if (editor->bMouseCaptured)
ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)); ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
ME_LinkNotify(editor,msg,wParam,lParam); ME_LinkNotify(editor,msg,wParam,lParam);
/* Set cursor if mouse is captured, since WM_SETCURSOR won't be received. */ /* Set cursor if mouse is captured, since WM_SETCURSOR won't be received. */
if (GetCapture() == editor->hWnd) if (editor->bMouseCaptured)
ME_SetCursor(editor); ME_SetCursor(editor);
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
if (GetCapture() == editor->hWnd) if (editor->bMouseCaptured) {
ReleaseCapture(); ReleaseCapture();
editor->bMouseCaptured = FALSE;
}
if (editor->nSelectionType == stDocument) if (editor->nSelectionType == stDocument)
editor->nSelectionType = stPosition; editor->nSelectionType = stPosition;
if ((editor->nEventMask & ENM_MOUSEEVENTS) && if ((editor->nEventMask & ENM_MOUSEEVENTS) &&

View File

@ -376,6 +376,8 @@ typedef struct tagME_TextEditor
/* Cache previously set vertical scrollbar info */ /* Cache previously set vertical scrollbar info */
SCROLLINFO vert_si; SCROLLINFO vert_si;
BOOL bMouseCaptured;
} ME_TextEditor; } ME_TextEditor;
typedef struct tagME_Context typedef struct tagME_Context