riched20: Make richedit control IME aware.

This commit is contained in:
Aric Stewart 2007-06-27 07:57:51 -05:00 committed by Alexandre Julliard
parent 33af21fdcf
commit c03125a1be
3 changed files with 62 additions and 1 deletions

View file

@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = riched20.dll MODULE = riched20.dll
IMPORTLIB = libriched20.$(IMPLIBEXT) IMPORTLIB = libriched20.$(IMPLIBEXT)
IMPORTS = ole32 user32 gdi32 kernel32 IMPORTS = ole32 imm32 user32 gdi32 kernel32
EXTRALIBS = -luuid EXTRALIBS = -luuid
C_SRCS = \ C_SRCS = \

View file

@ -227,6 +227,7 @@
#define NO_SHLWAPI_STREAM #define NO_SHLWAPI_STREAM
#include "shlwapi.h" #include "shlwapi.h"
#include "rtf.h" #include "rtf.h"
#include "imm.h"
#define STACK_SIZE_DEFAULT 100 #define STACK_SIZE_DEFAULT 100
#define STACK_SIZE_MAX 1000 #define STACK_SIZE_MAX 1000
@ -2515,6 +2516,64 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
ME_RewrapRepaint(editor); ME_RewrapRepaint(editor);
return DefWindowProcW(hWnd, msg, wParam, lParam); return DefWindowProcW(hWnd, msg, wParam, lParam);
} }
/* IME messages to make richedit controls IME aware */
case WM_IME_SETCONTEXT:
case WM_IME_CONTROL:
case WM_IME_SELECT:
case WM_IME_COMPOSITIONFULL:
return 0;
case WM_IME_STARTCOMPOSITION:
{
editor->imeStartIndex=ME_GetCursorOfs(editor,0);
ME_DeleteSelection(editor);
ME_CommitUndo(editor);
ME_UpdateRepaint(editor);
return 0;
}
case WM_IME_COMPOSITION:
{
HIMC hIMC;
ME_Style *style = ME_GetInsertStyle(editor, 0);
hIMC = ImmGetContext(hWnd);
ME_DeleteSelection(editor);
ME_CommitUndo(editor);
ME_SaveTempStyle(editor);
if (lParam & GCS_RESULTSTR)
{
LPWSTR lpCompStr = NULL;
DWORD dwBufLen;
dwBufLen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR));
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpCompStr, dwBufLen);
lpCompStr[dwBufLen/sizeof(WCHAR)] = 0;
ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style);
}
else if (lParam & GCS_COMPSTR)
{
LPWSTR lpCompStr = NULL;
DWORD dwBufLen;
dwBufLen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR));
ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, dwBufLen);
lpCompStr[dwBufLen/sizeof(WCHAR)] = 0;
ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style);
ME_SetSelection(editor,editor->imeStartIndex,
editor->imeStartIndex + dwBufLen/sizeof(WCHAR));
}
ME_ReleaseStyle(style);
ME_UpdateRepaint(editor);
return 0;
}
case WM_IME_ENDCOMPOSITION:
{
ME_DeleteSelection(editor);
editor->imeStartIndex=-1;
return 0;
}
case EM_GETOLEINTERFACE: case EM_GETOLEINTERFACE:
{ {
LPVOID *ppvObj = (LPVOID*) lParam; LPVOID *ppvObj = (LPVOID*) lParam;

View file

@ -322,6 +322,8 @@ typedef struct tagME_TextEditor
BOOL AutoURLDetect_bEnable; BOOL AutoURLDetect_bEnable;
WCHAR cPasswordMask; WCHAR cPasswordMask;
BOOL bHaveFocus; BOOL bHaveFocus;
/*for IME */
int imeStartIndex;
} ME_TextEditor; } ME_TextEditor;
typedef struct tagME_Context typedef struct tagME_Context