4 * Copyright 1998 Patrik Stridvall
5 * Copyright 2002, 2003 CodeWeavers, Aric Stewart
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(imm
);
35 #define FROM_IME 0xcafe1337
37 static void (*pX11DRV_ForceXIMReset
)(HWND
);
39 typedef struct tagInputContextData
41 LPBYTE CompositionString
;
42 LPBYTE CompositionReadingString
;
44 LPBYTE ResultReadingString
;
45 DWORD dwCompStringSize
; /* buffer size */
46 DWORD dwCompStringLength
; /* string length (in bytes) */
47 DWORD dwCompReadStringSize
;
48 DWORD dwResultStringSize
;
49 DWORD dwResultReadStringSize
;
57 COMPOSITIONFORM CompForm
;
60 static InputContextData
*root_context
= NULL
;
61 static HWND hwndDefault
= NULL
;
62 static HANDLE hImeInst
;
63 static const WCHAR WC_IMECLASSNAME
[] = {'I','M','E',0};
64 static ATOM atIMEClass
= 0;
67 static UINT WM_MSIME_SERVICE
;
68 static UINT WM_MSIME_RECONVERTOPTIONS
;
69 static UINT WM_MSIME_MOUSE
;
70 static UINT WM_MSIME_RECONVERTREQUEST
;
71 static UINT WM_MSIME_RECONVERT
;
72 static UINT WM_MSIME_QUERYPOSITION
;
73 static UINT WM_MSIME_DOCUMENTFEED
;
78 static LRESULT WINAPI
IME_WindowProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
,
80 static void UpdateDataInDefaultIMEWindow(HWND hwnd
);
81 static void ImmInternalPostIMEMessage(UINT
, WPARAM
, LPARAM
);
82 static void ImmInternalSetOpenStatus(BOOL fOpen
);
84 static VOID
IMM_PostResult(InputContextData
*data
)
87 TRACE("Posting result as IME_CHAR\n");
89 for (i
= 0; i
< data
->dwResultStringSize
/ sizeof (WCHAR
); i
++)
90 ImmInternalPostIMEMessage (WM_IME_CHAR
, ((WCHAR
*)data
->ResultString
)[i
],
93 /* clear the buffer */
94 if (data
->dwResultStringSize
)
95 HeapFree(GetProcessHeap(),0,data
->ResultString
);
96 data
->dwResultStringSize
= 0;
97 data
->ResultString
= NULL
;
100 static void IMM_Register(void)
103 ZeroMemory(&wndClass
, sizeof(WNDCLASSW
));
104 wndClass
.style
= CS_GLOBALCLASS
| CS_IME
| CS_HREDRAW
| CS_VREDRAW
;
105 wndClass
.lpfnWndProc
= (WNDPROC
) IME_WindowProc
;
106 wndClass
.cbClsExtra
= 0;
107 wndClass
.cbWndExtra
= 0;
108 wndClass
.hInstance
= hImeInst
;
109 wndClass
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
110 wndClass
.hIcon
= NULL
;
111 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
112 wndClass
.lpszMenuName
= 0;
113 wndClass
.lpszClassName
= WC_IMECLASSNAME
;
114 atIMEClass
= RegisterClassW(&wndClass
);
117 static void IMM_Unregister(void)
120 UnregisterClassW(WC_IMECLASSNAME
, NULL
);
124 static void IMM_RegisterMessages(void)
126 WM_MSIME_SERVICE
= RegisterWindowMessageA("MSIMEService");
127 WM_MSIME_RECONVERTOPTIONS
= RegisterWindowMessageA("MSIMEReconvertOptions");
128 WM_MSIME_MOUSE
= RegisterWindowMessageA("MSIMEMouseOperation");
129 WM_MSIME_RECONVERTREQUEST
= RegisterWindowMessageA("MSIMEReconvertRequest");
130 WM_MSIME_RECONVERT
= RegisterWindowMessageA("MSIMEReconvert");
131 WM_MSIME_QUERYPOSITION
= RegisterWindowMessageA("MSIMEQueryPosition");
132 WM_MSIME_DOCUMENTFEED
= RegisterWindowMessageA("MSIMEDocumentFeed");
136 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpReserved
)
140 TRACE("%p, %x, %p\n",hInstDLL
,fdwReason
,lpReserved
);
143 case DLL_PROCESS_ATTACH
:
144 DisableThreadLibraryCalls(hInstDLL
);
146 IMM_RegisterMessages();
147 x11drv
= GetModuleHandleA("winex11.drv");
148 if (x11drv
) pX11DRV_ForceXIMReset
= (void *)GetProcAddress( x11drv
, "ForceXIMReset");
150 case DLL_PROCESS_DETACH
:
153 DestroyWindow(hwndDefault
);
162 /* for posting messages as the IME */
163 static void ImmInternalPostIMEMessage(UINT msg
, WPARAM wParam
, LPARAM lParam
)
165 HWND target
= GetFocus();
167 PostMessageW(root_context
->hwnd
,msg
,wParam
,lParam
);
169 PostMessageW(target
, msg
, wParam
, lParam
);
172 static LRESULT
ImmInternalSendIMENotify(WPARAM notify
, LPARAM lParam
)
176 target
= root_context
->hwnd
;
177 if (!target
) target
= GetFocus();
180 return SendMessageW(target
, WM_IME_NOTIFY
, notify
, lParam
);
185 static void ImmInternalSetOpenStatus(BOOL fOpen
)
187 TRACE("Setting internal state to %s\n",(fOpen
)?"OPEN":"CLOSED");
189 root_context
->bOpen
= fOpen
;
190 root_context
->bInternalState
= fOpen
;
194 ShowWindow(hwndDefault
,SW_HIDE
);
196 if (root_context
->dwCompStringSize
)
197 HeapFree(GetProcessHeap(),0,root_context
->CompositionString
);
198 if (root_context
->dwCompReadStringSize
)
199 HeapFree(GetProcessHeap(),0,root_context
->CompositionReadingString
);
200 if (root_context
->dwResultStringSize
)
201 HeapFree(GetProcessHeap(),0,root_context
->ResultString
);
202 if (root_context
->dwResultReadStringSize
)
203 HeapFree(GetProcessHeap(),0,root_context
->ResultReadingString
);
204 root_context
->dwCompStringSize
= 0;
205 root_context
->dwCompStringLength
= 0;
206 root_context
->CompositionString
= NULL
;
207 root_context
->dwCompReadStringSize
= 0;
208 root_context
->CompositionReadingString
= NULL
;
209 root_context
->dwResultStringSize
= 0;
210 root_context
->ResultString
= NULL
;
211 root_context
->dwResultReadStringSize
= 0;
212 root_context
->ResultReadingString
= NULL
;
215 ShowWindow(hwndDefault
, SW_SHOWNOACTIVATE
);
217 ImmInternalSendIMENotify(IMN_SETOPENSTATUS
, 0);
221 /***********************************************************************
222 * ImmAssociateContext (IMM32.@)
224 HIMC WINAPI
ImmAssociateContext(HWND hWnd
, HIMC hIMC
)
226 InputContextData
*data
= (InputContextData
*)hIMC
;
228 WARN("(%p, %p): semi-stub\n", hWnd
, hIMC
);
234 * WINE SPECIFIC! MAY CONFLICT
235 * associate the root context we have an XIM created
239 root_context
= (InputContextData
*)hIMC
;
243 * If already associated just return
245 if (data
->hwnd
== hWnd
)
248 if (IsWindow(data
->hwnd
))
251 * Post a message that your context is switching
253 SendMessageW(data
->hwnd
, WM_IME_SETCONTEXT
, FALSE
, ISC_SHOWUIALL
);
258 if (IsWindow(data
->hwnd
))
261 * Post a message that your context is switching
263 SendMessageW(data
->hwnd
, WM_IME_SETCONTEXT
, TRUE
, ISC_SHOWUIALL
);
267 * TODO: We need to keep track of the old context associated
268 * with a window and return it for now we will return NULL;
273 /***********************************************************************
274 * ImmAssociateContextEx (IMM32.@)
276 BOOL WINAPI
ImmAssociateContextEx(HWND hWnd
, HIMC hIMC
, DWORD dwFlags
)
278 FIXME("(%p, %p, %d): stub\n", hWnd
, hIMC
, dwFlags
);
279 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
283 /***********************************************************************
284 * ImmConfigureIMEA (IMM32.@)
286 BOOL WINAPI
ImmConfigureIMEA(
287 HKL hKL
, HWND hWnd
, DWORD dwMode
, LPVOID lpData
)
289 FIXME("(%p, %p, %d, %p): stub\n",
290 hKL
, hWnd
, dwMode
, lpData
292 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
296 /***********************************************************************
297 * ImmConfigureIMEW (IMM32.@)
299 BOOL WINAPI
ImmConfigureIMEW(
300 HKL hKL
, HWND hWnd
, DWORD dwMode
, LPVOID lpData
)
302 FIXME("(%p, %p, %d, %p): stub\n",
303 hKL
, hWnd
, dwMode
, lpData
305 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
309 /***********************************************************************
310 * ImmCreateContext (IMM32.@)
312 HIMC WINAPI
ImmCreateContext(void)
314 InputContextData
*new_context
;
316 new_context
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(InputContextData
));
318 return (HIMC
)new_context
;
321 /***********************************************************************
322 * ImmDestroyContext (IMM32.@)
324 BOOL WINAPI
ImmDestroyContext(HIMC hIMC
)
326 InputContextData
*data
= (InputContextData
*)hIMC
;
328 TRACE("Destroying %p\n",hIMC
);
332 if (data
->dwCompStringSize
)
333 HeapFree(GetProcessHeap(),0,data
->CompositionString
);
334 if (data
->dwCompReadStringSize
)
335 HeapFree(GetProcessHeap(),0,data
->CompositionReadingString
);
336 if (data
->dwResultStringSize
)
337 HeapFree(GetProcessHeap(),0,data
->ResultString
);
338 if (data
->dwResultReadStringSize
)
339 HeapFree(GetProcessHeap(),0,data
->ResultReadingString
);
343 DeleteObject(data
->textfont
);
344 data
->textfont
= NULL
;
347 HeapFree(GetProcessHeap(),0,data
);
352 /***********************************************************************
353 * ImmDisableIME (IMM32.@)
355 BOOL WINAPI
ImmDisableIME(DWORD idThread
)
357 FIXME("(%d): stub\n", idThread
);
361 /***********************************************************************
362 * ImmEnumRegisterWordA (IMM32.@)
364 UINT WINAPI
ImmEnumRegisterWordA(
365 HKL hKL
, REGISTERWORDENUMPROCA lpfnEnumProc
,
366 LPCSTR lpszReading
, DWORD dwStyle
,
367 LPCSTR lpszRegister
, LPVOID lpData
)
369 FIXME("(%p, %p, %s, %d, %s, %p): stub\n",
371 debugstr_a(lpszReading
), dwStyle
,
372 debugstr_a(lpszRegister
), lpData
374 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
378 /***********************************************************************
379 * ImmEnumRegisterWordW (IMM32.@)
381 UINT WINAPI
ImmEnumRegisterWordW(
382 HKL hKL
, REGISTERWORDENUMPROCW lpfnEnumProc
,
383 LPCWSTR lpszReading
, DWORD dwStyle
,
384 LPCWSTR lpszRegister
, LPVOID lpData
)
386 FIXME("(%p, %p, %s, %d, %s, %p): stub\n",
388 debugstr_w(lpszReading
), dwStyle
,
389 debugstr_w(lpszRegister
), lpData
391 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
395 /***********************************************************************
396 * ImmEscapeA (IMM32.@)
398 LRESULT WINAPI
ImmEscapeA(
400 UINT uEscape
, LPVOID lpData
)
402 FIXME("(%p, %p, %d, %p): stub\n",
403 hKL
, hIMC
, uEscape
, lpData
405 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
409 /***********************************************************************
410 * ImmEscapeW (IMM32.@)
412 LRESULT WINAPI
ImmEscapeW(
414 UINT uEscape
, LPVOID lpData
)
416 FIXME("(%p, %p, %d, %p): stub\n",
417 hKL
, hIMC
, uEscape
, lpData
419 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
423 /***********************************************************************
424 * ImmGetCandidateListA (IMM32.@)
426 DWORD WINAPI
ImmGetCandidateListA(
427 HIMC hIMC
, DWORD deIndex
,
428 LPCANDIDATELIST lpCandList
, DWORD dwBufLen
)
430 FIXME("(%p, %d, %p, %d): stub\n",
434 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
438 /***********************************************************************
439 * ImmGetCandidateListCountA (IMM32.@)
441 DWORD WINAPI
ImmGetCandidateListCountA(
442 HIMC hIMC
, LPDWORD lpdwListCount
)
444 FIXME("(%p, %p): stub\n", hIMC
, lpdwListCount
);
445 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
449 /***********************************************************************
450 * ImmGetCandidateListCountW (IMM32.@)
452 DWORD WINAPI
ImmGetCandidateListCountW(
453 HIMC hIMC
, LPDWORD lpdwListCount
)
455 FIXME("(%p, %p): stub\n", hIMC
, lpdwListCount
);
456 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
460 /***********************************************************************
461 * ImmGetCandidateListW (IMM32.@)
463 DWORD WINAPI
ImmGetCandidateListW(
464 HIMC hIMC
, DWORD deIndex
,
465 LPCANDIDATELIST lpCandList
, DWORD dwBufLen
)
467 FIXME("(%p, %d, %p, %d): stub\n",
471 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
475 /***********************************************************************
476 * ImmGetCandidateWindow (IMM32.@)
478 BOOL WINAPI
ImmGetCandidateWindow(
479 HIMC hIMC
, DWORD dwBufLen
, LPCANDIDATEFORM lpCandidate
)
481 FIXME("(%p, %d, %p): stub\n", hIMC
, dwBufLen
, lpCandidate
);
482 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
486 /***********************************************************************
487 * ImmGetCompositionFontA (IMM32.@)
489 BOOL WINAPI
ImmGetCompositionFontA(HIMC hIMC
, LPLOGFONTA lplf
)
491 FIXME("(%p, %p): stub\n", hIMC
, lplf
);
492 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
496 /***********************************************************************
497 * ImmGetCompositionFontW (IMM32.@)
499 BOOL WINAPI
ImmGetCompositionFontW(HIMC hIMC
, LPLOGFONTW lplf
)
501 FIXME("(%p, %p): stub\n", hIMC
, lplf
);
502 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
506 /***********************************************************************
507 * ImmGetCompositionStringA (IMM32.@)
509 LONG WINAPI
ImmGetCompositionStringA(
510 HIMC hIMC
, DWORD dwIndex
, LPVOID lpBuf
, DWORD dwBufLen
)
514 InputContextData
*data
= (InputContextData
*)hIMC
;
516 TRACE("(%p, 0x%x, %p, %d)\n", hIMC
, dwIndex
, lpBuf
, dwBufLen
);
521 if (dwIndex
== GCS_RESULTSTR
)
523 TRACE("GSC_RESULTSTR %p %i\n",data
->ResultString
,
524 data
->dwResultStringSize
);
526 buf
= HeapAlloc( GetProcessHeap(), 0, data
->dwResultStringSize
* 3 );
527 rc
= WideCharToMultiByte(CP_ACP
, 0, (LPWSTR
)data
->ResultString
,
528 data
->dwResultStringSize
/ sizeof(WCHAR
), buf
,
529 data
->dwResultStringSize
* 3, NULL
, NULL
);
531 memcpy(lpBuf
,buf
,rc
);
534 HeapFree( GetProcessHeap(), 0, buf
);
536 else if (dwIndex
== GCS_COMPSTR
)
538 TRACE("GSC_COMPSTR %p %i\n", data
->CompositionString
, data
->dwCompStringLength
);
540 buf
= HeapAlloc( GetProcessHeap(), 0, data
->dwCompStringLength
* 3 );
541 rc
= WideCharToMultiByte(CP_ACP
, 0,(LPWSTR
)data
->CompositionString
,
542 data
->dwCompStringLength
/ sizeof(WCHAR
), buf
,
543 data
->dwCompStringLength
* 3, NULL
, NULL
);
545 memcpy(lpBuf
,buf
,rc
);
546 HeapFree( GetProcessHeap(), 0, buf
);
548 else if (dwIndex
== GCS_COMPATTR
)
550 TRACE("GSC_COMPATTR %p %i\n", data
->CompositionString
, data
->dwCompStringLength
);
552 rc
= WideCharToMultiByte(CP_ACP
, 0, (LPWSTR
)data
->CompositionString
,
553 data
->dwCompStringLength
/ sizeof(WCHAR
), NULL
,
559 for (i
= 0; i
< rc
; i
++)
560 ((LPBYTE
)lpBuf
)[i
] = ATTR_INPUT
;
563 else if (dwIndex
== GCS_COMPCLAUSE
)
565 TRACE("GSC_COMPCLAUSE %p %i\n", data
->CompositionString
, data
->dwCompStringLength
);
567 rc
= WideCharToMultiByte(CP_ACP
, 0, (LPWSTR
)data
->CompositionString
,
568 data
->dwCompStringLength
/ sizeof(WCHAR
), NULL
,
571 if (dwBufLen
>= sizeof(DWORD
)*2)
573 ((LPDWORD
)lpBuf
)[0] = 0;
574 ((LPDWORD
)lpBuf
)[1] = rc
;
576 rc
= sizeof(DWORD
)*2;
578 else if (dwIndex
== GCS_RESULTCLAUSE
)
580 TRACE("GSC_RESULTCLAUSE %p %i\n", data
->ResultString
, data
->dwResultStringSize
);
582 rc
= WideCharToMultiByte(CP_ACP
, 0, (LPWSTR
)data
->ResultString
,
583 data
->dwResultStringSize
/ sizeof(WCHAR
), NULL
,
586 if (dwBufLen
>= sizeof(DWORD
)*2)
588 ((LPDWORD
)lpBuf
)[0] = 0;
589 ((LPDWORD
)lpBuf
)[1] = rc
;
591 rc
= sizeof(DWORD
)*2;
595 FIXME("Unhandled index 0x%x\n",dwIndex
);
601 /***********************************************************************
602 * ImmGetCompositionStringW (IMM32.@)
604 LONG WINAPI
ImmGetCompositionStringW(
605 HIMC hIMC
, DWORD dwIndex
,
606 LPVOID lpBuf
, DWORD dwBufLen
)
609 InputContextData
*data
= (InputContextData
*)hIMC
;
611 TRACE("(%p, 0x%x, %p, %d)\n", hIMC
, dwIndex
, lpBuf
, dwBufLen
);
616 if (dwIndex
== GCS_RESULTSTR
)
620 if (dwBufLen
>= data
->dwResultStringSize
)
621 memcpy(lpBuf
,data
->ResultString
,data
->dwResultStringSize
);
623 rc
= data
->dwResultStringSize
;
625 else if (dwIndex
== GCS_RESULTREADSTR
)
627 if (dwBufLen
>= data
->dwResultReadStringSize
)
628 memcpy(lpBuf
,data
->ResultReadingString
,
629 data
->dwResultReadStringSize
);
631 rc
= data
->dwResultReadStringSize
;
633 else if (dwIndex
== GCS_COMPSTR
)
635 if (dwBufLen
>= data
->dwCompStringLength
)
636 memcpy(lpBuf
,data
->CompositionString
,data
->dwCompStringLength
);
638 rc
= data
->dwCompStringLength
;
640 else if (dwIndex
== GCS_COMPATTR
)
642 unsigned int len
= data
->dwCompStringLength
;
647 for (i
= 0; i
< len
; i
++)
648 ((LPBYTE
)lpBuf
)[i
] = ATTR_INPUT
;
653 else if (dwIndex
== GCS_COMPCLAUSE
)
655 if (dwBufLen
>= sizeof(DWORD
)*2)
657 ((LPDWORD
)lpBuf
)[0] = 0;
658 ((LPDWORD
)lpBuf
)[1] = data
->dwCompStringLength
/sizeof(WCHAR
);
660 rc
= sizeof(DWORD
)*2;
662 else if (dwIndex
== GCS_COMPREADSTR
)
664 if (dwBufLen
>= data
->dwCompReadStringSize
)
665 memcpy(lpBuf
,data
->CompositionReadingString
,
666 data
->dwCompReadStringSize
);
668 rc
= data
->dwCompReadStringSize
;
672 FIXME("Unhandled index 0x%x\n",dwIndex
);
678 /***********************************************************************
679 * ImmGetCompositionWindow (IMM32.@)
681 BOOL WINAPI
ImmGetCompositionWindow(HIMC hIMC
, LPCOMPOSITIONFORM lpCompForm
)
683 InputContextData
*data
= (InputContextData
*)hIMC
;
685 TRACE("(%p, %p)\n", hIMC
, lpCompForm
);
690 memcpy(lpCompForm
,&(data
->CompForm
),sizeof(COMPOSITIONFORM
));
694 /***********************************************************************
695 * ImmGetContext (IMM32.@)
698 HIMC WINAPI
ImmGetContext(HWND hWnd
)
705 root_context
->hwnd
= hWnd
;
706 return (HIMC
)root_context
;
709 /***********************************************************************
710 * ImmGetConversionListA (IMM32.@)
712 DWORD WINAPI
ImmGetConversionListA(
714 LPCSTR pSrc
, LPCANDIDATELIST lpDst
,
715 DWORD dwBufLen
, UINT uFlag
)
717 FIXME("(%p, %p, %s, %p, %d, %d): stub\n",
718 hKL
, hIMC
, debugstr_a(pSrc
), lpDst
, dwBufLen
, uFlag
720 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
724 /***********************************************************************
725 * ImmGetConversionListW (IMM32.@)
727 DWORD WINAPI
ImmGetConversionListW(
729 LPCWSTR pSrc
, LPCANDIDATELIST lpDst
,
730 DWORD dwBufLen
, UINT uFlag
)
732 FIXME("(%p, %p, %s, %p, %d, %d): stub\n",
733 hKL
, hIMC
, debugstr_w(pSrc
), lpDst
, dwBufLen
, uFlag
735 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
739 /***********************************************************************
740 * ImmGetConversionStatus (IMM32.@)
742 BOOL WINAPI
ImmGetConversionStatus(
743 HIMC hIMC
, LPDWORD lpfdwConversion
, LPDWORD lpfdwSentence
)
745 TRACE("(%p, %p, %p): best guess\n", hIMC
, lpfdwConversion
, lpfdwSentence
);
747 *lpfdwConversion
= IME_CMODE_NATIVE
;
749 *lpfdwSentence
= IME_SMODE_NONE
;
753 /***********************************************************************
754 * ImmGetDefaultIMEWnd (IMM32.@)
756 HWND WINAPI
ImmGetDefaultIMEWnd(HWND hWnd
)
758 FIXME("(%p - %p %p ): semi-stub\n", hWnd
,hwndDefault
, root_context
);
760 if (hwndDefault
== NULL
)
762 static const WCHAR the_name
[] = {'I','M','E','\0'};
765 hwndDefault
= CreateWindowExW( WS_EX_TOOLWINDOW
, WC_IMECLASSNAME
,
766 the_name
, WS_POPUP
, 0, 0, 1, 1, 0, 0,
769 TRACE("Default created (%p)\n",hwndDefault
);
772 return (HWND
)hwndDefault
;
775 /***********************************************************************
776 * ImmGetDescriptionA (IMM32.@)
778 UINT WINAPI
ImmGetDescriptionA(
779 HKL hKL
, LPSTR lpszDescription
, UINT uBufLen
)
784 TRACE("%p %p %d\n", hKL
, lpszDescription
, uBufLen
);
786 /* find out how many characters in the unicode buffer */
787 len
= ImmGetDescriptionW( hKL
, NULL
, 0 );
789 /* allocate a buffer of that size */
790 buf
= HeapAlloc( GetProcessHeap(), 0, (len
+ 1) * sizeof (WCHAR
) );
794 /* fetch the unicode buffer */
795 len
= ImmGetDescriptionW( hKL
, buf
, len
+ 1 );
797 /* convert it back to ASCII */
798 len
= WideCharToMultiByte( CP_ACP
, 0, buf
, len
+ 1,
799 lpszDescription
, uBufLen
, NULL
, NULL
);
801 HeapFree( GetProcessHeap(), 0, buf
);
806 /***********************************************************************
807 * ImmGetDescriptionW (IMM32.@)
809 UINT WINAPI
ImmGetDescriptionW(HKL hKL
, LPWSTR lpszDescription
, UINT uBufLen
)
811 static const WCHAR name
[] = { 'W','i','n','e',' ','X','I','M',0 };
813 FIXME("(%p, %p, %d): semi stub\n", hKL
, lpszDescription
, uBufLen
);
815 if (!uBufLen
) return lstrlenW( name
);
816 lstrcpynW( lpszDescription
, name
, uBufLen
);
817 return lstrlenW( lpszDescription
);
820 /***********************************************************************
821 * ImmGetGuideLineA (IMM32.@)
823 DWORD WINAPI
ImmGetGuideLineA(
824 HIMC hIMC
, DWORD dwIndex
, LPSTR lpBuf
, DWORD dwBufLen
)
826 FIXME("(%p, %d, %s, %d): stub\n",
827 hIMC
, dwIndex
, debugstr_a(lpBuf
), dwBufLen
829 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
833 /***********************************************************************
834 * ImmGetGuideLineW (IMM32.@)
836 DWORD WINAPI
ImmGetGuideLineW(HIMC hIMC
, DWORD dwIndex
, LPWSTR lpBuf
, DWORD dwBufLen
)
838 FIXME("(%p, %d, %s, %d): stub\n",
839 hIMC
, dwIndex
, debugstr_w(lpBuf
), dwBufLen
841 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
845 /***********************************************************************
846 * ImmGetIMEFileNameA (IMM32.@)
848 UINT WINAPI
ImmGetIMEFileNameA(
849 HKL hKL
, LPSTR lpszFileName
, UINT uBufLen
)
851 FIXME("(%p, %p, %d): stub\n", hKL
, lpszFileName
, uBufLen
);
852 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
856 /***********************************************************************
857 * ImmGetIMEFileNameW (IMM32.@)
859 UINT WINAPI
ImmGetIMEFileNameW(
860 HKL hKL
, LPWSTR lpszFileName
, UINT uBufLen
)
862 FIXME("(%p, %p, %d): stub\n", hKL
, lpszFileName
, uBufLen
);
863 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
867 /***********************************************************************
868 * ImmGetOpenStatus (IMM32.@)
870 BOOL WINAPI
ImmGetOpenStatus(HIMC hIMC
)
872 InputContextData
*data
= (InputContextData
*)hIMC
;
876 FIXME("(%p): semi-stub\n", hIMC
);
881 /***********************************************************************
882 * ImmGetProperty (IMM32.@)
884 DWORD WINAPI
ImmGetProperty(HKL hKL
, DWORD fdwIndex
)
887 TRACE("(%p, %d)\n", hKL
, fdwIndex
);
892 TRACE("(%s)\n", "IGP_PROPERTY");
893 rc
= IME_PROP_UNICODE
| IME_PROP_AT_CARET
;
896 FIXME("(%s)\n", "IGP_CONVERSION");
897 rc
= IME_CMODE_NATIVE
;
900 FIXME("%s)\n", "IGP_SENTENCE");
901 rc
= IME_SMODE_AUTOMATIC
;
904 TRACE("(%s)\n", "IGP_SETCOMPSTR");
908 TRACE("(%s)\n", "IGP_SELECT");
909 rc
= SELECT_CAP_CONVERSION
| SELECT_CAP_SENTENCE
;
911 case IGP_GETIMEVERSION
:
912 TRACE("(%s)\n", "IGP_GETIMEVERSION");
916 TRACE("(%s)\n", "IGP_UI");
925 /***********************************************************************
926 * ImmGetRegisterWordStyleA (IMM32.@)
928 UINT WINAPI
ImmGetRegisterWordStyleA(
929 HKL hKL
, UINT nItem
, LPSTYLEBUFA lpStyleBuf
)
931 FIXME("(%p, %d, %p): stub\n", hKL
, nItem
, lpStyleBuf
);
932 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
936 /***********************************************************************
937 * ImmGetRegisterWordStyleW (IMM32.@)
939 UINT WINAPI
ImmGetRegisterWordStyleW(
940 HKL hKL
, UINT nItem
, LPSTYLEBUFW lpStyleBuf
)
942 FIXME("(%p, %d, %p): stub\n", hKL
, nItem
, lpStyleBuf
);
943 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
947 /***********************************************************************
948 * ImmGetStatusWindowPos (IMM32.@)
950 BOOL WINAPI
ImmGetStatusWindowPos(HIMC hIMC
, LPPOINT lpptPos
)
952 FIXME("(%p, %p): stub\n", hIMC
, lpptPos
);
953 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
957 /***********************************************************************
958 * ImmGetVirtualKey (IMM32.@)
960 UINT WINAPI
ImmGetVirtualKey(HWND hWnd
)
962 OSVERSIONINFOA version
;
963 FIXME("(%p): stub\n", hWnd
);
964 GetVersionExA( &version
);
965 switch(version
.dwPlatformId
)
967 case VER_PLATFORM_WIN32_WINDOWS
:
968 return VK_PROCESSKEY
;
969 case VER_PLATFORM_WIN32_NT
:
972 FIXME("%d not supported\n",version
.dwPlatformId
);
973 return VK_PROCESSKEY
;
977 /***********************************************************************
978 * ImmInstallIMEA (IMM32.@)
980 HKL WINAPI
ImmInstallIMEA(
981 LPCSTR lpszIMEFileName
, LPCSTR lpszLayoutText
)
983 FIXME("(%s, %s): stub\n",
984 debugstr_a(lpszIMEFileName
), debugstr_a(lpszLayoutText
)
986 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
990 /***********************************************************************
991 * ImmInstallIMEW (IMM32.@)
993 HKL WINAPI
ImmInstallIMEW(
994 LPCWSTR lpszIMEFileName
, LPCWSTR lpszLayoutText
)
996 FIXME("(%s, %s): stub\n",
997 debugstr_w(lpszIMEFileName
), debugstr_w(lpszLayoutText
)
999 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1003 /***********************************************************************
1004 * ImmIsIME (IMM32.@)
1006 BOOL WINAPI
ImmIsIME(HKL hKL
)
1008 TRACE("(%p): semi-stub\n", hKL
);
1010 * FIXME: Dead key locales will return TRUE here when they should not
1011 * There is probably a more proper way to check this.
1013 return (root_context
!= NULL
);
1016 /***********************************************************************
1017 * ImmIsUIMessageA (IMM32.@)
1019 BOOL WINAPI
ImmIsUIMessageA(
1020 HWND hWndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1024 TRACE("(%p, %x, %ld, %ld)\n", hWndIME
, msg
, wParam
, lParam
);
1025 if ((msg
>= WM_IME_STARTCOMPOSITION
&& msg
<= WM_IME_KEYLAST
) ||
1026 (msg
>= WM_IME_SETCONTEXT
&& msg
<= WM_IME_KEYUP
) ||
1027 (msg
== WM_MSIME_SERVICE
) ||
1028 (msg
== WM_MSIME_RECONVERTOPTIONS
) ||
1029 (msg
== WM_MSIME_MOUSE
) ||
1030 (msg
== WM_MSIME_RECONVERTREQUEST
) ||
1031 (msg
== WM_MSIME_RECONVERT
) ||
1032 (msg
== WM_MSIME_QUERYPOSITION
) ||
1033 (msg
== WM_MSIME_DOCUMENTFEED
))
1037 ImmGetDefaultIMEWnd(NULL
);
1039 if (hWndIME
== NULL
)
1040 PostMessageA(hwndDefault
, msg
, wParam
, lParam
);
1047 /***********************************************************************
1048 * ImmIsUIMessageW (IMM32.@)
1050 BOOL WINAPI
ImmIsUIMessageW(
1051 HWND hWndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1054 TRACE("(%p, %d, %ld, %ld): stub\n", hWndIME
, msg
, wParam
, lParam
);
1055 if ((msg
>= WM_IME_STARTCOMPOSITION
&& msg
<= WM_IME_KEYLAST
) ||
1056 (msg
>= WM_IME_SETCONTEXT
&& msg
<= WM_IME_KEYUP
) ||
1057 (msg
== WM_MSIME_SERVICE
) ||
1058 (msg
== WM_MSIME_RECONVERTOPTIONS
) ||
1059 (msg
== WM_MSIME_MOUSE
) ||
1060 (msg
== WM_MSIME_RECONVERTREQUEST
) ||
1061 (msg
== WM_MSIME_RECONVERT
) ||
1062 (msg
== WM_MSIME_QUERYPOSITION
) ||
1063 (msg
== WM_MSIME_DOCUMENTFEED
))
1068 /***********************************************************************
1069 * ImmNotifyIME (IMM32.@)
1071 BOOL WINAPI
ImmNotifyIME(
1072 HIMC hIMC
, DWORD dwAction
, DWORD dwIndex
, DWORD dwValue
)
1076 TRACE("(%p, %d, %d, %d)\n",
1077 hIMC
, dwAction
, dwIndex
, dwValue
);
1084 case NI_CHANGECANDIDATELIST
:
1085 FIXME("%s\n","NI_CHANGECANDIDATELIST");
1087 case NI_CLOSECANDIDATE
:
1088 FIXME("%s\n","NI_CLOSECANDIDATE");
1090 case NI_COMPOSITIONSTR
:
1094 TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_CANCEL");
1095 if (pX11DRV_ForceXIMReset
)
1096 pX11DRV_ForceXIMReset(root_context
->hwnd
);
1097 if (root_context
->dwCompStringSize
)
1099 HeapFree(GetProcessHeap(),0,
1100 root_context
->CompositionString
);
1101 root_context
->dwCompStringSize
= 0;
1102 root_context
->dwCompStringLength
= 0;
1103 root_context
->CompositionString
= NULL
;
1104 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
, 0,
1110 TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_COMPLETE");
1111 if (hIMC
!= (HIMC
)FROM_IME
&& pX11DRV_ForceXIMReset
)
1112 pX11DRV_ForceXIMReset(root_context
->hwnd
);
1114 if (root_context
->dwResultStringSize
)
1116 HeapFree(GetProcessHeap(),0,root_context
->ResultString
);
1117 root_context
->dwResultStringSize
= 0;
1118 root_context
->ResultString
= NULL
;
1120 if (root_context
->dwCompStringLength
)
1122 root_context
->ResultString
= HeapAlloc(
1123 GetProcessHeap(), 0, root_context
->dwCompStringLength
);
1124 root_context
->dwResultStringSize
=
1125 root_context
->dwCompStringLength
;
1127 memcpy(root_context
->ResultString
,
1128 root_context
->CompositionString
,
1129 root_context
->dwCompStringLength
);
1131 HeapFree(GetProcessHeap(),0,
1132 root_context
->CompositionString
);
1134 root_context
->dwCompStringSize
= 0;
1135 root_context
->dwCompStringLength
= 0;
1136 root_context
->CompositionString
= NULL
;
1137 root_context
->bRead
= FALSE
;
1139 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
, 0,
1142 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
,
1143 root_context
->ResultString
[0],
1144 GCS_RESULTSTR
|GCS_RESULTCLAUSE
);
1146 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION
, 0, 0);
1147 root_context
->bInComposition
= FALSE
;
1151 FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_CONVERT");
1154 FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_REVERT");
1157 ERR("%s - %s (%i)\n","NI_COMPOSITIONSTR","UNKNOWN",dwIndex
);
1161 case NI_IMEMENUSELECTED
:
1162 FIXME("%s\n", "NI_IMEMENUSELECTED");
1164 case NI_OPENCANDIDATE
:
1165 FIXME("%s\n", "NI_OPENCANDIDATE");
1167 case NI_SELECTCANDIDATESTR
:
1168 FIXME("%s\n", "NI_SELECTCANDIDATESTR");
1170 case NI_SETCANDIDATE_PAGESIZE
:
1171 FIXME("%s\n", "NI_SETCANDIDATE_PAGESIZE");
1173 case NI_SETCANDIDATE_PAGESTART
:
1174 FIXME("%s\n", "NI_SETCANDIDATE_PAGESTART");
1183 /***********************************************************************
1184 * ImmRegisterWordA (IMM32.@)
1186 BOOL WINAPI
ImmRegisterWordA(
1187 HKL hKL
, LPCSTR lpszReading
, DWORD dwStyle
, LPCSTR lpszRegister
)
1189 FIXME("(%p, %s, %d, %s): stub\n",
1190 hKL
, debugstr_a(lpszReading
), dwStyle
, debugstr_a(lpszRegister
)
1192 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1196 /***********************************************************************
1197 * ImmRegisterWordW (IMM32.@)
1199 BOOL WINAPI
ImmRegisterWordW(
1200 HKL hKL
, LPCWSTR lpszReading
, DWORD dwStyle
, LPCWSTR lpszRegister
)
1202 FIXME("(%p, %s, %d, %s): stub\n",
1203 hKL
, debugstr_w(lpszReading
), dwStyle
, debugstr_w(lpszRegister
)
1205 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1209 /***********************************************************************
1210 * ImmReleaseContext (IMM32.@)
1212 BOOL WINAPI
ImmReleaseContext(HWND hWnd
, HIMC hIMC
)
1214 FIXME("(%p, %p): stub\n", hWnd
, hIMC
);
1219 /***********************************************************************
1220 * ImmSetCandidateWindow (IMM32.@)
1222 BOOL WINAPI
ImmSetCandidateWindow(
1223 HIMC hIMC
, LPCANDIDATEFORM lpCandidate
)
1225 FIXME("(%p, %p): stub\n", hIMC
, lpCandidate
);
1226 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1230 /***********************************************************************
1231 * ImmSetCompositionFontA (IMM32.@)
1233 BOOL WINAPI
ImmSetCompositionFontA(HIMC hIMC
, LPLOGFONTA lplf
)
1235 InputContextData
*data
= (InputContextData
*)hIMC
;
1236 TRACE("(%p, %p)\n", hIMC
, lplf
);
1241 memcpy(&data
->font
,lplf
,sizeof(LOGFONTA
));
1242 MultiByteToWideChar(CP_ACP
, 0, lplf
->lfFaceName
, -1, data
->font
.lfFaceName
,
1245 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONFONT
, 0);
1249 DeleteObject(data
->textfont
);
1250 data
->textfont
= NULL
;
1253 data
->textfont
= CreateFontIndirectW(&data
->font
);
1257 /***********************************************************************
1258 * ImmSetCompositionFontW (IMM32.@)
1260 BOOL WINAPI
ImmSetCompositionFontW(HIMC hIMC
, LPLOGFONTW lplf
)
1262 InputContextData
*data
= (InputContextData
*)hIMC
;
1263 TRACE("(%p, %p)\n", hIMC
, lplf
);
1268 memcpy(&data
->font
,lplf
,sizeof(LOGFONTW
));
1269 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONFONT
, 0);
1273 DeleteObject(data
->textfont
);
1274 data
->textfont
= NULL
;
1276 data
->textfont
= CreateFontIndirectW(&data
->font
);
1280 /***********************************************************************
1281 * ImmSetCompositionStringA (IMM32.@)
1283 BOOL WINAPI
ImmSetCompositionStringA(
1284 HIMC hIMC
, DWORD dwIndex
,
1285 LPCVOID lpComp
, DWORD dwCompLen
,
1286 LPCVOID lpRead
, DWORD dwReadLen
)
1290 WCHAR
*CompBuffer
= NULL
;
1291 WCHAR
*ReadBuffer
= NULL
;
1294 TRACE("(%p, %d, %p, %d, %p, %d): stub\n",
1295 hIMC
, dwIndex
, lpComp
, dwCompLen
, lpRead
, dwReadLen
);
1297 comp_len
= MultiByteToWideChar(CP_ACP
, 0, lpComp
, dwCompLen
, NULL
, 0);
1300 CompBuffer
= HeapAlloc(GetProcessHeap(),0,comp_len
* sizeof(WCHAR
));
1301 MultiByteToWideChar(CP_ACP
, 0, lpComp
, dwCompLen
, CompBuffer
, comp_len
);
1304 read_len
= MultiByteToWideChar(CP_ACP
, 0, lpRead
, dwReadLen
, NULL
, 0);
1307 ReadBuffer
= HeapAlloc(GetProcessHeap(),0,read_len
* sizeof(WCHAR
));
1308 MultiByteToWideChar(CP_ACP
, 0, lpRead
, dwReadLen
, ReadBuffer
, read_len
);
1311 rc
= ImmSetCompositionStringW(hIMC
, dwIndex
, CompBuffer
, comp_len
,
1312 ReadBuffer
, read_len
);
1314 HeapFree(GetProcessHeap(), 0, CompBuffer
);
1315 HeapFree(GetProcessHeap(), 0, ReadBuffer
);
1320 /***********************************************************************
1321 * ImmSetCompositionStringW (IMM32.@)
1323 BOOL WINAPI
ImmSetCompositionStringW(
1324 HIMC hIMC
, DWORD dwIndex
,
1325 LPCVOID lpComp
, DWORD dwCompLen
,
1326 LPCVOID lpRead
, DWORD dwReadLen
)
1331 TRACE("(%p, %d, %p, %d, %p, %d): stub\n",
1332 hIMC
, dwIndex
, lpComp
, dwCompLen
, lpRead
, dwReadLen
);
1335 if (hIMC
!= (HIMC
)FROM_IME
)
1336 FIXME("PROBLEM: This only sets the wine level string\n");
1340 * this sets the composition string in the imm32.dll level
1341 * of the composition buffer. we cannot manipulate the xim level
1342 * buffer, which means that once the xim level buffer changes again
1343 * any call to this function from the application will be lost
1346 if (lpRead
&& dwReadLen
)
1347 FIXME("Reading string unimplemented\n");
1350 * app operating this api to also receive the message from xim
1353 if (dwIndex
== SCS_SETSTR
)
1355 if (!root_context
->bInComposition
)
1357 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION
, 0, 0);
1358 root_context
->bInComposition
= TRUE
;
1361 flags
= GCS_COMPSTR
;
1363 if (root_context
->dwCompStringLength
)
1364 HeapFree(GetProcessHeap(),0,root_context
->CompositionString
);
1366 root_context
->dwCompStringLength
= dwCompLen
;
1367 root_context
->dwCompStringSize
= dwCompLen
;
1369 if (dwCompLen
&& lpComp
)
1371 root_context
->CompositionString
= HeapAlloc(GetProcessHeap(), 0,
1373 memcpy(root_context
->CompositionString
,lpComp
,dwCompLen
);
1375 wParam
= ((const WCHAR
*)lpComp
)[0];
1376 flags
|= GCS_COMPCLAUSE
| GCS_COMPATTR
;
1379 root_context
->CompositionString
= NULL
;
1383 UpdateDataInDefaultIMEWindow(hwndDefault
);
1385 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
, wParam
, flags
);
1390 /***********************************************************************
1391 * ImmSetCompositionWindow (IMM32.@)
1393 BOOL WINAPI
ImmSetCompositionWindow(
1394 HIMC hIMC
, LPCOMPOSITIONFORM lpCompForm
)
1396 BOOL reshow
= FALSE
;
1397 InputContextData
*data
= (InputContextData
*)hIMC
;
1399 TRACE("(%p, %p)\n", hIMC
, lpCompForm
);
1400 TRACE("\t%x, (%i,%i), (%i,%i - %i,%i)\n",lpCompForm
->dwStyle
,
1401 lpCompForm
->ptCurrentPos
.x
, lpCompForm
->ptCurrentPos
.y
, lpCompForm
->rcArea
.top
,
1402 lpCompForm
->rcArea
.left
, lpCompForm
->rcArea
.bottom
, lpCompForm
->rcArea
.right
);
1407 memcpy(&data
->CompForm
,lpCompForm
,sizeof(COMPOSITIONFORM
));
1409 if (IsWindowVisible(hwndDefault
))
1412 ShowWindow(hwndDefault
,SW_HIDE
);
1415 /* FIXME: this is a partial stub */
1418 ShowWindow(hwndDefault
,SW_SHOWNOACTIVATE
);
1420 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONWINDOW
, 0);
1424 /***********************************************************************
1425 * ImmSetConversionStatus (IMM32.@)
1427 BOOL WINAPI
ImmSetConversionStatus(
1428 HIMC hIMC
, DWORD fdwConversion
, DWORD fdwSentence
)
1430 FIXME("(%p, %d, %d): stub\n",
1431 hIMC
, fdwConversion
, fdwSentence
1433 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1437 /***********************************************************************
1438 * ImmSetOpenStatus (IMM32.@)
1440 BOOL WINAPI
ImmSetOpenStatus(HIMC hIMC
, BOOL fOpen
)
1442 InputContextData
*data
= (InputContextData
*)hIMC
;
1444 TRACE("%p %d\n", hIMC
, fOpen
);
1446 if (hIMC
== (HIMC
)FROM_IME
)
1448 ImmInternalSetOpenStatus(fOpen
);
1449 ImmInternalSendIMENotify(IMN_SETOPENSTATUS
, 0);
1456 if (fOpen
!= data
->bInternalState
)
1458 if (fOpen
== FALSE
&& pX11DRV_ForceXIMReset
)
1459 pX11DRV_ForceXIMReset(data
->hwnd
);
1462 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION
,0,0);
1464 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION
,0,0);
1466 ImmInternalSetOpenStatus(fOpen
);
1467 ImmInternalSetOpenStatus(!fOpen
);
1469 if (data
->bOpen
== FALSE
)
1470 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION
,0,0);
1472 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION
,0,0);
1479 /***********************************************************************
1480 * ImmSetStatusWindowPos (IMM32.@)
1482 BOOL WINAPI
ImmSetStatusWindowPos(HIMC hIMC
, LPPOINT lpptPos
)
1484 FIXME("(%p, %p): stub\n", hIMC
, lpptPos
);
1485 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1489 /***********************************************************************
1490 * ImmSimulateHotKey (IMM32.@)
1492 BOOL WINAPI
ImmSimulateHotKey(HWND hWnd
, DWORD dwHotKeyID
)
1494 FIXME("(%p, %d): stub\n", hWnd
, dwHotKeyID
);
1495 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1499 /***********************************************************************
1500 * ImmUnregisterWordA (IMM32.@)
1502 BOOL WINAPI
ImmUnregisterWordA(
1503 HKL hKL
, LPCSTR lpszReading
, DWORD dwStyle
, LPCSTR lpszUnregister
)
1505 FIXME("(%p, %s, %d, %s): stub\n",
1506 hKL
, debugstr_a(lpszReading
), dwStyle
, debugstr_a(lpszUnregister
)
1508 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1512 /***********************************************************************
1513 * ImmUnregisterWordW (IMM32.@)
1515 BOOL WINAPI
ImmUnregisterWordW(
1516 HKL hKL
, LPCWSTR lpszReading
, DWORD dwStyle
, LPCWSTR lpszUnregister
)
1518 FIXME("(%p, %s, %d, %s): stub\n",
1519 hKL
, debugstr_w(lpszReading
), dwStyle
, debugstr_w(lpszUnregister
)
1521 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1525 /***********************************************************************
1526 * ImmGetImeMenuItemsA (IMM32.@)
1528 DWORD WINAPI
ImmGetImeMenuItemsA( HIMC hIMC
, DWORD dwFlags
, DWORD dwType
,
1529 LPIMEMENUITEMINFOA lpImeParentMenu
, LPIMEMENUITEMINFOA lpImeMenu
,
1532 FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC
, dwFlags
, dwType
,
1533 lpImeParentMenu
, lpImeMenu
, dwSize
);
1537 /***********************************************************************
1538 * ImmGetImeMenuItemsW (IMM32.@)
1540 DWORD WINAPI
ImmGetImeMenuItemsW( HIMC hIMC
, DWORD dwFlags
, DWORD dwType
,
1541 LPIMEMENUITEMINFOW lpImeParentMenu
, LPIMEMENUITEMINFOW lpImeMenu
,
1544 FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC
, dwFlags
, dwType
,
1545 lpImeParentMenu
, lpImeMenu
, dwSize
);
1550 * Internal functions to help with IME window management
1552 static void PaintDefaultIMEWnd(HWND hwnd
)
1556 HDC hdc
= BeginPaint(hwnd
,&ps
);
1557 GetClientRect(hwnd
,&rect
);
1558 FillRect(hdc
, &rect
, (HBRUSH
)(COLOR_WINDOW
+ 1));
1560 if (root_context
->dwCompStringLength
&& root_context
->CompositionString
)
1564 HFONT oldfont
= NULL
;
1566 if (root_context
->textfont
)
1567 oldfont
= SelectObject(hdc
,root_context
->textfont
);
1570 GetTextExtentPoint32W(hdc
, (LPWSTR
)root_context
->CompositionString
,
1571 root_context
->dwCompStringLength
/ sizeof(WCHAR
),
1577 if (root_context
->CompForm
.dwStyle
== CFS_POINT
||
1578 root_context
->CompForm
.dwStyle
== CFS_FORCE_POSITION
)
1580 POINT cpt
= root_context
->CompForm
.ptCurrentPos
;
1581 ClientToScreen(root_context
->hwnd
,&cpt
);
1584 rect
.right
= rect
.left
+ pt
.x
+ 20;
1585 rect
.bottom
= rect
.top
+ pt
.y
+ 20;
1587 else if (root_context
->CompForm
.dwStyle
== CFS_RECT
)
1590 cpt
.x
= root_context
->CompForm
.rcArea
.left
;
1591 cpt
.y
= root_context
->CompForm
.rcArea
.top
;
1592 ClientToScreen(root_context
->hwnd
,&cpt
);
1595 cpt
.x
= root_context
->CompForm
.rcArea
.right
;
1596 cpt
.y
= root_context
->CompForm
.rcArea
.bottom
;
1597 ClientToScreen(root_context
->hwnd
,&cpt
);
1599 rect
.bottom
= cpt
.y
;
1603 rect
.right
= rect
.left
+ pt
.x
+ 20;
1604 rect
.bottom
= rect
.top
+ pt
.y
+ 20;
1606 MoveWindow(hwnd
, rect
.left
, rect
.top
, rect
.right
- rect
.left
,
1607 rect
.bottom
- rect
.top
, FALSE
);
1608 TextOutW(hdc
, 10,10,(LPWSTR
)root_context
->CompositionString
,
1609 root_context
->dwCompStringLength
/ sizeof(WCHAR
));
1612 SelectObject(hdc
,oldfont
);
1617 static void UpdateDataInDefaultIMEWindow(HWND hwnd
)
1619 RedrawWindow(hwnd
,NULL
,NULL
,RDW_ERASENOW
|RDW_INVALIDATE
);
1623 * The window proc for the default IME window
1625 static LRESULT WINAPI
IME_WindowProc(HWND hwnd
, UINT msg
, WPARAM wParam
,
1630 TRACE("Incoming Message 0x%x (0x%08x, 0x%08x)\n", msg
, (UINT
)wParam
,
1636 PaintDefaultIMEWnd(hwnd
);
1643 SetWindowTextA(hwnd
,"Wine Ime Active");
1648 SetFocus((HWND
)wParam
);
1650 FIXME("Received focus, should never have focus\n");
1652 case WM_IME_COMPOSITION
:
1653 TRACE("IME message %s, 0x%x, 0x%x (%i)\n",
1654 "WM_IME_COMPOSITION", (UINT
)wParam
, (UINT
)lParam
,
1655 root_context
->bRead
);
1656 if (lParam
& GCS_RESULTSTR
)
1657 IMM_PostResult(root_context
);
1659 UpdateDataInDefaultIMEWindow(hwnd
);
1661 case WM_IME_STARTCOMPOSITION
:
1662 TRACE("IME message %s, 0x%x, 0x%x\n",
1663 "WM_IME_STARTCOMPOSITION", (UINT
)wParam
, (UINT
)lParam
);
1664 root_context
->hwnd
= GetFocus();
1665 ShowWindow(hwndDefault
,SW_SHOWNOACTIVATE
);
1667 case WM_IME_ENDCOMPOSITION
:
1668 TRACE("IME message %s, 0x%x, 0x%x\n",
1669 "WM_IME_ENDCOMPOSITION", (UINT
)wParam
, (UINT
)lParam
);
1670 ShowWindow(hwndDefault
,SW_HIDE
);
1673 TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_SELECT",
1674 (UINT
)wParam
, (UINT
)lParam
);
1676 case WM_IME_CONTROL
:
1677 TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_CONTROL",
1678 (UINT
)wParam
, (UINT
)lParam
);
1682 TRACE("!! IME NOTIFY\n");
1685 TRACE("Non-standard message 0x%x\n",msg
);
1687 /* check the MSIME messages */
1688 if (msg
== WM_MSIME_SERVICE
)
1690 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_SERVICE",
1691 (UINT
)wParam
, (UINT
)lParam
);
1694 else if (msg
== WM_MSIME_RECONVERTOPTIONS
)
1696 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTOPTIONS",
1697 (UINT
)wParam
, (UINT
)lParam
);
1699 else if (msg
== WM_MSIME_MOUSE
)
1701 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_MOUSE",
1702 (UINT
)wParam
, (UINT
)lParam
);
1704 else if (msg
== WM_MSIME_RECONVERTREQUEST
)
1706 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTREQUEST",
1707 (UINT
)wParam
, (UINT
)lParam
);
1709 else if (msg
== WM_MSIME_RECONVERT
)
1711 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERT",
1712 (UINT
)wParam
, (UINT
)lParam
);
1714 else if (msg
== WM_MSIME_QUERYPOSITION
)
1716 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_QUERYPOSITION",
1717 (UINT
)wParam
, (UINT
)lParam
);
1719 else if (msg
== WM_MSIME_DOCUMENTFEED
)
1721 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_DOCUMENTFEED",
1722 (UINT
)wParam
, (UINT
)lParam
);
1724 /* DefWndProc if not an IME message */
1725 else if (!rc
&& !((msg
>= WM_IME_STARTCOMPOSITION
&& msg
<= WM_IME_KEYLAST
) ||
1726 (msg
>= WM_IME_SETCONTEXT
&& msg
<= WM_IME_KEYUP
)))
1727 rc
= DefWindowProcW(hwnd
,msg
,wParam
,lParam
);