4 * Copyright 1998 Patrik Stridvall
5 * Copyright 2002, 2003, 2007 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
30 #include "wine/debug.h"
35 #include "wine/list.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(imm);
39 typedef struct tagIMCCInternal
45 #define MAKE_FUNCPTR(f) typeof(f) * p##f
46 typedef struct _tagImmHkl{
51 WCHAR imeClassName[17]; /* 16 character max */
54 /* Function Pointers */
55 MAKE_FUNCPTR(ImeInquire);
56 MAKE_FUNCPTR(ImeConfigure);
57 MAKE_FUNCPTR(ImeDestroy);
58 MAKE_FUNCPTR(ImeEscape);
59 MAKE_FUNCPTR(ImeSelect);
60 MAKE_FUNCPTR(ImeSetActiveContext);
61 MAKE_FUNCPTR(ImeToAsciiEx);
62 MAKE_FUNCPTR(NotifyIME);
63 MAKE_FUNCPTR(ImeRegisterWord);
64 MAKE_FUNCPTR(ImeUnregisterWord);
65 MAKE_FUNCPTR(ImeEnumRegisterWord);
66 MAKE_FUNCPTR(ImeSetCompositionString);
67 MAKE_FUNCPTR(ImeConversionList);
68 MAKE_FUNCPTR(ImeProcessKey);
69 MAKE_FUNCPTR(ImeGetRegisterWordStyle);
70 MAKE_FUNCPTR(ImeGetImeMenuItems);
74 typedef struct tagInputContextData
84 typedef struct _tagTRANSMSG {
88 } TRANSMSG, *LPTRANSMSG;
90 typedef struct _tagIMMThreadData {
95 static DWORD tlsIndex = 0;
96 static struct list ImmHklList = LIST_INIT(ImmHklList);
99 static UINT WM_MSIME_SERVICE;
100 static UINT WM_MSIME_RECONVERTOPTIONS;
101 static UINT WM_MSIME_MOUSE;
102 static UINT WM_MSIME_RECONVERTREQUEST;
103 static UINT WM_MSIME_RECONVERT;
104 static UINT WM_MSIME_QUERYPOSITION;
105 static UINT WM_MSIME_DOCUMENTFEED;
107 static const WCHAR szwWineIMCProperty[] = {'W','i','n','e','I','m','m','H','I','M','C','P','r','o','p','e','r','t','y',0};
109 #define is_himc_ime_unicode(p) (p->immKbd->imeInfo.fdwProperty & IME_PROP_UNICODE)
110 #define is_kbd_ime_unicode(p) (p->imeInfo.fdwProperty & IME_PROP_UNICODE)
112 static BOOL IMM_DestroyContext(HIMC hIMC);
114 static inline WCHAR *strdupAtoW( const char *str )
119 DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
120 if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
121 MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
126 static inline CHAR *strdupWtoA( const WCHAR *str )
131 DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
132 if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
133 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
138 static IMMThreadData* IMM_GetThreadData(void)
140 return (IMMThreadData*)TlsGetValue(tlsIndex);
143 static void IMM_InitThreadData(void)
145 IMMThreadData* data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
146 sizeof(IMMThreadData));
147 TlsSetValue(tlsIndex,data);
149 TRACE("Thread Data Created\n");
152 static void IMM_FreeThreadData(void)
154 IMMThreadData* data = TlsGetValue(tlsIndex);
155 IMM_DestroyContext(data->defaultContext);
156 DestroyWindow(data->hwndDefault);
157 HeapFree(GetProcessHeap(),0,data);
158 TRACE("Thread Data Destroyed\n");
161 static HMODULE LoadDefaultWineIME(void)
163 char buffer[MAX_PATH], libname[32], *name, *next;
167 TRACE("Attempting to fall back to wine default IME\n");
169 strcpy( buffer, "x11" ); /* default value */
170 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
171 if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
173 DWORD type, count = sizeof(buffer);
174 RegQueryValueExA( hkey, "Ime", 0, &type, (LPBYTE) buffer, &count );
181 next = strchr( name, ',' );
182 if (next) *next++ = 0;
184 snprintf( libname, sizeof(libname), "wine%s.drv", name );
185 if ((module = LoadLibraryA( libname )) != 0) break;
192 /* ImmHkl loading and freeing */
193 #define LOAD_FUNCPTR(f) if((ptr->p##f = (LPVOID)GetProcAddress(ptr->hIME, #f)) == NULL){WARN("Can't find function %s in ime\n", #f);}
194 static ImmHkl *IMM_GetImmHkl(HKL hkl)
197 WCHAR filename[MAX_PATH];
199 TRACE("Seeking ime for keyboard 0x%x\n",(unsigned)hkl);
201 LIST_FOR_EACH_ENTRY(ptr, &ImmHklList, ImmHkl, entry)
206 /* not found... create it */
208 ptr = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ImmHkl));
211 if (ImmGetIMEFileNameW(hkl, filename, MAX_PATH)) ptr->hIME = LoadLibraryW(filename);
213 ptr->hIME = LoadDefaultWineIME();
216 LOAD_FUNCPTR(ImeInquire);
217 if (!ptr->pImeInquire || !ptr->pImeInquire(&ptr->imeInfo, ptr->imeClassName, NULL))
219 FreeLibrary(ptr->hIME);
224 LOAD_FUNCPTR(ImeDestroy);
225 LOAD_FUNCPTR(ImeSelect);
226 if (!ptr->pImeSelect || !ptr->pImeDestroy)
228 FreeLibrary(ptr->hIME);
233 LOAD_FUNCPTR(ImeConfigure);
234 LOAD_FUNCPTR(ImeEscape);
235 LOAD_FUNCPTR(ImeSetActiveContext);
236 LOAD_FUNCPTR(ImeToAsciiEx);
237 LOAD_FUNCPTR(NotifyIME);
238 LOAD_FUNCPTR(ImeRegisterWord);
239 LOAD_FUNCPTR(ImeUnregisterWord);
240 LOAD_FUNCPTR(ImeEnumRegisterWord);
241 LOAD_FUNCPTR(ImeSetCompositionString);
242 LOAD_FUNCPTR(ImeConversionList);
243 LOAD_FUNCPTR(ImeProcessKey);
244 LOAD_FUNCPTR(ImeGetRegisterWordStyle);
245 LOAD_FUNCPTR(ImeGetImeMenuItems);
246 /* make sure our classname is WCHAR */
247 if (!is_kbd_ime_unicode(ptr))
250 MultiByteToWideChar(CP_ACP, 0, (LPSTR)ptr->imeClassName,
252 lstrcpyW(ptr->imeClassName, bufW);
257 list_add_head(&ImmHklList,&ptr->entry);
263 static void IMM_FreeAllImmHkl(void)
265 ImmHkl *ptr,*cursor2;
267 LIST_FOR_EACH_ENTRY_SAFE(ptr, cursor2, &ImmHklList, ImmHkl, entry)
269 list_remove(&ptr->entry);
273 FreeLibrary(ptr->hIME);
275 HeapFree(GetProcessHeap(),0,ptr);
279 static void IMM_RegisterMessages(void)
281 WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService");
282 WM_MSIME_RECONVERTOPTIONS = RegisterWindowMessageA("MSIMEReconvertOptions");
283 WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation");
284 WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest");
285 WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert");
286 WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition");
287 WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed");
290 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpReserved)
292 TRACE("%p, %x, %p\n",hInstDLL,fdwReason,lpReserved);
295 case DLL_PROCESS_ATTACH:
296 IMM_RegisterMessages();
297 tlsIndex = TlsAlloc();
298 IMM_InitThreadData();
300 case DLL_THREAD_ATTACH:
301 IMM_InitThreadData();
303 case DLL_THREAD_DETACH:
304 IMM_FreeThreadData();
306 case DLL_PROCESS_DETACH:
307 IMM_FreeThreadData();
315 /* for posting messages as the IME */
316 static void ImmInternalPostIMEMessage(InputContextData *data, UINT msg, WPARAM wParam, LPARAM lParam)
318 HWND target = GetFocus();
320 PostMessageW(data->IMC.hWnd,msg,wParam,lParam);
322 PostMessageW(target, msg, wParam, lParam);
325 static LRESULT ImmInternalSendIMENotify(InputContextData *data, WPARAM notify, LPARAM lParam)
329 target = data->IMC.hWnd;
330 if (!target) target = GetFocus();
333 return SendMessageW(target, WM_IME_NOTIFY, notify, lParam);
338 static HIMCC ImmCreateBlankCompStr(void)
341 LPCOMPOSITIONSTRING ptr;
342 rc = ImmCreateIMCC(sizeof(COMPOSITIONSTRING));
343 ptr = (LPCOMPOSITIONSTRING)ImmLockIMCC(rc);
344 memset(ptr,0,sizeof(COMPOSITIONSTRING));
345 ptr->dwSize = sizeof(COMPOSITIONSTRING);
350 /***********************************************************************
351 * ImmAssociateContext (IMM32.@)
353 HIMC WINAPI ImmAssociateContext(HWND hWnd, HIMC hIMC)
356 InputContextData *data = (InputContextData*)hIMC;
358 TRACE("(%p, %p):\n", hWnd, hIMC);
360 if (!IMM_GetThreadData()->defaultContext)
361 IMM_GetThreadData()->defaultContext = ImmCreateContext();
364 * If already associated just return
366 if (hIMC && data->IMC.hWnd == hWnd)
371 old = (HIMC)RemovePropW(hWnd,szwWineIMCProperty);
374 old = IMM_GetThreadData()->defaultContext;
375 else if (old == (HIMC)-1)
378 if (hIMC != IMM_GetThreadData()->defaultContext)
380 if (hIMC == NULL) /* Meaning disable imm for that window*/
381 SetPropW(hWnd,szwWineIMCProperty,(HANDLE)-1);
383 SetPropW(hWnd,szwWineIMCProperty,(HANDLE)hIMC);
388 InputContextData *old_data = (InputContextData*)old;
389 if (old_data->IMC.hWnd == hWnd)
390 old_data->IMC.hWnd = NULL;
397 if (IsWindow(data->IMC.hWnd))
400 * Post a message that your context is switching
402 SendMessageW(data->IMC.hWnd, WM_IME_SETCONTEXT, FALSE, ISC_SHOWUIALL);
405 data->IMC.hWnd = hWnd;
407 if (IsWindow(data->IMC.hWnd))
410 * Post a message that your context is switching
412 SendMessageW(data->IMC.hWnd, WM_IME_SETCONTEXT, TRUE, ISC_SHOWUIALL);
418 /***********************************************************************
419 * ImmAssociateContextEx (IMM32.@)
421 BOOL WINAPI ImmAssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags)
423 FIXME("(%p, %p, %d): stub\n", hWnd, hIMC, dwFlags);
424 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
428 /***********************************************************************
429 * ImmConfigureIMEA (IMM32.@)
431 BOOL WINAPI ImmConfigureIMEA(
432 HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData)
434 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
436 TRACE("(%p, %p, %d, %p):\n", hKL, hWnd, dwMode, lpData);
438 if (immHkl->hIME && immHkl->pImeConfigure)
440 if (dwMode != IME_CONFIG_REGISTERWORD || !is_kbd_ime_unicode(immHkl))
441 return immHkl->pImeConfigure(hKL,hWnd,dwMode,lpData);
445 REGISTERWORDA *rwa = (REGISTERWORDA*)lpData;
448 rww.lpReading = strdupAtoW(rwa->lpReading);
449 rww.lpWord = strdupAtoW(rwa->lpWord);
450 rc = immHkl->pImeConfigure(hKL,hWnd,dwMode,&rww);
451 HeapFree(GetProcessHeap(),0,rww.lpReading);
452 HeapFree(GetProcessHeap(),0,rww.lpWord);
460 /***********************************************************************
461 * ImmConfigureIMEW (IMM32.@)
463 BOOL WINAPI ImmConfigureIMEW(
464 HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData)
466 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
468 TRACE("(%p, %p, %d, %p):\n", hKL, hWnd, dwMode, lpData);
470 if (immHkl->hIME && immHkl->pImeConfigure)
472 if (dwMode != IME_CONFIG_REGISTERWORD || is_kbd_ime_unicode(immHkl))
473 return immHkl->pImeConfigure(hKL,hWnd,dwMode,lpData);
476 REGISTERWORDW *rww = (REGISTERWORDW*)lpData;
480 rwa.lpReading = strdupWtoA(rww->lpReading);
481 rwa.lpWord = strdupWtoA(rww->lpWord);
482 rc = immHkl->pImeConfigure(hKL,hWnd,dwMode,&rwa);
483 HeapFree(GetProcessHeap(),0,rwa.lpReading);
484 HeapFree(GetProcessHeap(),0,rwa.lpWord);
492 /***********************************************************************
493 * ImmCreateContext (IMM32.@)
495 HIMC WINAPI ImmCreateContext(void)
497 InputContextData *new_context;
501 new_context = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(InputContextData));
504 new_context->immKbd = IMM_GetImmHkl(GetKeyboardLayout(0));
506 if (!new_context->immKbd->hIME)
508 TRACE("IME dll could not be loaded\n");
509 HeapFree(GetProcessHeap(),0,new_context);
513 /* the HIMCCs are never NULL */
514 new_context->IMC.hCompStr = ImmCreateBlankCompStr();
515 new_context->IMC.hMsgBuf = ImmCreateIMCC(0);
516 new_context->IMC.hCandInfo = ImmCreateIMCC(sizeof(CANDIDATEINFO));
517 ci = ImmLockIMCC(new_context->IMC.hCandInfo);
518 memset(ci,0,sizeof(CANDIDATEINFO));
519 ci->dwSize = sizeof(CANDIDATEINFO);
520 ImmUnlockIMCC(new_context->IMC.hCandInfo);
521 new_context->IMC.hGuideLine = ImmCreateIMCC(sizeof(GUIDELINE));
522 gl = ImmLockIMCC(new_context->IMC.hGuideLine);
523 memset(gl,0,sizeof(GUIDELINE));
524 gl->dwSize = sizeof(GUIDELINE);
525 ImmUnlockIMCC(new_context->IMC.hGuideLine);
527 /* Initialize the IME Private */
528 new_context->IMC.hPrivate = ImmCreateIMCC(new_context->immKbd->imeInfo.dwPrivateDataSize);
530 if (!new_context->immKbd->pImeSelect(new_context, TRUE))
532 TRACE("Selection of IME failed\n");
533 IMM_DestroyContext(new_context);
537 new_context->immKbd->uSelected++;
538 TRACE("Created context 0x%x\n",(UINT)new_context);
540 return (HIMC)new_context;
543 static BOOL IMM_DestroyContext(HIMC hIMC)
545 InputContextData *data = (InputContextData*)hIMC;
547 TRACE("Destroying %p\n",hIMC);
551 data->immKbd->uSelected --;
552 data->immKbd->pImeSelect(hIMC, FALSE);
554 if (IMM_GetThreadData()->hwndDefault == data->imeWnd)
555 IMM_GetThreadData()->hwndDefault = NULL;
556 DestroyWindow(data->imeWnd);
558 ImmDestroyIMCC(data->IMC.hCompStr);
559 ImmDestroyIMCC(data->IMC.hCandInfo);
560 ImmDestroyIMCC(data->IMC.hGuideLine);
561 ImmDestroyIMCC(data->IMC.hPrivate);
562 ImmDestroyIMCC(data->IMC.hMsgBuf);
564 HeapFree(GetProcessHeap(),0,data);
569 /***********************************************************************
570 * ImmDestroyContext (IMM32.@)
572 BOOL WINAPI ImmDestroyContext(HIMC hIMC)
574 if (hIMC != IMM_GetThreadData()->defaultContext)
575 return IMM_DestroyContext(hIMC);
580 /***********************************************************************
581 * ImmDisableIME (IMM32.@)
583 BOOL WINAPI ImmDisableIME(DWORD idThread)
585 FIXME("(%d): stub\n", idThread);
589 /***********************************************************************
590 * ImmEnumRegisterWordA (IMM32.@)
592 UINT WINAPI ImmEnumRegisterWordA(
593 HKL hKL, REGISTERWORDENUMPROCA lpfnEnumProc,
594 LPCSTR lpszReading, DWORD dwStyle,
595 LPCSTR lpszRegister, LPVOID lpData)
597 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
598 TRACE("(%p, %p, %s, %d, %s, %p):\n", hKL, lpfnEnumProc,
599 debugstr_a(lpszReading), dwStyle, debugstr_a(lpszRegister), lpData);
600 if (immHkl->hIME && immHkl->pImeEnumRegisterWord)
602 if (!is_kbd_ime_unicode(immHkl))
603 return immHkl->pImeEnumRegisterWord((REGISTERWORDENUMPROCW)lpfnEnumProc,
604 (LPCWSTR)lpszReading, dwStyle, (LPCWSTR)lpszRegister, lpData);
607 FIXME("A procedure called with W ime back end\n");
608 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
616 /***********************************************************************
617 * ImmEnumRegisterWordW (IMM32.@)
619 UINT WINAPI ImmEnumRegisterWordW(
620 HKL hKL, REGISTERWORDENUMPROCW lpfnEnumProc,
621 LPCWSTR lpszReading, DWORD dwStyle,
622 LPCWSTR lpszRegister, LPVOID lpData)
624 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
625 TRACE("(%p, %p, %s, %d, %s, %p):\n", hKL, lpfnEnumProc,
626 debugstr_w(lpszReading), dwStyle, debugstr_w(lpszRegister), lpData);
627 if (immHkl->hIME && immHkl->pImeEnumRegisterWord)
629 if (is_kbd_ime_unicode(immHkl))
630 return immHkl->pImeEnumRegisterWord(lpfnEnumProc, lpszReading, dwStyle,
631 lpszRegister, lpData);
634 FIXME("W procedure called with A ime back end\n");
635 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
643 /***********************************************************************
644 * ImmEscapeA (IMM32.@)
646 LRESULT WINAPI ImmEscapeA(
648 UINT uEscape, LPVOID lpData)
650 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
651 TRACE("(%p, %p, %d, %p):\n", hKL, hIMC, uEscape, lpData);
653 if (immHkl->hIME && immHkl->pImeEscape)
655 if (!is_kbd_ime_unicode(immHkl))
656 return immHkl->pImeEscape(hIMC,uEscape,lpData);
659 FIXME("A procedure called with W ime back end\n");
660 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
668 /***********************************************************************
669 * ImmEscapeW (IMM32.@)
671 LRESULT WINAPI ImmEscapeW(
673 UINT uEscape, LPVOID lpData)
675 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
676 TRACE("(%p, %p, %d, %p):\n", hKL, hIMC, uEscape, lpData);
678 if (immHkl->hIME && immHkl->pImeEscape)
680 if (is_kbd_ime_unicode(immHkl))
681 return immHkl->pImeEscape(hIMC,uEscape,lpData);
684 FIXME("W procedure called with A ime back end\n");
685 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
693 /***********************************************************************
694 * ImmGetCandidateListA (IMM32.@)
696 DWORD WINAPI ImmGetCandidateListA(
697 HIMC hIMC, DWORD deIndex,
698 LPCANDIDATELIST lpCandList, DWORD dwBufLen)
700 FIXME("(%p, %d, %p, %d): stub\n",
704 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
708 /***********************************************************************
709 * ImmGetCandidateListCountA (IMM32.@)
711 DWORD WINAPI ImmGetCandidateListCountA(
712 HIMC hIMC, LPDWORD lpdwListCount)
714 FIXME("(%p, %p): stub\n", hIMC, lpdwListCount);
715 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
719 /***********************************************************************
720 * ImmGetCandidateListCountW (IMM32.@)
722 DWORD WINAPI ImmGetCandidateListCountW(
723 HIMC hIMC, LPDWORD lpdwListCount)
725 FIXME("(%p, %p): stub\n", hIMC, lpdwListCount);
726 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
730 /***********************************************************************
731 * ImmGetCandidateListW (IMM32.@)
733 DWORD WINAPI ImmGetCandidateListW(
734 HIMC hIMC, DWORD deIndex,
735 LPCANDIDATELIST lpCandList, DWORD dwBufLen)
737 FIXME("(%p, %d, %p, %d): stub\n",
741 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
745 /***********************************************************************
746 * ImmGetCandidateWindow (IMM32.@)
748 BOOL WINAPI ImmGetCandidateWindow(
749 HIMC hIMC, DWORD dwBufLen, LPCANDIDATEFORM lpCandidate)
751 FIXME("(%p, %d, %p): stub\n", hIMC, dwBufLen, lpCandidate);
752 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
756 /***********************************************************************
757 * ImmGetCompositionFontA (IMM32.@)
759 BOOL WINAPI ImmGetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
764 TRACE("(%p, %p):\n", hIMC, lplf);
766 rc = ImmGetCompositionFontW(hIMC,&lfW);
769 memcpy(lplf,&lfW,sizeof(LOGFONTA));
770 WideCharToMultiByte(CP_ACP, 0, lfW.lfFaceName, -1, lplf->lfFaceName,
771 LF_FACESIZE, NULL, NULL);
776 /***********************************************************************
777 * ImmGetCompositionFontW (IMM32.@)
779 BOOL WINAPI ImmGetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
781 InputContextData *data = (InputContextData*)hIMC;
783 TRACE("(%p, %p):\n", hIMC, lplf);
788 *lplf = data->IMC.lfFont.W;
793 /***********************************************************************
794 * ImmGetCompositionStringA (IMM32.@)
796 LONG WINAPI ImmGetCompositionStringA(
797 HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
801 InputContextData *data = (InputContextData*)hIMC;
802 LPCOMPOSITIONSTRING compstr;
805 TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen);
810 if (!data->IMC.hCompStr)
813 compdata = ImmLockIMCC(data->IMC.hCompStr);
814 compstr = (LPCOMPOSITIONSTRING)compdata;
816 if (dwIndex == GCS_RESULTSTR && compstr->dwResultStrLen > 0 &&
817 compstr->dwResultStrOffset > 0)
819 LPWSTR ResultStr = (LPWSTR)(compdata + compstr->dwResultStrOffset);
821 TRACE("GSC_RESULTSTR %p %i\n",ResultStr,
822 compstr->dwResultStrLen);
824 buf = HeapAlloc( GetProcessHeap(), 0, compstr->dwResultStrLen * 3 );
825 rc = WideCharToMultiByte(CP_ACP, 0, ResultStr,
826 compstr->dwResultStrLen , buf,
827 compstr->dwResultStrLen * 3, NULL, NULL);
829 memcpy(lpBuf,buf,rc);
831 HeapFree( GetProcessHeap(), 0, buf );
833 else if (dwIndex == GCS_COMPSTR && compstr->dwCompStrLen > 0 &&
834 compstr->dwCompStrOffset > 0)
836 LPWSTR CompString = (LPWSTR)(compdata + compstr->dwCompStrOffset);
838 TRACE("GSC_COMPSTR %p %i\n", CompString, compstr->dwCompStrLen);
840 buf = HeapAlloc( GetProcessHeap(), 0, compstr->dwCompStrLen * 3 );
841 rc = WideCharToMultiByte(CP_ACP, 0, CompString,
842 compstr->dwCompStrLen, buf,
843 compstr->dwCompStrLen * 3, NULL, NULL);
845 memcpy(lpBuf,buf,rc);
846 HeapFree( GetProcessHeap(), 0, buf );
848 else if (dwIndex == GCS_COMPATTR && compstr->dwCompAttrLen > 0 &&
849 compstr->dwCompAttrOffset > 0)
851 LPWSTR Compattr = (LPWSTR)(compdata + compstr->dwCompAttrOffset);
852 TRACE("GSC_COMPATTR %p %i\n", Compattr , compstr->dwCompAttrLen);
854 rc = compstr->dwCompAttrLen;
856 memcpy(lpBuf,Compattr,rc);
858 else if (dwIndex == GCS_COMPCLAUSE && compstr->dwCompClauseLen > 0 &&
859 compstr->dwCompClauseOffset > 0)
861 LPWSTR Compclause = (LPWSTR)(compdata + compstr->dwCompClauseOffset);
862 TRACE("GSC_COMPCLAUSE %p %i\n", Compclause, compstr->dwCompClauseLen);
864 rc = compstr->dwCompClauseLen;
865 if (dwBufLen >= compstr->dwCompClauseLen)
866 memcpy(lpBuf,Compclause,rc);
868 else if (dwIndex == GCS_RESULTCLAUSE && compstr->dwResultClauseLen > 0 &&
869 compstr->dwResultClauseOffset > 0)
871 LPWSTR Resultclause = (LPWSTR)(compdata + compstr->dwResultClauseOffset);
872 TRACE("GSC_RESULTCLAUSE %p %i\n", Resultclause, compstr->dwResultClauseLen);
874 rc = compstr->dwResultClauseLen;
875 if (dwBufLen >= compstr->dwResultClauseLen)
876 memcpy(lpBuf,Resultclause,rc);
878 else if (dwIndex == GCS_CURSORPOS)
880 TRACE("GSC_CURSORPOS\n");
881 rc = compstr->dwCursorPos;
883 else if (dwIndex == GCS_DELTASTART)
885 TRACE("GCS_DELTASTART\n");
886 rc = compstr->dwDeltaStart;
890 FIXME("Unhandled index 0x%x\n",dwIndex);
893 ImmUnlockIMCC(data->IMC.hCompStr);
898 /***********************************************************************
899 * ImmGetCompositionStringW (IMM32.@)
901 LONG WINAPI ImmGetCompositionStringW(
902 HIMC hIMC, DWORD dwIndex,
903 LPVOID lpBuf, DWORD dwBufLen)
906 InputContextData *data = (InputContextData*)hIMC;
907 LPCOMPOSITIONSTRING compstr;
910 TRACE("(%p, 0x%x, %p, %d)\n", hIMC, dwIndex, lpBuf, dwBufLen);
915 if (!data->IMC.hCompStr)
918 compdata = ImmLockIMCC(data->IMC.hCompStr);
919 compstr = (LPCOMPOSITIONSTRING)compdata;
921 if (dwIndex == GCS_RESULTSTR && compstr->dwResultStrLen > 0 &&
922 compstr->dwResultStrOffset > 0)
924 LPWSTR ResultStr = (LPWSTR)(compdata + compstr->dwResultStrOffset);
925 rc = compstr->dwResultStrLen * sizeof(WCHAR);
928 memcpy(lpBuf,ResultStr,rc);
930 else if (dwIndex == GCS_RESULTREADSTR && compstr->dwResultReadStrLen > 0 &&
931 compstr->dwResultReadStrOffset > 0)
933 LPWSTR ResultReadString = (LPWSTR)(compdata + compstr->dwResultReadStrOffset);
935 rc = compstr->dwResultReadStrLen * sizeof(WCHAR);
937 memcpy(lpBuf,ResultReadString,rc);
939 else if (dwIndex == GCS_COMPSTR && compstr->dwCompStrLen > 0 &&
940 compstr->dwCompStrOffset > 0)
942 LPWSTR CompString = (LPWSTR)(compdata + compstr->dwCompStrOffset);
943 rc = compstr->dwCompStrLen * sizeof(WCHAR);
945 memcpy(lpBuf,CompString,rc);
947 else if (dwIndex == GCS_COMPATTR && compstr->dwCompAttrLen > 0 &&
948 compstr->dwCompAttrOffset > 0)
951 LPWSTR Compattr = (LPWSTR)(compdata + compstr->dwCompAttrOffset);
953 rc = compstr->dwCompAttrLen;
955 memcpy(lpBuf,Compattr,rc);
957 else if (dwIndex == GCS_COMPCLAUSE && compstr->dwCompClauseLen > 0 &&
958 compstr->dwCompClauseOffset > 0)
960 LPWSTR Compclause = (LPWSTR)(compdata + compstr->dwCompClauseOffset);
962 rc = compstr->dwCompClauseLen;
963 if (dwBufLen >= compstr->dwCompClauseLen)
964 memcpy(lpBuf,Compclause,rc);
966 else if (dwIndex == GCS_COMPREADSTR && compstr->dwCompReadStrLen > 0 &&
967 compstr->dwCompReadStrOffset > 0)
969 LPWSTR CompReadString = (LPWSTR)(compdata + compstr->dwCompReadStrOffset);
971 rc = compstr->dwCompReadStrLen * sizeof(WCHAR);
974 memcpy(lpBuf,CompReadString,rc);
976 else if (dwIndex == GCS_CURSORPOS)
978 TRACE("GSC_CURSORPOS\n");
979 rc = compstr->dwCursorPos;
981 else if (dwIndex == GCS_DELTASTART)
983 TRACE("GCS_DELTASTART\n");
984 rc = compstr->dwDeltaStart;
988 FIXME("Unhandled index 0x%x\n",dwIndex);
991 ImmUnlockIMCC(data->IMC.hCompStr);
996 /***********************************************************************
997 * ImmGetCompositionWindow (IMM32.@)
999 BOOL WINAPI ImmGetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
1001 InputContextData *data = (InputContextData*)hIMC;
1003 TRACE("(%p, %p)\n", hIMC, lpCompForm);
1008 *lpCompForm = data->IMC.cfCompForm;
1012 /***********************************************************************
1013 * ImmGetContext (IMM32.@)
1016 HIMC WINAPI ImmGetContext(HWND hWnd)
1020 TRACE("%p\n", hWnd);
1021 if (!IMM_GetThreadData()->defaultContext)
1022 IMM_GetThreadData()->defaultContext = ImmCreateContext();
1024 rc = (HIMC)GetPropW(hWnd,szwWineIMCProperty);
1027 else if (rc == NULL)
1028 rc = IMM_GetThreadData()->defaultContext;
1032 InputContextData *data = (InputContextData*)rc;
1033 data->IMC.hWnd = hWnd;
1035 TRACE("returning %p\n", rc);
1040 /***********************************************************************
1041 * ImmGetConversionListA (IMM32.@)
1043 DWORD WINAPI ImmGetConversionListA(
1045 LPCSTR pSrc, LPCANDIDATELIST lpDst,
1046 DWORD dwBufLen, UINT uFlag)
1048 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
1049 TRACE("(%p, %p, %s, %p, %d, %d):\n", hKL, hIMC, debugstr_a(pSrc), lpDst,
1051 if (immHkl->hIME && immHkl->pImeConversionList)
1053 if (!is_kbd_ime_unicode(immHkl))
1054 return immHkl->pImeConversionList(hIMC,(LPCWSTR)pSrc,lpDst,dwBufLen,uFlag);
1057 FIXME("A procedure called with W ime back end\n");
1058 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1066 /***********************************************************************
1067 * ImmGetConversionListW (IMM32.@)
1069 DWORD WINAPI ImmGetConversionListW(
1071 LPCWSTR pSrc, LPCANDIDATELIST lpDst,
1072 DWORD dwBufLen, UINT uFlag)
1074 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
1075 TRACE("(%p, %p, %s, %p, %d, %d):\n", hKL, hIMC, debugstr_w(pSrc), lpDst,
1077 if (immHkl->hIME && immHkl->pImeConversionList)
1079 if (is_kbd_ime_unicode(immHkl))
1080 return immHkl->pImeConversionList(hIMC,pSrc,lpDst,dwBufLen,uFlag);
1083 FIXME("W procedure called with A ime back end\n");
1084 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1092 /***********************************************************************
1093 * ImmGetConversionStatus (IMM32.@)
1095 BOOL WINAPI ImmGetConversionStatus(
1096 HIMC hIMC, LPDWORD lpfdwConversion, LPDWORD lpfdwSentence)
1098 InputContextData *data = (InputContextData*)hIMC;
1100 TRACE("%p %p %p\n", hIMC, lpfdwConversion, lpfdwSentence);
1105 if (lpfdwConversion)
1106 *lpfdwConversion = data->IMC.fdwConversion;
1108 *lpfdwSentence = data->IMC.fdwSentence;
1113 /***********************************************************************
1114 * ImmGetDefaultIMEWnd (IMM32.@)
1116 HWND WINAPI ImmGetDefaultIMEWnd(HWND hWnd)
1118 TRACE("Default is %x\n",(unsigned)IMM_GetThreadData()->hwndDefault);
1119 return IMM_GetThreadData()->hwndDefault;
1122 /***********************************************************************
1123 * ImmGetDescriptionA (IMM32.@)
1125 UINT WINAPI ImmGetDescriptionA(
1126 HKL hKL, LPSTR lpszDescription, UINT uBufLen)
1131 TRACE("%p %p %d\n", hKL, lpszDescription, uBufLen);
1133 /* find out how many characters in the unicode buffer */
1134 len = ImmGetDescriptionW( hKL, NULL, 0 );
1136 /* allocate a buffer of that size */
1137 buf = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof (WCHAR) );
1141 /* fetch the unicode buffer */
1142 len = ImmGetDescriptionW( hKL, buf, len + 1 );
1144 /* convert it back to ASCII */
1145 len = WideCharToMultiByte( CP_ACP, 0, buf, len + 1,
1146 lpszDescription, uBufLen, NULL, NULL );
1148 HeapFree( GetProcessHeap(), 0, buf );
1153 /***********************************************************************
1154 * ImmGetDescriptionW (IMM32.@)
1156 UINT WINAPI ImmGetDescriptionW(HKL hKL, LPWSTR lpszDescription, UINT uBufLen)
1158 static const WCHAR name[] = { 'W','i','n','e',' ','X','I','M',0 };
1160 FIXME("(%p, %p, %d): semi stub\n", hKL, lpszDescription, uBufLen);
1162 if (!uBufLen) return lstrlenW( name );
1163 lstrcpynW( lpszDescription, name, uBufLen );
1164 return lstrlenW( lpszDescription );
1167 /***********************************************************************
1168 * ImmGetGuideLineA (IMM32.@)
1170 DWORD WINAPI ImmGetGuideLineA(
1171 HIMC hIMC, DWORD dwIndex, LPSTR lpBuf, DWORD dwBufLen)
1173 FIXME("(%p, %d, %s, %d): stub\n",
1174 hIMC, dwIndex, debugstr_a(lpBuf), dwBufLen
1176 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1180 /***********************************************************************
1181 * ImmGetGuideLineW (IMM32.@)
1183 DWORD WINAPI ImmGetGuideLineW(HIMC hIMC, DWORD dwIndex, LPWSTR lpBuf, DWORD dwBufLen)
1185 FIXME("(%p, %d, %s, %d): stub\n",
1186 hIMC, dwIndex, debugstr_w(lpBuf), dwBufLen
1188 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1192 /***********************************************************************
1193 * ImmGetIMEFileNameA (IMM32.@)
1195 UINT WINAPI ImmGetIMEFileNameA( HKL hKL, LPSTR lpszFileName, UINT uBufLen)
1198 UINT wBufLen = uBufLen;
1201 if (uBufLen && lpszFileName)
1202 bufW = HeapAlloc(GetProcessHeap(),0,uBufLen * sizeof(WCHAR));
1203 else /* We need this to get the number of byte required */
1205 bufW = HeapAlloc(GetProcessHeap(),0,MAX_PATH * sizeof(WCHAR));
1209 rc = ImmGetIMEFileNameW(hKL,bufW,wBufLen);
1213 if (uBufLen && lpszFileName)
1214 rc = WideCharToMultiByte(CP_ACP, 0, bufW, -1, lpszFileName,
1215 uBufLen, NULL, NULL);
1216 else /* get the length */
1217 rc = WideCharToMultiByte(CP_ACP, 0, bufW, -1, NULL, 0, NULL,
1221 HeapFree(GetProcessHeap(),0,bufW);
1225 /***********************************************************************
1226 * ImmGetIMEFileNameW (IMM32.@)
1228 UINT WINAPI ImmGetIMEFileNameW(HKL hKL, LPWSTR lpszFileName, UINT uBufLen)
1230 static const WCHAR szImeFileW[] = {'I','m','e',' ','F','i','l','e',0};
1231 static const WCHAR fmt[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s','\\','%','0','8','x',0};
1236 WCHAR regKey[sizeof(fmt)/sizeof(WCHAR)+8];
1238 wsprintfW( regKey, fmt, (unsigned)hKL );
1239 rc = RegOpenKeyW( HKEY_LOCAL_MACHINE, regKey, &hkey);
1240 if (rc != ERROR_SUCCESS)
1247 rc = RegGetValueW(hkey, NULL, szImeFileW, RRF_RT_REG_SZ, NULL, NULL, &length);
1249 if (rc != ERROR_SUCCESS)
1255 if (length > uBufLen * sizeof(WCHAR) || !lpszFileName)
1260 SetLastError(ERROR_INSUFFICIENT_BUFFER);
1264 return length / sizeof(WCHAR);
1267 RegGetValueW(hkey, NULL, szImeFileW, RRF_RT_REG_SZ, NULL, lpszFileName, &length);
1271 return length / sizeof(WCHAR);
1274 /***********************************************************************
1275 * ImmGetOpenStatus (IMM32.@)
1277 BOOL WINAPI ImmGetOpenStatus(HIMC hIMC)
1279 InputContextData *data = (InputContextData*)hIMC;
1283 FIXME("(%p): semi-stub\n", hIMC);
1285 return data->IMC.fOpen;
1288 /***********************************************************************
1289 * ImmGetProperty (IMM32.@)
1291 DWORD WINAPI ImmGetProperty(HKL hKL, DWORD fdwIndex)
1296 TRACE("(%p, %d)\n", hKL, fdwIndex);
1297 kbd = IMM_GetImmHkl(hKL);
1299 if (kbd && kbd->hIME)
1303 case IGP_PROPERTY: rc = kbd->imeInfo.fdwProperty; break;
1304 case IGP_CONVERSION: rc = kbd->imeInfo.fdwConversionCaps; break;
1305 case IGP_SENTENCE: rc = kbd->imeInfo.fdwSentenceCaps; break;
1306 case IGP_SETCOMPSTR: rc = kbd->imeInfo.fdwSCSCaps; break;
1307 case IGP_SELECT: rc = kbd->imeInfo.fdwSelectCaps; break;
1308 case IGP_GETIMEVERSION: rc = IMEVER_0400; break;
1309 case IGP_UI: rc = 0; break;
1316 /***********************************************************************
1317 * ImmGetRegisterWordStyleA (IMM32.@)
1319 UINT WINAPI ImmGetRegisterWordStyleA(
1320 HKL hKL, UINT nItem, LPSTYLEBUFA lpStyleBuf)
1322 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
1323 TRACE("(%p, %d, %p):\n", hKL, nItem, lpStyleBuf);
1324 if (immHkl->hIME && immHkl->pImeGetRegisterWordStyle)
1326 if (!is_kbd_ime_unicode(immHkl))
1327 return immHkl->pImeGetRegisterWordStyle(nItem,(LPSTYLEBUFW)lpStyleBuf);
1333 rc = immHkl->pImeGetRegisterWordStyle(nItem,&sbw);
1334 WideCharToMultiByte(CP_ACP, 0, sbw.szDescription, -1,
1335 lpStyleBuf->szDescription, 32, NULL, NULL);
1336 lpStyleBuf->dwStyle = sbw.dwStyle;
1344 /***********************************************************************
1345 * ImmGetRegisterWordStyleW (IMM32.@)
1347 UINT WINAPI ImmGetRegisterWordStyleW(
1348 HKL hKL, UINT nItem, LPSTYLEBUFW lpStyleBuf)
1350 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
1351 TRACE("(%p, %d, %p):\n", hKL, nItem, lpStyleBuf);
1352 if (immHkl->hIME && immHkl->pImeGetRegisterWordStyle)
1354 if (is_kbd_ime_unicode(immHkl))
1355 return immHkl->pImeGetRegisterWordStyle(nItem,lpStyleBuf);
1361 rc = immHkl->pImeGetRegisterWordStyle(nItem,(LPSTYLEBUFW)&sba);
1362 MultiByteToWideChar(CP_ACP, 0, sba.szDescription, -1,
1363 lpStyleBuf->szDescription, 32);
1364 lpStyleBuf->dwStyle = sba.dwStyle;
1372 /***********************************************************************
1373 * ImmGetStatusWindowPos (IMM32.@)
1375 BOOL WINAPI ImmGetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
1377 FIXME("(%p, %p): stub\n", hIMC, lpptPos);
1378 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1382 /***********************************************************************
1383 * ImmGetVirtualKey (IMM32.@)
1385 UINT WINAPI ImmGetVirtualKey(HWND hWnd)
1387 OSVERSIONINFOA version;
1388 InputContextData *data = (InputContextData *)ImmGetContext( hWnd );
1389 TRACE("%p\n", hWnd);
1392 return data->lastVK;
1394 GetVersionExA( &version );
1395 switch(version.dwPlatformId)
1397 case VER_PLATFORM_WIN32_WINDOWS:
1398 return VK_PROCESSKEY;
1399 case VER_PLATFORM_WIN32_NT:
1402 FIXME("%d not supported\n",version.dwPlatformId);
1403 return VK_PROCESSKEY;
1407 /***********************************************************************
1408 * ImmInstallIMEA (IMM32.@)
1410 HKL WINAPI ImmInstallIMEA(
1411 LPCSTR lpszIMEFileName, LPCSTR lpszLayoutText)
1413 FIXME("(%s, %s): stub\n",
1414 debugstr_a(lpszIMEFileName), debugstr_a(lpszLayoutText)
1416 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1420 /***********************************************************************
1421 * ImmInstallIMEW (IMM32.@)
1423 HKL WINAPI ImmInstallIMEW(
1424 LPCWSTR lpszIMEFileName, LPCWSTR lpszLayoutText)
1426 FIXME("(%s, %s): stub\n",
1427 debugstr_w(lpszIMEFileName), debugstr_w(lpszLayoutText)
1429 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1433 /***********************************************************************
1434 * ImmIsIME (IMM32.@)
1436 BOOL WINAPI ImmIsIME(HKL hKL)
1439 TRACE("(%p):\n", hKL);
1440 ptr = IMM_GetImmHkl(hKL);
1441 return (ptr && ptr->hIME);
1444 /***********************************************************************
1445 * ImmIsUIMessageA (IMM32.@)
1447 BOOL WINAPI ImmIsUIMessageA(
1448 HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
1452 TRACE("(%p, %x, %ld, %ld)\n", hWndIME, msg, wParam, lParam);
1453 if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
1454 (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP) ||
1455 (msg == WM_MSIME_SERVICE) ||
1456 (msg == WM_MSIME_RECONVERTOPTIONS) ||
1457 (msg == WM_MSIME_MOUSE) ||
1458 (msg == WM_MSIME_RECONVERTREQUEST) ||
1459 (msg == WM_MSIME_RECONVERT) ||
1460 (msg == WM_MSIME_QUERYPOSITION) ||
1461 (msg == WM_MSIME_DOCUMENTFEED))
1464 if (!IMM_GetThreadData()->hwndDefault)
1465 ImmGetDefaultIMEWnd(NULL);
1467 if (hWndIME == NULL)
1468 PostMessageA(IMM_GetThreadData()->hwndDefault, msg, wParam, lParam);
1475 /***********************************************************************
1476 * ImmIsUIMessageW (IMM32.@)
1478 BOOL WINAPI ImmIsUIMessageW(
1479 HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
1482 TRACE("(%p, %d, %ld, %ld):\n", hWndIME, msg, wParam, lParam);
1483 if ((msg >= WM_IME_STARTCOMPOSITION && msg <= WM_IME_KEYLAST) ||
1484 (msg >= WM_IME_SETCONTEXT && msg <= WM_IME_KEYUP) ||
1485 (msg == WM_MSIME_SERVICE) ||
1486 (msg == WM_MSIME_RECONVERTOPTIONS) ||
1487 (msg == WM_MSIME_MOUSE) ||
1488 (msg == WM_MSIME_RECONVERTREQUEST) ||
1489 (msg == WM_MSIME_RECONVERT) ||
1490 (msg == WM_MSIME_QUERYPOSITION) ||
1491 (msg == WM_MSIME_DOCUMENTFEED))
1496 /***********************************************************************
1497 * ImmNotifyIME (IMM32.@)
1499 BOOL WINAPI ImmNotifyIME(
1500 HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
1502 InputContextData *data = (InputContextData*)hIMC;
1504 TRACE("(%p, %d, %d, %d)\n",
1505 hIMC, dwAction, dwIndex, dwValue);
1507 if (!data || ! data->immKbd->pNotifyIME)
1510 return data->immKbd->pNotifyIME(hIMC,dwAction,dwIndex,dwValue);
1513 /***********************************************************************
1514 * ImmRegisterWordA (IMM32.@)
1516 BOOL WINAPI ImmRegisterWordA(
1517 HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszRegister)
1519 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
1520 TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_a(lpszReading), dwStyle,
1521 debugstr_a(lpszRegister));
1522 if (immHkl->hIME && immHkl->pImeRegisterWord)
1524 if (!is_kbd_ime_unicode(immHkl))
1525 return immHkl->pImeRegisterWord((LPCWSTR)lpszReading,dwStyle,
1526 (LPCWSTR)lpszRegister);
1529 LPWSTR lpszwReading = strdupAtoW(lpszReading);
1530 LPWSTR lpszwRegister = strdupAtoW(lpszRegister);
1533 rc = immHkl->pImeRegisterWord(lpszwReading,dwStyle,lpszwRegister);
1534 HeapFree(GetProcessHeap(),0,lpszwReading);
1535 HeapFree(GetProcessHeap(),0,lpszwRegister);
1543 /***********************************************************************
1544 * ImmRegisterWordW (IMM32.@)
1546 BOOL WINAPI ImmRegisterWordW(
1547 HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszRegister)
1549 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
1550 TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_w(lpszReading), dwStyle,
1551 debugstr_w(lpszRegister));
1552 if (immHkl->hIME && immHkl->pImeRegisterWord)
1554 if (is_kbd_ime_unicode(immHkl))
1555 return immHkl->pImeRegisterWord(lpszReading,dwStyle,lpszRegister);
1558 LPSTR lpszaReading = strdupWtoA(lpszReading);
1559 LPSTR lpszaRegister = strdupWtoA(lpszRegister);
1562 rc = immHkl->pImeRegisterWord((LPCWSTR)lpszaReading,dwStyle,
1563 (LPCWSTR)lpszaRegister);
1564 HeapFree(GetProcessHeap(),0,lpszaReading);
1565 HeapFree(GetProcessHeap(),0,lpszaRegister);
1573 /***********************************************************************
1574 * ImmReleaseContext (IMM32.@)
1576 BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
1578 static int shown = 0;
1581 FIXME("(%p, %p): stub\n", hWnd, hIMC);
1587 /***********************************************************************
1588 * ImmRequestMessageA(IMM32.@)
1590 LRESULT WINAPI ImmRequestMessageA(HIMC hIMC, WPARAM wParam, LPARAM lParam)
1592 FIXME("(%p %ld %ld): stub\n", hIMC, wParam, wParam);
1593 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1597 /***********************************************************************
1598 * ImmRequestMessageW(IMM32.@)
1600 LRESULT WINAPI ImmRequestMessageW(HIMC hIMC, WPARAM wParam, LPARAM lParam)
1602 FIXME("(%p %ld %ld): stub\n", hIMC, wParam, wParam);
1603 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1607 /***********************************************************************
1608 * ImmSetCandidateWindow (IMM32.@)
1610 BOOL WINAPI ImmSetCandidateWindow(
1611 HIMC hIMC, LPCANDIDATEFORM lpCandidate)
1613 FIXME("(%p, %p): stub\n", hIMC, lpCandidate);
1614 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1618 /***********************************************************************
1619 * ImmSetCompositionFontA (IMM32.@)
1621 BOOL WINAPI ImmSetCompositionFontA(HIMC hIMC, LPLOGFONTA lplf)
1623 InputContextData *data = (InputContextData*)hIMC;
1624 TRACE("(%p, %p)\n", hIMC, lplf);
1629 memcpy(&data->IMC.lfFont.W,lplf,sizeof(LOGFONTA));
1630 MultiByteToWideChar(CP_ACP, 0, lplf->lfFaceName, -1, data->IMC.lfFont.W.lfFaceName,
1632 ImmInternalSendIMENotify(data, IMN_SETCOMPOSITIONFONT, 0);
1637 /***********************************************************************
1638 * ImmSetCompositionFontW (IMM32.@)
1640 BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
1642 InputContextData *data = (InputContextData*)hIMC;
1643 TRACE("(%p, %p)\n", hIMC, lplf);
1648 data->IMC.lfFont.W = *lplf;
1649 ImmInternalSendIMENotify(data, IMN_SETCOMPOSITIONFONT, 0);
1654 /***********************************************************************
1655 * ImmSetCompositionStringA (IMM32.@)
1657 BOOL WINAPI ImmSetCompositionStringA(
1658 HIMC hIMC, DWORD dwIndex,
1659 LPCVOID lpComp, DWORD dwCompLen,
1660 LPCVOID lpRead, DWORD dwReadLen)
1664 WCHAR *CompBuffer = NULL;
1665 WCHAR *ReadBuffer = NULL;
1667 InputContextData *data = (InputContextData*)hIMC;
1669 TRACE("(%p, %d, %p, %d, %p, %d):\n",
1670 hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
1675 if (!is_himc_ime_unicode(data))
1676 return data->immKbd->pImeSetCompositionString(hIMC, dwIndex, lpComp,
1677 dwCompLen, lpRead, dwReadLen);
1679 comp_len = MultiByteToWideChar(CP_ACP, 0, lpComp, dwCompLen, NULL, 0);
1682 CompBuffer = HeapAlloc(GetProcessHeap(),0,comp_len * sizeof(WCHAR));
1683 MultiByteToWideChar(CP_ACP, 0, lpComp, dwCompLen, CompBuffer, comp_len);
1686 read_len = MultiByteToWideChar(CP_ACP, 0, lpRead, dwReadLen, NULL, 0);
1689 ReadBuffer = HeapAlloc(GetProcessHeap(),0,read_len * sizeof(WCHAR));
1690 MultiByteToWideChar(CP_ACP, 0, lpRead, dwReadLen, ReadBuffer, read_len);
1693 rc = ImmSetCompositionStringW(hIMC, dwIndex, CompBuffer, comp_len,
1694 ReadBuffer, read_len);
1696 HeapFree(GetProcessHeap(), 0, CompBuffer);
1697 HeapFree(GetProcessHeap(), 0, ReadBuffer);
1702 /***********************************************************************
1703 * ImmSetCompositionStringW (IMM32.@)
1705 BOOL WINAPI ImmSetCompositionStringW(
1706 HIMC hIMC, DWORD dwIndex,
1707 LPCVOID lpComp, DWORD dwCompLen,
1708 LPCVOID lpRead, DWORD dwReadLen)
1712 CHAR *CompBuffer = NULL;
1713 CHAR *ReadBuffer = NULL;
1715 InputContextData *data = (InputContextData*)hIMC;
1717 TRACE("(%p, %d, %p, %d, %p, %d):\n",
1718 hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen);
1723 if (is_himc_ime_unicode(data))
1724 return data->immKbd->pImeSetCompositionString(hIMC, dwIndex, lpComp,
1725 dwCompLen, lpRead, dwReadLen);
1727 comp_len = WideCharToMultiByte(CP_ACP, 0, lpComp, dwCompLen, NULL, 0, NULL,
1731 CompBuffer = HeapAlloc(GetProcessHeap(),0,comp_len);
1732 WideCharToMultiByte(CP_ACP, 0, lpComp, dwCompLen, CompBuffer, comp_len,
1736 read_len = WideCharToMultiByte(CP_ACP, 0, lpRead, dwReadLen, NULL, 0, NULL,
1740 ReadBuffer = HeapAlloc(GetProcessHeap(),0,read_len);
1741 WideCharToMultiByte(CP_ACP, 0, lpRead, dwReadLen, ReadBuffer, read_len,
1745 rc = ImmSetCompositionStringA(hIMC, dwIndex, CompBuffer, comp_len,
1746 ReadBuffer, read_len);
1748 HeapFree(GetProcessHeap(), 0, CompBuffer);
1749 HeapFree(GetProcessHeap(), 0, ReadBuffer);
1754 /***********************************************************************
1755 * ImmSetCompositionWindow (IMM32.@)
1757 BOOL WINAPI ImmSetCompositionWindow(
1758 HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
1760 BOOL reshow = FALSE;
1761 InputContextData *data = (InputContextData*)hIMC;
1763 TRACE("(%p, %p)\n", hIMC, lpCompForm);
1764 TRACE("\t%x, (%i,%i), (%i,%i - %i,%i)\n",lpCompForm->dwStyle,
1765 lpCompForm->ptCurrentPos.x, lpCompForm->ptCurrentPos.y, lpCompForm->rcArea.top,
1766 lpCompForm->rcArea.left, lpCompForm->rcArea.bottom, lpCompForm->rcArea.right);
1771 data->IMC.cfCompForm = *lpCompForm;
1773 if (IsWindowVisible(IMM_GetThreadData()->hwndDefault))
1776 ShowWindow(IMM_GetThreadData()->hwndDefault,SW_HIDE);
1779 /* FIXME: this is a partial stub */
1782 ShowWindow(IMM_GetThreadData()->hwndDefault,SW_SHOWNOACTIVATE);
1784 ImmInternalSendIMENotify(data, IMN_SETCOMPOSITIONWINDOW, 0);
1788 /***********************************************************************
1789 * ImmSetConversionStatus (IMM32.@)
1791 BOOL WINAPI ImmSetConversionStatus(
1792 HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
1794 DWORD oldConversion, oldSentence;
1795 InputContextData *data = (InputContextData*)hIMC;
1797 TRACE("%p %d %d\n", hIMC, fdwConversion, fdwSentence);
1802 if ( fdwConversion != data->IMC.fdwConversion )
1804 oldConversion = data->IMC.fdwConversion;
1805 data->IMC.fdwConversion = fdwConversion;
1806 ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, oldConversion, IMC_SETCONVERSIONMODE);
1807 ImmInternalSendIMENotify(data, IMN_SETCONVERSIONMODE, 0);
1809 if ( fdwSentence != data->IMC.fdwSentence )
1811 oldSentence = data->IMC.fdwSentence;
1812 data->IMC.fdwSentence = fdwSentence;
1813 ImmNotifyIME(hIMC, NI_CONTEXTUPDATED, oldSentence, IMC_SETSENTENCEMODE);
1814 ImmInternalSendIMENotify(data, IMN_SETSENTENCEMODE, 0);
1820 /***********************************************************************
1821 * ImmSetOpenStatus (IMM32.@)
1823 BOOL WINAPI ImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
1825 InputContextData *data = (InputContextData*)hIMC;
1827 TRACE("%p %d\n", hIMC, fOpen);
1832 if (data->imeWnd == NULL)
1834 /* create the ime window */
1835 data->imeWnd = CreateWindowExW( WS_EX_TOOLWINDOW,
1836 data->immKbd->imeClassName, NULL, WS_POPUP, 0, 0, 1, 1, 0,
1837 0, data->immKbd->hIME, 0);
1838 SetWindowLongW(data->imeWnd, IMMGWL_IMC, (LONG)data);
1839 IMM_GetThreadData()->hwndDefault = data->imeWnd;
1842 if (!fOpen != !data->IMC.fOpen)
1844 data->IMC.fOpen = fOpen;
1845 ImmNotifyIME( hIMC, NI_CONTEXTUPDATED, 0, IMC_SETOPENSTATUS);
1846 ImmInternalSendIMENotify(data, IMN_SETOPENSTATUS, 0);
1852 /***********************************************************************
1853 * ImmSetStatusWindowPos (IMM32.@)
1855 BOOL WINAPI ImmSetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
1857 FIXME("(%p, %p): stub\n", hIMC, lpptPos);
1858 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1862 /***********************************************************************
1863 * ImmCreateSoftKeyboard(IMM32.@)
1865 HWND WINAPI ImmCreateSoftKeyboard(UINT uType, UINT hOwner, int x, int y)
1867 FIXME("(%d, %d, %d, %d): stub\n", uType, hOwner, x, y);
1868 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1872 /***********************************************************************
1873 * ImmDestroySoftKeyboard(IMM32.@)
1875 BOOL WINAPI ImmDestroySoftKeyboard(HWND hSoftWnd)
1877 FIXME("(%p): stub\n", hSoftWnd);
1878 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1882 /***********************************************************************
1883 * ImmShowSoftKeyboard(IMM32.@)
1885 BOOL WINAPI ImmShowSoftKeyboard(HWND hSoftWnd, int nCmdShow)
1887 FIXME("(%p, %d): stub\n", hSoftWnd, nCmdShow);
1888 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1892 /***********************************************************************
1893 * ImmSimulateHotKey (IMM32.@)
1895 BOOL WINAPI ImmSimulateHotKey(HWND hWnd, DWORD dwHotKeyID)
1897 FIXME("(%p, %d): stub\n", hWnd, dwHotKeyID);
1898 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1902 /***********************************************************************
1903 * ImmUnregisterWordA (IMM32.@)
1905 BOOL WINAPI ImmUnregisterWordA(
1906 HKL hKL, LPCSTR lpszReading, DWORD dwStyle, LPCSTR lpszUnregister)
1908 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
1909 TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_a(lpszReading), dwStyle,
1910 debugstr_a(lpszUnregister));
1911 if (immHkl->hIME && immHkl->pImeUnregisterWord)
1913 if (!is_kbd_ime_unicode(immHkl))
1914 return immHkl->pImeUnregisterWord((LPCWSTR)lpszReading,dwStyle,
1915 (LPCWSTR)lpszUnregister);
1918 LPWSTR lpszwReading = strdupAtoW(lpszReading);
1919 LPWSTR lpszwUnregister = strdupAtoW(lpszUnregister);
1922 rc = immHkl->pImeUnregisterWord(lpszwReading,dwStyle,lpszwUnregister);
1923 HeapFree(GetProcessHeap(),0,lpszwReading);
1924 HeapFree(GetProcessHeap(),0,lpszwUnregister);
1932 /***********************************************************************
1933 * ImmUnregisterWordW (IMM32.@)
1935 BOOL WINAPI ImmUnregisterWordW(
1936 HKL hKL, LPCWSTR lpszReading, DWORD dwStyle, LPCWSTR lpszUnregister)
1938 ImmHkl *immHkl = IMM_GetImmHkl(hKL);
1939 TRACE("(%p, %s, %d, %s):\n", hKL, debugstr_w(lpszReading), dwStyle,
1940 debugstr_w(lpszUnregister));
1941 if (immHkl->hIME && immHkl->pImeUnregisterWord)
1943 if (is_kbd_ime_unicode(immHkl))
1944 return immHkl->pImeUnregisterWord(lpszReading,dwStyle,lpszUnregister);
1947 LPSTR lpszaReading = strdupWtoA(lpszReading);
1948 LPSTR lpszaUnregister = strdupWtoA(lpszUnregister);
1951 rc = immHkl->pImeUnregisterWord((LPCWSTR)lpszaReading,dwStyle,
1952 (LPCWSTR)lpszaUnregister);
1953 HeapFree(GetProcessHeap(),0,lpszaReading);
1954 HeapFree(GetProcessHeap(),0,lpszaUnregister);
1962 /***********************************************************************
1963 * ImmGetImeMenuItemsA (IMM32.@)
1965 DWORD WINAPI ImmGetImeMenuItemsA( HIMC hIMC, DWORD dwFlags, DWORD dwType,
1966 LPIMEMENUITEMINFOA lpImeParentMenu, LPIMEMENUITEMINFOA lpImeMenu,
1969 InputContextData *data = (InputContextData*)hIMC;
1970 TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType,
1971 lpImeParentMenu, lpImeMenu, dwSize);
1972 if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems)
1974 if (!is_himc_ime_unicode(data) || (!lpImeParentMenu && !lpImeMenu))
1975 return data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType,
1976 (IMEMENUITEMINFOW*)lpImeParentMenu,
1977 (IMEMENUITEMINFOW*)lpImeMenu, dwSize);
1980 IMEMENUITEMINFOW lpImeParentMenuW;
1981 IMEMENUITEMINFOW *lpImeMenuW, *parent = NULL;
1984 if (lpImeParentMenu)
1985 parent = &lpImeParentMenuW;
1988 int count = dwSize / sizeof(LPIMEMENUITEMINFOA);
1989 dwSize = count * sizeof(IMEMENUITEMINFOW);
1990 lpImeMenuW = HeapAlloc(GetProcessHeap(), 0, dwSize);
1995 rc = data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType,
1996 parent, lpImeMenuW, dwSize);
1998 if (lpImeParentMenu)
2000 memcpy(lpImeParentMenu,&lpImeParentMenuW,sizeof(IMEMENUITEMINFOA));
2001 lpImeParentMenu->hbmpItem = lpImeParentMenuW.hbmpItem;
2002 WideCharToMultiByte(CP_ACP, 0, lpImeParentMenuW.szString,
2003 -1, lpImeParentMenu->szString, IMEMENUITEM_STRING_SIZE,
2006 if (lpImeMenu && rc)
2009 for (i = 0; i < rc; i++)
2011 memcpy(&lpImeMenu[i],&lpImeMenuW[1],sizeof(IMEMENUITEMINFOA));
2012 lpImeMenu[i].hbmpItem = lpImeMenuW[i].hbmpItem;
2013 WideCharToMultiByte(CP_ACP, 0, lpImeMenuW[i].szString,
2014 -1, lpImeMenu[i].szString, IMEMENUITEM_STRING_SIZE,
2018 HeapFree(GetProcessHeap(),0,lpImeMenuW);
2026 /***********************************************************************
2027 * ImmGetImeMenuItemsW (IMM32.@)
2029 DWORD WINAPI ImmGetImeMenuItemsW( HIMC hIMC, DWORD dwFlags, DWORD dwType,
2030 LPIMEMENUITEMINFOW lpImeParentMenu, LPIMEMENUITEMINFOW lpImeMenu,
2033 InputContextData *data = (InputContextData*)hIMC;
2034 TRACE("(%p, %i, %i, %p, %p, %i):\n", hIMC, dwFlags, dwType,
2035 lpImeParentMenu, lpImeMenu, dwSize);
2036 if (data->immKbd->hIME && data->immKbd->pImeGetImeMenuItems)
2038 if (is_himc_ime_unicode(data) || (!lpImeParentMenu && !lpImeMenu))
2039 return data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType,
2040 lpImeParentMenu, lpImeMenu, dwSize);
2043 IMEMENUITEMINFOA lpImeParentMenuA;
2044 IMEMENUITEMINFOA *lpImeMenuA, *parent = NULL;
2047 if (lpImeParentMenu)
2048 parent = &lpImeParentMenuA;
2051 int count = dwSize / sizeof(LPIMEMENUITEMINFOW);
2052 dwSize = count * sizeof(IMEMENUITEMINFOA);
2053 lpImeMenuA = HeapAlloc(GetProcessHeap(), 0, dwSize);
2058 rc = data->immKbd->pImeGetImeMenuItems(hIMC, dwFlags, dwType,
2059 (IMEMENUITEMINFOW*)parent,
2060 (IMEMENUITEMINFOW*)lpImeMenuA, dwSize);
2062 if (lpImeParentMenu)
2064 memcpy(lpImeParentMenu,&lpImeParentMenuA,sizeof(IMEMENUITEMINFOA));
2065 lpImeParentMenu->hbmpItem = lpImeParentMenuA.hbmpItem;
2066 MultiByteToWideChar(CP_ACP, 0, lpImeParentMenuA.szString,
2067 -1, lpImeParentMenu->szString, IMEMENUITEM_STRING_SIZE);
2069 if (lpImeMenu && rc)
2072 for (i = 0; i < rc; i++)
2074 memcpy(&lpImeMenu[i],&lpImeMenuA[1],sizeof(IMEMENUITEMINFOA));
2075 lpImeMenu[i].hbmpItem = lpImeMenuA[i].hbmpItem;
2076 MultiByteToWideChar(CP_ACP, 0, lpImeMenuA[i].szString,
2077 -1, lpImeMenu[i].szString, IMEMENUITEM_STRING_SIZE);
2080 HeapFree(GetProcessHeap(),0,lpImeMenuA);
2088 /***********************************************************************
2089 * ImmLockIMC(IMM32.@)
2091 LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
2093 InputContextData *data = (InputContextData*)hIMC;
2101 /***********************************************************************
2102 * ImmUnlockIMC(IMM32.@)
2104 BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
2106 InputContextData *data = (InputContextData*)hIMC;
2108 return (data->dwLock!=0);
2111 /***********************************************************************
2112 * ImmGetIMCLockCount(IMM32.@)
2114 DWORD WINAPI ImmGetIMCLockCount(HIMC hIMC)
2116 InputContextData *data = (InputContextData*)hIMC;
2117 return data->dwLock;
2120 /***********************************************************************
2121 * ImmCreateIMCC(IMM32.@)
2123 HIMCC WINAPI ImmCreateIMCC(DWORD size)
2125 IMCCInternal *internal;
2126 int real_size = size + sizeof(IMCCInternal);
2128 internal = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, real_size);
2129 if (internal == NULL)
2132 internal->dwSize = size;
2133 return (HIMCC)internal;
2136 /***********************************************************************
2137 * ImmDestroyIMCC(IMM32.@)
2139 HIMCC WINAPI ImmDestroyIMCC(HIMCC block)
2141 HeapFree(GetProcessHeap(),0,block);
2145 /***********************************************************************
2146 * ImmLockIMCC(IMM32.@)
2148 LPVOID WINAPI ImmLockIMCC(HIMCC imcc)
2150 IMCCInternal *internal;
2151 internal = (IMCCInternal*) imcc;
2153 internal->dwLock ++;
2154 return internal + 1;
2157 /***********************************************************************
2158 * ImmUnlockIMCC(IMM32.@)
2160 BOOL WINAPI ImmUnlockIMCC(HIMCC imcc)
2162 IMCCInternal *internal;
2163 internal = (IMCCInternal*) imcc;
2165 internal->dwLock --;
2166 return (internal->dwLock!=0);
2169 /***********************************************************************
2170 * ImmGetIMCCLockCount(IMM32.@)
2172 DWORD WINAPI ImmGetIMCCLockCount(HIMCC imcc)
2174 IMCCInternal *internal;
2175 internal = (IMCCInternal*) imcc;
2177 return internal->dwLock;
2180 /***********************************************************************
2181 * ImmReSizeIMCC(IMM32.@)
2183 HIMCC WINAPI ImmReSizeIMCC(HIMCC imcc, DWORD size)
2185 IMCCInternal *internal,*newone;
2186 int real_size = size + sizeof(IMCCInternal);
2188 internal = (IMCCInternal*) imcc;
2190 newone = HeapReAlloc(GetProcessHeap(), 0, internal, real_size);
2191 newone->dwSize = size;
2196 /***********************************************************************
2197 * ImmGetIMCCSize(IMM32.@)
2199 DWORD WINAPI ImmGetIMCCSize(HIMCC imcc)
2201 IMCCInternal *internal;
2202 internal = (IMCCInternal*) imcc;
2204 return internal->dwSize;
2207 /***********************************************************************
2208 * ImmGenerateMessage(IMM32.@)
2210 BOOL WINAPI ImmGenerateMessage(HIMC hIMC)
2212 InputContextData *data = (InputContextData*)hIMC;
2214 TRACE("%i messages queued\n",data->IMC.dwNumMsgBuf);
2215 if (data->IMC.dwNumMsgBuf > 0)
2217 LPTRANSMSG lpTransMsg;
2220 lpTransMsg = (LPTRANSMSG)ImmLockIMCC(data->IMC.hMsgBuf);
2221 for (i = 0; i < data->IMC.dwNumMsgBuf; i++)
2222 ImmInternalPostIMEMessage(data, lpTransMsg[i].message, lpTransMsg[i].wParam, lpTransMsg[i].lParam);
2224 ImmUnlockIMCC(data->IMC.hMsgBuf);
2226 data->IMC.dwNumMsgBuf = 0;
2232 /***********************************************************************
2233 * ImmTranslateMessage(IMM32.@)
2234 * ( Undocumented, call internally and from user32.dll )
2236 BOOL WINAPI ImmTranslateMessage(HWND hwnd, UINT msg, WCHAR chr, LPARAM lKeyData)
2238 InputContextData *data;
2239 HIMC imc = ImmGetContext(hwnd);
2245 static const int list_count = 10;
2247 TRACE("%p %x %x %x\n",hwnd, msg, chr, (UINT)lKeyData);
2250 data = (InputContextData*)imc;
2254 if (!data->immKbd->hIME || !data->immKbd->pImeToAsciiEx)
2257 GetKeyboardState(state);
2258 scancode = lKeyData >> 0x10 & 0xff;
2260 list = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, list_count * sizeof(TRANSMSG) + sizeof(DWORD));
2261 ((DWORD*)list)[0] = list_count;
2263 if (data->immKbd->imeInfo.fdwProperty & IME_PROP_KBD_CHAR_FIRST)
2265 if (!is_himc_ime_unicode(data))
2266 ToAscii(data->lastVK, scancode, state, &chr, 0);
2268 ToUnicodeEx(data->lastVK, scancode, state, &chr, 1, 0, GetKeyboardLayout(0));
2269 uVirtKey = MAKELONG(data->lastVK,chr);
2272 uVirtKey = data->lastVK;
2274 msg_count = data->immKbd->pImeToAsciiEx(uVirtKey, scancode, state, list, 0, imc);
2275 TRACE("%i messages generated\n",msg_count);
2276 if (msg_count && msg_count <= list_count)
2279 LPTRANSMSG msgs = (LPTRANSMSG)((LPBYTE)list + sizeof(DWORD));
2281 for (i = 0; i < msg_count; i++)
2282 ImmInternalPostIMEMessage(data, msgs[i].message, msgs[i].wParam, msgs[i].lParam);
2284 else if (msg_count > list_count)
2285 ImmGenerateMessage(imc);
2287 HeapFree(GetProcessHeap(),0,list);
2289 data->lastVK = VK_PROCESSKEY;
2291 return (msg_count > 0);
2294 /***********************************************************************
2295 * ImmProcessKey(IMM32.@)
2296 * ( Undocumented, called from user32.dll )
2298 BOOL WINAPI ImmProcessKey(HWND hwnd, HKL hKL, UINT vKey, LPARAM lKeyData, DWORD unknown)
2300 InputContextData *data;
2301 HIMC imc = ImmGetContext(hwnd);
2304 TRACE("%p %p %x %x %x\n",hwnd, hKL, vKey, (UINT)lKeyData, unknown);
2307 data = (InputContextData*)imc;
2311 if (!data->immKbd->hIME || !data->immKbd->pImeProcessKey)
2314 GetKeyboardState(state);
2315 if (data->immKbd->pImeProcessKey(imc, vKey, lKeyData, state))
2317 data->lastVK = vKey;
2321 data->lastVK = VK_PROCESSKEY;