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
29 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(imm
);
36 #define FROM_IME 0xcafe1337
38 static void (*pX11DRV_ForceXIMReset
)(HWND
);
40 typedef struct tagIMCCInternal
46 typedef struct tagInputContextData
57 typedef struct _tagTRANSMSG
{
61 } TRANSMSG
, *LPTRANSMSG
;
63 static InputContextData
*root_context
= NULL
;
64 static HWND hwndDefault
= NULL
;
65 static HANDLE hImeInst
;
66 static const WCHAR WC_IMECLASSNAME
[] = {'I','M','E',0};
67 static ATOM atIMEClass
= 0;
70 static UINT WM_MSIME_SERVICE
;
71 static UINT WM_MSIME_RECONVERTOPTIONS
;
72 static UINT WM_MSIME_MOUSE
;
73 static UINT WM_MSIME_RECONVERTREQUEST
;
74 static UINT WM_MSIME_RECONVERT
;
75 static UINT WM_MSIME_QUERYPOSITION
;
76 static UINT WM_MSIME_DOCUMENTFEED
;
81 static LRESULT WINAPI
IME_WindowProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
,
83 static void UpdateDataInDefaultIMEWindow(HWND hwnd
, BOOL showable
);
84 static void ImmInternalPostIMEMessage(UINT
, WPARAM
, LPARAM
);
85 static void ImmInternalSetOpenStatus(BOOL fOpen
);
86 static HIMCC
updateResultStr(HIMCC old
, LPWSTR resultstr
, DWORD len
);
88 static VOID
IMM_PostResult(InputContextData
*data
)
91 LPCOMPOSITIONSTRING compstr
;
96 TRACE("Posting result as IME_CHAR\n");
97 compdata
= ImmLockIMCC(root_context
->IMC
.hCompStr
);
98 compstr
= (LPCOMPOSITIONSTRING
)compdata
;
99 ResultStr
= (LPWSTR
)(compdata
+ compstr
->dwResultStrOffset
);
101 for (i
= 0; i
< compstr
->dwResultStrLen
; i
++)
102 ImmInternalPostIMEMessage (WM_IME_CHAR
, ResultStr
[i
], 1);
104 ImmUnlockIMCC(root_context
->IMC
.hCompStr
);
106 /* clear the buffer */
107 newCompStr
= updateResultStr(root_context
->IMC
.hCompStr
, NULL
, 0);
108 ImmDestroyIMCC(root_context
->IMC
.hCompStr
);
109 root_context
->IMC
.hCompStr
= newCompStr
;
112 static void IMM_Register(void)
115 ZeroMemory(&wndClass
, sizeof(WNDCLASSW
));
116 wndClass
.style
= CS_GLOBALCLASS
| CS_IME
| CS_HREDRAW
| CS_VREDRAW
;
117 wndClass
.lpfnWndProc
= (WNDPROC
) IME_WindowProc
;
118 wndClass
.cbClsExtra
= 0;
119 wndClass
.cbWndExtra
= 0;
120 wndClass
.hInstance
= hImeInst
;
121 wndClass
.hCursor
= LoadCursorW(NULL
, (LPWSTR
)IDC_ARROW
);
122 wndClass
.hIcon
= NULL
;
123 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1);
124 wndClass
.lpszMenuName
= 0;
125 wndClass
.lpszClassName
= WC_IMECLASSNAME
;
126 atIMEClass
= RegisterClassW(&wndClass
);
129 static void IMM_Unregister(void)
132 UnregisterClassW(WC_IMECLASSNAME
, NULL
);
136 static void IMM_RegisterMessages(void)
138 WM_MSIME_SERVICE
= RegisterWindowMessageA("MSIMEService");
139 WM_MSIME_RECONVERTOPTIONS
= RegisterWindowMessageA("MSIMEReconvertOptions");
140 WM_MSIME_MOUSE
= RegisterWindowMessageA("MSIMEMouseOperation");
141 WM_MSIME_RECONVERTREQUEST
= RegisterWindowMessageA("MSIMEReconvertRequest");
142 WM_MSIME_RECONVERT
= RegisterWindowMessageA("MSIMEReconvert");
143 WM_MSIME_QUERYPOSITION
= RegisterWindowMessageA("MSIMEQueryPosition");
144 WM_MSIME_DOCUMENTFEED
= RegisterWindowMessageA("MSIMEDocumentFeed");
148 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpReserved
)
152 TRACE("%p, %x, %p\n",hInstDLL
,fdwReason
,lpReserved
);
155 case DLL_PROCESS_ATTACH
:
156 DisableThreadLibraryCalls(hInstDLL
);
158 IMM_RegisterMessages();
159 x11drv
= GetModuleHandleA("winex11.drv");
160 if (x11drv
) pX11DRV_ForceXIMReset
= (void *)GetProcAddress( x11drv
, "ForceXIMReset");
162 case DLL_PROCESS_DETACH
:
165 DestroyWindow(hwndDefault
);
174 /* for posting messages as the IME */
175 static void ImmInternalPostIMEMessage(UINT msg
, WPARAM wParam
, LPARAM lParam
)
177 HWND target
= GetFocus();
179 PostMessageW(root_context
->IMC
.hWnd
,msg
,wParam
,lParam
);
181 PostMessageW(target
, msg
, wParam
, lParam
);
184 static LRESULT
ImmInternalSendIMENotify(WPARAM notify
, LPARAM lParam
)
188 target
= root_context
->IMC
.hWnd
;
189 if (!target
) target
= GetFocus();
192 return SendMessageW(target
, WM_IME_NOTIFY
, notify
, lParam
);
197 static HIMCC
ImmCreateBlankCompStr(void)
200 LPCOMPOSITIONSTRING ptr
;
201 rc
= ImmCreateIMCC(sizeof(COMPOSITIONSTRING
));
202 ptr
= (LPCOMPOSITIONSTRING
)ImmLockIMCC(rc
);
203 memset(ptr
,0,sizeof(COMPOSITIONSTRING
));
204 ptr
->dwSize
= sizeof(COMPOSITIONSTRING
);
209 static void ImmInternalSetOpenStatus(BOOL fOpen
)
211 TRACE("Setting internal state to %s\n",(fOpen
)?"OPEN":"CLOSED");
213 if (root_context
->IMC
.fOpen
&& fOpen
== FALSE
)
215 ShowWindow(hwndDefault
,SW_HIDE
);
216 ImmDestroyIMCC(root_context
->IMC
.hCompStr
);
217 root_context
->IMC
.hCompStr
= ImmCreateBlankCompStr();
220 root_context
->IMC
.fOpen
= fOpen
;
221 root_context
->bInternalState
= fOpen
;
223 ImmInternalSendIMENotify(IMN_SETOPENSTATUS
, 0);
226 static int updateField(DWORD origLen
, DWORD origOffset
, DWORD currentOffset
,
227 LPBYTE target
, LPBYTE source
, DWORD
* lenParam
,
228 DWORD
* offsetParam
, BOOL wchars
)
230 if (origLen
> 0 && origOffset
> 0)
232 int truelen
= origLen
;
234 truelen
*= sizeof(WCHAR
);
236 memcpy(&target
[currentOffset
], &source
[origOffset
], truelen
);
239 *offsetParam
= currentOffset
;
240 currentOffset
+= truelen
;
242 return currentOffset
;
245 static HIMCC
updateCompStr(HIMCC old
, LPWSTR compstr
, DWORD len
)
247 /* we need to make sure the CompStr, CompClaus and CompAttr fields are all
251 LPBYTE newdata
= NULL
;
252 LPBYTE olddata
= NULL
;
253 LPCOMPOSITIONSTRING new_one
;
254 LPCOMPOSITIONSTRING lpcs
= NULL
;
255 INT current_offset
= 0;
257 TRACE("%s, %i\n",debugstr_wn(compstr
,len
),len
);
259 if (old
== NULL
&& compstr
== NULL
&& len
== 0)
264 olddata
= ImmLockIMCC(old
);
265 lpcs
= (LPCOMPOSITIONSTRING
)olddata
;
268 needed_size
= sizeof(COMPOSITIONSTRING
) + len
* sizeof(WCHAR
) +
269 len
+ sizeof(DWORD
) * 2;
273 needed_size
+= lpcs
->dwCompReadAttrLen
;
274 needed_size
+= lpcs
->dwCompReadClauseLen
;
275 needed_size
+= lpcs
->dwCompReadStrLen
* sizeof(DWORD
);
276 needed_size
+= lpcs
->dwResultReadClauseLen
;
277 needed_size
+= lpcs
->dwResultReadStrLen
* sizeof(DWORD
);
278 needed_size
+= lpcs
->dwResultClauseLen
;
279 needed_size
+= lpcs
->dwResultStrLen
* sizeof(DWORD
);
280 needed_size
+= lpcs
->dwPrivateSize
;
282 rc
= ImmCreateIMCC(needed_size
);
283 newdata
= ImmLockIMCC(rc
);
284 new_one
= (LPCOMPOSITIONSTRING
)newdata
;
286 new_one
->dwSize
= needed_size
;
287 current_offset
= sizeof(COMPOSITIONSTRING
);
290 current_offset
= updateField(lpcs
->dwCompReadAttrLen
,
291 lpcs
->dwCompReadAttrOffset
,
292 current_offset
, newdata
, olddata
,
293 &new_one
->dwCompReadAttrLen
,
294 &new_one
->dwCompReadAttrOffset
, FALSE
);
296 current_offset
= updateField(lpcs
->dwCompReadClauseLen
,
297 lpcs
->dwCompReadClauseOffset
,
298 current_offset
, newdata
, olddata
,
299 &new_one
->dwCompReadClauseLen
,
300 &new_one
->dwCompReadClauseOffset
, FALSE
);
302 current_offset
= updateField(lpcs
->dwCompReadStrLen
,
303 lpcs
->dwCompReadStrOffset
,
304 current_offset
, newdata
, olddata
,
305 &new_one
->dwCompReadStrLen
,
306 &new_one
->dwCompReadStrOffset
, TRUE
);
308 /* new CompAttr, CompClause, CompStr, dwCursorPos */
309 new_one
->dwDeltaStart
= 0;
311 current_offset
= updateField(lpcs
->dwResultReadClauseLen
,
312 lpcs
->dwResultReadClauseOffset
,
313 current_offset
, newdata
, olddata
,
314 &new_one
->dwResultReadClauseLen
,
315 &new_one
->dwResultReadClauseOffset
, FALSE
);
317 current_offset
= updateField(lpcs
->dwResultReadStrLen
,
318 lpcs
->dwResultReadStrOffset
,
319 current_offset
, newdata
, olddata
,
320 &new_one
->dwResultReadStrLen
,
321 &new_one
->dwResultReadStrOffset
, TRUE
);
323 current_offset
= updateField(lpcs
->dwResultClauseLen
,
324 lpcs
->dwResultClauseOffset
,
325 current_offset
, newdata
, olddata
,
326 &new_one
->dwResultClauseLen
,
327 &new_one
->dwResultClauseOffset
, FALSE
);
329 current_offset
= updateField(lpcs
->dwResultStrLen
,
330 lpcs
->dwResultStrOffset
,
331 current_offset
, newdata
, olddata
,
332 &new_one
->dwResultStrLen
,
333 &new_one
->dwResultStrOffset
, TRUE
);
335 current_offset
= updateField(lpcs
->dwPrivateSize
,
336 lpcs
->dwPrivateOffset
,
337 current_offset
, newdata
, olddata
,
338 &new_one
->dwPrivateSize
,
339 &new_one
->dwPrivateOffset
, FALSE
);
344 new_one
->dwCompAttrLen
= len
;
347 new_one
->dwCompAttrOffset
= current_offset
;
348 memset(&newdata
[current_offset
],ATTR_INPUT
,len
);
349 current_offset
+= len
;
355 new_one
->dwCompClauseLen
= sizeof(DWORD
) * 2;
356 new_one
->dwCompClauseOffset
= current_offset
;
357 *(DWORD
*)(&newdata
[current_offset
]) = 0;
358 current_offset
+= sizeof(DWORD
);
359 *(DWORD
*)(&newdata
[current_offset
]) = len
;
360 current_offset
+= sizeof(DWORD
);
364 new_one
->dwCompStrLen
= len
;
367 new_one
->dwCompStrOffset
= current_offset
;
368 memcpy(&newdata
[current_offset
],compstr
,len
*sizeof(WCHAR
));
372 new_one
->dwCursorPos
= len
;
381 static HIMCC
updateResultStr(HIMCC old
, LPWSTR resultstr
, DWORD len
)
383 /* we need to make sure the ResultStr and ResultClause fields are all
387 LPBYTE newdata
= NULL
;
388 LPBYTE olddata
= NULL
;
389 LPCOMPOSITIONSTRING new_one
;
390 LPCOMPOSITIONSTRING lpcs
= NULL
;
391 INT current_offset
= 0;
393 TRACE("%s, %i\n",debugstr_wn(resultstr
,len
),len
);
395 if (old
== NULL
&& resultstr
== NULL
&& len
== 0)
400 olddata
= ImmLockIMCC(old
);
401 lpcs
= (LPCOMPOSITIONSTRING
)olddata
;
404 needed_size
= sizeof(COMPOSITIONSTRING
) + len
* sizeof(WCHAR
) +
409 needed_size
+= lpcs
->dwCompReadAttrLen
;
410 needed_size
+= lpcs
->dwCompReadClauseLen
;
411 needed_size
+= lpcs
->dwCompReadStrLen
* sizeof(DWORD
);
412 needed_size
+= lpcs
->dwCompAttrLen
;
413 needed_size
+= lpcs
->dwCompClauseLen
;
414 needed_size
+= lpcs
->dwCompStrLen
* sizeof(DWORD
);
415 needed_size
+= lpcs
->dwResultReadClauseLen
;
416 needed_size
+= lpcs
->dwResultReadStrLen
* sizeof(DWORD
);
417 needed_size
+= lpcs
->dwPrivateSize
;
419 rc
= ImmCreateIMCC(needed_size
);
420 newdata
= ImmLockIMCC(rc
);
421 new_one
= (LPCOMPOSITIONSTRING
)newdata
;
423 new_one
->dwSize
= needed_size
;
424 current_offset
= sizeof(COMPOSITIONSTRING
);
427 current_offset
= updateField(lpcs
->dwCompReadAttrLen
,
428 lpcs
->dwCompReadAttrOffset
,
429 current_offset
, newdata
, olddata
,
430 &new_one
->dwCompReadAttrLen
,
431 &new_one
->dwCompReadAttrOffset
, FALSE
);
433 current_offset
= updateField(lpcs
->dwCompReadClauseLen
,
434 lpcs
->dwCompReadClauseOffset
,
435 current_offset
, newdata
, olddata
,
436 &new_one
->dwCompReadClauseLen
,
437 &new_one
->dwCompReadClauseOffset
, FALSE
);
439 current_offset
= updateField(lpcs
->dwCompReadStrLen
,
440 lpcs
->dwCompReadStrOffset
,
441 current_offset
, newdata
, olddata
,
442 &new_one
->dwCompReadStrLen
,
443 &new_one
->dwCompReadStrOffset
, TRUE
);
445 current_offset
= updateField(lpcs
->dwCompAttrLen
,
446 lpcs
->dwCompAttrOffset
,
447 current_offset
, newdata
, olddata
,
448 &new_one
->dwCompAttrLen
,
449 &new_one
->dwCompAttrOffset
, FALSE
);
451 current_offset
= updateField(lpcs
->dwCompClauseLen
,
452 lpcs
->dwCompClauseOffset
,
453 current_offset
, newdata
, olddata
,
454 &new_one
->dwCompClauseLen
,
455 &new_one
->dwCompClauseOffset
, FALSE
);
457 current_offset
= updateField(lpcs
->dwCompStrLen
,
458 lpcs
->dwCompStrOffset
,
459 current_offset
, newdata
, olddata
,
460 &new_one
->dwCompStrLen
,
461 &new_one
->dwCompStrOffset
, TRUE
);
463 new_one
->dwCursorPos
= lpcs
->dwCursorPos
;
464 new_one
->dwDeltaStart
= 0;
466 current_offset
= updateField(lpcs
->dwResultReadClauseLen
,
467 lpcs
->dwResultReadClauseOffset
,
468 current_offset
, newdata
, olddata
,
469 &new_one
->dwResultReadClauseLen
,
470 &new_one
->dwResultReadClauseOffset
, FALSE
);
472 current_offset
= updateField(lpcs
->dwResultReadStrLen
,
473 lpcs
->dwResultReadStrOffset
,
474 current_offset
, newdata
, olddata
,
475 &new_one
->dwResultReadStrLen
,
476 &new_one
->dwResultReadStrOffset
, TRUE
);
478 /* new ResultClause , ResultStr */
480 current_offset
= updateField(lpcs
->dwPrivateSize
,
481 lpcs
->dwPrivateOffset
,
482 current_offset
, newdata
, olddata
,
483 &new_one
->dwPrivateSize
,
484 &new_one
->dwPrivateOffset
, FALSE
);
491 new_one
->dwResultClauseLen
= sizeof(DWORD
) * 2;
492 new_one
->dwResultClauseOffset
= current_offset
;
493 *(DWORD
*)(&newdata
[current_offset
]) = 0;
494 current_offset
+= sizeof(DWORD
);
495 *(DWORD
*)(&newdata
[current_offset
]) = len
;
496 current_offset
+= sizeof(DWORD
);
500 new_one
->dwResultStrLen
= len
;
503 new_one
->dwResultStrOffset
= current_offset
;
504 memcpy(&newdata
[current_offset
],resultstr
,len
*sizeof(WCHAR
));
515 /***********************************************************************
516 * ImmAssociateContext (IMM32.@)
518 HIMC WINAPI
ImmAssociateContext(HWND hWnd
, HIMC hIMC
)
520 InputContextData
*data
= (InputContextData
*)hIMC
;
522 WARN("(%p, %p): semi-stub\n", hWnd
, hIMC
);
528 * WINE SPECIFIC! MAY CONFLICT
529 * associate the root context we have an XIM created
533 root_context
= (InputContextData
*)hIMC
;
537 * If already associated just return
539 if (data
->IMC
.hWnd
== hWnd
)
542 if (IsWindow(data
->IMC
.hWnd
))
545 * Post a message that your context is switching
547 SendMessageW(data
->IMC
.hWnd
, WM_IME_SETCONTEXT
, FALSE
, ISC_SHOWUIALL
);
550 data
->IMC
.hWnd
= hWnd
;
552 if (IsWindow(data
->IMC
.hWnd
))
555 * Post a message that your context is switching
557 SendMessageW(data
->IMC
.hWnd
, WM_IME_SETCONTEXT
, TRUE
, ISC_SHOWUIALL
);
561 * TODO: We need to keep track of the old context associated
562 * with a window and return it for now we will return NULL;
567 /***********************************************************************
568 * ImmAssociateContextEx (IMM32.@)
570 BOOL WINAPI
ImmAssociateContextEx(HWND hWnd
, HIMC hIMC
, DWORD dwFlags
)
572 FIXME("(%p, %p, %d): stub\n", hWnd
, hIMC
, dwFlags
);
573 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
577 /***********************************************************************
578 * ImmConfigureIMEA (IMM32.@)
580 BOOL WINAPI
ImmConfigureIMEA(
581 HKL hKL
, HWND hWnd
, DWORD dwMode
, LPVOID lpData
)
583 FIXME("(%p, %p, %d, %p): stub\n",
584 hKL
, hWnd
, dwMode
, lpData
586 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
590 /***********************************************************************
591 * ImmConfigureIMEW (IMM32.@)
593 BOOL WINAPI
ImmConfigureIMEW(
594 HKL hKL
, HWND hWnd
, DWORD dwMode
, LPVOID lpData
)
596 FIXME("(%p, %p, %d, %p): stub\n",
597 hKL
, hWnd
, dwMode
, lpData
599 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
603 /***********************************************************************
604 * ImmCreateContext (IMM32.@)
606 HIMC WINAPI
ImmCreateContext(void)
608 InputContextData
*new_context
;
610 new_context
= HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY
,sizeof(InputContextData
));
612 /* hCompStr is never NULL */
613 new_context
->IMC
.hCompStr
= ImmCreateBlankCompStr();
615 return (HIMC
)new_context
;
618 /***********************************************************************
619 * ImmDestroyContext (IMM32.@)
621 BOOL WINAPI
ImmDestroyContext(HIMC hIMC
)
623 InputContextData
*data
= (InputContextData
*)hIMC
;
625 TRACE("Destroying %p\n",hIMC
);
629 ImmDestroyIMCC(data
->IMC
.hCompStr
);
630 ImmDestroyIMCC(data
->IMC
.hCandInfo
);
631 ImmDestroyIMCC(data
->IMC
.hGuideLine
);
632 ImmDestroyIMCC(data
->IMC
.hPrivate
);
633 ImmDestroyIMCC(data
->IMC
.hMsgBuf
);
637 DeleteObject(data
->textfont
);
638 data
->textfont
= NULL
;
641 HeapFree(GetProcessHeap(),0,data
);
646 /***********************************************************************
647 * ImmDisableIME (IMM32.@)
649 BOOL WINAPI
ImmDisableIME(DWORD idThread
)
651 FIXME("(%d): stub\n", idThread
);
655 /***********************************************************************
656 * ImmEnumRegisterWordA (IMM32.@)
658 UINT WINAPI
ImmEnumRegisterWordA(
659 HKL hKL
, REGISTERWORDENUMPROCA lpfnEnumProc
,
660 LPCSTR lpszReading
, DWORD dwStyle
,
661 LPCSTR lpszRegister
, LPVOID lpData
)
663 FIXME("(%p, %p, %s, %d, %s, %p): stub\n",
665 debugstr_a(lpszReading
), dwStyle
,
666 debugstr_a(lpszRegister
), lpData
668 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
672 /***********************************************************************
673 * ImmEnumRegisterWordW (IMM32.@)
675 UINT WINAPI
ImmEnumRegisterWordW(
676 HKL hKL
, REGISTERWORDENUMPROCW lpfnEnumProc
,
677 LPCWSTR lpszReading
, DWORD dwStyle
,
678 LPCWSTR lpszRegister
, LPVOID lpData
)
680 FIXME("(%p, %p, %s, %d, %s, %p): stub\n",
682 debugstr_w(lpszReading
), dwStyle
,
683 debugstr_w(lpszRegister
), lpData
685 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
689 /***********************************************************************
690 * ImmEscapeA (IMM32.@)
692 LRESULT WINAPI
ImmEscapeA(
694 UINT uEscape
, LPVOID lpData
)
696 FIXME("(%p, %p, %d, %p): stub\n",
697 hKL
, hIMC
, uEscape
, lpData
699 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
703 /***********************************************************************
704 * ImmEscapeW (IMM32.@)
706 LRESULT WINAPI
ImmEscapeW(
708 UINT uEscape
, LPVOID lpData
)
710 FIXME("(%p, %p, %d, %p): stub\n",
711 hKL
, hIMC
, uEscape
, lpData
713 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
717 /***********************************************************************
718 * ImmGetCandidateListA (IMM32.@)
720 DWORD WINAPI
ImmGetCandidateListA(
721 HIMC hIMC
, DWORD deIndex
,
722 LPCANDIDATELIST lpCandList
, DWORD dwBufLen
)
724 FIXME("(%p, %d, %p, %d): stub\n",
728 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
732 /***********************************************************************
733 * ImmGetCandidateListCountA (IMM32.@)
735 DWORD WINAPI
ImmGetCandidateListCountA(
736 HIMC hIMC
, LPDWORD lpdwListCount
)
738 FIXME("(%p, %p): stub\n", hIMC
, lpdwListCount
);
739 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
743 /***********************************************************************
744 * ImmGetCandidateListCountW (IMM32.@)
746 DWORD WINAPI
ImmGetCandidateListCountW(
747 HIMC hIMC
, LPDWORD lpdwListCount
)
749 FIXME("(%p, %p): stub\n", hIMC
, lpdwListCount
);
750 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
754 /***********************************************************************
755 * ImmGetCandidateListW (IMM32.@)
757 DWORD WINAPI
ImmGetCandidateListW(
758 HIMC hIMC
, DWORD deIndex
,
759 LPCANDIDATELIST lpCandList
, DWORD dwBufLen
)
761 FIXME("(%p, %d, %p, %d): stub\n",
765 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
769 /***********************************************************************
770 * ImmGetCandidateWindow (IMM32.@)
772 BOOL WINAPI
ImmGetCandidateWindow(
773 HIMC hIMC
, DWORD dwBufLen
, LPCANDIDATEFORM lpCandidate
)
775 FIXME("(%p, %d, %p): stub\n", hIMC
, dwBufLen
, lpCandidate
);
776 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
780 /***********************************************************************
781 * ImmGetCompositionFontA (IMM32.@)
783 BOOL WINAPI
ImmGetCompositionFontA(HIMC hIMC
, LPLOGFONTA lplf
)
785 FIXME("(%p, %p): stub\n", hIMC
, lplf
);
786 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
790 /***********************************************************************
791 * ImmGetCompositionFontW (IMM32.@)
793 BOOL WINAPI
ImmGetCompositionFontW(HIMC hIMC
, LPLOGFONTW lplf
)
795 FIXME("(%p, %p): stub\n", hIMC
, lplf
);
796 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
800 /***********************************************************************
801 * ImmGetCompositionStringA (IMM32.@)
803 LONG WINAPI
ImmGetCompositionStringA(
804 HIMC hIMC
, DWORD dwIndex
, LPVOID lpBuf
, DWORD dwBufLen
)
808 InputContextData
*data
= (InputContextData
*)hIMC
;
809 LPCOMPOSITIONSTRING compstr
;
812 TRACE("(%p, 0x%x, %p, %d)\n", hIMC
, dwIndex
, lpBuf
, dwBufLen
);
817 if (!data
->IMC
.hCompStr
)
820 compdata
= ImmLockIMCC(data
->IMC
.hCompStr
);
821 compstr
= (LPCOMPOSITIONSTRING
)compdata
;
823 if (dwIndex
== GCS_RESULTSTR
&& compstr
->dwResultStrLen
> 0 &&
824 compstr
->dwResultStrOffset
> 0)
826 LPWSTR ResultStr
= (LPWSTR
)(compdata
+ compstr
->dwResultStrOffset
);
828 TRACE("GSC_RESULTSTR %p %i\n",ResultStr
,
829 compstr
->dwResultStrLen
);
831 buf
= HeapAlloc( GetProcessHeap(), 0, compstr
->dwResultStrLen
* 3 );
832 rc
= WideCharToMultiByte(CP_ACP
, 0, ResultStr
,
833 compstr
->dwResultStrLen
, buf
,
834 compstr
->dwResultStrLen
* 3, NULL
, NULL
);
836 memcpy(lpBuf
,buf
,rc
);
839 HeapFree( GetProcessHeap(), 0, buf
);
841 else if (dwIndex
== GCS_COMPSTR
&& compstr
->dwCompStrLen
> 0 &&
842 compstr
->dwCompStrOffset
> 0)
844 LPWSTR CompString
= (LPWSTR
)(compdata
+ compstr
->dwCompStrOffset
);
846 TRACE("GSC_COMPSTR %p %i\n", CompString
, compstr
->dwCompStrLen
);
848 buf
= HeapAlloc( GetProcessHeap(), 0, compstr
->dwCompStrLen
* 3 );
849 rc
= WideCharToMultiByte(CP_ACP
, 0, CompString
,
850 compstr
->dwCompStrLen
, buf
,
851 compstr
->dwCompStrLen
* 3, NULL
, NULL
);
853 memcpy(lpBuf
,buf
,rc
);
854 HeapFree( GetProcessHeap(), 0, buf
);
856 else if (dwIndex
== GCS_COMPATTR
&& compstr
->dwCompAttrLen
> 0 &&
857 compstr
->dwCompAttrOffset
> 0)
859 LPWSTR Compattr
= (LPWSTR
)(compdata
+ compstr
->dwCompAttrOffset
);
860 TRACE("GSC_COMPATTR %p %i\n", Compattr
, compstr
->dwCompAttrLen
);
862 rc
= compstr
->dwCompAttrLen
;
864 memcpy(lpBuf
,Compattr
,rc
);
866 else if (dwIndex
== GCS_COMPCLAUSE
&& compstr
->dwCompClauseLen
> 0 &&
867 compstr
->dwCompClauseOffset
> 0)
869 LPWSTR Compclause
= (LPWSTR
)(compdata
+ compstr
->dwCompClauseOffset
);
870 TRACE("GSC_COMPCLAUSE %p %i\n", Compclause
, compstr
->dwCompClauseLen
);
872 rc
= compstr
->dwCompClauseLen
;
873 if (dwBufLen
>= compstr
->dwCompClauseLen
)
874 memcpy(lpBuf
,Compclause
,rc
);
876 else if (dwIndex
== GCS_RESULTCLAUSE
&& compstr
->dwResultClauseLen
> 0 &&
877 compstr
->dwResultClauseOffset
> 0)
879 LPWSTR Resultclause
= (LPWSTR
)(compdata
+ compstr
->dwResultClauseOffset
);
880 TRACE("GSC_RESULTCLAUSE %p %i\n", Resultclause
, compstr
->dwResultClauseLen
);
882 rc
= compstr
->dwResultClauseLen
;
883 if (dwBufLen
>= compstr
->dwResultClauseLen
)
884 memcpy(lpBuf
,Resultclause
,rc
);
886 else if (dwIndex
== GCS_CURSORPOS
)
888 TRACE("GSC_CURSORPOS\n");
889 rc
= compstr
->dwCursorPos
;
891 else if (dwIndex
== GCS_DELTASTART
)
893 TRACE("GCS_DELTASTART\n");
894 rc
= compstr
->dwDeltaStart
;
898 FIXME("Unhandled index 0x%x\n",dwIndex
);
901 ImmUnlockIMCC(data
->IMC
.hCompStr
);
906 /***********************************************************************
907 * ImmGetCompositionStringW (IMM32.@)
909 LONG WINAPI
ImmGetCompositionStringW(
910 HIMC hIMC
, DWORD dwIndex
,
911 LPVOID lpBuf
, DWORD dwBufLen
)
914 InputContextData
*data
= (InputContextData
*)hIMC
;
915 LPCOMPOSITIONSTRING compstr
;
918 TRACE("(%p, 0x%x, %p, %d)\n", hIMC
, dwIndex
, lpBuf
, dwBufLen
);
923 if (!data
->IMC
.hCompStr
)
926 compdata
= ImmLockIMCC(data
->IMC
.hCompStr
);
927 compstr
= (LPCOMPOSITIONSTRING
)compdata
;
929 if (dwIndex
== GCS_RESULTSTR
&& compstr
->dwResultStrLen
> 0 &&
930 compstr
->dwResultStrOffset
> 0)
932 LPWSTR ResultStr
= (LPWSTR
)(compdata
+ compstr
->dwResultStrOffset
);
934 rc
= compstr
->dwResultStrLen
* sizeof(WCHAR
);
937 memcpy(lpBuf
,ResultStr
,rc
);
939 else if (dwIndex
== GCS_RESULTREADSTR
&& compstr
->dwResultReadStrLen
> 0 &&
940 compstr
->dwResultReadStrOffset
> 0)
942 LPWSTR ResultReadString
= (LPWSTR
)(compdata
+ compstr
->dwResultReadStrOffset
);
944 rc
= compstr
->dwResultReadStrLen
* sizeof(WCHAR
);
946 memcpy(lpBuf
,ResultReadString
,rc
);
948 else if (dwIndex
== GCS_COMPSTR
&& compstr
->dwCompStrLen
> 0 &&
949 compstr
->dwCompStrOffset
> 0)
951 LPWSTR CompString
= (LPWSTR
)(compdata
+ compstr
->dwCompStrOffset
);
952 rc
= compstr
->dwCompStrLen
* sizeof(WCHAR
);
954 memcpy(lpBuf
,CompString
,rc
);
956 else if (dwIndex
== GCS_COMPATTR
&& compstr
->dwCompAttrLen
> 0 &&
957 compstr
->dwCompAttrOffset
> 0)
960 LPWSTR Compattr
= (LPWSTR
)(compdata
+ compstr
->dwCompAttrOffset
);
962 rc
= compstr
->dwCompAttrLen
;
964 memcpy(lpBuf
,Compattr
,rc
);
966 else if (dwIndex
== GCS_COMPCLAUSE
&& compstr
->dwCompClauseLen
> 0 &&
967 compstr
->dwCompClauseOffset
> 0)
969 LPWSTR Compclause
= (LPWSTR
)(compdata
+ compstr
->dwCompClauseOffset
);
971 rc
= compstr
->dwCompClauseLen
;
972 if (dwBufLen
>= compstr
->dwCompClauseLen
)
973 memcpy(lpBuf
,Compclause
,rc
);
975 else if (dwIndex
== GCS_COMPREADSTR
&& compstr
->dwCompReadStrLen
> 0 &&
976 compstr
->dwCompReadStrOffset
> 0)
978 LPWSTR CompReadString
= (LPWSTR
)(compdata
+ compstr
->dwCompReadStrOffset
);
980 rc
= compstr
->dwCompReadStrLen
* sizeof(WCHAR
);
983 memcpy(lpBuf
,CompReadString
,rc
);
985 else if (dwIndex
== GCS_CURSORPOS
)
987 TRACE("GSC_CURSORPOS\n");
988 rc
= compstr
->dwCursorPos
;
990 else if (dwIndex
== GCS_DELTASTART
)
992 TRACE("GCS_DELTASTART\n");
993 rc
= compstr
->dwDeltaStart
;
997 FIXME("Unhandled index 0x%x\n",dwIndex
);
1000 ImmUnlockIMCC(data
->IMC
.hCompStr
);
1005 /***********************************************************************
1006 * ImmGetCompositionWindow (IMM32.@)
1008 BOOL WINAPI
ImmGetCompositionWindow(HIMC hIMC
, LPCOMPOSITIONFORM lpCompForm
)
1010 InputContextData
*data
= (InputContextData
*)hIMC
;
1012 TRACE("(%p, %p)\n", hIMC
, lpCompForm
);
1017 memcpy(lpCompForm
,&(data
->IMC
.cfCompForm
),sizeof(COMPOSITIONFORM
));
1021 /***********************************************************************
1022 * ImmGetContext (IMM32.@)
1025 HIMC WINAPI
ImmGetContext(HWND hWnd
)
1027 TRACE("%p\n", hWnd
);
1032 root_context
->IMC
.hWnd
= hWnd
;
1033 return (HIMC
)root_context
;
1036 /***********************************************************************
1037 * ImmGetConversionListA (IMM32.@)
1039 DWORD WINAPI
ImmGetConversionListA(
1041 LPCSTR pSrc
, LPCANDIDATELIST lpDst
,
1042 DWORD dwBufLen
, UINT uFlag
)
1044 FIXME("(%p, %p, %s, %p, %d, %d): stub\n",
1045 hKL
, hIMC
, debugstr_a(pSrc
), lpDst
, dwBufLen
, uFlag
1047 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1051 /***********************************************************************
1052 * ImmGetConversionListW (IMM32.@)
1054 DWORD WINAPI
ImmGetConversionListW(
1056 LPCWSTR pSrc
, LPCANDIDATELIST lpDst
,
1057 DWORD dwBufLen
, UINT uFlag
)
1059 FIXME("(%p, %p, %s, %p, %d, %d): stub\n",
1060 hKL
, hIMC
, debugstr_w(pSrc
), lpDst
, dwBufLen
, uFlag
1062 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1066 /***********************************************************************
1067 * ImmGetConversionStatus (IMM32.@)
1069 BOOL WINAPI
ImmGetConversionStatus(
1070 HIMC hIMC
, LPDWORD lpfdwConversion
, LPDWORD lpfdwSentence
)
1072 TRACE("(%p, %p, %p): best guess\n", hIMC
, lpfdwConversion
, lpfdwSentence
);
1073 if (lpfdwConversion
)
1074 *lpfdwConversion
= IME_CMODE_NATIVE
;
1076 *lpfdwSentence
= IME_SMODE_NONE
;
1080 /***********************************************************************
1081 * ImmGetDefaultIMEWnd (IMM32.@)
1083 HWND WINAPI
ImmGetDefaultIMEWnd(HWND hWnd
)
1085 static int shown
= 0;
1088 FIXME("(%p - %p %p ): semi-stub\n", hWnd
,hwndDefault
, root_context
);
1092 if (hwndDefault
== NULL
)
1094 static const WCHAR the_name
[] = {'I','M','E','\0'};
1097 hwndDefault
= CreateWindowExW( WS_EX_TOOLWINDOW
, WC_IMECLASSNAME
,
1098 the_name
, WS_POPUP
, 0, 0, 1, 1, 0, 0,
1101 TRACE("Default created (%p)\n",hwndDefault
);
1107 /***********************************************************************
1108 * ImmGetDescriptionA (IMM32.@)
1110 UINT WINAPI
ImmGetDescriptionA(
1111 HKL hKL
, LPSTR lpszDescription
, UINT uBufLen
)
1116 TRACE("%p %p %d\n", hKL
, lpszDescription
, uBufLen
);
1118 /* find out how many characters in the unicode buffer */
1119 len
= ImmGetDescriptionW( hKL
, NULL
, 0 );
1121 /* allocate a buffer of that size */
1122 buf
= HeapAlloc( GetProcessHeap(), 0, (len
+ 1) * sizeof (WCHAR
) );
1126 /* fetch the unicode buffer */
1127 len
= ImmGetDescriptionW( hKL
, buf
, len
+ 1 );
1129 /* convert it back to ASCII */
1130 len
= WideCharToMultiByte( CP_ACP
, 0, buf
, len
+ 1,
1131 lpszDescription
, uBufLen
, NULL
, NULL
);
1133 HeapFree( GetProcessHeap(), 0, buf
);
1138 /***********************************************************************
1139 * ImmGetDescriptionW (IMM32.@)
1141 UINT WINAPI
ImmGetDescriptionW(HKL hKL
, LPWSTR lpszDescription
, UINT uBufLen
)
1143 static const WCHAR name
[] = { 'W','i','n','e',' ','X','I','M',0 };
1145 FIXME("(%p, %p, %d): semi stub\n", hKL
, lpszDescription
, uBufLen
);
1147 if (!uBufLen
) return lstrlenW( name
);
1148 lstrcpynW( lpszDescription
, name
, uBufLen
);
1149 return lstrlenW( lpszDescription
);
1152 /***********************************************************************
1153 * ImmGetGuideLineA (IMM32.@)
1155 DWORD WINAPI
ImmGetGuideLineA(
1156 HIMC hIMC
, DWORD dwIndex
, LPSTR lpBuf
, DWORD dwBufLen
)
1158 FIXME("(%p, %d, %s, %d): stub\n",
1159 hIMC
, dwIndex
, debugstr_a(lpBuf
), dwBufLen
1161 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1165 /***********************************************************************
1166 * ImmGetGuideLineW (IMM32.@)
1168 DWORD WINAPI
ImmGetGuideLineW(HIMC hIMC
, DWORD dwIndex
, LPWSTR lpBuf
, DWORD dwBufLen
)
1170 FIXME("(%p, %d, %s, %d): stub\n",
1171 hIMC
, dwIndex
, debugstr_w(lpBuf
), dwBufLen
1173 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1177 /***********************************************************************
1178 * ImmGetIMEFileNameA (IMM32.@)
1180 UINT WINAPI
ImmGetIMEFileNameA(
1181 HKL hKL
, LPSTR lpszFileName
, UINT uBufLen
)
1183 FIXME("(%p, %p, %d): stub\n", hKL
, lpszFileName
, uBufLen
);
1184 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1188 /***********************************************************************
1189 * ImmGetIMEFileNameW (IMM32.@)
1191 UINT WINAPI
ImmGetIMEFileNameW(
1192 HKL hKL
, LPWSTR lpszFileName
, UINT uBufLen
)
1194 FIXME("(%p, %p, %d): stub\n", hKL
, lpszFileName
, uBufLen
);
1195 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1199 /***********************************************************************
1200 * ImmGetOpenStatus (IMM32.@)
1202 BOOL WINAPI
ImmGetOpenStatus(HIMC hIMC
)
1204 InputContextData
*data
= (InputContextData
*)hIMC
;
1208 FIXME("(%p): semi-stub\n", hIMC
);
1210 return data
->IMC
.fOpen
;
1213 /***********************************************************************
1214 * ImmGetProperty (IMM32.@)
1216 DWORD WINAPI
ImmGetProperty(HKL hKL
, DWORD fdwIndex
)
1219 TRACE("(%p, %d)\n", hKL
, fdwIndex
);
1224 TRACE("(%s)\n", "IGP_PROPERTY");
1225 rc
= IME_PROP_UNICODE
| IME_PROP_AT_CARET
;
1227 case IGP_CONVERSION
:
1228 FIXME("(%s)\n", "IGP_CONVERSION");
1229 rc
= IME_CMODE_NATIVE
;
1232 FIXME("%s)\n", "IGP_SENTENCE");
1233 rc
= IME_SMODE_AUTOMATIC
;
1235 case IGP_SETCOMPSTR
:
1236 TRACE("(%s)\n", "IGP_SETCOMPSTR");
1240 TRACE("(%s)\n", "IGP_SELECT");
1241 rc
= SELECT_CAP_CONVERSION
| SELECT_CAP_SENTENCE
;
1243 case IGP_GETIMEVERSION
:
1244 TRACE("(%s)\n", "IGP_GETIMEVERSION");
1248 TRACE("(%s)\n", "IGP_UI");
1257 /***********************************************************************
1258 * ImmGetRegisterWordStyleA (IMM32.@)
1260 UINT WINAPI
ImmGetRegisterWordStyleA(
1261 HKL hKL
, UINT nItem
, LPSTYLEBUFA lpStyleBuf
)
1263 FIXME("(%p, %d, %p): stub\n", hKL
, nItem
, lpStyleBuf
);
1264 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1268 /***********************************************************************
1269 * ImmGetRegisterWordStyleW (IMM32.@)
1271 UINT WINAPI
ImmGetRegisterWordStyleW(
1272 HKL hKL
, UINT nItem
, LPSTYLEBUFW lpStyleBuf
)
1274 FIXME("(%p, %d, %p): stub\n", hKL
, nItem
, lpStyleBuf
);
1275 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1279 /***********************************************************************
1280 * ImmGetStatusWindowPos (IMM32.@)
1282 BOOL WINAPI
ImmGetStatusWindowPos(HIMC hIMC
, LPPOINT lpptPos
)
1284 FIXME("(%p, %p): stub\n", hIMC
, lpptPos
);
1285 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1289 /***********************************************************************
1290 * ImmGetVirtualKey (IMM32.@)
1292 UINT WINAPI
ImmGetVirtualKey(HWND hWnd
)
1294 OSVERSIONINFOA version
;
1295 FIXME("(%p): stub\n", hWnd
);
1296 GetVersionExA( &version
);
1297 switch(version
.dwPlatformId
)
1299 case VER_PLATFORM_WIN32_WINDOWS
:
1300 return VK_PROCESSKEY
;
1301 case VER_PLATFORM_WIN32_NT
:
1304 FIXME("%d not supported\n",version
.dwPlatformId
);
1305 return VK_PROCESSKEY
;
1309 /***********************************************************************
1310 * ImmInstallIMEA (IMM32.@)
1312 HKL WINAPI
ImmInstallIMEA(
1313 LPCSTR lpszIMEFileName
, LPCSTR lpszLayoutText
)
1315 FIXME("(%s, %s): stub\n",
1316 debugstr_a(lpszIMEFileName
), debugstr_a(lpszLayoutText
)
1318 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1322 /***********************************************************************
1323 * ImmInstallIMEW (IMM32.@)
1325 HKL WINAPI
ImmInstallIMEW(
1326 LPCWSTR lpszIMEFileName
, LPCWSTR lpszLayoutText
)
1328 FIXME("(%s, %s): stub\n",
1329 debugstr_w(lpszIMEFileName
), debugstr_w(lpszLayoutText
)
1331 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1335 /***********************************************************************
1336 * ImmIsIME (IMM32.@)
1338 BOOL WINAPI
ImmIsIME(HKL hKL
)
1340 TRACE("(%p): semi-stub\n", hKL
);
1342 * FIXME: Dead key locales will return TRUE here when they should not
1343 * There is probably a more proper way to check this.
1345 return (root_context
!= NULL
);
1348 /***********************************************************************
1349 * ImmIsUIMessageA (IMM32.@)
1351 BOOL WINAPI
ImmIsUIMessageA(
1352 HWND hWndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1356 TRACE("(%p, %x, %ld, %ld)\n", hWndIME
, msg
, wParam
, lParam
);
1357 if ((msg
>= WM_IME_STARTCOMPOSITION
&& msg
<= WM_IME_KEYLAST
) ||
1358 (msg
>= WM_IME_SETCONTEXT
&& msg
<= WM_IME_KEYUP
) ||
1359 (msg
== WM_MSIME_SERVICE
) ||
1360 (msg
== WM_MSIME_RECONVERTOPTIONS
) ||
1361 (msg
== WM_MSIME_MOUSE
) ||
1362 (msg
== WM_MSIME_RECONVERTREQUEST
) ||
1363 (msg
== WM_MSIME_RECONVERT
) ||
1364 (msg
== WM_MSIME_QUERYPOSITION
) ||
1365 (msg
== WM_MSIME_DOCUMENTFEED
))
1369 ImmGetDefaultIMEWnd(NULL
);
1371 if (hWndIME
== NULL
)
1372 PostMessageA(hwndDefault
, msg
, wParam
, lParam
);
1379 /***********************************************************************
1380 * ImmIsUIMessageW (IMM32.@)
1382 BOOL WINAPI
ImmIsUIMessageW(
1383 HWND hWndIME
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
1386 TRACE("(%p, %d, %ld, %ld): stub\n", hWndIME
, msg
, wParam
, lParam
);
1387 if ((msg
>= WM_IME_STARTCOMPOSITION
&& msg
<= WM_IME_KEYLAST
) ||
1388 (msg
>= WM_IME_SETCONTEXT
&& msg
<= WM_IME_KEYUP
) ||
1389 (msg
== WM_MSIME_SERVICE
) ||
1390 (msg
== WM_MSIME_RECONVERTOPTIONS
) ||
1391 (msg
== WM_MSIME_MOUSE
) ||
1392 (msg
== WM_MSIME_RECONVERTREQUEST
) ||
1393 (msg
== WM_MSIME_RECONVERT
) ||
1394 (msg
== WM_MSIME_QUERYPOSITION
) ||
1395 (msg
== WM_MSIME_DOCUMENTFEED
))
1400 /***********************************************************************
1401 * ImmNotifyIME (IMM32.@)
1403 BOOL WINAPI
ImmNotifyIME(
1404 HIMC hIMC
, DWORD dwAction
, DWORD dwIndex
, DWORD dwValue
)
1408 TRACE("(%p, %d, %d, %d)\n",
1409 hIMC
, dwAction
, dwIndex
, dwValue
);
1416 case NI_CHANGECANDIDATELIST
:
1417 FIXME("%s\n","NI_CHANGECANDIDATELIST");
1419 case NI_CLOSECANDIDATE
:
1420 FIXME("%s\n","NI_CLOSECANDIDATE");
1422 case NI_COMPOSITIONSTR
:
1426 TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_CANCEL");
1429 LPCOMPOSITIONSTRING lpCompStr
;
1431 if (pX11DRV_ForceXIMReset
)
1432 pX11DRV_ForceXIMReset(root_context
->IMC
.hWnd
);
1434 lpCompStr
= ImmLockIMCC(root_context
->IMC
.hCompStr
);
1435 send
= (lpCompStr
->dwCompStrLen
!= 0);
1436 ImmUnlockIMCC(root_context
->IMC
.hCompStr
);
1438 ImmDestroyIMCC(root_context
->IMC
.hCompStr
);
1439 root_context
->IMC
.hCompStr
= ImmCreateBlankCompStr();
1442 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
, 0,
1448 TRACE("%s - %s\n","NI_COMPOSITIONSTR","CPS_COMPLETE");
1449 if (hIMC
!= (HIMC
)FROM_IME
&& pX11DRV_ForceXIMReset
)
1450 pX11DRV_ForceXIMReset(root_context
->IMC
.hWnd
);
1455 LPCOMPOSITIONSTRING cs
= NULL
;
1456 LPBYTE cdata
= NULL
;
1458 /* clear existing result */
1459 newCompStr
= updateResultStr(root_context
->IMC
.hCompStr
, NULL
, 0);
1460 ImmDestroyIMCC(root_context
->IMC
.hCompStr
);
1461 root_context
->IMC
.hCompStr
= newCompStr
;
1463 if (root_context
->IMC
.hCompStr
)
1465 cdata
= ImmLockIMCC(root_context
->IMC
.hCompStr
);
1466 cs
= (LPCOMPOSITIONSTRING
)cdata
;
1467 cplen
= cs
->dwCompStrLen
;
1468 cpstr
= (LPWSTR
)&(cdata
[cs
->dwCompStrOffset
]);
1469 ImmUnlockIMCC(root_context
->IMC
.hCompStr
);
1473 WCHAR param
= cpstr
[0];
1474 newCompStr
= updateResultStr(root_context
->IMC
.hCompStr
, cpstr
, cplen
);
1475 ImmDestroyIMCC(root_context
->IMC
.hCompStr
);
1476 root_context
->IMC
.hCompStr
= newCompStr
;
1477 newCompStr
= updateCompStr(root_context
->IMC
.hCompStr
, NULL
, 0);
1478 ImmDestroyIMCC(root_context
->IMC
.hCompStr
);
1479 root_context
->IMC
.hCompStr
= newCompStr
;
1481 root_context
->bRead
= FALSE
;
1483 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
, 0,
1486 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
,
1488 GCS_RESULTSTR
|GCS_RESULTCLAUSE
);
1491 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION
, 0, 0);
1492 root_context
->bInComposition
= FALSE
;
1496 FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_CONVERT");
1499 FIXME("%s - %s\n","NI_COMPOSITIONSTR","CPS_REVERT");
1502 ERR("%s - %s (%i)\n","NI_COMPOSITIONSTR","UNKNOWN",dwIndex
);
1506 case NI_IMEMENUSELECTED
:
1507 FIXME("%s\n", "NI_IMEMENUSELECTED");
1509 case NI_OPENCANDIDATE
:
1510 FIXME("%s\n", "NI_OPENCANDIDATE");
1512 case NI_SELECTCANDIDATESTR
:
1513 FIXME("%s\n", "NI_SELECTCANDIDATESTR");
1515 case NI_SETCANDIDATE_PAGESIZE
:
1516 FIXME("%s\n", "NI_SETCANDIDATE_PAGESIZE");
1518 case NI_SETCANDIDATE_PAGESTART
:
1519 FIXME("%s\n", "NI_SETCANDIDATE_PAGESTART");
1528 /***********************************************************************
1529 * ImmRegisterWordA (IMM32.@)
1531 BOOL WINAPI
ImmRegisterWordA(
1532 HKL hKL
, LPCSTR lpszReading
, DWORD dwStyle
, LPCSTR lpszRegister
)
1534 FIXME("(%p, %s, %d, %s): stub\n",
1535 hKL
, debugstr_a(lpszReading
), dwStyle
, debugstr_a(lpszRegister
)
1537 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1541 /***********************************************************************
1542 * ImmRegisterWordW (IMM32.@)
1544 BOOL WINAPI
ImmRegisterWordW(
1545 HKL hKL
, LPCWSTR lpszReading
, DWORD dwStyle
, LPCWSTR lpszRegister
)
1547 FIXME("(%p, %s, %d, %s): stub\n",
1548 hKL
, debugstr_w(lpszReading
), dwStyle
, debugstr_w(lpszRegister
)
1550 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1554 /***********************************************************************
1555 * ImmReleaseContext (IMM32.@)
1557 BOOL WINAPI
ImmReleaseContext(HWND hWnd
, HIMC hIMC
)
1559 static int shown
= 0;
1562 FIXME("(%p, %p): stub\n", hWnd
, hIMC
);
1568 /***********************************************************************
1569 * ImmSetCandidateWindow (IMM32.@)
1571 BOOL WINAPI
ImmSetCandidateWindow(
1572 HIMC hIMC
, LPCANDIDATEFORM lpCandidate
)
1574 FIXME("(%p, %p): stub\n", hIMC
, lpCandidate
);
1575 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1579 /***********************************************************************
1580 * ImmSetCompositionFontA (IMM32.@)
1582 BOOL WINAPI
ImmSetCompositionFontA(HIMC hIMC
, LPLOGFONTA lplf
)
1584 InputContextData
*data
= (InputContextData
*)hIMC
;
1585 TRACE("(%p, %p)\n", hIMC
, lplf
);
1590 memcpy(&data
->IMC
.lfFont
.W
,lplf
,sizeof(LOGFONTA
));
1591 MultiByteToWideChar(CP_ACP
, 0, lplf
->lfFaceName
, -1, data
->IMC
.lfFont
.W
.lfFaceName
,
1594 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONFONT
, 0);
1598 DeleteObject(data
->textfont
);
1599 data
->textfont
= NULL
;
1602 data
->textfont
= CreateFontIndirectW(&data
->IMC
.lfFont
.W
);
1606 /***********************************************************************
1607 * ImmSetCompositionFontW (IMM32.@)
1609 BOOL WINAPI
ImmSetCompositionFontW(HIMC hIMC
, LPLOGFONTW lplf
)
1611 InputContextData
*data
= (InputContextData
*)hIMC
;
1612 TRACE("(%p, %p)\n", hIMC
, lplf
);
1617 memcpy(&data
->IMC
.lfFont
.W
,lplf
,sizeof(LOGFONTW
));
1618 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONFONT
, 0);
1622 DeleteObject(data
->textfont
);
1623 data
->textfont
= NULL
;
1625 data
->textfont
= CreateFontIndirectW(&data
->IMC
.lfFont
.W
);
1629 /***********************************************************************
1630 * ImmSetCompositionStringA (IMM32.@)
1632 BOOL WINAPI
ImmSetCompositionStringA(
1633 HIMC hIMC
, DWORD dwIndex
,
1634 LPCVOID lpComp
, DWORD dwCompLen
,
1635 LPCVOID lpRead
, DWORD dwReadLen
)
1639 WCHAR
*CompBuffer
= NULL
;
1640 WCHAR
*ReadBuffer
= NULL
;
1643 TRACE("(%p, %d, %p, %d, %p, %d): stub\n",
1644 hIMC
, dwIndex
, lpComp
, dwCompLen
, lpRead
, dwReadLen
);
1646 comp_len
= MultiByteToWideChar(CP_ACP
, 0, lpComp
, dwCompLen
, NULL
, 0);
1649 CompBuffer
= HeapAlloc(GetProcessHeap(),0,comp_len
* sizeof(WCHAR
));
1650 MultiByteToWideChar(CP_ACP
, 0, lpComp
, dwCompLen
, CompBuffer
, comp_len
);
1653 read_len
= MultiByteToWideChar(CP_ACP
, 0, lpRead
, dwReadLen
, NULL
, 0);
1656 ReadBuffer
= HeapAlloc(GetProcessHeap(),0,read_len
* sizeof(WCHAR
));
1657 MultiByteToWideChar(CP_ACP
, 0, lpRead
, dwReadLen
, ReadBuffer
, read_len
);
1660 rc
= ImmSetCompositionStringW(hIMC
, dwIndex
, CompBuffer
, comp_len
,
1661 ReadBuffer
, read_len
);
1663 HeapFree(GetProcessHeap(), 0, CompBuffer
);
1664 HeapFree(GetProcessHeap(), 0, ReadBuffer
);
1669 /***********************************************************************
1670 * ImmSetCompositionStringW (IMM32.@)
1672 BOOL WINAPI
ImmSetCompositionStringW(
1673 HIMC hIMC
, DWORD dwIndex
,
1674 LPCVOID lpComp
, DWORD dwCompLen
,
1675 LPCVOID lpRead
, DWORD dwReadLen
)
1680 TRACE("(%p, %d, %p, %d, %p, %d): stub\n",
1681 hIMC
, dwIndex
, lpComp
, dwCompLen
, lpRead
, dwReadLen
);
1684 if (hIMC
!= (HIMC
)FROM_IME
)
1685 FIXME("PROBLEM: This only sets the wine level string\n");
1689 * this sets the composition string in the imm32.dll level
1690 * of the composition buffer. we cannot manipulate the xim level
1691 * buffer, which means that once the xim level buffer changes again
1692 * any call to this function from the application will be lost
1695 if (lpRead
&& dwReadLen
)
1696 FIXME("Reading string unimplemented\n");
1699 * app operating this api to also receive the message from xim
1702 if (dwIndex
== SCS_SETSTR
)
1705 if (!root_context
->bInComposition
)
1707 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION
, 0, 0);
1708 root_context
->bInComposition
= TRUE
;
1711 flags
= GCS_COMPSTR
;
1713 if (dwCompLen
&& lpComp
)
1715 newCompStr
= updateCompStr(root_context
->IMC
.hCompStr
, (LPWSTR
)lpComp
, dwCompLen
/ sizeof(WCHAR
));
1716 ImmDestroyIMCC(root_context
->IMC
.hCompStr
);
1717 root_context
->IMC
.hCompStr
= newCompStr
;
1719 wParam
= ((const WCHAR
*)lpComp
)[0];
1720 flags
|= GCS_COMPCLAUSE
| GCS_COMPATTR
| GCS_DELTASTART
;
1724 newCompStr
= updateCompStr(root_context
->IMC
.hCompStr
, NULL
, 0);
1725 ImmDestroyIMCC(root_context
->IMC
.hCompStr
);
1726 root_context
->IMC
.hCompStr
= newCompStr
;
1730 UpdateDataInDefaultIMEWindow(hwndDefault
,FALSE
);
1732 ImmInternalPostIMEMessage(WM_IME_COMPOSITION
, wParam
, flags
);
1737 /***********************************************************************
1738 * ImmSetCompositionWindow (IMM32.@)
1740 BOOL WINAPI
ImmSetCompositionWindow(
1741 HIMC hIMC
, LPCOMPOSITIONFORM lpCompForm
)
1743 BOOL reshow
= FALSE
;
1744 InputContextData
*data
= (InputContextData
*)hIMC
;
1746 TRACE("(%p, %p)\n", hIMC
, lpCompForm
);
1747 TRACE("\t%x, (%i,%i), (%i,%i - %i,%i)\n",lpCompForm
->dwStyle
,
1748 lpCompForm
->ptCurrentPos
.x
, lpCompForm
->ptCurrentPos
.y
, lpCompForm
->rcArea
.top
,
1749 lpCompForm
->rcArea
.left
, lpCompForm
->rcArea
.bottom
, lpCompForm
->rcArea
.right
);
1754 memcpy(&data
->IMC
.cfCompForm
,lpCompForm
,sizeof(COMPOSITIONFORM
));
1756 if (IsWindowVisible(hwndDefault
))
1759 ShowWindow(hwndDefault
,SW_HIDE
);
1762 /* FIXME: this is a partial stub */
1765 ShowWindow(hwndDefault
,SW_SHOWNOACTIVATE
);
1767 ImmInternalSendIMENotify(IMN_SETCOMPOSITIONWINDOW
, 0);
1771 /***********************************************************************
1772 * ImmSetConversionStatus (IMM32.@)
1774 BOOL WINAPI
ImmSetConversionStatus(
1775 HIMC hIMC
, DWORD fdwConversion
, DWORD fdwSentence
)
1777 static int shown
= 0;
1780 FIXME("(%p, %d, %d): stub\n",
1781 hIMC
, fdwConversion
, fdwSentence
1785 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1789 /***********************************************************************
1790 * ImmSetOpenStatus (IMM32.@)
1792 BOOL WINAPI
ImmSetOpenStatus(HIMC hIMC
, BOOL fOpen
)
1794 InputContextData
*data
= (InputContextData
*)hIMC
;
1796 TRACE("%p %d\n", hIMC
, fOpen
);
1798 if (hIMC
== (HIMC
)FROM_IME
)
1800 ImmInternalSetOpenStatus(fOpen
);
1801 ImmInternalSendIMENotify(IMN_SETOPENSTATUS
, 0);
1808 if (fOpen
!= data
->bInternalState
)
1810 if (fOpen
== FALSE
&& pX11DRV_ForceXIMReset
)
1811 pX11DRV_ForceXIMReset(data
->IMC
.hWnd
);
1814 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION
,0,0);
1816 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION
,0,0);
1818 ImmInternalSetOpenStatus(fOpen
);
1819 ImmInternalSetOpenStatus(!fOpen
);
1821 if (data
->IMC
.fOpen
== FALSE
)
1822 ImmInternalPostIMEMessage(WM_IME_ENDCOMPOSITION
,0,0);
1824 ImmInternalPostIMEMessage(WM_IME_STARTCOMPOSITION
,0,0);
1831 /***********************************************************************
1832 * ImmSetStatusWindowPos (IMM32.@)
1834 BOOL WINAPI
ImmSetStatusWindowPos(HIMC hIMC
, LPPOINT lpptPos
)
1836 FIXME("(%p, %p): stub\n", hIMC
, lpptPos
);
1837 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1841 /***********************************************************************
1842 * ImmSimulateHotKey (IMM32.@)
1844 BOOL WINAPI
ImmSimulateHotKey(HWND hWnd
, DWORD dwHotKeyID
)
1846 FIXME("(%p, %d): stub\n", hWnd
, dwHotKeyID
);
1847 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1851 /***********************************************************************
1852 * ImmUnregisterWordA (IMM32.@)
1854 BOOL WINAPI
ImmUnregisterWordA(
1855 HKL hKL
, LPCSTR lpszReading
, DWORD dwStyle
, LPCSTR lpszUnregister
)
1857 FIXME("(%p, %s, %d, %s): stub\n",
1858 hKL
, debugstr_a(lpszReading
), dwStyle
, debugstr_a(lpszUnregister
)
1860 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1864 /***********************************************************************
1865 * ImmUnregisterWordW (IMM32.@)
1867 BOOL WINAPI
ImmUnregisterWordW(
1868 HKL hKL
, LPCWSTR lpszReading
, DWORD dwStyle
, LPCWSTR lpszUnregister
)
1870 FIXME("(%p, %s, %d, %s): stub\n",
1871 hKL
, debugstr_w(lpszReading
), dwStyle
, debugstr_w(lpszUnregister
)
1873 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1877 /***********************************************************************
1878 * ImmGetImeMenuItemsA (IMM32.@)
1880 DWORD WINAPI
ImmGetImeMenuItemsA( HIMC hIMC
, DWORD dwFlags
, DWORD dwType
,
1881 LPIMEMENUITEMINFOA lpImeParentMenu
, LPIMEMENUITEMINFOA lpImeMenu
,
1884 FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC
, dwFlags
, dwType
,
1885 lpImeParentMenu
, lpImeMenu
, dwSize
);
1889 /***********************************************************************
1890 * ImmGetImeMenuItemsW (IMM32.@)
1892 DWORD WINAPI
ImmGetImeMenuItemsW( HIMC hIMC
, DWORD dwFlags
, DWORD dwType
,
1893 LPIMEMENUITEMINFOW lpImeParentMenu
, LPIMEMENUITEMINFOW lpImeMenu
,
1896 FIXME("(%p, %i, %i, %p, %p, %i): stub\n", hIMC
, dwFlags
, dwType
,
1897 lpImeParentMenu
, lpImeMenu
, dwSize
);
1901 /***********************************************************************
1902 * ImmLockIMC(IMM32.@)
1904 LPINPUTCONTEXT WINAPI
ImmLockIMC(HIMC hIMC
)
1906 InputContextData
*data
= (InputContextData
*)hIMC
;
1914 /***********************************************************************
1915 * ImmUnlockIMC(IMM32.@)
1917 BOOL WINAPI
ImmUnlockIMC(HIMC hIMC
)
1919 InputContextData
*data
= (InputContextData
*)hIMC
;
1921 return (data
->dwLock
!=0);
1924 /***********************************************************************
1925 * ImmGetIMCLockCount(IMM32.@)
1927 DWORD WINAPI
ImmGetIMCLockCount(HIMC hIMC
)
1929 InputContextData
*data
= (InputContextData
*)hIMC
;
1930 return data
->dwLock
;
1933 /***********************************************************************
1934 * ImmCreateIMCC(IMM32.@)
1936 HIMCC WINAPI
ImmCreateIMCC(DWORD size
)
1938 IMCCInternal
*internal
;
1939 int real_size
= size
+ sizeof(IMCCInternal
);
1941 internal
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, real_size
);
1942 if (internal
== NULL
)
1945 internal
->dwSize
= size
;
1946 return (HIMCC
)internal
;
1949 /***********************************************************************
1950 * ImmDestroyIMCC(IMM32.@)
1952 HIMCC WINAPI
ImmDestroyIMCC(HIMCC block
)
1954 HeapFree(GetProcessHeap(),0,block
);
1958 /***********************************************************************
1959 * ImmLockIMCC(IMM32.@)
1961 LPVOID WINAPI
ImmLockIMCC(HIMCC imcc
)
1963 IMCCInternal
*internal
;
1964 internal
= (IMCCInternal
*) imcc
;
1966 internal
->dwLock
++;
1967 return internal
+ 1;
1970 /***********************************************************************
1971 * ImmUnlockIMCC(IMM32.@)
1973 BOOL WINAPI
ImmUnlockIMCC(HIMCC imcc
)
1975 IMCCInternal
*internal
;
1976 internal
= (IMCCInternal
*) imcc
;
1978 internal
->dwLock
--;
1979 return (internal
->dwLock
!=0);
1982 /***********************************************************************
1983 * ImmGetIMCCLockCount(IMM32.@)
1985 DWORD WINAPI
ImmGetIMCCLockCount(HIMCC imcc
)
1987 IMCCInternal
*internal
;
1988 internal
= (IMCCInternal
*) imcc
;
1990 return internal
->dwLock
;
1993 /***********************************************************************
1994 * ImmReSizeIMCC(IMM32.@)
1996 HIMCC WINAPI
ImmReSizeIMCC(HIMCC imcc
, DWORD size
)
1998 IMCCInternal
*internal
,*newone
;
1999 int real_size
= size
+ sizeof(IMCCInternal
);
2001 internal
= (IMCCInternal
*) imcc
;
2003 newone
= HeapReAlloc(GetProcessHeap(), 0, internal
, real_size
);
2004 newone
->dwSize
= size
;
2009 /***********************************************************************
2010 * ImmGetIMCCSize(IMM32.@)
2012 DWORD WINAPI
ImmGetIMCCSize(HIMCC imcc
)
2014 IMCCInternal
*internal
;
2015 internal
= (IMCCInternal
*) imcc
;
2017 return internal
->dwSize
;
2020 /***********************************************************************
2021 * ImmGenerateMessage(IMM32.@)
2023 BOOL WINAPI
ImmGenerateMessage(HIMC hIMC
)
2025 InputContextData
*data
= (InputContextData
*)hIMC
;
2027 TRACE("%i messages queued\n",data
->IMC
.dwNumMsgBuf
);
2028 if (data
->IMC
.dwNumMsgBuf
> 0)
2030 LPTRANSMSG lpTransMsg
;
2033 lpTransMsg
= (LPTRANSMSG
)ImmLockIMCC(data
->IMC
.hMsgBuf
);
2034 for (i
= 0; i
< data
->IMC
.dwNumMsgBuf
; i
++)
2035 ImmInternalPostIMEMessage(lpTransMsg
[i
].message
, lpTransMsg
[i
].wParam
, lpTransMsg
[i
].lParam
);
2037 ImmUnlockIMCC(data
->IMC
.hMsgBuf
);
2038 ImmDestroyIMCC(data
->IMC
.hMsgBuf
);
2040 data
->IMC
.dwNumMsgBuf
= 0;
2041 data
->IMC
.hMsgBuf
= NULL
;
2048 * Internal functions to help with IME window management
2050 static void PaintDefaultIMEWnd(HWND hwnd
)
2054 HDC hdc
= BeginPaint(hwnd
,&ps
);
2055 LPCOMPOSITIONSTRING compstr
;
2056 LPBYTE compdata
= NULL
;
2058 MONITORINFO mon_info
;
2061 GetClientRect(hwnd
,&rect
);
2062 FillRect(hdc
, &rect
, (HBRUSH
)(COLOR_WINDOW
+ 1));
2064 compdata
= ImmLockIMCC(root_context
->IMC
.hCompStr
);
2065 compstr
= (LPCOMPOSITIONSTRING
)compdata
;
2067 if (compstr
->dwCompStrLen
&& compstr
->dwCompStrOffset
)
2071 HFONT oldfont
= NULL
;
2074 CompString
= (LPWSTR
)(compdata
+ compstr
->dwCompStrOffset
);
2075 if (root_context
->textfont
)
2076 oldfont
= SelectObject(hdc
,root_context
->textfont
);
2079 GetTextExtentPoint32W(hdc
, CompString
, compstr
->dwCompStrLen
, &size
);
2085 * How this works based on tests on windows:
2086 * CFS_POINT: then we start our window at the point and grow it as large
2087 * as it needs to be for the string.
2088 * CFS_RECT: we still use the ptCurrentPos as a starting point and our
2089 * window is only as large as we need for the string, but we do not
2090 * grow such that our window exceeds the given rect. Wrapping if
2091 * needed and possible. If our ptCurrentPos is outside of our rect
2092 * then no window is displayed.
2093 * CFS_FORCE_POSITION: appears to behave just like CFS_POINT
2094 * maybe becase the default MSIME does not do any IME adjusting.
2096 if (root_context
->IMC
.cfCompForm
.dwStyle
!= CFS_DEFAULT
)
2098 POINT cpt
= root_context
->IMC
.cfCompForm
.ptCurrentPos
;
2099 ClientToScreen(root_context
->IMC
.hWnd
,&cpt
);
2102 rect
.right
= rect
.left
+ pt
.x
;
2103 rect
.bottom
= rect
.top
+ pt
.y
;
2104 monitor
= MonitorFromPoint(cpt
, MONITOR_DEFAULTTOPRIMARY
);
2106 else /* CFS_DEFAULT */
2108 /* Windows places the default IME window in the bottom left */
2109 HWND target
= root_context
->IMC
.hWnd
;
2110 if (!target
) target
= GetFocus();
2112 GetWindowRect(target
,&rect
);
2113 rect
.top
= rect
.bottom
;
2114 rect
.right
= rect
.left
+ pt
.x
+ 20;
2115 rect
.bottom
= rect
.top
+ pt
.y
+ 20;
2117 monitor
= MonitorFromWindow(target
, MONITOR_DEFAULTTOPRIMARY
);
2120 if (root_context
->IMC
.cfCompForm
.dwStyle
== CFS_RECT
)
2123 client
=root_context
->IMC
.cfCompForm
.rcArea
;
2124 MapWindowPoints( root_context
->IMC
.hWnd
, 0, (POINT
*)&client
, 2 );
2125 IntersectRect(&rect
,&rect
,&client
);
2126 /* TODO: Wrap the input if needed */
2129 if (root_context
->IMC
.cfCompForm
.dwStyle
== CFS_DEFAULT
)
2131 /* make sure we are on the desktop */
2132 mon_info
.cbSize
= sizeof(mon_info
);
2133 GetMonitorInfoW(monitor
, &mon_info
);
2135 if (rect
.bottom
> mon_info
.rcWork
.bottom
)
2137 int shift
= rect
.bottom
- mon_info
.rcWork
.bottom
;
2139 rect
.bottom
-= shift
;
2143 rect
.right
-= rect
.left
;
2146 if (rect
.right
> mon_info
.rcWork
.right
)
2148 int shift
= rect
.right
- mon_info
.rcWork
.right
;
2150 rect
.right
-= shift
;
2154 SetWindowPos(hwnd
, HWND_TOPMOST
, rect
.left
, rect
.top
, rect
.right
- rect
.left
, rect
.bottom
- rect
.top
, SWP_NOACTIVATE
);
2156 TextOutW(hdc
, offX
,offY
, CompString
, compstr
->dwCompStrLen
);
2159 SelectObject(hdc
,oldfont
);
2162 ImmUnlockIMCC(root_context
->IMC
.hCompStr
);
2167 static void UpdateDataInDefaultIMEWindow(HWND hwnd
, BOOL showable
)
2169 LPCOMPOSITIONSTRING compstr
;
2171 if (root_context
->IMC
.hCompStr
)
2172 compstr
= ImmLockIMCC(root_context
->IMC
.hCompStr
);
2176 if (compstr
== NULL
|| compstr
->dwCompStrLen
== 0)
2177 ShowWindow(hwndDefault
,SW_HIDE
);
2179 ShowWindow(hwndDefault
,SW_SHOWNOACTIVATE
);
2181 RedrawWindow(hwnd
,NULL
,NULL
,RDW_ERASENOW
|RDW_INVALIDATE
);
2183 if (compstr
!= NULL
)
2184 ImmUnlockIMCC(root_context
->IMC
.hCompStr
);
2188 * The window proc for the default IME window
2190 static LRESULT WINAPI
IME_WindowProc(HWND hwnd
, UINT msg
, WPARAM wParam
,
2195 TRACE("Incoming Message 0x%x (0x%08x, 0x%08x)\n", msg
, (UINT
)wParam
,
2201 PaintDefaultIMEWnd(hwnd
);
2208 SetWindowTextA(hwnd
,"Wine Ime Active");
2213 SetFocus((HWND
)wParam
);
2215 FIXME("Received focus, should never have focus\n");
2217 case WM_IME_COMPOSITION
:
2218 TRACE("IME message %s, 0x%x, 0x%x (%i)\n",
2219 "WM_IME_COMPOSITION", (UINT
)wParam
, (UINT
)lParam
,
2220 root_context
->bRead
);
2221 if (lParam
& GCS_RESULTSTR
)
2222 IMM_PostResult(root_context
);
2224 UpdateDataInDefaultIMEWindow(hwnd
,TRUE
);
2226 case WM_IME_STARTCOMPOSITION
:
2227 TRACE("IME message %s, 0x%x, 0x%x\n",
2228 "WM_IME_STARTCOMPOSITION", (UINT
)wParam
, (UINT
)lParam
);
2229 root_context
->IMC
.hWnd
= GetFocus();
2230 ShowWindow(hwndDefault
,SW_SHOWNOACTIVATE
);
2232 case WM_IME_ENDCOMPOSITION
:
2233 TRACE("IME message %s, 0x%x, 0x%x\n",
2234 "WM_IME_ENDCOMPOSITION", (UINT
)wParam
, (UINT
)lParam
);
2235 ShowWindow(hwndDefault
,SW_HIDE
);
2238 TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_SELECT",
2239 (UINT
)wParam
, (UINT
)lParam
);
2241 case WM_IME_CONTROL
:
2242 TRACE("IME message %s, 0x%x, 0x%x\n","WM_IME_CONTROL",
2243 (UINT
)wParam
, (UINT
)lParam
);
2247 TRACE("!! IME NOTIFY\n");
2250 TRACE("Non-standard message 0x%x\n",msg
);
2252 /* check the MSIME messages */
2253 if (msg
== WM_MSIME_SERVICE
)
2255 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_SERVICE",
2256 (UINT
)wParam
, (UINT
)lParam
);
2259 else if (msg
== WM_MSIME_RECONVERTOPTIONS
)
2261 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTOPTIONS",
2262 (UINT
)wParam
, (UINT
)lParam
);
2264 else if (msg
== WM_MSIME_MOUSE
)
2266 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_MOUSE",
2267 (UINT
)wParam
, (UINT
)lParam
);
2269 else if (msg
== WM_MSIME_RECONVERTREQUEST
)
2271 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERTREQUEST",
2272 (UINT
)wParam
, (UINT
)lParam
);
2274 else if (msg
== WM_MSIME_RECONVERT
)
2276 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_RECONVERT",
2277 (UINT
)wParam
, (UINT
)lParam
);
2279 else if (msg
== WM_MSIME_QUERYPOSITION
)
2281 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_QUERYPOSITION",
2282 (UINT
)wParam
, (UINT
)lParam
);
2284 else if (msg
== WM_MSIME_DOCUMENTFEED
)
2286 TRACE("IME message %s, 0x%x, 0x%x\n","WM_MSIME_DOCUMENTFEED",
2287 (UINT
)wParam
, (UINT
)lParam
);
2289 /* DefWndProc if not an IME message */
2290 else if (!rc
&& !((msg
>= WM_IME_STARTCOMPOSITION
&& msg
<= WM_IME_KEYLAST
) ||
2291 (msg
>= WM_IME_SETCONTEXT
&& msg
<= WM_IME_KEYUP
)))
2292 rc
= DefWindowProcW(hwnd
,msg
,wParam
,lParam
);