xref: /reactos/dll/win32/msimtf/activeimmapp.c (revision 02e84521)
1 /*
2  *  ActiveIMMApp Interface
3  *
4  *  Copyright 2008  CodeWeavers, Aric Stewart
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #include "config.h"
22 
23 #include <stdarg.h>
24 
25 #define COBJMACROS
26 
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "winreg.h"
31 #include "winuser.h"
32 #include "winerror.h"
33 #include "objbase.h"
34 #include "dimm.h"
35 #include "imm.h"
36 
37 #include "wine/unicode.h"
38 
39 #include "wine/debug.h"
40 
41 WINE_DEFAULT_DEBUG_CHANNEL(msimtf);
42 
43 typedef struct tagActiveIMMApp {
44     IActiveIMMApp IActiveIMMApp_iface;
45     IActiveIMMMessagePumpOwner IActiveIMMMessagePumpOwner_iface;
46     LONG refCount;
47 } ActiveIMMApp;
48 
49 static inline ActiveIMMApp *impl_from_IActiveIMMApp(IActiveIMMApp *iface)
50 {
51     return CONTAINING_RECORD(iface, ActiveIMMApp, IActiveIMMApp_iface);
52 }
53 
54 static void ActiveIMMApp_Destructor(ActiveIMMApp* This)
55 {
56     TRACE("\n");
57     HeapFree(GetProcessHeap(),0,This);
58 }
59 
60 static HRESULT WINAPI ActiveIMMApp_QueryInterface (IActiveIMMApp* iface,
61         REFIID iid, LPVOID *ppvOut)
62 {
63     ActiveIMMApp *This = impl_from_IActiveIMMApp(iface);
64     *ppvOut = NULL;
65 
66     if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_IActiveIMMApp))
67     {
68         *ppvOut = &This->IActiveIMMApp_iface;
69     }
70     else if (IsEqualIID(iid, &IID_IActiveIMMMessagePumpOwner))
71     {
72         *ppvOut = &This->IActiveIMMMessagePumpOwner_iface;
73     }
74 
75     if (*ppvOut)
76     {
77         IUnknown_AddRef(iface);
78         return S_OK;
79     }
80 
81     WARN("unsupported interface: %s\n", debugstr_guid(iid));
82     return E_NOINTERFACE;
83 }
84 
85 static ULONG WINAPI ActiveIMMApp_AddRef(IActiveIMMApp* iface)
86 {
87     ActiveIMMApp *This = impl_from_IActiveIMMApp(iface);
88     return InterlockedIncrement(&This->refCount);
89 }
90 
91 static ULONG WINAPI ActiveIMMApp_Release(IActiveIMMApp* iface)
92 {
93     ActiveIMMApp *This = impl_from_IActiveIMMApp(iface);
94     ULONG ret;
95 
96     ret = InterlockedDecrement(&This->refCount);
97     if (ret == 0)
98         ActiveIMMApp_Destructor(This);
99     return ret;
100 }
101 
102 static HRESULT WINAPI ActiveIMMApp_AssociateContext(IActiveIMMApp* iface,
103         HWND hWnd, HIMC hIME, HIMC *phPrev)
104 {
105     *phPrev = ImmAssociateContext(hWnd,hIME);
106     return S_OK;
107 }
108 
109 static HRESULT WINAPI ActiveIMMApp_ConfigureIMEA(IActiveIMMApp* This,
110         HKL hKL, HWND hwnd, DWORD dwMode, REGISTERWORDA *pData)
111 {
112     BOOL rc;
113 
114     rc = ImmConfigureIMEA(hKL, hwnd, dwMode, pData);
115     if (rc)
116         return E_FAIL;
117     else
118         return S_OK;
119 }
120 
121 static HRESULT WINAPI ActiveIMMApp_ConfigureIMEW(IActiveIMMApp* This,
122         HKL hKL, HWND hWnd, DWORD dwMode, REGISTERWORDW *pData)
123 {
124     BOOL rc;
125 
126     rc = ImmConfigureIMEW(hKL, hWnd, dwMode, pData);
127     if (rc)
128         return E_FAIL;
129     else
130         return S_OK;
131 }
132 
133 static HRESULT WINAPI ActiveIMMApp_CreateContext(IActiveIMMApp* This,
134         HIMC *phIMC)
135 {
136     *phIMC = ImmCreateContext();
137     if (*phIMC)
138         return S_OK;
139     else
140         return E_FAIL;
141 }
142 
143 static HRESULT WINAPI ActiveIMMApp_DestroyContext(IActiveIMMApp* This,
144         HIMC hIME)
145 {
146     BOOL rc;
147 
148     rc = ImmDestroyContext(hIME);
149     if (rc)
150         return S_OK;
151     else
152         return E_FAIL;
153 }
154 
155 static HRESULT WINAPI ActiveIMMApp_EnumRegisterWordA(IActiveIMMApp* This,
156         HKL hKL, LPSTR szReading, DWORD dwStyle, LPSTR szRegister,
157         LPVOID pData, IEnumRegisterWordA **pEnum)
158 {
159     FIXME("Stub\n");
160     return E_NOTIMPL;
161 }
162 
163 static HRESULT WINAPI ActiveIMMApp_EnumRegisterWordW(IActiveIMMApp* This,
164         HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szRegister,
165         LPVOID pData, IEnumRegisterWordW **pEnum)
166 {
167     FIXME("Stub\n");
168     return E_NOTIMPL;
169 }
170 
171 static HRESULT WINAPI ActiveIMMApp_EscapeA(IActiveIMMApp* This,
172         HKL hKL, HIMC hIMC, UINT uEscape, LPVOID pData, LRESULT *plResult)
173 {
174     *plResult = ImmEscapeA(hKL, hIMC, uEscape, pData);
175     return S_OK;
176 }
177 
178 static HRESULT WINAPI ActiveIMMApp_EscapeW(IActiveIMMApp* This,
179         HKL hKL, HIMC hIMC, UINT uEscape, LPVOID pData, LRESULT *plResult)
180 {
181     *plResult = ImmEscapeW(hKL, hIMC, uEscape, pData);
182     return S_OK;
183 }
184 
185 static HRESULT WINAPI ActiveIMMApp_GetCandidateListA(IActiveIMMApp* This,
186         HIMC hIMC, DWORD dwIndex, UINT uBufLen, CANDIDATELIST *pCandList,
187         UINT *puCopied)
188 {
189     *puCopied = ImmGetCandidateListA(hIMC, dwIndex, pCandList, uBufLen);
190     return S_OK;
191 }
192 
193 static HRESULT WINAPI ActiveIMMApp_GetCandidateListW(IActiveIMMApp* This,
194         HIMC hIMC, DWORD dwIndex, UINT uBufLen, CANDIDATELIST *pCandList,
195         UINT *puCopied)
196 {
197     *puCopied = ImmGetCandidateListW(hIMC, dwIndex, pCandList, uBufLen);
198     return S_OK;
199 }
200 
201 static HRESULT WINAPI ActiveIMMApp_GetCandidateListCountA(IActiveIMMApp* This,
202         HIMC hIMC, DWORD *pdwListSize, DWORD *pdwBufLen)
203 {
204    *pdwBufLen = ImmGetCandidateListCountA(hIMC, pdwListSize);
205     return S_OK;
206 }
207 
208 static HRESULT WINAPI ActiveIMMApp_GetCandidateListCountW(IActiveIMMApp* This,
209         HIMC hIMC, DWORD *pdwListSize, DWORD *pdwBufLen)
210 {
211    *pdwBufLen = ImmGetCandidateListCountA(hIMC, pdwListSize);
212     return S_OK;
213 }
214 
215 static HRESULT WINAPI ActiveIMMApp_GetCandidateWindow(IActiveIMMApp* This,
216         HIMC hIMC, DWORD dwIndex, CANDIDATEFORM *pCandidate)
217 {
218     BOOL rc;
219     rc = ImmGetCandidateWindow(hIMC,dwIndex,pCandidate);
220     if (rc)
221         return S_OK;
222     else
223         return E_FAIL;
224 }
225 
226 static HRESULT WINAPI ActiveIMMApp_GetCompositionFontA(IActiveIMMApp* This,
227         HIMC hIMC, LOGFONTA *plf)
228 {
229     BOOL rc;
230     rc = ImmGetCompositionFontA(hIMC,plf);
231     if (rc)
232         return S_OK;
233     else
234         return E_FAIL;
235 }
236 
237 static HRESULT WINAPI ActiveIMMApp_GetCompositionFontW(IActiveIMMApp* This,
238         HIMC hIMC, LOGFONTW *plf)
239 {
240     BOOL rc;
241     rc = ImmGetCompositionFontW(hIMC,plf);
242     if (rc)
243         return S_OK;
244     else
245         return E_FAIL;
246 }
247 
248 static HRESULT WINAPI ActiveIMMApp_GetCompositionStringA(IActiveIMMApp* This,
249         HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LONG *plCopied, LPVOID pBuf)
250 {
251     *plCopied = ImmGetCompositionStringA(hIMC, dwIndex, pBuf, dwBufLen);
252     return S_OK;
253 }
254 
255 static HRESULT WINAPI ActiveIMMApp_GetCompositionStringW(IActiveIMMApp* This,
256         HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LONG *plCopied, LPVOID pBuf)
257 {
258     *plCopied = ImmGetCompositionStringW(hIMC, dwIndex, pBuf, dwBufLen);
259     return S_OK;
260 }
261 
262 static HRESULT WINAPI ActiveIMMApp_GetCompositionWindow(IActiveIMMApp* This,
263         HIMC hIMC, COMPOSITIONFORM *pCompForm)
264 {
265     BOOL rc;
266 
267     rc = ImmGetCompositionWindow(hIMC,pCompForm);
268 
269     if (rc)
270         return S_OK;
271     else
272         return E_FAIL;
273 }
274 
275 static HRESULT WINAPI ActiveIMMApp_GetContext(IActiveIMMApp* This,
276         HWND hwnd, HIMC *phIMC)
277 {
278     *phIMC = ImmGetContext(hwnd);
279     return S_OK;
280 }
281 
282 static HRESULT WINAPI ActiveIMMApp_GetConversionListA(IActiveIMMApp* This,
283         HKL hKL, HIMC hIMC, LPSTR pSrc, UINT uBufLen, UINT uFlag,
284         CANDIDATELIST *pDst, UINT *puCopied)
285 {
286     *puCopied = ImmGetConversionListA(hKL, hIMC, pSrc, pDst, uBufLen, uFlag);
287     return S_OK;
288 }
289 
290 static HRESULT WINAPI ActiveIMMApp_GetConversionListW(IActiveIMMApp* This,
291         HKL hKL, HIMC hIMC, LPWSTR pSrc, UINT uBufLen, UINT uFlag,
292         CANDIDATELIST *pDst, UINT *puCopied)
293 {
294     *puCopied = ImmGetConversionListW(hKL, hIMC, pSrc, pDst, uBufLen, uFlag);
295     return S_OK;
296 }
297 
298 static HRESULT WINAPI ActiveIMMApp_GetConversionStatus(IActiveIMMApp* This,
299         HIMC hIMC, DWORD *pfdwConversion, DWORD *pfdwSentence)
300 {
301     BOOL rc;
302 
303     rc = ImmGetConversionStatus(hIMC, pfdwConversion, pfdwSentence);
304 
305     if (rc)
306         return S_OK;
307     else
308         return E_FAIL;
309 }
310 
311 static HRESULT WINAPI ActiveIMMApp_GetDefaultIMEWnd(IActiveIMMApp* This,
312         HWND hWnd, HWND *phDefWnd)
313 {
314     *phDefWnd = ImmGetDefaultIMEWnd(hWnd);
315     return S_OK;
316 }
317 
318 static HRESULT WINAPI ActiveIMMApp_GetDescriptionA(IActiveIMMApp* This,
319         HKL hKL, UINT uBufLen, LPSTR szDescription, UINT *puCopied)
320 {
321     *puCopied = ImmGetDescriptionA(hKL, szDescription, uBufLen);
322     return S_OK;
323 }
324 
325 static HRESULT WINAPI ActiveIMMApp_GetDescriptionW(IActiveIMMApp* This,
326         HKL hKL, UINT uBufLen, LPWSTR szDescription, UINT *puCopied)
327 {
328     *puCopied = ImmGetDescriptionW(hKL, szDescription, uBufLen);
329     return S_OK;
330 }
331 
332 static HRESULT WINAPI ActiveIMMApp_GetGuideLineA(IActiveIMMApp* This,
333         HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LPSTR pBuf,
334         DWORD *pdwResult)
335 {
336     *pdwResult = ImmGetGuideLineA(hIMC, dwIndex, pBuf, dwBufLen);
337     return S_OK;
338 }
339 
340 static HRESULT WINAPI ActiveIMMApp_GetGuideLineW(IActiveIMMApp* This,
341         HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LPWSTR pBuf,
342         DWORD *pdwResult)
343 {
344     *pdwResult = ImmGetGuideLineW(hIMC, dwIndex, pBuf, dwBufLen);
345     return S_OK;
346 }
347 
348 static HRESULT WINAPI ActiveIMMApp_GetIMEFileNameA(IActiveIMMApp* This,
349         HKL hKL, UINT uBufLen, LPSTR szFileName, UINT *puCopied)
350 {
351     *puCopied = ImmGetIMEFileNameA(hKL, szFileName, uBufLen);
352     return S_OK;
353 }
354 
355 static HRESULT WINAPI ActiveIMMApp_GetIMEFileNameW(IActiveIMMApp* This,
356         HKL hKL, UINT uBufLen, LPWSTR szFileName, UINT *puCopied)
357 {
358     *puCopied = ImmGetIMEFileNameW(hKL, szFileName, uBufLen);
359     return S_OK;
360 }
361 
362 static HRESULT WINAPI ActiveIMMApp_GetOpenStatus(IActiveIMMApp* This,
363         HIMC hIMC)
364 {
365     return ImmGetOpenStatus(hIMC);
366 }
367 
368 static HRESULT WINAPI ActiveIMMApp_GetProperty(IActiveIMMApp* This,
369         HKL hKL, DWORD fdwIndex, DWORD *pdwProperty)
370 {
371     *pdwProperty = ImmGetProperty(hKL, fdwIndex);
372     return S_OK;
373 }
374 
375 static HRESULT WINAPI ActiveIMMApp_GetRegisterWordStyleA(IActiveIMMApp* This,
376         HKL hKL, UINT nItem, STYLEBUFA *pStyleBuf, UINT *puCopied)
377 {
378     *puCopied = ImmGetRegisterWordStyleA(hKL, nItem, pStyleBuf);
379     return S_OK;
380 }
381 
382 static HRESULT WINAPI ActiveIMMApp_GetRegisterWordStyleW(IActiveIMMApp* This,
383         HKL hKL, UINT nItem, STYLEBUFW *pStyleBuf, UINT *puCopied)
384 {
385     *puCopied = ImmGetRegisterWordStyleW(hKL, nItem, pStyleBuf);
386     return S_OK;
387 }
388 
389 static HRESULT WINAPI ActiveIMMApp_GetStatusWindowPos(IActiveIMMApp* This,
390         HIMC hIMC, POINT *pptPos)
391 {
392     BOOL rc;
393     rc = ImmGetStatusWindowPos(hIMC, pptPos);
394 
395     if (rc)
396         return S_OK;
397     else
398         return E_FAIL;
399 }
400 
401 static HRESULT WINAPI ActiveIMMApp_GetVirtualKey(IActiveIMMApp* This,
402         HWND hWnd, UINT *puVirtualKey)
403 {
404     *puVirtualKey = ImmGetVirtualKey(hWnd);
405     return S_OK;
406 }
407 
408 static HRESULT WINAPI ActiveIMMApp_InstallIMEA(IActiveIMMApp* This,
409         LPSTR szIMEFileName, LPSTR szLayoutText, HKL *phKL)
410 {
411     *phKL = ImmInstallIMEA(szIMEFileName,szLayoutText);
412     return S_OK;
413 }
414 
415 static HRESULT WINAPI ActiveIMMApp_InstallIMEW(IActiveIMMApp* This,
416         LPWSTR szIMEFileName, LPWSTR szLayoutText, HKL *phKL)
417 {
418     *phKL = ImmInstallIMEW(szIMEFileName,szLayoutText);
419     return S_OK;
420 }
421 
422 static HRESULT WINAPI ActiveIMMApp_IsIME(IActiveIMMApp* This,
423         HKL hKL)
424 {
425     return ImmIsIME(hKL);
426 }
427 
428 static HRESULT WINAPI ActiveIMMApp_IsUIMessageA(IActiveIMMApp* This,
429         HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
430 {
431     return ImmIsUIMessageA(hWndIME,msg,wParam,lParam);
432 }
433 
434 static HRESULT WINAPI ActiveIMMApp_IsUIMessageW(IActiveIMMApp* This,
435         HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
436 {
437     return ImmIsUIMessageW(hWndIME,msg,wParam,lParam);
438 }
439 
440 static HRESULT WINAPI ActiveIMMApp_NotifyIME(IActiveIMMApp* This,
441         HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
442 {
443     BOOL rc;
444 
445     rc = ImmNotifyIME(hIMC,dwAction,dwIndex,dwValue);
446 
447     if (rc)
448         return S_OK;
449     else
450         return E_FAIL;
451 }
452 
453 static HRESULT WINAPI ActiveIMMApp_RegisterWordA(IActiveIMMApp* This,
454         HKL hKL, LPSTR szReading, DWORD dwStyle, LPSTR szRegister)
455 {
456     BOOL rc;
457 
458     rc = ImmRegisterWordA(hKL,szReading,dwStyle,szRegister);
459 
460     if (rc)
461         return S_OK;
462     else
463         return E_FAIL;
464 }
465 
466 static HRESULT WINAPI ActiveIMMApp_RegisterWordW(IActiveIMMApp* This,
467         HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szRegister)
468 {
469     BOOL rc;
470 
471     rc = ImmRegisterWordW(hKL,szReading,dwStyle,szRegister);
472 
473     if (rc)
474         return S_OK;
475     else
476         return E_FAIL;
477 }
478 
479 static HRESULT WINAPI ActiveIMMApp_ReleaseContext(IActiveIMMApp* This,
480         HWND hWnd, HIMC hIMC)
481 {
482     BOOL rc;
483 
484     rc = ImmReleaseContext(hWnd,hIMC);
485 
486     if (rc)
487         return S_OK;
488     else
489         return E_FAIL;
490 }
491 
492 static HRESULT WINAPI ActiveIMMApp_SetCandidateWindow(IActiveIMMApp* This,
493         HIMC hIMC, CANDIDATEFORM *pCandidate)
494 {
495     BOOL rc;
496 
497     rc = ImmSetCandidateWindow(hIMC,pCandidate);
498 
499     if (rc)
500         return S_OK;
501     else
502         return E_FAIL;
503 }
504 
505 static HRESULT WINAPI ActiveIMMApp_SetCompositionFontA(IActiveIMMApp* This,
506         HIMC hIMC, LOGFONTA *plf)
507 {
508     BOOL rc;
509 
510     rc = ImmSetCompositionFontA(hIMC,plf);
511 
512     if (rc)
513         return S_OK;
514     else
515         return E_FAIL;
516 }
517 
518 static HRESULT WINAPI ActiveIMMApp_SetCompositionFontW(IActiveIMMApp* This,
519         HIMC hIMC, LOGFONTW *plf)
520 {
521     BOOL rc;
522 
523     rc = ImmSetCompositionFontW(hIMC,plf);
524 
525     if (rc)
526         return S_OK;
527     else
528         return E_FAIL;
529 }
530 
531 static HRESULT WINAPI ActiveIMMApp_SetCompositionStringA(IActiveIMMApp* This,
532         HIMC hIMC, DWORD dwIndex, LPVOID pComp, DWORD dwCompLen,
533         LPVOID pRead, DWORD dwReadLen)
534 {
535     BOOL rc;
536 
537     rc = ImmSetCompositionStringA(hIMC,dwIndex,pComp,dwCompLen,pRead,dwReadLen);
538 
539     if (rc)
540         return S_OK;
541     else
542         return E_FAIL;
543 }
544 
545 static HRESULT WINAPI ActiveIMMApp_SetCompositionStringW(IActiveIMMApp* This,
546         HIMC hIMC, DWORD dwIndex, LPVOID pComp, DWORD dwCompLen,
547         LPVOID pRead, DWORD dwReadLen)
548 {
549     BOOL rc;
550 
551     rc = ImmSetCompositionStringW(hIMC,dwIndex,pComp,dwCompLen,pRead,dwReadLen);
552 
553     if (rc)
554         return S_OK;
555     else
556         return E_FAIL;
557 }
558 
559 static HRESULT WINAPI ActiveIMMApp_SetCompositionWindow(IActiveIMMApp* This,
560         HIMC hIMC, COMPOSITIONFORM *pCompForm)
561 {
562     BOOL rc;
563 
564     rc = ImmSetCompositionWindow(hIMC,pCompForm);
565 
566     if (rc)
567         return S_OK;
568     else
569         return E_FAIL;
570 }
571 
572 static HRESULT WINAPI ActiveIMMApp_SetConversionStatus(IActiveIMMApp* This,
573         HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
574 {
575     BOOL rc;
576 
577     rc = ImmSetConversionStatus(hIMC,fdwConversion,fdwSentence);
578 
579     if (rc)
580         return S_OK;
581     else
582         return E_FAIL;
583 }
584 
585 static HRESULT WINAPI ActiveIMMApp_SetOpenStatus(IActiveIMMApp* This,
586         HIMC hIMC, BOOL fOpen)
587 {
588     BOOL rc;
589 
590     rc = ImmSetOpenStatus(hIMC,fOpen);
591 
592     if (rc)
593         return S_OK;
594     else
595         return E_FAIL;
596 }
597 
598 static HRESULT WINAPI ActiveIMMApp_SetStatusWindowPos(IActiveIMMApp* This,
599         HIMC hIMC, POINT *pptPos)
600 {
601     BOOL rc;
602 
603     rc = ImmSetStatusWindowPos(hIMC,pptPos);
604 
605     if (rc)
606         return S_OK;
607     else
608         return E_FAIL;
609 }
610 
611 static HRESULT WINAPI ActiveIMMApp_SimulateHotKey(IActiveIMMApp* This,
612         HWND hwnd, DWORD dwHotKeyID)
613 {
614     BOOL rc;
615 
616     rc = ImmSimulateHotKey(hwnd,dwHotKeyID);
617 
618     if (rc)
619         return S_OK;
620     else
621         return E_FAIL;
622 }
623 
624 static HRESULT WINAPI ActiveIMMApp_UnregisterWordA(IActiveIMMApp* This,
625         HKL hKL, LPSTR szReading, DWORD dwStyle, LPSTR szUnregister)
626 {
627     BOOL rc;
628 
629     rc = ImmUnregisterWordA(hKL,szReading,dwStyle,szUnregister);
630 
631     if (rc)
632         return S_OK;
633     else
634         return E_FAIL;
635 
636 }
637 
638 static HRESULT WINAPI ActiveIMMApp_UnregisterWordW(IActiveIMMApp* This,
639         HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szUnregister)
640 {
641     BOOL rc;
642 
643     rc = ImmUnregisterWordW(hKL,szReading,dwStyle,szUnregister);
644 
645     if (rc)
646         return S_OK;
647     else
648         return E_FAIL;
649 }
650 
651 static HRESULT WINAPI ActiveIMMApp_Activate(IActiveIMMApp* This,
652         BOOL fRestoreLayout)
653 {
654     FIXME("Stub\n");
655     return S_OK;
656 }
657 
658 static HRESULT WINAPI ActiveIMMApp_Deactivate(IActiveIMMApp* This)
659 {
660     FIXME("Stub\n");
661     return S_OK;
662 }
663 
664 static HRESULT WINAPI ActiveIMMApp_OnDefWindowProc(IActiveIMMApp* This,
665         HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
666 {
667 #ifndef __REACTOS__
668     FIXME("Stub (%p %x %lx %lx)\n",hWnd,Msg,wParam,lParam);
669 #endif
670     return E_FAIL;
671 }
672 
673 static HRESULT WINAPI ActiveIMMApp_FilterClientWindows(IActiveIMMApp* This,
674         ATOM *aaClassList, UINT uSize)
675 {
676     FIXME("Stub\n");
677     return S_OK;
678 }
679 
680 static HRESULT WINAPI ActiveIMMApp_GetCodePageA(IActiveIMMApp* This,
681         HKL hKL, UINT *uCodePage)
682 {
683     FIXME("Stub\n");
684     return E_NOTIMPL;
685 }
686 
687 static HRESULT WINAPI ActiveIMMApp_GetLangId(IActiveIMMApp* This,
688         HKL hKL, LANGID *plid)
689 {
690     FIXME("Stub\n");
691     return E_NOTIMPL;
692 }
693 
694 static HRESULT WINAPI ActiveIMMApp_AssociateContextEx(IActiveIMMApp* This,
695         HWND hWnd, HIMC hIMC, DWORD dwFlags)
696 {
697     BOOL rc;
698 
699     rc = ImmAssociateContextEx(hWnd,hIMC,dwFlags);
700 
701     if (rc)
702         return S_OK;
703     else
704         return E_FAIL;
705 }
706 
707 static HRESULT WINAPI ActiveIMMApp_DisableIME(IActiveIMMApp* This,
708         DWORD idThread)
709 {
710     BOOL rc;
711 
712     rc = ImmDisableIME(idThread);
713 
714     if (rc)
715         return S_OK;
716     else
717         return E_FAIL;
718 }
719 
720 static HRESULT WINAPI ActiveIMMApp_GetImeMenuItemsA(IActiveIMMApp* This,
721         HIMC hIMC, DWORD dwFlags, DWORD dwType,
722         IMEMENUITEMINFOA *pImeParentMenu, IMEMENUITEMINFOA *pImeMenu,
723         DWORD dwSize, DWORD *pdwResult)
724 {
725     *pdwResult = ImmGetImeMenuItemsA(hIMC,dwFlags,dwType,pImeParentMenu,pImeMenu,dwSize);
726     return S_OK;
727 }
728 
729 static HRESULT WINAPI ActiveIMMApp_GetImeMenuItemsW(IActiveIMMApp* This,
730         HIMC hIMC, DWORD dwFlags, DWORD dwType,
731         IMEMENUITEMINFOW *pImeParentMenu, IMEMENUITEMINFOW *pImeMenu,
732         DWORD dwSize, DWORD *pdwResult)
733 {
734     *pdwResult = ImmGetImeMenuItemsW(hIMC,dwFlags,dwType,pImeParentMenu,pImeMenu,dwSize);
735     return S_OK;
736 }
737 
738 static HRESULT WINAPI ActiveIMMApp_EnumInputContext(IActiveIMMApp* This,
739         DWORD idThread, IEnumInputContext **ppEnum)
740 {
741     FIXME("Stub\n");
742     return E_NOTIMPL;
743 }
744 
745 static const IActiveIMMAppVtbl ActiveIMMAppVtbl =
746 {
747     ActiveIMMApp_QueryInterface,
748     ActiveIMMApp_AddRef,
749     ActiveIMMApp_Release,
750 
751     ActiveIMMApp_AssociateContext,
752     ActiveIMMApp_ConfigureIMEA,
753     ActiveIMMApp_ConfigureIMEW,
754     ActiveIMMApp_CreateContext,
755     ActiveIMMApp_DestroyContext,
756     ActiveIMMApp_EnumRegisterWordA,
757     ActiveIMMApp_EnumRegisterWordW,
758     ActiveIMMApp_EscapeA,
759     ActiveIMMApp_EscapeW,
760     ActiveIMMApp_GetCandidateListA,
761     ActiveIMMApp_GetCandidateListW,
762     ActiveIMMApp_GetCandidateListCountA,
763     ActiveIMMApp_GetCandidateListCountW,
764     ActiveIMMApp_GetCandidateWindow,
765     ActiveIMMApp_GetCompositionFontA,
766     ActiveIMMApp_GetCompositionFontW,
767     ActiveIMMApp_GetCompositionStringA,
768     ActiveIMMApp_GetCompositionStringW,
769     ActiveIMMApp_GetCompositionWindow,
770     ActiveIMMApp_GetContext,
771     ActiveIMMApp_GetConversionListA,
772     ActiveIMMApp_GetConversionListW,
773     ActiveIMMApp_GetConversionStatus,
774     ActiveIMMApp_GetDefaultIMEWnd,
775     ActiveIMMApp_GetDescriptionA,
776     ActiveIMMApp_GetDescriptionW,
777     ActiveIMMApp_GetGuideLineA,
778     ActiveIMMApp_GetGuideLineW,
779     ActiveIMMApp_GetIMEFileNameA,
780     ActiveIMMApp_GetIMEFileNameW,
781     ActiveIMMApp_GetOpenStatus,
782     ActiveIMMApp_GetProperty,
783     ActiveIMMApp_GetRegisterWordStyleA,
784     ActiveIMMApp_GetRegisterWordStyleW,
785     ActiveIMMApp_GetStatusWindowPos,
786     ActiveIMMApp_GetVirtualKey,
787     ActiveIMMApp_InstallIMEA,
788     ActiveIMMApp_InstallIMEW,
789     ActiveIMMApp_IsIME,
790     ActiveIMMApp_IsUIMessageA,
791     ActiveIMMApp_IsUIMessageW,
792     ActiveIMMApp_NotifyIME,
793     ActiveIMMApp_RegisterWordA,
794     ActiveIMMApp_RegisterWordW,
795     ActiveIMMApp_ReleaseContext,
796     ActiveIMMApp_SetCandidateWindow,
797     ActiveIMMApp_SetCompositionFontA,
798     ActiveIMMApp_SetCompositionFontW,
799     ActiveIMMApp_SetCompositionStringA,
800     ActiveIMMApp_SetCompositionStringW,
801     ActiveIMMApp_SetCompositionWindow,
802     ActiveIMMApp_SetConversionStatus,
803     ActiveIMMApp_SetOpenStatus,
804     ActiveIMMApp_SetStatusWindowPos,
805     ActiveIMMApp_SimulateHotKey,
806     ActiveIMMApp_UnregisterWordA,
807     ActiveIMMApp_UnregisterWordW,
808 
809     ActiveIMMApp_Activate,
810     ActiveIMMApp_Deactivate,
811     ActiveIMMApp_OnDefWindowProc,
812     ActiveIMMApp_FilterClientWindows,
813     ActiveIMMApp_GetCodePageA,
814     ActiveIMMApp_GetLangId,
815     ActiveIMMApp_AssociateContextEx,
816     ActiveIMMApp_DisableIME,
817     ActiveIMMApp_GetImeMenuItemsA,
818     ActiveIMMApp_GetImeMenuItemsW,
819     ActiveIMMApp_EnumInputContext
820 };
821 
822 static inline ActiveIMMApp *impl_from_IActiveIMMMessagePumpOwner(IActiveIMMMessagePumpOwner *iface)
823 {
824     return CONTAINING_RECORD(iface, ActiveIMMApp, IActiveIMMMessagePumpOwner_iface);
825 }
826 
827 static HRESULT WINAPI ActiveIMMMessagePumpOwner_QueryInterface(IActiveIMMMessagePumpOwner* iface,
828         REFIID iid, LPVOID *ppvOut)
829 {
830     ActiveIMMApp *This = impl_from_IActiveIMMMessagePumpOwner(iface);
831     return IActiveIMMApp_QueryInterface(&This->IActiveIMMApp_iface, iid, ppvOut);
832 }
833 
834 static ULONG WINAPI ActiveIMMMessagePumpOwner_AddRef(IActiveIMMMessagePumpOwner* iface)
835 {
836     ActiveIMMApp *This = impl_from_IActiveIMMMessagePumpOwner(iface);
837     return IActiveIMMApp_AddRef(&This->IActiveIMMApp_iface);
838 }
839 
840 static ULONG WINAPI ActiveIMMMessagePumpOwner_Release(IActiveIMMMessagePumpOwner* iface)
841 {
842     ActiveIMMApp *This = impl_from_IActiveIMMMessagePumpOwner(iface);
843     return IActiveIMMApp_Release(&This->IActiveIMMApp_iface);
844 }
845 
846 static HRESULT WINAPI ActiveIMMMessagePumpOwner_Start(IActiveIMMMessagePumpOwner* iface)
847 {
848     ActiveIMMApp *This = impl_from_IActiveIMMMessagePumpOwner(iface);
849     FIXME("(%p)->(): stub\n", This);
850     return E_NOTIMPL;
851 }
852 
853 static HRESULT WINAPI ActiveIMMMessagePumpOwner_End(IActiveIMMMessagePumpOwner* iface)
854 {
855     ActiveIMMApp *This = impl_from_IActiveIMMMessagePumpOwner(iface);
856     FIXME("(%p)->(): stub\n", This);
857     return E_NOTIMPL;
858 }
859 
860 static HRESULT WINAPI ActiveIMMMessagePumpOwner_OnTranslateMessage(IActiveIMMMessagePumpOwner* iface,
861         const MSG *msg)
862 {
863     ActiveIMMApp *This = impl_from_IActiveIMMMessagePumpOwner(iface);
864     FIXME("(%p)->(%p): stub\n", This, msg);
865     return E_NOTIMPL;
866 }
867 
868 static HRESULT WINAPI ActiveIMMMessagePumpOwner_Pause(IActiveIMMMessagePumpOwner* iface,
869         DWORD *cookie)
870 {
871     ActiveIMMApp *This = impl_from_IActiveIMMMessagePumpOwner(iface);
872     FIXME("(%p)->(%p): stub\n", This, cookie);
873     return E_NOTIMPL;
874 }
875 
876 static HRESULT WINAPI ActiveIMMMessagePumpOwner_Resume(IActiveIMMMessagePumpOwner* iface,
877         DWORD cookie)
878 {
879     ActiveIMMApp *This = impl_from_IActiveIMMMessagePumpOwner(iface);
880     FIXME("(%p)->(%u): stub\n", This, cookie);
881     return E_NOTIMPL;
882 }
883 
884 static const IActiveIMMMessagePumpOwnerVtbl ActiveIMMMessagePumpOwnerVtbl =
885 {
886     ActiveIMMMessagePumpOwner_QueryInterface,
887     ActiveIMMMessagePumpOwner_AddRef,
888     ActiveIMMMessagePumpOwner_Release,
889     ActiveIMMMessagePumpOwner_Start,
890     ActiveIMMMessagePumpOwner_End,
891     ActiveIMMMessagePumpOwner_OnTranslateMessage,
892     ActiveIMMMessagePumpOwner_Pause,
893     ActiveIMMMessagePumpOwner_Resume,
894 };
895 
896 DECLSPEC_HIDDEN HRESULT ActiveIMMApp_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
897 {
898     ActiveIMMApp *This;
899     if (pUnkOuter)
900         return CLASS_E_NOAGGREGATION;
901 
902     This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ActiveIMMApp));
903     if (This == NULL)
904         return E_OUTOFMEMORY;
905 
906     This->IActiveIMMApp_iface.lpVtbl = &ActiveIMMAppVtbl;
907     This->IActiveIMMMessagePumpOwner_iface.lpVtbl = &ActiveIMMMessagePumpOwnerVtbl;
908     This->refCount = 1;
909 
910     TRACE("returning %p\n",This);
911     *ppOut = (IUnknown *)&This->IActiveIMMApp_iface;
912     return S_OK;
913 }
914