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(),0,sizeof(InputContextData
));
317 ZeroMemory(new_context
,sizeof(InputContextData
));
319 return (HIMC
)new_context
;
322 /***********************************************************************
323 * ImmDestroyContext (IMM32.@)
325 BOOL WINAPI
ImmDestroyContext(HIMC hIMC
)
327 InputContextData
*data
= (InputContextData
*)hIMC
;
329 TRACE("Destroying %p\n",hIMC
);
333 if (data
->dwCompStringSize
)
334 HeapFree(GetProcessHeap(),0,data
->CompositionString
);
335 if (data
->dwCompReadStringSize
)
336 HeapFree(GetProcessHeap(),0,data
->CompositionReadingString
);
337 if (data
->dwResultStringSize
)
338 HeapFree(GetProcessHeap(),0,data
->ResultString
);
339 if (data
->dwResultReadStringSize
)
340 HeapFree(GetProcessHeap(),0,data
->ResultReadingString
);
344 DeleteObject(data
->textfont
);
345 data
->textfont
= NULL
;
348 HeapFree(GetProcessHeap(),0,data
);
353 /***********************************************************************
354 * ImmDisableIME (IMM32.@)
356 BOOL WINAPI
ImmDisableIME(DWORD idThread
)
358 FIXME("(%d): stub\n", idThread
);
362 /***********************************************************************
363 * ImmEnumRegisterWordA (IMM32.@)
365 UINT WINAPI
ImmEnumRegisterWordA(
366 HKL hKL
, REGISTERWORDENUMPROCA lpfnEnumProc
,
367 LPCSTR lpszReading
, DWORD dwStyle
,
368 LPCSTR lpszRegister
, LPVOID lpData
)
370 FIXME("(%p, %p, %s, %d, %s, %p): stub\n",
372 debugstr_a(lpszReading
), dwStyle
,
373 debugstr_a(lpszRegister
), lpData
375 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
379 /***********************************************************************
380 * ImmEnumRegisterWordW (IMM32.@)
382 UINT WINAPI
ImmEnumRegisterWordW(
383 HKL hKL
, REGISTERWORDENUMPROCW lpfnEnumProc
,
384 LPCWSTR lpszReading
, DWORD dwStyle
,
385 LPCWSTR lpszRegister
, LPVOID lpData
)
387 FIXME("(%p, %p, %s, %d, %s, %p): stub\n",
389 debugstr_w(lpszReading
), dwStyle
,
390 debugstr_w(lpszRegister
), lpData
392 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
396 /***********************************************************************
397 * ImmEscapeA (IMM32.@)
399 LRESULT WINAPI
ImmEscapeA(
401 UINT uEscape
, LPVOID lpData
)
403 FIXME("(%p, %p, %d, %p): stub\n",
404 hKL
, hIMC
, uEscape
, lpData
406 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
410 /***********************************************************************
411 * ImmEscapeW (IMM32.@)
413 LRESULT WINAPI
ImmEscapeW(
415 UINT uEscape
, LPVOID lpData
)
417 FIXME("(%p, %p, %d, %p): stub\n",
418 hKL
, hIMC
, uEscape
, lpData
420 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
424 /***********************************************************************
425 * ImmGetCandidateListA (IMM32.@)
427 DWORD WINAPI
ImmGetCandidateListA(
428 HIMC hIMC
, DWORD deIndex
,
429 LPCANDIDATELIST lpCandList
, DWORD dwBufLen
)
431 FIXME("(%p, %d, %p, %d): stub\n",
435 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
439 /***********************************************************************
440 * ImmGetCandidateListCountA (IMM32.@)
442 DWORD WINAPI
ImmGetCandidateListCountA(
443 HIMC hIMC
, LPDWORD lpdwListCount
)
445 FIXME("(%p, %p): stub\n", hIMC
, lpdwListCount
);
446 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
450 /***********************************************************************
451 * ImmGetCandidateListCountW (IMM32.@)
453 DWORD WINAPI
ImmGetCandidateListCountW(
454 HIMC hIMC
, LPDWORD lpdwListCount
)
456 FIXME("(%p, %p): stub\n", hIMC
, lpdwListCount
);
457 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
461 /***********************************************************************
462 * ImmGetCandidateListW (IMM32.@)
464 DWORD WINAPI
ImmGetCandidateListW(
465 HIMC hIMC
, DWORD deIndex
,
466 LPCANDIDATELIST lpCandList
, DWORD dwBufLen
)
468 FIXME("(%p, %d, %p, %d): stub\n",
472 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
476 /***********************************************************************
477 * ImmGetCandidateWindow (IMM32.@)
479 BOOL WINAPI
ImmGetCandidateWindow(
480 HIMC hIMC
, DWORD dwBufLen
, LPCANDIDATEFORM lpCandidate
)
482 FIXME("(%p, %d, %p): stub\n", hIMC
, dwBufLen
, lpCandidate
);
483 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
487 /***********************************************************************
488 * ImmGetCompositionFontA (IMM32.@)
490 BOOL WINAPI
ImmGetCompositionFontA(HIMC hIMC
, LPLOGFONTA lplf
)
492 FIXME("(%p, %p): stub\n", hIMC
, lplf
);
493 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
497 /***********************************************************************
498 * ImmGetCompositionFontW (IMM32.@)
500 BOOL WINAPI
ImmGetCompositionFontW(HIMC hIMC
, LPLOGFONTW lplf
)
502 FIXME("(%p, %p): stub\n", hIMC
, lplf
);
503 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
507 /***********************************************************************
508 * ImmGetCompositionStringA (IMM32.@)
510 LONG WINAPI
ImmGetCompositionStringA(
511 HIMC hIMC
, DWORD dwIndex
, LPVOID lpBuf
, DWORD dwBufLen
)
515 InputContextData
*data
= (InputContextData
*)hIMC
;
517 TRACE("(%p, 0x%x, %p, %d)\n", hIMC
, dwIndex
, lpBuf
, dwBufLen
);
522 if (dwIndex
== GCS_RESULTSTR
)
524 TRACE("GSC_RESULTSTR %p %i\n",data
->ResultString
,
525 data
->dwResultStringSize
);
527 buf
= HeapAlloc( GetProcessHeap(), 0, data
->dwResultStringSize
* 3 );
528 rc
= WideCharToMultiByte(CP_ACP
, 0, (LPWSTR
)data
->ResultString
,
529 data
->dwResultStringSize
/ sizeof(WCHAR
), buf
,
530 data
->dwResultStringSize
* 3, NULL
, NULL
);
532 memcpy(lpBuf
,buf
,rc
);
535 HeapFree( GetProcessHeap(), 0, buf
);
537 else if (dwIndex
== GCS_COMPSTR
)
539 TRACE("GSC_COMPSTR %p %i\n", data
->CompositionString
, data
->dwCompStringLength
);
541 buf
= HeapAlloc( GetProcessHeap(), 0, data
->dwCompStringLength
* 3 );
542 rc
= WideCharToMultiByte(CP_ACP
, 0,(LPWSTR
)data
->CompositionString
,
543 data
->dwCompStringLength
/ sizeof(WCHAR
), buf
,
544 data
->dwCompStringLength
* 3, NULL
, NULL
);
546 memcpy(lpBuf
,buf
,rc
);
547 HeapFree( GetProcessHeap(), 0, buf
);
549 else if (dwIndex
== GCS_COMPATTR
)
551 TRACE("GSC_COMPATTR %p %i\n", data
->CompositionString
, data
->dwCompStringLength
);
553 rc
= WideCharToMultiByte(CP_ACP
, 0, (LPWSTR
)data
->CompositionString
,
554 data
->dwCompStringLength
/ sizeof(WCHAR
), NULL
,
560 for (i
= 0; i
< rc
; i
++)
561 ((LPBYTE
)lpBuf
)[i
] = ATTR_INPUT
;
564 else if (dwIndex
== GCS_COMPCLAUSE
)
566 TRACE("GSC_COMPCLAUSE %p %i\n", data
->CompositionString
, data
->dwCompStringLength
);
568 rc
= WideCharToMultiByte(CP_ACP
, 0, (LPWSTR
)data
->CompositionString
,
569 data
->dwCompStringLength
/ sizeof(WCHAR
), NULL
,
572 if (dwBufLen
>= sizeof(DWORD
)*2)
574 ((LPDWORD
)lpBuf
)[0] = 0;
575 ((LPDWORD
)lpBuf
)[1] = rc
;
577 rc
= sizeof(DWORD
)*2;
579 else if (dwIndex
== GCS_RESULTCLAUSE
)
581 TRACE("GSC_RESULTCLAUSE %p %i\n", data
->ResultString
, data
->dwResultStringSize
);
583 rc
= WideCharToMultiByte(CP_ACP
, 0, (LPWSTR
)data
->ResultString
,
584 data
->dwResultStringSize
/ sizeof(WCHAR
), NULL
,
587 if (dwBufLen
>= sizeof(DWORD
)*2)
589 ((LPDWORD
)lpBuf
)[0] = 0;
590 ((LPDWORD
)lpBuf
)[1] = rc
;
592 rc
= sizeof(DWORD
)*2;
596 FIXME("Unhandled index 0x%x\n",dwIndex
);
602 /***********************************************************************
603 * ImmGetCompositionStringW (IMM32.@)
605 LONG WINAPI
ImmGetCompositionStringW(
606 HIMC hIMC
, DWORD dwIndex
,
607 LPVOID lpBuf
, DWORD dwBufLen
)
610 InputContextData
*data
= (InputContextData
*)hIMC
;
612 TRACE("(%p, 0x%x, %p, %d)\n", hIMC
, dwIndex
, lpBuf
, dwBufLen
);
617 if (dwIndex
== GCS_RESULTSTR
)
621 if (dwBufLen
>= data
->dwResultStringSize
)
622 memcpy(lpBuf
,data
->ResultString
,data
->dwResultStringSize
);
624 rc
= data
->dwResultStringSize
;
626 else if (dwIndex
== GCS_RESULTREADSTR
)
628 if (dwBufLen
>= data
->dwResultReadStringSize
)
629 memcpy(lpBuf
,data
->ResultReadingString
,
630 data
->dwResultReadStringSize
);
632 rc
= data
->dwResultReadStringSize
;
634 else if (dwIndex
== GCS_COMPSTR
)
636 if (dwBufLen
>= data
->dwCompStringLength
)
637 memcpy(lpBuf
,data
->CompositionString
,data
->dwCompStringLength
);
639 rc
= data
->dwCompStringLength
;
641 else if (dwIndex
== GCS_COMPATTR
)
643 unsigned int len
= data
->dwCompStringLength
;
648 for (i
= 0; i
< len
; i
++)
649 ((LPBYTE
)lpBuf
)[i
] = ATTR_INPUT
;
654 else if (dwIndex
== GCS_COMPCLAUSE
)
656 if (dwBufLen
>= sizeof(DWORD
)*2)
658 ((LPDWORD
)lpBuf
)[0] = 0;
659 ((LPDWORD
)lpBuf
)[1] = data
->dwCompStringLength
/sizeof(WCHAR
);
661 rc
= sizeof(DWORD
)*2;
663 else if (dwIndex
== GCS_COMPREADSTR
)
665 if (dwBufLen
>= data
->dwCompReadStringSize
)
666 memcpy(lpBuf
,data
->CompositionReadingString
,
667 data
->dwCompReadStringSize
);
669 rc
= data
->dwCompReadStringSize
;
673 FIXME("Unhandled index 0x%x\n",dwIndex
);
679 /***********************************************************************
680 * ImmGetCompositionWindow (IMM32.@)
682 BOOL WINAPI
ImmGetCompositionWindow(HIMC hIMC
, LPCOMPOSITIONFORM lpCompForm
)
684 InputContextData
*data
= (InputContextData
*)hIMC
;
686 TRACE("(%p, %p)\n", hIMC
, lpCompForm
);
691 memcpy(lpCompForm
,&(data
->CompForm
),sizeof(COMPOSITIONFORM
));
695 /***********************************************************************
696 * ImmGetContext (IMM32.@)
699 HIMC WINAPI
ImmGetContext(HWND hWnd
)
706 root_context
->hwnd
= hWnd
;
707 return (HIMC
)root_context
;
710 /***********************************************************************
711 * ImmGetConversionListA (IMM32.@)
713 DWORD WINAPI
ImmGetConversionListA(
715 LPCSTR pSrc
, LPCANDIDATELIST lpDst
,
716 DWORD dwBufLen
, UINT uFlag
)
718 FIXME("(%p, %p, %s, %p, %d, %d): stub\n",
719 hKL
, hIMC
, debugstr_a(pSrc
), lpDst
, dwBufLen
, uFlag
721 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
725 /***********************************************************************
726 * ImmGetConversionListW (IMM32.@)
728 DWORD WINAPI
ImmGetConversionListW(
730 LPCWSTR pSrc
, LPCANDIDATELIST lpDst
,
731 DWORD dwBufLen
, UINT uFlag
)
733 FIXME("(%p, %p, %s, %p, %d, %d): stub\n",
734 hKL
, hIMC
, debugstr_w(pSrc
), lpDst
, dwBufLen
, uFlag
736 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
740 /***********************************************************************
741 * ImmGetConversionStatus (IMM32.@)
743 BOOL WINAPI
ImmGetConversionStatus(
744 HIMC hIMC
, LPDWORD lpfdwConversion
, LPDWORD lpfdwSentence
)
746 TRACE("(%p, %p, %p): best guess\n", hIMC
, lpfdwConversion
, lpfdwSentence
);
748 *lpfdwConversion
= IME_CMODE_NATIVE
;
750 *lpfdwSentence
= IME_SMODE_NONE
;
754 /***********************************************************************
755 * ImmGetDefaultIMEWnd (IMM32.@)
757 HWND WINAPI
ImmGetDefaultIMEWnd(HWND hWnd
)
759 FIXME("(%p - %p %p ): semi-stub\n", hWnd
,hwndDefault
, root_context
);
761 if (hwndDefault
== NULL
)
763 static const WCHAR the_name
[] = {'I','M','E','\0'};
766 hwndDefault
= CreateWindowExW( WS_EX_CLIENTEDGE
, WC_IMECLASSNAME
,
767 the_name
, WS_POPUPWINDOW
|WS_CAPTION
, 0, 0, 120, 55, 0, 0,
770 TRACE("Default created (%p)\n",hwndDefault
);
773 return (HWND
)hwndDefault
;
776 /***********************************************************************
777 * ImmGetDescriptionA (IMM32.@)
779 UINT WINAPI
ImmGetDescriptionA(
780 HKL hKL
, LPSTR lpszDescription
, UINT uBufLen
)
785 TRACE("%p %p %d\n", hKL
, lpszDescription
, uBufLen
);
787 /* find out how many characters in the unicode buffer */
788 len
= ImmGetDescriptionW( hKL
, NULL
, 0 );
790 /* allocate a buffer of that size */
791 buf
= HeapAlloc( GetProcessHeap(), 0, (len
+ 1) * sizeof (WCHAR
) );
795 /* fetch the unicode buffer */
796 len
= ImmGetDescriptionW( hKL
, buf
, len
+ 1 );
798 /* convert it back to ASCII */
799 len
= WideCharToMultiByte( CP_ACP
, 0, buf
, len
+ 1,
800 lpszDescription
, uBufLen
, NULL
, NULL
);
802 HeapFree( GetProcessHeap(), 0, buf
);
807 /***********************************************************************
808 * ImmGetDescriptionW (IMM32.@)
810 UINT WINAPI
ImmGetDescriptionW(HKL hKL
, LPWSTR lpszDescription
, UINT uBufLen
)
812 static const WCHAR name
[] = { 'W','i','n','e',' ','X','I','M',0 };
814 FIXME("(%p, %p, %d): semi stub\n", hKL
, lpszDescription
, uBufLen
);
816 if (!uBufLen
) return lstrlenW( name
);
817 lstrcpynW( lpszDescription
, name
, uBufLen
);
818 return lstrlenW( lpszDescription
);
821 /***********************************************************************
822 * ImmGetGuideLineA (IMM32.@)
824 DWORD WINAPI
ImmGetGuideLineA(
825 HIMC hIMC
, DWORD dwIndex
, LPSTR lpBuf
, DWORD dwBufLen
)
827 FIXME("(%p, %d, %s, %d): stub\n",
828 hIMC
, dwIndex
, debugstr_a(lpBuf
), dwBufLen
830 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
834 /***********************************************************************
835 * ImmGetGuideLineW (IMM32.@)
837 DWORD WINAPI
ImmGetGuideLineW(HIMC hIMC
, DWORD dwIndex
, LPWSTR lpBuf
, DWORD dwBufLen
)
839 FIXME("(%p, %d, %s, %d): stub\n",
840 hIMC
, dwIndex
, debugstr_w(lpBuf
), dwBufLen
842 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
846 /***********************************************************************
847 * ImmGetIMEFileNameA (IMM32.@)
849 UINT WINAPI
ImmGetIMEFileNameA(
850 HKL hKL
, LPSTR lpszFileName
, UINT uBufLen
)
852 FIXME("(%p, %p, %d): stub\n", hKL
, lpszFileName
, uBufLen
);
853 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
857 /***********************************************************************
858 * ImmGetIMEFileNameW (IMM32.@)
860 UINT WINAPI
ImmGetIMEFileNameW(
861 HKL hKL
, LPWSTR lpszFileName
, UINT uBufLen
)
863 FIXME("(%p, %p, %d): stub\n", hKL
, lpszFileName
, uBufLen
);
864 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
868 /***********************************************************************
869 * ImmGetOpenStatus (IMM32.@)
871 BOOL WINAPI
ImmGetOpenStatus(HIMC hIMC
)
873 InputContextData
*data
= (InputContextData
*)hIMC
;
877 FIXME("(%p): semi-stub\n", hIMC
);
882 /***********************************************************************
883 * ImmGetProperty (IMM32.@)
885 DWORD WINAPI
ImmGetProperty(HKL hKL
, DWORD fdwIndex
)
888 TRACE("(%p, %d)\n", hKL
, fdwIndex
);
893 TRACE("(%s)\n", "IGP_PROPERTY");
894 rc
= IME_PROP_UNICODE
| IME_PROP_AT_CARET
;
897 FIXME("(%s)\n", "IGP_CONVERSION");
898 rc
= IME_CMODE_NATIVE
;
901 FIXME("%s)\n", "IGP_SENTENCE");
902 rc
= IME_SMODE_AUTOMATIC
;
905 TRACE("(%s)\n", "IGP_SETCOMPSTR");
909 TRACE("(%s)\n", "IGP_SELECT");
910 rc
= SELECT_CAP_CONVERSION
| SELECT_CAP_SENTENCE
;
912 case IGP_GETIMEVERSION
:
913 TRACE("(%s)\n", "IGP_GETIMEVERSION");
917 TRACE("(%s)\n", "IGP_UI");
926 /***********************************************************************
927 * ImmGetRegisterWordStyleA (IMM32.@)
929 UINT WINAPI
ImmGetRegisterWordStyleA(
930 HKL hKL
, UINT nItem
, LPSTYLEBUFA lpStyleBuf
)
932 FIXME("(%p, %d, %p): stub\n", hKL
, nItem
, lpStyleBuf
);
933 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
937 /***********************************************************************
938 * ImmGetRegisterWordStyleW (IMM32.@)
940 UINT WINAPI
ImmGetRegisterWordStyleW(
941 HKL hKL
, UINT nItem
, LPSTYLEBUFW lpStyleBuf
)
943 FIXME("(%p, %d, %p): stub\n", hKL
, nItem
, lpStyleBuf
);
944 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
948 /***********************************************************************
949 * ImmGetStatusWindowPos (IMM32.@)
951 BOOL WINAPI
ImmGetStatusWindowPos(HIMC hIMC
, LPPOINT lpptPos
)
953 FIXME("(%p, %p): stub\n", hIMC
, lpptPos
);
954 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
958 /***********************************************************************
959 * ImmGetVirtualKey (IMM32.@)
961 UINT WINAPI
ImmGetVirtualKey(HWND hWnd
)
963 OSVERSIONINFOA version
;
964 FIXME("(%p): stub\n", hWnd
);
965 GetVersionExA( &version
);
966 switch(version
.dwPlatformId
)
968 case VER_PLATFORM_WIN32_WINDOWS
:
969 return VK_PROCESSKEY
;
970 case VER_PLATFORM_WIN32_NT
:
973 FIXME("%d not supported\n",version
.dwPlatformId
);
974 return VK_PROCESSKEY
;
978 /***********************************************************************
979 * ImmInstallIMEA (IMM32.@)
981 HKL WINAPI
ImmInstallIMEA(
982 LPCSTR lpszIMEFileName
, LPCSTR lpszLayoutText
)
984 FIXME("(%s, %s): stub\n",
985 debugstr_a(lpszIMEFileName
), debugstr_a(lpszLayoutText
)
987 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
991 /***********************************************************************
992 * ImmInstallIMEW (IMM32.@)
994 HKL WINAPI
ImmInstallIMEW(
995 LPCWSTR lpszIMEFileName
, LPCWSTR lpszLayoutText
)
997 FIXME("(%s, %s): stub\n",
998 debugstr_w(lpszIMEFileName
), debugstr_w(lpszLayoutText
)
1000 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1004 /***********************************************************************
1005 * ImmIsIME (IMM32.@)
1007 BOOL WINAPI
ImmIsIME(HKL hKL
)
1009 TRACE("(%p): semi-stub\n", hKL
);
1011 * FIXME: Dead key locales will return TRUE here when they should not
1012 * There is probably a more proper way to check this.
1014 return (root_context
!= NULL
);
1017 /***********************************************************************
1018 * ImmIsUIMessageA (IMM32.@)
1020 BOOL WINAPI
ImmIsUIMessageA(
1021 HWND hWndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1025 TRACE("(%p, %x, %d, %ld)\n", hWndIME
, msg
, wParam
, lParam
);
1026 if ((msg
>= WM_IME_STARTCOMPOSITION
&& msg
<= WM_IME_KEYLAST
) ||
1027 (msg
>= WM_IME_SETCONTEXT
&& msg
<= WM_IME_KEYUP
) ||
1028 (msg
== WM_MSIME_SERVICE
) ||
1029 (msg
== WM_MSIME_RECONVERTOPTIONS
) ||
1030 (msg
== WM_MSIME_MOUSE
) ||
1031 (msg
== WM_MSIME_RECONVERTREQUEST
) ||
1032 (msg
== WM_MSIME_RECONVERT
) ||
1033 (msg
== WM_MSIME_QUERYPOSITION
) ||
1034 (msg
== WM_MSIME_DOCUMENTFEED
))
1038 ImmGetDefaultIMEWnd(NULL
);
1040 if (hWndIME
== NULL
)
1041 PostMessageA(hwndDefault
, msg
, wParam
, lParam
);
1048 /***********************************************************************
1049 * ImmIsUIMessageW (IMM32.@)
1051 BOOL WINAPI
ImmIsUIMessageW(
1052 HWND hWndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1055 TRACE("(%p, %d, %d, %ld): stub\n", hWndIME
, msg
, wParam
, lParam
);
1056 if ((msg
>= WM_IME_STARTCOMPOSITION
&& msg
<= WM_IME_KEYLAST
) ||
1057 (msg
>= WM_IME_SETCONTEXT
&& msg
<= WM_IME_KEYUP
) ||
1058 (msg
== WM_MSIME_SERVICE
) ||
1059 (msg
== WM_MSIME_RECONVERTOPTIONS
) ||
1060 (msg
== WM_MSIME_MOUSE
) ||
1061 (msg
== WM_MSIME_RECONVERTREQUEST
) ||
1062 (msg
== WM_MSIME_RECONVERT
) ||
1063 (msg
== WM_MSIME_QUERYPOSITION
) ||
1064 (msg
== WM_MSIME_DOCUMENTFEED
))
1069 /***********************************************************************
1070 * ImmNotifyIME (IMM32.@)
1072 BOOL WINAPI
ImmNotifyIME(
1073 HIMC hIMC
, DWORD dwAction
, DWORD dwIndex
, DWORD dwValue
)
1077 TRACE("(%p, %d, %d, %d)\n",
1078 hIMC
, dwAction
, dwIndex
, dwValue
);
1085 case NI_CHANGECANDIDATELIST
:
1086 FIXME("%s\n","NI_CHANGECANDIDATELIST");
1088 case NI_CLOSECANDIDATE
:
1089 FIXME("%s\n","NI_CLOSECANDIDATE");
1091 case NI_COMPOSITIONSTR
:
1095 TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_CANCEL");
1096 if (pX11DRV_ForceXIMReset
)
1097 pX11DRV_ForceXIMReset(root_context
->hwnd
);
1098 if (root_context
->dwCompStringSize
)
1100 HeapFree(GetProcessHeap(),0,
1101 root_context
->CompositionString
);
1102 root_context
->dwCompStringSize
= 0;
1103 root_context
->dwCompStringLength
= 0;
1104 root_context
->CompositionString
= NULL
;
1105 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
, 0,
1111 TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_COMPLETE");
1112 if (hIMC
!= (HIMC
)FROM_IME
&& pX11DRV_ForceXIMReset
)
1113 pX11DRV_ForceXIMReset(root_context
->hwnd
);
1115 if (root_context
->dwResultStringSize
)
1117 HeapFree(GetProcessHeap(),0,root_context
->ResultString
);
1118 root_context
->dwResultStringSize
= 0;
1119 root_context
->ResultString
= NULL
;
1121 if (root_context
->dwCompStringLength
)
1123 root_context
->ResultString
= HeapAlloc(
1124 GetProcessHeap(), 0, root_context
->dwCompStringLength
);
1125 root_context
->dwResultStringSize
=
1126 root_context
->dwCompStringLength
;
1128 memcpy(root_context
->ResultString
,
1129 root_context
->CompositionString
,
1130 root_context
->dwCompStringLength
);
1132 HeapFree(GetProcessHeap(),0,
1133 root_context
->CompositionString
);
1135 root_context
->dwCompStringSize
= 0;
1136 root_context
->dwCompStringLength
= 0;
1137 root_context
->CompositionString
= NULL
;
1138 root_context
->bRead
= FALSE
;
1140 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
, 0,
1143 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
,
1144 root_context
->ResultString
[0],
1145 GCS_RESULTSTR
|GCS_RESULTCLAUSE
);
1147 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION
, 0, 0);
1148 root_context
->bInComposition
= FALSE
;
1152 FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_CONVERT");
1155 FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_REVERT");
1158 ERR("%s - %s (%i)\n","NI_COMPOSITIONSTR","UNKNOWN",dwIndex
);
1162 case NI_IMEMENUSELECTED
:
1163 FIXME("%s\n", "NI_IMEMENUSELECTED");
1165 case NI_OPENCANDIDATE
:
1166 FIXME("%s\n", "NI_OPENCANDIDATE");
1168 case NI_SELECTCANDIDATESTR
:
1169 FIXME("%s\n", "NI_SELECTCANDIDATESTR");
1171 case NI_SETCANDIDATE_PAGESIZE
:
1172 FIXME("%s\n", "NI_SETCANDIDATE_PAGESIZE");
1174 case NI_SETCANDIDATE_PAGESTART
:
1175 FIXME("%s\n", "NI_SETCANDIDATE_PAGESTART");
1184 /***********************************************************************
1185 * ImmRegisterWordA (IMM32.@)
1187 BOOL WINAPI
ImmRegisterWordA(
1188 HKL hKL
, LPCSTR lpszReading
, DWORD dwStyle
, LPCSTR lpszRegister
)
1190 FIXME("(%p, %s, %d, %s): stub\n",
1191 hKL
, debugstr_a(lpszReading
), dwStyle
, debugstr_a(lpszRegister
)
1193 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1197 /***********************************************************************
1198 * ImmRegisterWordW (IMM32.@)
1200 BOOL WINAPI
ImmRegisterWordW(
1201 HKL hKL
, LPCWSTR lpszReading
, DWORD dwStyle
, LPCWSTR lpszRegister
)
1203 FIXME("(%p, %s, %d, %s): stub\n",
1204 hKL
, debugstr_w(lpszReading
), dwStyle
, debugstr_w(lpszRegister
)
1206 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1210 /***********************************************************************
1211 * ImmReleaseContext (IMM32.@)
1213 BOOL WINAPI
ImmReleaseContext(HWND hWnd
, HIMC hIMC
)
1215 FIXME("(%p, %p): stub\n", hWnd
, hIMC
);
1220 /***********************************************************************
1221 * ImmSetCandidateWindow (IMM32.@)
1223 BOOL WINAPI
ImmSetCandidateWindow(
1224 HIMC hIMC
, LPCANDIDATEFORM lpCandidate
)
1226 FIXME("(%p, %p): stub\n", hIMC
, lpCandidate
);
1227 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1231 /***********************************************************************
1232 * ImmSetCompositionFontA (IMM32.@)
1234 BOOL WINAPI
ImmSetCompositionFontA(HIMC hIMC
, LPLOGFONTA lplf
)
1236 InputContextData
*data
= (InputContextData
*)hIMC
;
1237 TRACE("(%p, %p)\n", hIMC
, lplf
);
1242 memcpy(&data
->font
,lplf
,sizeof(LOGFONTA
));
1243 MultiByteToWideChar(CP_ACP
, 0, lplf
->lfFaceName
, -1, data
->font
.lfFaceName
,
1246 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONFONT
, 0);
1250 DeleteObject(data
->textfont
);
1251 data
->textfont
= NULL
;
1254 data
->textfont
= CreateFontIndirectW(&data
->font
);
1258 /***********************************************************************
1259 * ImmSetCompositionFontW (IMM32.@)
1261 BOOL WINAPI
ImmSetCompositionFontW(HIMC hIMC
, LPLOGFONTW lplf
)
1263 InputContextData
*data
= (InputContextData
*)hIMC
;
1264 TRACE("(%p, %p)\n", hIMC
, lplf
);
1269 memcpy(&data
->font
,lplf
,sizeof(LOGFONTW
));
1270 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONFONT
, 0);
1274 DeleteObject(data
->textfont
);
1275 data
->textfont
= NULL
;
1277 data
->textfont
= CreateFontIndirectW(&data
->font
);
1281 /***********************************************************************
1282 * ImmSetCompositionStringA (IMM32.@)
1284 BOOL WINAPI
ImmSetCompositionStringA(
1285 HIMC hIMC
, DWORD dwIndex
,
1286 LPCVOID lpComp
, DWORD dwCompLen
,
1287 LPCVOID lpRead
, DWORD dwReadLen
)
1291 WCHAR
*CompBuffer
= NULL
;
1292 WCHAR
*ReadBuffer
= NULL
;
1295 TRACE("(%p, %d, %p, %d, %p, %d): stub\n",
1296 hIMC
, dwIndex
, lpComp
, dwCompLen
, lpRead
, dwReadLen
);
1298 comp_len
= MultiByteToWideChar(CP_ACP
, 0, lpComp
, dwCompLen
, NULL
, 0);
1301 CompBuffer
= HeapAlloc(GetProcessHeap(),0,comp_len
* sizeof(WCHAR
));
1302 MultiByteToWideChar(CP_ACP
, 0, lpComp
, dwCompLen
, CompBuffer
, comp_len
);
1305 read_len
= MultiByteToWideChar(CP_ACP
, 0, lpRead
, dwReadLen
, NULL
, 0);
1308 ReadBuffer
= HeapAlloc(GetProcessHeap(),0,read_len
* sizeof(WCHAR
));
1309 MultiByteToWideChar(CP_ACP
, 0, lpRead
, dwReadLen
, ReadBuffer
, read_len
);
1312 rc
= ImmSetCompositionStringW(hIMC
, dwIndex
, CompBuffer
, comp_len
,
1313 ReadBuffer
, read_len
);
1315 HeapFree(GetProcessHeap(), 0, CompBuffer
);
1316 HeapFree(GetProcessHeap(), 0, ReadBuffer
);
1321 /***********************************************************************
1322 * ImmSetCompositionStringW (IMM32.@)
1324 BOOL WINAPI
ImmSetCompositionStringW(
1325 HIMC hIMC
, DWORD dwIndex
,
1326 LPCVOID lpComp
, DWORD dwCompLen
,
1327 LPCVOID lpRead
, DWORD dwReadLen
)
1332 TRACE("(%p, %d, %p, %d, %p, %d): stub\n",
1333 hIMC
, dwIndex
, lpComp
, dwCompLen
, lpRead
, dwReadLen
);
1336 if (hIMC
!= (HIMC
)FROM_IME
)
1337 FIXME("PROBLEM: This only sets the wine level string\n");
1341 * this sets the composition string in the imm32.dll level
1342 * of the composition buffer. we cannot manipulate the xim level
1343 * buffer, which means that once the xim level buffer changes again
1344 * any call to this function from the application will be lost
1347 if (lpRead
&& dwReadLen
)
1348 FIXME("Reading string unimplemented\n");
1351 * app operating this api to also receive the message from xim
1354 if (dwIndex
== SCS_SETSTR
)
1356 if (!root_context
->bInComposition
)
1358 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION
, 0, 0);
1359 root_context
->bInComposition
= TRUE
;
1362 flags
= GCS_COMPSTR
;
1364 if (root_context
->dwCompStringLength
)
1365 HeapFree(GetProcessHeap(),0,root_context
->CompositionString
);
1367 root_context
->dwCompStringLength
= dwCompLen
;
1368 root_context
->dwCompStringSize
= dwCompLen
;
1370 if (dwCompLen
&& lpComp
)
1372 root_context
->CompositionString
= HeapAlloc(GetProcessHeap(), 0,
1374 memcpy(root_context
->CompositionString
,lpComp
,dwCompLen
);
1376 wParam
= ((const WCHAR
*)lpComp
)[0];
1377 flags
|= GCS_COMPCLAUSE
| GCS_COMPATTR
;
1380 root_context
->CompositionString
= NULL
;
1384 UpdateDataInDefaultIMEWindow(hwndDefault
);
1386 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
, wParam
, flags
);
1391 /***********************************************************************
1392 * ImmSetCompositionWindow (IMM32.@)
1394 BOOL WINAPI
ImmSetCompositionWindow(
1395 HIMC hIMC
, LPCOMPOSITIONFORM lpCompForm
)
1397 BOOL reshow
= FALSE
;
1398 InputContextData
*data
= (InputContextData
*)hIMC
;
1400 TRACE("(%p, %p)\n", hIMC
, lpCompForm
);
1401 TRACE("\t%x, (%i,%i), (%i,%i - %i,%i)\n",lpCompForm
->dwStyle
,
1402 lpCompForm
->ptCurrentPos
.x
, lpCompForm
->ptCurrentPos
.y
, lpCompForm
->rcArea
.top
,
1403 lpCompForm
->rcArea
.left
, lpCompForm
->rcArea
.bottom
, lpCompForm
->rcArea
.right
);
1408 memcpy(&data
->CompForm
,lpCompForm
,sizeof(COMPOSITIONFORM
));
1410 if (IsWindowVisible(hwndDefault
))
1413 ShowWindow(hwndDefault
,SW_HIDE
);
1416 /* FIXME: this is a partial stub */
1419 ShowWindow(hwndDefault
,SW_SHOWNOACTIVATE
);
1421 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONWINDOW
, 0);
1425 /***********************************************************************
1426 * ImmSetConversionStatus (IMM32.@)
1428 BOOL WINAPI
ImmSetConversionStatus(
1429 HIMC hIMC
, DWORD fdwConversion
, DWORD fdwSentence
)
1431 FIXME("(%p, %d, %d): stub\n",
1432 hIMC
, fdwConversion
, fdwSentence
1434 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1438 /***********************************************************************
1439 * ImmSetOpenStatus (IMM32.@)
1441 BOOL WINAPI
ImmSetOpenStatus(HIMC hIMC
, BOOL fOpen
)
1443 InputContextData
*data
= (InputContextData
*)hIMC
;
1445 TRACE("%p %d\n", hIMC
, fOpen
);
1447 if (hIMC
== (HIMC
)FROM_IME
)
1449 ImmInternalSetOpenStatus(fOpen
);
1450 ImmInternalSendIMENotify(IMN_SETOPENSTATUS
, 0);
1457 if (fOpen
!= data
->bInternalState
)
1459 if (fOpen
== FALSE
&& pX11DRV_ForceXIMReset
)
1460 pX11DRV_ForceXIMReset(data
->hwnd
);
1463 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION
,0,0);
1465 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION
,0,0);
1467 ImmInternalSetOpenStatus(fOpen
);
1468 ImmInternalSetOpenStatus(!fOpen
);
1470 if (data
->bOpen
== FALSE
)
1471 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION
,0,0);
1473 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION
,0,0);
1480 /***********************************************************************
1481 * ImmSetStatusWindowPos (IMM32.@)
1483 BOOL WINAPI
ImmSetStatusWindowPos(HIMC hIMC
, LPPOINT lpptPos
)
1485 FIXME("(%p, %p): stub\n", hIMC
, lpptPos
);
1486 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1490 /***********************************************************************
1491 * ImmSimulateHotKey (IMM32.@)
1493 BOOL WINAPI
ImmSimulateHotKey(HWND hWnd
, DWORD dwHotKeyID
)
1495 FIXME("(%p, %d): stub\n", hWnd
, dwHotKeyID
);
1496 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1500 /***********************************************************************
1501 * ImmUnregisterWordA (IMM32.@)
1503 BOOL WINAPI
ImmUnregisterWordA(
1504 HKL hKL
, LPCSTR lpszReading
, DWORD dwStyle
, LPCSTR lpszUnregister
)
1506 FIXME("(%p, %s, %d, %s): stub\n",
1507 hKL
, debugstr_a(lpszReading
), dwStyle
, debugstr_a(lpszUnregister
)
1509 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1513 /***********************************************************************
1514 * ImmUnregisterWordW (IMM32.@)
1516 BOOL WINAPI
ImmUnregisterWordW(
1517 HKL hKL
, LPCWSTR lpszReading
, DWORD dwStyle
, LPCWSTR lpszUnregister
)
1519 FIXME("(%p, %s, %d, %s): stub\n",
1520 hKL
, debugstr_w(lpszReading
), dwStyle
, debugstr_w(lpszUnregister
)
1522 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1526 /***********************************************************************
1527 * ImmGetImeMenuItemsA (IMM32.@)
1529 DWORD WINAPI
ImmGetImeMenuItemsA( HIMC hIMC
, DWORD dwFlags
, DWORD dwType
,
1530 LPIMEMENUITEMINFOA lpImeParentMenu
, LPIMEMENUITEMINFOA lpImeMenu
,
1533 FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC
, dwFlags
, dwType
,
1534 lpImeParentMenu
, lpImeMenu
, dwSize
);
1538 /***********************************************************************
1539 * ImmGetImeMenuItemsW (IMM32.@)
1541 DWORD WINAPI
ImmGetImeMenuItemsW( HIMC hIMC
, DWORD dwFlags
, DWORD dwType
,
1542 LPIMEMENUITEMINFOW lpImeParentMenu
, LPIMEMENUITEMINFOW lpImeMenu
,
1545 FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC
, dwFlags
, dwType
,
1546 lpImeParentMenu
, lpImeMenu
, dwSize
);
1551 * Internal functions to help with IME window management
1553 static void PaintDefaultIMEWnd(HWND hwnd
)
1557 HDC hdc
= BeginPaint(hwnd
,&ps
);
1558 GetClientRect(hwnd
,&rect
);
1560 if (root_context
->dwCompStringLength
&& root_context
->CompositionString
)
1564 HFONT oldfont
= NULL
;
1566 if (root_context
->textfont
)
1567 oldfont
= SelectObject(hdc
,root_context
->textfont
);
1569 TextOutW(hdc
, 0,0,(LPWSTR
)root_context
->CompositionString
,
1570 root_context
->dwCompStringLength
/ sizeof(WCHAR
));
1572 GetTextExtentPoint32W(hdc
, (LPWSTR
)root_context
->CompositionString
,
1573 root_context
->dwCompStringLength
/ sizeof(WCHAR
),
1581 SelectObject(hdc
,oldfont
);
1583 FillRect(hdc
,&rect
, (HBRUSH
) (COLOR_WINDOW
+1));
1587 static void UpdateDataInDefaultIMEWindow(HWND hwnd
)
1589 RedrawWindow(hwnd
,NULL
,NULL
,RDW_ERASENOW
|RDW_INVALIDATE
);
1593 * The window proc for the default IME window
1595 static LRESULT WINAPI
IME_WindowProc(HWND hwnd
, UINT msg
, WPARAM wParam
,
1600 TRACE("Incoming Message 0x%x (0x%08x, 0x%08x)\n", msg
, (UINT
)wParam
,
1606 PaintDefaultIMEWnd(hwnd
);
1613 SetWindowTextA(hwnd
,"Wine Ime Active");
1618 SetFocus((HWND
)wParam
);
1620 FIXME("Received focus, should never have focus\n");
1622 case WM_IME_COMPOSITION
:
1623 TRACE("IME message %s, 0x%x, 0x%x (%i)\n",
1624 "WM_IME_COMPOSITION", (UINT
)wParam
, (UINT
)lParam
,
1625 root_context
->bRead
);
1626 if (lParam
& GCS_RESULTSTR
)
1627 IMM_PostResult(root_context
);
1629 UpdateDataInDefaultIMEWindow(hwnd
);
1631 case WM_IME_STARTCOMPOSITION
:
1632 TRACE("IME message %s, 0x%x, 0x%x\n",
1633 "WM_IME_STARTCOMPOSITION", (UINT
)wParam
, (UINT
)lParam
);
1634 root_context
->hwnd
= GetFocus();
1635 ShowWindow(hwndDefault
,SW_SHOWNOACTIVATE
);
1637 case WM_IME_ENDCOMPOSITION
:
1638 TRACE("IME message %s, 0x%x, 0x%x\n",
1639 "WM_IME_ENDCOMPOSITION", (UINT
)wParam
, (UINT
)lParam
);
1640 ShowWindow(hwndDefault
,SW_HIDE
);
1643 TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_SELECT",
1644 (UINT
)wParam
, (UINT
)lParam
);
1646 case WM_IME_CONTROL
:
1647 TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_CONTROL",
1648 (UINT
)wParam
, (UINT
)lParam
);
1652 TRACE("!! IME NOTIFY\n");
1655 TRACE("Non-standard message 0x%x\n",msg
);
1657 /* check the MSIME messages */
1658 if (msg
== WM_MSIME_SERVICE
)
1660 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_SERVICE",
1661 (UINT
)wParam
, (UINT
)lParam
);
1664 else if (msg
== WM_MSIME_RECONVERTOPTIONS
)
1666 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTOPTIONS",
1667 (UINT
)wParam
, (UINT
)lParam
);
1669 else if (msg
== WM_MSIME_MOUSE
)
1671 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_MOUSE",
1672 (UINT
)wParam
, (UINT
)lParam
);
1674 else if (msg
== WM_MSIME_RECONVERTREQUEST
)
1676 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTREQUEST",
1677 (UINT
)wParam
, (UINT
)lParam
);
1679 else if (msg
== WM_MSIME_RECONVERT
)
1681 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERT",
1682 (UINT
)wParam
, (UINT
)lParam
);
1684 else if (msg
== WM_MSIME_QUERYPOSITION
)
1686 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_QUERYPOSITION",
1687 (UINT
)wParam
, (UINT
)lParam
);
1689 else if (msg
== WM_MSIME_DOCUMENTFEED
)
1691 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_DOCUMENTFEED",
1692 (UINT
)wParam
, (UINT
)lParam
);
1694 /* DefWndProc if not an IME message */
1695 else if (!rc
&& !((msg
>= WM_IME_STARTCOMPOSITION
&& msg
<= WM_IME_KEYLAST
) ||
1696 (msg
>= WM_IME_SETCONTEXT
&& msg
<= WM_IME_KEYUP
)))
1697 rc
= DefWindowProcW(hwnd
,msg
,wParam
,lParam
);