4 * Copyright 1998 Patrik Stridvall
5 * Copyright 2002, 2003 CodeWeavers, Aric Stewart
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(imm);
35 #define FROM_IME 0xcafe1337
37 static void (*pX11DRV_ForceXIMReset)(HWND);
39 typedef struct tagInputContextData
41 LPBYTE CompositionString;
42 LPBYTE CompositionReadingString;
44 LPBYTE ResultReadingString;
45 DWORD dwCompStringSize; /* buffer size */
46 DWORD dwCompStringLength; /* string length (in bytes) */
47 DWORD dwCompReadStringSize;
48 DWORD dwResultStringSize;
49 DWORD dwResultReadStringSize;
57 COMPOSITIONFORM CompForm;
60 static InputContextData *root_context = NULL;
61 static HWND hwndDefault = NULL;
62 static HANDLE hImeInst;
63 static const WCHAR WC_IMECLASSNAME[] = {'I','M','E',0};
64 static ATOM atIMEClass = 0;
67 static UINT WM_MSIME_SERVICE;
68 static UINT WM_MSIME_RECONVERTOPTIONS;
69 static UINT WM_MSIME_MOUSE;
70 static UINT WM_MSIME_RECONVERTREQUEST;
71 static UINT WM_MSIME_RECONVERT;
72 static UINT WM_MSIME_QUERYPOSITION;
73 static UINT WM_MSIME_DOCUMENTFEED;
78 static LRESULT WINAPI IME_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
80 static void UpdateDataInDefaultIMEWindow(HWND hwnd);
81 static void ImmInternalPostIMEMessage(UINT, WPARAM, LPARAM);
82 static void ImmInternalSetOpenStatus(BOOL fOpen);
84 static VOID IMM_PostResult(InputContextData *data)
87 TRACE("Posting result as IME_CHAR\n");
89 for (i = 0; i < data->dwResultStringSize / sizeof (WCHAR); i++)
90 ImmInternalPostIMEMessage (WM_IME_CHAR, ((WCHAR*)data->ResultString)[i],
93 /* clear the buffer */
94 if (data->dwResultStringSize)
95 HeapFree(GetProcessHeap(),0,data->ResultString);
96 data->dwResultStringSize = 0;
97 data->ResultString = NULL;
100 static void IMM_Register(void)
103 ZeroMemory(&wndClass, sizeof(WNDCLASSW));
104 wndClass.style = CS_GLOBALCLASS | CS_IME | CS_HREDRAW | CS_VREDRAW;
105 wndClass.lpfnWndProc = (WNDPROC) IME_WindowProc;
106 wndClass.cbClsExtra = 0;
107 wndClass.cbWndExtra = 0;
108 wndClass.hInstance = hImeInst;
109 wndClass.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
110 wndClass.hIcon = NULL;
111 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW +1);
112 wndClass.lpszMenuName = 0;
113 wndClass.lpszClassName = WC_IMECLASSNAME;
114 atIMEClass = RegisterClassW(&wndClass);
117 static void IMM_Unregister(void)
120 UnregisterClassW(WC_IMECLASSNAME, NULL);
124 static void IMM_RegisterMessages(void)
126 WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService");
127 WM_MSIME_RECONVERTOPTIONS = RegisterWindowMessageA("MSIMEReconvertOptions");
128 WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation");
129 WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest");
130 WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert");
131 WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition");
132 WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed");
136 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved)
140 TRACE("%p, %x, %p\n",hInstDLL,fdwReason,lpReserved);
143 case DLL_PROCESS_ATTACH:
144 DisableThreadLibraryCalls(hInstDLL);
146 IMM_RegisterMessages();
147 x11drv = GetModuleHandleA("winex11.drv");
148 if (x11drv) pX11DRV_ForceXIMReset = (void *)GetProcAddress( x11drv, "ForceXIMReset");
150 case DLL_PROCESS_DETACH:
153 DestroyWindow(hwndDefault);
162 /* for posting messages as the IME */
163 static void ImmInternalPostIMEMessage(UINT msg, WPARAM wParam, LPARAM lParam)
165 HWND target = GetFocus();
167 PostMessageW(root_context->hwnd,msg,wParam,lParam);
169 PostMessageW(target, msg, wParam, lParam);
172 static LRESULT ImmInternalSendIMENotify(WPARAM notify, LPARAM lParam)
176 target = root_context->hwnd;
177 if (!target) target = GetFocus();
180 return SendMessageW(target, WM_IME_NOTIFY, notify, lParam);
185 static void ImmInternalSetOpenStatus(BOOL fOpen)
187 TRACE("Setting internal state to %s\n",(fOpen)?"OPEN":"CLOSED");
189 root_context->bOpen = fOpen;
190 root_context->bInternalState = fOpen;
194 ShowWindow(hwndDefault,SW_HIDE);
196 if (root_context->dwCompStringSize)
197 HeapFree(GetProcessHeap(),0,root_context->CompositionString);
198 if (root_context->dwCompReadStringSize)
199 HeapFree(GetProcessHeap(),0,root_context->CompositionReadingString);
200 if (root_context->dwResultStringSize)
201 HeapFree(GetProcessHeap(),0,root_context->ResultString);
202 if (root_context->dwResultReadStringSize)
203 HeapFree(GetProcessHeap(),0,root_context->ResultReadingString);
204 root_context->dwCompStringSize = 0;
205 root_context->dwCompStringLength = 0;
206 root_context->CompositionString = NULL;
207 root_context->dwCompReadStringSize = 0;
208 root_context->CompositionReadingString = NULL;
209 root_context->dwResultStringSize = 0;
210 root_context->ResultString = NULL;
211 root_context->dwResultReadStringSize = 0;
212 root_context->ResultReadingString = NULL;
215 ShowWindow(hwndDefault, SW_SHOWNOACTIVATE);
217 ImmInternalSendIMENotify(IMN_SETOPENSTATUS, 0);
221 /***********************************************************************
222 * ImmAssociateContext (IMM32.@)
224 HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
226 InputContextData *data = (InputContextData*)hIMC;
228 WARN("(%p, %p): semi-stub\n", hWnd, hIMC);
234 * WINE SPECIFIC! MAY CONFLICT
235 * associate the root context we have an XIM created
239 root_context = (InputContextData*)hIMC;
243 * If already associated just return
245 if (data->hwnd == hWnd)
248 if (IsWindow(data->hwnd))
251 * Post a message that your context is switching
253 SendMessageW(data->hwnd, WM_IME_SETCONTEXT, FALSE, ISC_SHOWUIALL);
258 if (IsWindow(data->hwnd))
261 * Post a message that your context is switching
263 SendMessageW(data->hwnd, WM_IME_SETCONTEXT, TRUE, ISC_SHOWUIALL);
267 * TODO: We need to keep track of the old context associated
268 * with a window and return it for now we will return NULL;
273 /***********************************************************************
274 * ImmAssociateContextEx (IMM32.@)
276 BOOL WINAPI ImmAssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags)
278 FIXME("(%p, %p, %d): stub\n", hWnd, hIMC, dwFlags);
279 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
283 /***********************************************************************
284 * ImmConfigureIMEA (IMM32.@)
286 BOOL WINAPI ImmConfigureIMEA(
287 HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData)
289 FIXME("(%p, %p, %d, %p): stub\n",
290 hKL, hWnd, dwMode, lpData
292 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
296 /***********************************************************************
297 * ImmConfigureIMEW (IMM32.@)
299 BOOL WINAPI ImmConfigureIMEW(
300 HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData)
302 FIXME("(%p, %p, %d, %p): stub\n",
303 hKL, hWnd, dwMode, lpData
305 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
309 /***********************************************************************
310 * ImmCreateContext (IMM32.@)
312 HIMC WINAPI ImmCreateContext(void)
314 InputContextData *new_context;
316 new_context = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(InputContextData));
318 return (HIMC)new_context;
321 /***********************************************************************
322 * ImmDestroyContext (IMM32.@)
324 BOOL WINAPI ImmDestroyContext(HIMC hIMC)
326 InputContextData *data = (InputContextData*)hIMC;
328 TRACE("Destroying %p\n",hIMC);
332 if (data->dwCompStringSize)
333 HeapFree(GetProcessHeap(),0,data->CompositionString);
334 if (data->dwCompReadStringSize)
335 HeapFree(GetProcessHeap(),0,data->CompositionReadingString);
336 if (data->dwResultStringSize)
337 HeapFree(GetProcessHeap(),0,data->ResultString);
338 if (data->dwResultReadStringSize)
339 HeapFree(GetProcessHeap(),0,data->ResultReadingString);
343 DeleteObject(data->textfont);
344 data->textfont = NULL;
347 HeapFree(GetProcessHeap(),0,data);
352 /***********************************************************************
353 * ImmDisableIME (IMM32.@)
355 BOOL WINAPI ImmDisableIME(DWORD idThread)
357 FIXME("(%d): stub\n", idThread);
361 /***********************************************************************
362 * ImmEnumRegisterWordA (IMM32.@)
364 UINT WINAPI ImmEnumRegisterWordA(
365 HKL hKL, REGISTERWORDENUMPROCA lpfnEnumProc,
366 LPCSTR lpszReading, DWORD dwStyle,
367 LPCSTR lpszRegister, LPVOID lpData)
369 FIXME("(%p, %p, %s, %d, %s, %p): stub\n",
371 debugstr_a(lpszReading), dwStyle,
372 debugstr_a(lpszRegister), lpData
374 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
378 /***********************************************************************
379 * ImmEnumRegisterWordW (IMM32.@)
381 UINT WINAPI ImmEnumRegisterWordW(
382 HKL hKL, REGISTERWORDENUMPROCW lpfnEnumProc,
383 LPCWSTR lpszReading, DWORD dwStyle,
384 LPCWSTR lpszRegister, LPVOID lpData)
386 FIXME("(%p, %p, %s, %d, %s, %p): stub\n",
388 debugstr_w(lpszReading), dwStyle,
389 debugstr_w(lpszRegister), lpData
391 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
395 /***********************************************************************
396 * ImmEscapeA (IMM32.@)
398 LRESULT WINAPI ImmEscapeA(
400 UINT uEscape, LPVOID lpData)
402 FIXME("(%p, %p, %d, %p): stub\n",
403 hKL, hIMC, uEscape, lpData
405 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
409 /***********************************************************************
410 * ImmEscapeW (IMM32.@)
412 LRESULT WINAPI ImmEscapeW(
414 UINT uEscape, LPVOID lpData)
416 FIXME("(%p, %p, %d, %p): stub\n",
417 hKL, hIMC, uEscape, lpData
419 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
423 /***********************************************************************
424 * ImmGetCandidateListA (IMM32.@)
426 DWORD WINAPI ImmGetCandidateListA(
427 HIMC hIMC, DWORD deIndex,
428 LPCANDIDATELIST lpCandList, DWORD dwBufLen)
430 FIXME("(%p, %d, %p, %d): stub\n",
434 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
438 /***********************************************************************
439 * ImmGetCandidateListCountA (IMM32.@)
441 DWORD WINAPI ImmGetCandidateListCountA(
442 HIMC hIMC, LPDWORD lpdwListCount)
444 FIXME("(%p, %p): stub\n", hIMC, lpdwListCount);
445 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
449 /***********************************************************************
450 * ImmGetCandidateListCountW (IMM32.@)
452 DWORD WINAPI ImmGetCandidateListCountW(
453 HIMC hIMC, LPDWORD lpdwListCount)
455 FIXME("(%p, %p): stub\n", hIMC, lpdwListCount);
456 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
460 /***********************************************************************
461 * ImmGetCandidateListW (IMM32.@)
463 DWORD WINAPI ImmGetCandidateListW(
464 HIMC hIMC, DWORD deIndex,
465 LPCANDIDATELIST lpCandList, DWORD dwBufLen)
467 FIXME("(%p, %d, %p, %d): stub\n",
471 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
475 /***********************************************************************
476 * ImmGetCandidateWindow (IMM32.@)
478 BOOL WINAPI ImmGetCandidateWindow(
479 HIMC hIMC, DWORD dwBufLen, LPCANDIDATEFORM lpCandidate)
481 FIXME("(%p, %d, %p): stub\n", hIMC, dwBufLen, lpCandidate);
482 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
486 /***********************************************************************
487 * ImmGetCompositionFontA (IMM32.@)
489 BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
491 FIXME("(%p, %p): stub\n", hIMC, lplf);
492 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
496 /***********************************************************************
497 * ImmGetCompositionFontW (IMM32.@)
499 BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
501 FIXME("(%p, %p): stub\n", hIMC, lplf);
502 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
506 /***********************************************************************
507 * ImmGetCompositionStringA (IMM32.@)
509 LONG WINAPI ImmGetCompositionStringA(
510 HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
514 InputContextData *data = (InputContextData*)hIMC;
516 TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen);
521 if (dwIndex == GCS_RESULTSTR)
523 TRACE("GSC_RESULTSTR %p %i\n",data->ResultString,
524 data->dwResultStringSize);
526 buf = HeapAlloc( GetProcessHeap(), 0, data->dwResultStringSize * 3 );
527 rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)data->ResultString,
528 data->dwResultStringSize / sizeof(WCHAR), buf,
529 data->dwResultStringSize * 3, NULL, NULL);
531 memcpy(lpBuf,buf,rc);
534 HeapFree( GetProcessHeap(), 0, buf );
536 else if (dwIndex == GCS_COMPSTR)
538 TRACE("GSC_COMPSTR %p %i\n", data->CompositionString, data->dwCompStringLength);
540 buf = HeapAlloc( GetProcessHeap(), 0, data->dwCompStringLength * 3 );
541 rc = WideCharToMultiByte(CP_ACP, 0,(LPWSTR)data->CompositionString,
542 data->dwCompStringLength/ sizeof(WCHAR), buf,
543 data->dwCompStringLength* 3, NULL, NULL);
545 memcpy(lpBuf,buf,rc);
546 HeapFree( GetProcessHeap(), 0, buf );
548 else if (dwIndex == GCS_COMPATTR)
550 TRACE("GSC_COMPATTR %p %i\n", data->CompositionString, data->dwCompStringLength);
552 rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)data->CompositionString,
553 data->dwCompStringLength/ sizeof(WCHAR), NULL,
559 for (i = 0; i < rc; i++)
560 ((LPBYTE)lpBuf)[i] = ATTR_INPUT;
563 else if (dwIndex == GCS_COMPCLAUSE)
565 TRACE("GSC_COMPCLAUSE %p %i\n", data->CompositionString, data->dwCompStringLength);
567 rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)data->CompositionString,
568 data->dwCompStringLength/ sizeof(WCHAR), NULL,
571 if (dwBufLen >= sizeof(DWORD)*2)
573 ((LPDWORD)lpBuf)[0] = 0;
574 ((LPDWORD)lpBuf)[1] = rc;
576 rc = sizeof(DWORD)*2;
578 else if (dwIndex == GCS_RESULTCLAUSE)
580 TRACE("GSC_RESULTCLAUSE %p %i\n", data->ResultString, data->dwResultStringSize);
582 rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)data->ResultString,
583 data->dwResultStringSize/ sizeof(WCHAR), NULL,
586 if (dwBufLen >= sizeof(DWORD)*2)
588 ((LPDWORD)lpBuf)[0] = 0;
589 ((LPDWORD)lpBuf)[1] = rc;
591 rc = sizeof(DWORD)*2;
593 else if (dwIndex == GCS_CURSORPOS)
595 TRACE("GSC_CURSORPOS\n");
596 rc = WideCharToMultiByte(CP_ACP, 0, (LPWSTR)data->CompositionString,
597 data->dwCompStringLength/ sizeof(WCHAR), NULL,
602 FIXME("Unhandled index 0x%x\n",dwIndex);
608 /***********************************************************************
609 * ImmGetCompositionStringW (IMM32.@)
611 LONG WINAPI ImmGetCompositionStringW(
612 HIMC hIMC, DWORD dwIndex,
613 LPVOID lpBuf, DWORD dwBufLen)
616 InputContextData *data = (InputContextData*)hIMC;
618 TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen);
623 if (dwIndex == GCS_RESULTSTR)
627 if (dwBufLen >= data->dwResultStringSize)
628 memcpy(lpBuf,data->ResultString,data->dwResultStringSize);
630 rc = data->dwResultStringSize;
632 else if (dwIndex == GCS_RESULTREADSTR)
634 if (dwBufLen >= data->dwResultReadStringSize)
635 memcpy(lpBuf,data->ResultReadingString,
636 data->dwResultReadStringSize);
638 rc = data->dwResultReadStringSize;
640 else if (dwIndex == GCS_COMPSTR)
642 if (dwBufLen >= data->dwCompStringLength)
643 memcpy(lpBuf,data->CompositionString,data->dwCompStringLength);
645 rc = data->dwCompStringLength;
647 else if (dwIndex == GCS_COMPATTR)
649 unsigned int len = data->dwCompStringLength;
654 for (i = 0; i < len; i++)
655 ((LPBYTE)lpBuf)[i] = ATTR_INPUT;
660 else if (dwIndex == GCS_COMPCLAUSE)
662 if (dwBufLen >= sizeof(DWORD)*2)
664 ((LPDWORD)lpBuf)[0] = 0;
665 ((LPDWORD)lpBuf)[1] = data->dwCompStringLength/sizeof(WCHAR);
667 rc = sizeof(DWORD)*2;
669 else if (dwIndex == GCS_COMPREADSTR)
671 if (dwBufLen >= data->dwCompReadStringSize)
672 memcpy(lpBuf,data->CompositionReadingString,
673 data->dwCompReadStringSize);
675 rc = data->dwCompReadStringSize;
677 else if (dwIndex == GCS_CURSORPOS)
679 TRACE("GSC_CURSORPOS\n");
680 rc = data->dwCompStringLength;
684 FIXME("Unhandled index 0x%x\n",dwIndex);
690 /***********************************************************************
691 * ImmGetCompositionWindow (IMM32.@)
693 BOOL WINAPI ImmGetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
695 InputContextData *data = (InputContextData*)hIMC;
697 TRACE("(%p, %p)\n", hIMC, lpCompForm);
702 memcpy(lpCompForm,&(data->CompForm),sizeof(COMPOSITIONFORM));
706 /***********************************************************************
707 * ImmGetContext (IMM32.@)
710 HIMC WINAPI ImmGetContext(HWND hWnd)
717 root_context->hwnd = hWnd;
718 return (HIMC)root_context;
721 /***********************************************************************
722 * ImmGetConversionListA (IMM32.@)
724 DWORD WINAPI ImmGetConversionListA(
726 LPCSTR pSrc, LPCANDIDATELIST lpDst,
727 DWORD dwBufLen, UINT uFlag)
729 FIXME("(%p, %p, %s, %p, %d, %d): stub\n",
730 hKL, hIMC, debugstr_a(pSrc), lpDst, dwBufLen, uFlag
732 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
736 /***********************************************************************
737 * ImmGetConversionListW (IMM32.@)
739 DWORD WINAPI ImmGetConversionListW(
741 LPCWSTR pSrc, LPCANDIDATELIST lpDst,
742 DWORD dwBufLen, UINT uFlag)
744 FIXME("(%p, %p, %s, %p, %d, %d): stub\n",
745 hKL, hIMC, debugstr_w(pSrc), lpDst, dwBufLen, uFlag
747 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
751 /***********************************************************************
752 * ImmGetConversionStatus (IMM32.@)
754 BOOL WINAPI ImmGetConversionStatus(
755 HIMC hIMC, LPDWORD lpfdwConversion, LPDWORD lpfdwSentence)
757 TRACE("(%p, %p, %p): best guess\n", hIMC, lpfdwConversion, lpfdwSentence);
759 *lpfdwConversion = IME_CMODE_NATIVE;
761 *lpfdwSentence = IME_SMODE_NONE;
765 /***********************************************************************
766 * ImmGetDefaultIMEWnd (IMM32.@)
768 HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
770 FIXME("(%p - %p %p ): semi-stub\n", hWnd,hwndDefault, root_context);
772 if (hwndDefault == NULL)
774 static const WCHAR the_name[] = {'I','M','E','\0'};
777 hwndDefault = CreateWindowExW( WS_EX_TOOLWINDOW, WC_IMECLASSNAME,
778 the_name, WS_POPUP, 0, 0, 1, 1, 0, 0,
781 TRACE("Default created (%p)\n",hwndDefault);
784 return (HWND)hwndDefault;
787 /***********************************************************************
788 * ImmGetDescriptionA (IMM32.@)
790 UINT WINAPI ImmGetDescriptionA(
791 HKL hKL, LPSTR lpszDescription, UINT uBufLen)
796 TRACE("%p %p %d\n", hKL, lpszDescription, uBufLen);
798 /* find out how many characters in the unicode buffer */
799 len = ImmGetDescriptionW( hKL, NULL, 0 );
801 /* allocate a buffer of that size */
802 buf = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof (WCHAR) );
806 /* fetch the unicode buffer */
807 len = ImmGetDescriptionW( hKL, buf, len + 1 );
809 /* convert it back to ASCII */
810 len = WideCharToMultiByte( CP_ACP, 0, buf, len + 1,
811 lpszDescription, uBufLen, NULL, NULL );
813 HeapFree( GetProcessHeap(), 0, buf );
818 /***********************************************************************
819 * ImmGetDescriptionW (IMM32.@)
821 UINT WINAPI ImmGetDescriptionW(HKL hKL, LPWSTR lpszDescription, UINT uBufLen)
823 static const WCHAR name[] = { 'W','i','n','e',' ','X','I','M',0 };
825 FIXME("(%p, %p, %d): semi stub\n", hKL, lpszDescription, uBufLen);
827 if (!uBufLen) return lstrlenW( name );
828 lstrcpynW( lpszDescription, name, uBufLen );
829 return lstrlenW( lpszDescription );
832 /***********************************************************************
833 * ImmGetGuideLineA (IMM32.@)
835 DWORD WINAPI ImmGetGuideLineA(
836 HIMC hIMC, DWORD dwIndex, LPSTR lpBuf, DWORD dwBufLen)
838 FIXME("(%p, %d, %s, %d): stub\n",
839 hIMC, dwIndex, debugstr_a(lpBuf), dwBufLen
841 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
845 /***********************************************************************
846 * ImmGetGuideLineW (IMM32.@)
848 DWORD WINAPI ImmGetGuideLineW(HIMC hIMC, DWORD dwIndex, LPWSTR lpBuf, DWORD dwBufLen)
850 FIXME("(%p, %d, %s, %d): stub\n",
851 hIMC, dwIndex, debugstr_w(lpBuf), dwBufLen
853 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
857 /***********************************************************************
858 * ImmGetIMEFileNameA (IMM32.@)
860 UINT WINAPI ImmGetIMEFileNameA(
861 HKL hKL, LPSTR lpszFileName, UINT uBufLen)
863 FIXME("(%p, %p, %d): stub\n", hKL, lpszFileName, uBufLen);
864 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
868 /***********************************************************************
869 * ImmGetIMEFileNameW (IMM32.@)
871 UINT WINAPI ImmGetIMEFileNameW(
872 HKL hKL, LPWSTR lpszFileName, UINT uBufLen)
874 FIXME("(%p, %p, %d): stub\n", hKL, lpszFileName, uBufLen);
875 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
879 /***********************************************************************
880 * ImmGetOpenStatus (IMM32.@)
882 BOOL WINAPI ImmGetOpenStatus(HIMC hIMC)
884 InputContextData *data = (InputContextData*)hIMC;
888 FIXME("(%p): semi-stub\n", hIMC);
893 /***********************************************************************
894 * ImmGetProperty (IMM32.@)
896 DWORD WINAPI ImmGetProperty(HKL hKL, DWORD fdwIndex)
899 TRACE("(%p, %d)\n", hKL, fdwIndex);
904 TRACE("(%s)\n", "IGP_PROPERTY");
905 rc = IME_PROP_UNICODE | IME_PROP_AT_CARET;
908 FIXME("(%s)\n", "IGP_CONVERSION");
909 rc = IME_CMODE_NATIVE;
912 FIXME("%s)\n", "IGP_SENTENCE");
913 rc = IME_SMODE_AUTOMATIC;
916 TRACE("(%s)\n", "IGP_SETCOMPSTR");
920 TRACE("(%s)\n", "IGP_SELECT");
921 rc = SELECT_CAP_CONVERSION | SELECT_CAP_SENTENCE;
923 case IGP_GETIMEVERSION:
924 TRACE("(%s)\n", "IGP_GETIMEVERSION");
928 TRACE("(%s)\n", "IGP_UI");
937 /***********************************************************************
938 * ImmGetRegisterWordStyleA (IMM32.@)
940 UINT WINAPI ImmGetRegisterWordStyleA(
941 HKL hKL, UINT nItem, LPSTYLEBUFA lpStyleBuf)
943 FIXME("(%p, %d, %p): stub\n", hKL, nItem, lpStyleBuf);
944 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
948 /***********************************************************************
949 * ImmGetRegisterWordStyleW (IMM32.@)
951 UINT WINAPI ImmGetRegisterWordStyleW(
952 HKL hKL, UINT nItem, LPSTYLEBUFW lpStyleBuf)
954 FIXME("(%p, %d, %p): stub\n", hKL, nItem, lpStyleBuf);
955 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
959 /***********************************************************************
960 * ImmGetStatusWindowPos (IMM32.@)
962 BOOL WINAPI ImmGetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
964 FIXME("(%p, %p): stub\n", hIMC, lpptPos);
965 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
969 /***********************************************************************
970 * ImmGetVirtualKey (IMM32.@)
972 UINT WINAPI ImmGetVirtualKey(HWND hWnd)
974 OSVERSIONINFOA version;
975 FIXME("(%p): stub\n", hWnd);
976 GetVersionExA( &version );
977 switch(version.dwPlatformId)
979 case VER_PLATFORM_WIN32_WINDOWS:
980 return VK_PROCESSKEY;
981 case VER_PLATFORM_WIN32_NT:
984 FIXME("%d not supported\n",version.dwPlatformId);
985 return VK_PROCESSKEY;
989 /***********************************************************************
990 * ImmInstallIMEA (IMM32.@)
992 HKL WINAPI ImmInstallIMEA(
993 LPCSTR lpszIMEFileName, LPCSTR lpszLayoutText)
995 FIXME("(%s, %s): stub\n",
996 debugstr_a(lpszIMEFileName), debugstr_a(lpszLayoutText)
998 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1002 /***********************************************************************
1003 * ImmInstallIMEW (IMM32.@)
1005 HKL WINAPI ImmInstallIMEW(
1006 LPCWSTR lpszIMEFileName, LPCWSTR lpszLayoutText)
1008 FIXME("(%s, %s): stub\n",
1009 debugstr_w(lpszIMEFileName), debugstr_w(lpszLayoutText)
1011 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1015 /***********************************************************************
1016 * ImmIsIME (IMM32.@)
1018 BOOL WINAPI ImmIsIME(HKL hKL)
1020 TRACE("(%p): semi-stub\n", hKL);
1022 * FIXME: Dead key locales will return TRUE here when they should not
1023 * There is probably a more proper way to check this.
1025 return (root_context != NULL);
1028 /***********************************************************************
1029 * ImmIsUIMessageA (IMM32.@)
1031 BOOL WINAPI ImmIsUIMessageA(
1032 HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
1036 TRACE("(%p, %x, %ld, %ld)\n", hWndIME, msg, wParam, lParam);
1037 if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
1038 (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP) ||
1039 (msg == WM_MSIME_SERVICE) ||
1040 (msg == WM_MSIME_RECONVERTOPTIONS) ||
1041 (msg == WM_MSIME_MOUSE) ||
1042 (msg == WM_MSIME_RECONVERTREQUEST) ||
1043 (msg == WM_MSIME_RECONVERT) ||
1044 (msg == WM_MSIME_QUERYPOSITION) ||
1045 (msg == WM_MSIME_DOCUMENTFEED))
1049 ImmGetDefaultIMEWnd(NULL);
1051 if (hWndIME == NULL)
1052 PostMessageA(hwndDefault, msg, wParam, lParam);
1059 /***********************************************************************
1060 * ImmIsUIMessageW (IMM32.@)
1062 BOOL WINAPI ImmIsUIMessageW(
1063 HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
1066 TRACE("(%p, %d, %ld, %ld): stub\n", hWndIME, msg, wParam, lParam);
1067 if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
1068 (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP) ||
1069 (msg == WM_MSIME_SERVICE) ||
1070 (msg == WM_MSIME_RECONVERTOPTIONS) ||
1071 (msg == WM_MSIME_MOUSE) ||
1072 (msg == WM_MSIME_RECONVERTREQUEST) ||
1073 (msg == WM_MSIME_RECONVERT) ||
1074 (msg == WM_MSIME_QUERYPOSITION) ||
1075 (msg == WM_MSIME_DOCUMENTFEED))
1080 /***********************************************************************
1081 * ImmNotifyIME (IMM32.@)
1083 BOOL WINAPI ImmNotifyIME(
1084 HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
1088 TRACE("(%p, %d, %d, %d)\n",
1089 hIMC, dwAction, dwIndex, dwValue);
1096 case NI_CHANGECANDIDATELIST:
1097 FIXME("%s\n","NI_CHANGECANDIDATELIST");
1099 case NI_CLOSECANDIDATE:
1100 FIXME("%s\n","NI_CLOSECANDIDATE");
1102 case NI_COMPOSITIONSTR:
1106 TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_CANCEL");
1107 if (pX11DRV_ForceXIMReset)
1108 pX11DRV_ForceXIMReset(root_context->hwnd);
1109 if (root_context->dwCompStringSize)
1111 HeapFree(GetProcessHeap(),0,
1112 root_context->CompositionString);
1113 root_context->dwCompStringSize = 0;
1114 root_context->dwCompStringLength = 0;
1115 root_context->CompositionString = NULL;
1116 ImmInternalPostIMEMessage(WM_IME_COMPOSITION, 0,
1122 TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_COMPLETE");
1123 if (hIMC != (HIMC)FROM_IME && pX11DRV_ForceXIMReset)
1124 pX11DRV_ForceXIMReset(root_context->hwnd);
1126 if (root_context->dwResultStringSize)
1128 HeapFree(GetProcessHeap(),0,root_context->ResultString);
1129 root_context->dwResultStringSize = 0;
1130 root_context->ResultString = NULL;
1132 if (root_context->dwCompStringLength)
1134 root_context->ResultString = HeapAlloc(
1135 GetProcessHeap(), 0, root_context->dwCompStringLength);
1136 root_context->dwResultStringSize =
1137 root_context->dwCompStringLength;
1139 memcpy(root_context->ResultString,
1140 root_context->CompositionString,
1141 root_context->dwCompStringLength);
1143 HeapFree(GetProcessHeap(),0,
1144 root_context->CompositionString);
1146 root_context->dwCompStringSize = 0;
1147 root_context->dwCompStringLength = 0;
1148 root_context->CompositionString = NULL;
1149 root_context->bRead = FALSE;
1151 ImmInternalPostIMEMessage(WM_IME_COMPOSITION, 0,
1154 ImmInternalPostIMEMessage(WM_IME_COMPOSITION,
1155 root_context->ResultString[0],
1156 GCS_RESULTSTR|GCS_RESULTCLAUSE);
1158 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION, 0, 0);
1159 root_context->bInComposition = FALSE;
1163 FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_CONVERT");
1166 FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_REVERT");
1169 ERR("%s - %s (%i)\n","NI_COMPOSITIONSTR","UNKNOWN",dwIndex);
1173 case NI_IMEMENUSELECTED:
1174 FIXME("%s\n", "NI_IMEMENUSELECTED");
1176 case NI_OPENCANDIDATE:
1177 FIXME("%s\n", "NI_OPENCANDIDATE");
1179 case NI_SELECTCANDIDATESTR:
1180 FIXME("%s\n", "NI_SELECTCANDIDATESTR");
1182 case NI_SETCANDIDATE_PAGESIZE:
1183 FIXME("%s\n", "NI_SETCANDIDATE_PAGESIZE");
1185 case NI_SETCANDIDATE_PAGESTART:
1186 FIXME("%s\n", "NI_SETCANDIDATE_PAGESTART");
1195 /***********************************************************************
1196 * ImmRegisterWordA (IMM32.@)
1198 BOOL WINAPI ImmRegisterWordA(
1199 HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszRegister)
1201 FIXME("(%p, %s, %d, %s): stub\n",
1202 hKL, debugstr_a(lpszReading), dwStyle, debugstr_a(lpszRegister)
1204 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1208 /***********************************************************************
1209 * ImmRegisterWordW (IMM32.@)
1211 BOOL WINAPI ImmRegisterWordW(
1212 HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszRegister)
1214 FIXME("(%p, %s, %d, %s): stub\n",
1215 hKL, debugstr_w(lpszReading), dwStyle, debugstr_w(lpszRegister)
1217 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1221 /***********************************************************************
1222 * ImmReleaseContext (IMM32.@)
1224 BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
1226 FIXME("(%p, %p): stub\n", hWnd, hIMC);
1231 /***********************************************************************
1232 * ImmSetCandidateWindow (IMM32.@)
1234 BOOL WINAPI ImmSetCandidateWindow(
1235 HIMC hIMC, LPCANDIDATEFORM lpCandidate)
1237 FIXME("(%p, %p): stub\n", hIMC, lpCandidate);
1238 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1242 /***********************************************************************
1243 * ImmSetCompositionFontA (IMM32.@)
1245 BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
1247 InputContextData *data = (InputContextData*)hIMC;
1248 TRACE("(%p, %p)\n", hIMC, lplf);
1253 memcpy(&data->font,lplf,sizeof(LOGFONTA));
1254 MultiByteToWideChar(CP_ACP, 0, lplf->lfFaceName, -1, data->font.lfFaceName,
1257 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONFONT, 0);
1261 DeleteObject(data->textfont);
1262 data->textfont = NULL;
1265 data->textfont = CreateFontIndirectW(&data->font);
1269 /***********************************************************************
1270 * ImmSetCompositionFontW (IMM32.@)
1272 BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
1274 InputContextData *data = (InputContextData*)hIMC;
1275 TRACE("(%p, %p)\n", hIMC, lplf);
1280 memcpy(&data->font,lplf,sizeof(LOGFONTW));
1281 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONFONT, 0);
1285 DeleteObject(data->textfont);
1286 data->textfont = NULL;
1288 data->textfont = CreateFontIndirectW(&data->font);
1292 /***********************************************************************
1293 * ImmSetCompositionStringA (IMM32.@)
1295 BOOL WINAPI ImmSetCompositionStringA(
1296 HIMC hIMC, DWORD dwIndex,
1297 LPCVOID lpComp, DWORD dwCompLen,
1298 LPCVOID lpRead, DWORD dwReadLen)
1302 WCHAR *CompBuffer = NULL;
1303 WCHAR *ReadBuffer = NULL;
1306 TRACE("(%p, %d, %p, %d, %p, %d): stub\n",
1307 hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
1309 comp_len = MultiByteToWideChar(CP_ACP, 0, lpComp, dwCompLen, NULL, 0);
1312 CompBuffer = HeapAlloc(GetProcessHeap(),0,comp_len * sizeof(WCHAR));
1313 MultiByteToWideChar(CP_ACP, 0, lpComp, dwCompLen, CompBuffer, comp_len);
1316 read_len = MultiByteToWideChar(CP_ACP, 0, lpRead, dwReadLen, NULL, 0);
1319 ReadBuffer = HeapAlloc(GetProcessHeap(),0,read_len * sizeof(WCHAR));
1320 MultiByteToWideChar(CP_ACP, 0, lpRead, dwReadLen, ReadBuffer, read_len);
1323 rc = ImmSetCompositionStringW(hIMC, dwIndex, CompBuffer, comp_len,
1324 ReadBuffer, read_len);
1326 HeapFree(GetProcessHeap(), 0, CompBuffer);
1327 HeapFree(GetProcessHeap(), 0, ReadBuffer);
1332 /***********************************************************************
1333 * ImmSetCompositionStringW (IMM32.@)
1335 BOOL WINAPI ImmSetCompositionStringW(
1336 HIMC hIMC, DWORD dwIndex,
1337 LPCVOID lpComp, DWORD dwCompLen,
1338 LPCVOID lpRead, DWORD dwReadLen)
1343 TRACE("(%p, %d, %p, %d, %p, %d): stub\n",
1344 hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
1347 if (hIMC != (HIMC)FROM_IME)
1348 FIXME("PROBLEM: This only sets the wine level string\n");
1352 * this sets the composition string in the imm32.dll level
1353 * of the composition buffer. we cannot manipulate the xim level
1354 * buffer, which means that once the xim level buffer changes again
1355 * any call to this function from the application will be lost
1358 if (lpRead && dwReadLen)
1359 FIXME("Reading string unimplemented\n");
1362 * app operating this api to also receive the message from xim
1365 if (dwIndex == SCS_SETSTR)
1367 if (!root_context->bInComposition)
1369 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION, 0, 0);
1370 root_context->bInComposition = TRUE;
1373 flags = GCS_COMPSTR;
1375 if (root_context->dwCompStringLength)
1376 HeapFree(GetProcessHeap(),0,root_context->CompositionString);
1378 root_context->dwCompStringLength = dwCompLen;
1379 root_context->dwCompStringSize = dwCompLen;
1381 if (dwCompLen && lpComp)
1383 root_context->CompositionString = HeapAlloc(GetProcessHeap(), 0,
1385 memcpy(root_context->CompositionString,lpComp,dwCompLen);
1387 wParam = ((const WCHAR*)lpComp)[0];
1388 flags |= GCS_COMPCLAUSE | GCS_COMPATTR;
1391 root_context->CompositionString = NULL;
1395 UpdateDataInDefaultIMEWindow(hwndDefault);
1397 ImmInternalPostIMEMessage(WM_IME_COMPOSITION, wParam, flags);
1402 /***********************************************************************
1403 * ImmSetCompositionWindow (IMM32.@)
1405 BOOL WINAPI ImmSetCompositionWindow(
1406 HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
1408 BOOL reshow = FALSE;
1409 InputContextData *data = (InputContextData*)hIMC;
1411 TRACE("(%p, %p)\n", hIMC, lpCompForm);
1412 TRACE("\t%x, (%i,%i), (%i,%i - %i,%i)\n",lpCompForm->dwStyle,
1413 lpCompForm->ptCurrentPos.x, lpCompForm->ptCurrentPos.y, lpCompForm->rcArea.top,
1414 lpCompForm->rcArea.left, lpCompForm->rcArea.bottom, lpCompForm->rcArea.right);
1419 memcpy(&data->CompForm,lpCompForm,sizeof(COMPOSITIONFORM));
1421 if (IsWindowVisible(hwndDefault))
1424 ShowWindow(hwndDefault,SW_HIDE);
1427 /* FIXME: this is a partial stub */
1430 ShowWindow(hwndDefault,SW_SHOWNOACTIVATE);
1432 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONWINDOW, 0);
1436 /***********************************************************************
1437 * ImmSetConversionStatus (IMM32.@)
1439 BOOL WINAPI ImmSetConversionStatus(
1440 HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
1442 FIXME("(%p, %d, %d): stub\n",
1443 hIMC, fdwConversion, fdwSentence
1445 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1449 /***********************************************************************
1450 * ImmSetOpenStatus (IMM32.@)
1452 BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
1454 InputContextData *data = (InputContextData*)hIMC;
1456 TRACE("%p %d\n", hIMC, fOpen);
1458 if (hIMC == (HIMC)FROM_IME)
1460 ImmInternalSetOpenStatus(fOpen);
1461 ImmInternalSendIMENotify(IMN_SETOPENSTATUS, 0);
1468 if (fOpen != data->bInternalState)
1470 if (fOpen == FALSE && pX11DRV_ForceXIMReset)
1471 pX11DRV_ForceXIMReset(data->hwnd);
1474 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION,0,0);
1476 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION,0,0);
1478 ImmInternalSetOpenStatus(fOpen);
1479 ImmInternalSetOpenStatus(!fOpen);
1481 if (data->bOpen == FALSE)
1482 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION,0,0);
1484 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION,0,0);
1491 /***********************************************************************
1492 * ImmSetStatusWindowPos (IMM32.@)
1494 BOOL WINAPI ImmSetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
1496 FIXME("(%p, %p): stub\n", hIMC, lpptPos);
1497 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1501 /***********************************************************************
1502 * ImmSimulateHotKey (IMM32.@)
1504 BOOL WINAPI ImmSimulateHotKey(HWND hWnd, DWORD dwHotKeyID)
1506 FIXME("(%p, %d): stub\n", hWnd, dwHotKeyID);
1507 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1511 /***********************************************************************
1512 * ImmUnregisterWordA (IMM32.@)
1514 BOOL WINAPI ImmUnregisterWordA(
1515 HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszUnregister)
1517 FIXME("(%p, %s, %d, %s): stub\n",
1518 hKL, debugstr_a(lpszReading), dwStyle, debugstr_a(lpszUnregister)
1520 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1524 /***********************************************************************
1525 * ImmUnregisterWordW (IMM32.@)
1527 BOOL WINAPI ImmUnregisterWordW(
1528 HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszUnregister)
1530 FIXME("(%p, %s, %d, %s): stub\n",
1531 hKL, debugstr_w(lpszReading), dwStyle, debugstr_w(lpszUnregister)
1533 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1537 /***********************************************************************
1538 * ImmGetImeMenuItemsA (IMM32.@)
1540 DWORD WINAPI ImmGetImeMenuItemsA( HIMC hIMC, DWORD dwFlags, DWORD dwType,
1541 LPIMEMENUITEMINFOA lpImeParentMenu, LPIMEMENUITEMINFOA lpImeMenu,
1544 FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC, dwFlags, dwType,
1545 lpImeParentMenu, lpImeMenu, dwSize);
1549 /***********************************************************************
1550 * ImmGetImeMenuItemsW (IMM32.@)
1552 DWORD WINAPI ImmGetImeMenuItemsW( HIMC hIMC, DWORD dwFlags, DWORD dwType,
1553 LPIMEMENUITEMINFOW lpImeParentMenu, LPIMEMENUITEMINFOW lpImeMenu,
1556 FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC, dwFlags, dwType,
1557 lpImeParentMenu, lpImeMenu, dwSize);
1562 * Internal functions to help with IME window management
1564 static void PaintDefaultIMEWnd(HWND hwnd)
1568 HDC hdc = BeginPaint(hwnd,&ps);
1569 GetClientRect(hwnd,&rect);
1570 FillRect(hdc, &rect, (HBRUSH)(COLOR_WINDOW + 1));
1572 if (root_context->dwCompStringLength && root_context->CompositionString)
1576 HFONT oldfont = NULL;
1578 if (root_context->textfont)
1579 oldfont = SelectObject(hdc,root_context->textfont);
1582 GetTextExtentPoint32W(hdc, (LPWSTR)root_context->CompositionString,
1583 root_context->dwCompStringLength / sizeof(WCHAR),
1589 if (root_context->CompForm.dwStyle == CFS_POINT ||
1590 root_context->CompForm.dwStyle == CFS_FORCE_POSITION)
1592 POINT cpt = root_context->CompForm.ptCurrentPos;
1593 ClientToScreen(root_context->hwnd,&cpt);
1596 rect.right = rect.left + pt.x + 20;
1597 rect.bottom = rect.top + pt.y + 20;
1599 else if (root_context->CompForm.dwStyle == CFS_RECT)
1602 cpt.x = root_context->CompForm.rcArea.left;
1603 cpt.y = root_context->CompForm.rcArea.top;
1604 ClientToScreen(root_context->hwnd,&cpt);
1607 cpt.x = root_context->CompForm.rcArea.right;
1608 cpt.y = root_context->CompForm.rcArea.bottom;
1609 ClientToScreen(root_context->hwnd,&cpt);
1611 rect.bottom = cpt.y;
1615 rect.right = rect.left + pt.x + 20;
1616 rect.bottom = rect.top + pt.y + 20;
1618 MoveWindow(hwnd, rect.left, rect.top, rect.right - rect.left ,
1619 rect.bottom - rect.top, FALSE);
1620 TextOutW(hdc, 10,10,(LPWSTR)root_context->CompositionString,
1621 root_context->dwCompStringLength / sizeof(WCHAR));
1624 SelectObject(hdc,oldfont);
1629 static void UpdateDataInDefaultIMEWindow(HWND hwnd)
1631 RedrawWindow(hwnd,NULL,NULL,RDW_ERASENOW|RDW_INVALIDATE);
1635 * The window proc for the default IME window
1637 static LRESULT WINAPI IME_WindowProc(HWND hwnd, UINT msg, WPARAM wParam,
1642 TRACE("Incoming Message 0x%x (0x%08x, 0x%08x)\n", msg, (UINT)wParam,
1648 PaintDefaultIMEWnd(hwnd);
1655 SetWindowTextA(hwnd,"Wine Ime Active");
1660 SetFocus((HWND)wParam);
1662 FIXME("Received focus, should never have focus\n");
1664 case WM_IME_COMPOSITION:
1665 TRACE("IME message %s, 0x%x, 0x%x (%i)\n",
1666 "WM_IME_COMPOSITION", (UINT)wParam, (UINT)lParam,
1667 root_context->bRead);
1668 if (lParam & GCS_RESULTSTR)
1669 IMM_PostResult(root_context);
1671 UpdateDataInDefaultIMEWindow(hwnd);
1673 case WM_IME_STARTCOMPOSITION:
1674 TRACE("IME message %s, 0x%x, 0x%x\n",
1675 "WM_IME_STARTCOMPOSITION", (UINT)wParam, (UINT)lParam);
1676 root_context->hwnd = GetFocus();
1677 ShowWindow(hwndDefault,SW_SHOWNOACTIVATE);
1679 case WM_IME_ENDCOMPOSITION:
1680 TRACE("IME message %s, 0x%x, 0x%x\n",
1681 "WM_IME_ENDCOMPOSITION", (UINT)wParam, (UINT)lParam);
1682 ShowWindow(hwndDefault,SW_HIDE);
1685 TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_SELECT",
1686 (UINT)wParam, (UINT)lParam);
1688 case WM_IME_CONTROL:
1689 TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_CONTROL",
1690 (UINT)wParam, (UINT)lParam);
1694 TRACE("!! IME NOTIFY\n");
1697 TRACE("Non-standard message 0x%x\n",msg);
1699 /* check the MSIME messages */
1700 if (msg == WM_MSIME_SERVICE)
1702 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_SERVICE",
1703 (UINT)wParam, (UINT)lParam);
1706 else if (msg == WM_MSIME_RECONVERTOPTIONS)
1708 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTOPTIONS",
1709 (UINT)wParam, (UINT)lParam);
1711 else if (msg == WM_MSIME_MOUSE)
1713 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_MOUSE",
1714 (UINT)wParam, (UINT)lParam);
1716 else if (msg == WM_MSIME_RECONVERTREQUEST)
1718 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTREQUEST",
1719 (UINT)wParam, (UINT)lParam);
1721 else if (msg == WM_MSIME_RECONVERT)
1723 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERT",
1724 (UINT)wParam, (UINT)lParam);
1726 else if (msg == WM_MSIME_QUERYPOSITION)
1728 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_QUERYPOSITION",
1729 (UINT)wParam, (UINT)lParam);
1731 else if (msg == WM_MSIME_DOCUMENTFEED)
1733 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_DOCUMENTFEED",
1734 (UINT)wParam, (UINT)lParam);
1736 /* DefWndProc if not an IME message */
1737 else if (!rc && !((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
1738 (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP)))
1739 rc = DefWindowProcW(hwnd,msg,wParam,lParam);