setupapi: Fix total size when appending multi-string values.
[wine] / dlls / msimtf / activeimmapp.c
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     LONG refCount;
46 } ActiveIMMApp;
47
48 static inline ActiveIMMApp *impl_from_IActiveIMMApp(IActiveIMMApp *iface)
49 {
50     return CONTAINING_RECORD(iface, ActiveIMMApp, IActiveIMMApp_iface);
51 }
52
53 static void ActiveIMMApp_Destructor(ActiveIMMApp* This)
54 {
55     TRACE("\n");
56     HeapFree(GetProcessHeap(),0,This);
57 }
58
59 static HRESULT WINAPI ActiveIMMApp_QueryInterface (IActiveIMMApp* iface,
60         REFIID iid, LPVOID *ppvOut)
61 {
62     ActiveIMMApp *This = impl_from_IActiveIMMApp(iface);
63     *ppvOut = NULL;
64
65     if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_IActiveIMMApp))
66     {
67         *ppvOut = This;
68     }
69
70     if (*ppvOut)
71     {
72         IUnknown_AddRef(iface);
73         return S_OK;
74     }
75
76     WARN("unsupported interface: %s\n", debugstr_guid(iid));
77     return E_NOINTERFACE;
78 }
79
80 static ULONG WINAPI ActiveIMMApp_AddRef(IActiveIMMApp* iface)
81 {
82     ActiveIMMApp *This = impl_from_IActiveIMMApp(iface);
83     return InterlockedIncrement(&This->refCount);
84 }
85
86 static ULONG WINAPI ActiveIMMApp_Release(IActiveIMMApp* iface)
87 {
88     ActiveIMMApp *This = impl_from_IActiveIMMApp(iface);
89     ULONG ret;
90
91     ret = InterlockedDecrement(&This->refCount);
92     if (ret == 0)
93         ActiveIMMApp_Destructor(This);
94     return ret;
95 }
96
97 static HRESULT WINAPI ActiveIMMApp_AssociateContext(IActiveIMMApp* iface,
98         HWND hWnd, HIMC hIME, HIMC *phPrev)
99 {
100     *phPrev = ImmAssociateContext(hWnd,hIME);
101     return S_OK;
102 }
103
104 static HRESULT WINAPI ActiveIMMApp_ConfigureIMEA(IActiveIMMApp* This,
105         HKL hKL, HWND hwnd, DWORD dwMode, REGISTERWORDA *pData)
106 {
107     BOOL rc;
108
109     rc = ImmConfigureIMEA(hKL, hwnd, dwMode, pData);
110     if (rc)
111         return E_FAIL;
112     else
113         return S_OK;
114 }
115
116 static HRESULT WINAPI ActiveIMMApp_ConfigureIMEW(IActiveIMMApp* This,
117         HKL hKL, HWND hWnd, DWORD dwMode, REGISTERWORDW *pData)
118 {
119     BOOL rc;
120
121     rc = ImmConfigureIMEW(hKL, hWnd, dwMode, pData);
122     if (rc)
123         return E_FAIL;
124     else
125         return S_OK;
126 }
127
128 static HRESULT WINAPI ActiveIMMApp_CreateContext(IActiveIMMApp* This,
129         HIMC *phIMC)
130 {
131     *phIMC = ImmCreateContext();
132     if (*phIMC)
133         return S_OK;
134     else
135         return E_FAIL;
136 }
137
138 static HRESULT WINAPI ActiveIMMApp_DestroyContext(IActiveIMMApp* This,
139         HIMC hIME)
140 {
141     BOOL rc;
142
143     rc = ImmDestroyContext(hIME);
144     if (rc)
145         return S_OK;
146     else
147         return E_FAIL;
148 }
149
150 static HRESULT WINAPI ActiveIMMApp_EnumRegisterWordA(IActiveIMMApp* This,
151         HKL hKL, LPSTR szReading, DWORD dwStyle, LPSTR szRegister,
152         LPVOID pData, IEnumRegisterWordA **pEnum)
153 {
154     FIXME("Stub\n");
155     return E_NOTIMPL;
156 }
157
158 static HRESULT WINAPI ActiveIMMApp_EnumRegisterWordW(IActiveIMMApp* This,
159         HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szRegister,
160         LPVOID pData, IEnumRegisterWordW **pEnum)
161 {
162     FIXME("Stub\n");
163     return E_NOTIMPL;
164 }
165
166 static HRESULT WINAPI ActiveIMMApp_EscapeA(IActiveIMMApp* This,
167         HKL hKL, HIMC hIMC, UINT uEscape, LPVOID pData, LRESULT *plResult)
168 {
169     *plResult = ImmEscapeA(hKL, hIMC, uEscape, pData);
170     return S_OK;
171 }
172
173 static HRESULT WINAPI ActiveIMMApp_EscapeW(IActiveIMMApp* This,
174         HKL hKL, HIMC hIMC, UINT uEscape, LPVOID pData, LRESULT *plResult)
175 {
176     *plResult = ImmEscapeW(hKL, hIMC, uEscape, pData);
177     return S_OK;
178 }
179
180 static HRESULT WINAPI ActiveIMMApp_GetCandidateListA(IActiveIMMApp* This,
181         HIMC hIMC, DWORD dwIndex, UINT uBufLen, CANDIDATELIST *pCandList,
182         UINT *puCopied)
183 {
184     *puCopied = ImmGetCandidateListA(hIMC, dwIndex, pCandList, uBufLen);
185     return S_OK;
186 }
187
188 static HRESULT WINAPI ActiveIMMApp_GetCandidateListW(IActiveIMMApp* This,
189         HIMC hIMC, DWORD dwIndex, UINT uBufLen, CANDIDATELIST *pCandList,
190         UINT *puCopied)
191 {
192     *puCopied = ImmGetCandidateListW(hIMC, dwIndex, pCandList, uBufLen);
193     return S_OK;
194 }
195
196 static HRESULT WINAPI ActiveIMMApp_GetCandidateListCountA(IActiveIMMApp* This,
197         HIMC hIMC, DWORD *pdwListSize, DWORD *pdwBufLen)
198 {
199    *pdwBufLen = ImmGetCandidateListCountA(hIMC, pdwListSize);
200     return S_OK;
201 }
202
203 static HRESULT WINAPI ActiveIMMApp_GetCandidateListCountW(IActiveIMMApp* This,
204         HIMC hIMC, DWORD *pdwListSize, DWORD *pdwBufLen)
205 {
206    *pdwBufLen = ImmGetCandidateListCountA(hIMC, pdwListSize);
207     return S_OK;
208 }
209
210 static HRESULT WINAPI ActiveIMMApp_GetCandidateWindow(IActiveIMMApp* This,
211         HIMC hIMC, DWORD dwIndex, CANDIDATEFORM *pCandidate)
212 {
213     BOOL rc;
214     rc = ImmGetCandidateWindow(hIMC,dwIndex,pCandidate);
215     if (rc)
216         return S_OK;
217     else
218         return E_FAIL;
219 }
220
221 static HRESULT WINAPI ActiveIMMApp_GetCompositionFontA(IActiveIMMApp* This,
222         HIMC hIMC, LOGFONTA *plf)
223 {
224     BOOL rc;
225     rc = ImmGetCompositionFontA(hIMC,plf);
226     if (rc)
227         return S_OK;
228     else
229         return E_FAIL;
230 }
231
232 static HRESULT WINAPI ActiveIMMApp_GetCompositionFontW(IActiveIMMApp* This,
233         HIMC hIMC, LOGFONTW *plf)
234 {
235     BOOL rc;
236     rc = ImmGetCompositionFontW(hIMC,plf);
237     if (rc)
238         return S_OK;
239     else
240         return E_FAIL;
241 }
242
243 static HRESULT WINAPI ActiveIMMApp_GetCompositionStringA(IActiveIMMApp* This,
244         HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LONG *plCopied, LPVOID pBuf)
245 {
246     *plCopied = ImmGetCompositionStringA(hIMC, dwIndex, pBuf, dwBufLen);
247     return S_OK;
248 }
249
250 static HRESULT WINAPI ActiveIMMApp_GetCompositionStringW(IActiveIMMApp* This,
251         HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LONG *plCopied, LPVOID pBuf)
252 {
253     *plCopied = ImmGetCompositionStringW(hIMC, dwIndex, pBuf, dwBufLen);
254     return S_OK;
255 }
256
257 static HRESULT WINAPI ActiveIMMApp_GetCompositionWindow(IActiveIMMApp* This,
258         HIMC hIMC, COMPOSITIONFORM *pCompForm)
259 {
260     BOOL rc;
261
262     rc = ImmGetCompositionWindow(hIMC,pCompForm);
263
264     if (rc)
265         return S_OK;
266     else
267         return E_FAIL;
268 }
269
270 static HRESULT WINAPI ActiveIMMApp_GetContext(IActiveIMMApp* This,
271         HWND hwnd, HIMC *phIMC)
272 {
273     *phIMC = ImmGetContext(hwnd);
274     return S_OK;
275 }
276
277 static HRESULT WINAPI ActiveIMMApp_GetConversionListA(IActiveIMMApp* This,
278         HKL hKL, HIMC hIMC, LPSTR pSrc, UINT uBufLen, UINT uFlag,
279         CANDIDATELIST *pDst, UINT *puCopied)
280 {
281     *puCopied = ImmGetConversionListA(hKL, hIMC, pSrc, pDst, uBufLen, uFlag);
282     return S_OK;
283 }
284
285 static HRESULT WINAPI ActiveIMMApp_GetConversionListW(IActiveIMMApp* This,
286         HKL hKL, HIMC hIMC, LPWSTR pSrc, UINT uBufLen, UINT uFlag,
287         CANDIDATELIST *pDst, UINT *puCopied)
288 {
289     *puCopied = ImmGetConversionListW(hKL, hIMC, pSrc, pDst, uBufLen, uFlag);
290     return S_OK;
291 }
292
293 static HRESULT WINAPI ActiveIMMApp_GetConversionStatus(IActiveIMMApp* This,
294         HIMC hIMC, DWORD *pfdwConversion, DWORD *pfdwSentence)
295 {
296     BOOL rc;
297
298     rc = ImmGetConversionStatus(hIMC, pfdwConversion, pfdwSentence);
299
300     if (rc)
301         return S_OK;
302     else
303         return E_FAIL;
304 }
305
306 static HRESULT WINAPI ActiveIMMApp_GetDefaultIMEWnd(IActiveIMMApp* This,
307         HWND hWnd, HWND *phDefWnd)
308 {
309     *phDefWnd = ImmGetDefaultIMEWnd(hWnd);
310     return S_OK;
311 }
312
313 static HRESULT WINAPI ActiveIMMApp_GetDescriptionA(IActiveIMMApp* This,
314         HKL hKL, UINT uBufLen, LPSTR szDescription, UINT *puCopied)
315 {
316     *puCopied = ImmGetDescriptionA(hKL, szDescription, uBufLen);
317     return S_OK;
318 }
319
320 static HRESULT WINAPI ActiveIMMApp_GetDescriptionW(IActiveIMMApp* This,
321         HKL hKL, UINT uBufLen, LPWSTR szDescription, UINT *puCopied)
322 {
323     *puCopied = ImmGetDescriptionW(hKL, szDescription, uBufLen);
324     return S_OK;
325 }
326
327 static HRESULT WINAPI ActiveIMMApp_GetGuideLineA(IActiveIMMApp* This,
328         HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LPSTR pBuf,
329         DWORD *pdwResult)
330 {
331     *pdwResult = ImmGetGuideLineA(hIMC, dwIndex, pBuf, dwBufLen);
332     return S_OK;
333 }
334
335 static HRESULT WINAPI ActiveIMMApp_GetGuideLineW(IActiveIMMApp* This,
336         HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LPWSTR pBuf,
337         DWORD *pdwResult)
338 {
339     *pdwResult = ImmGetGuideLineW(hIMC, dwIndex, pBuf, dwBufLen);
340     return S_OK;
341 }
342
343 static HRESULT WINAPI ActiveIMMApp_GetIMEFileNameA(IActiveIMMApp* This,
344         HKL hKL, UINT uBufLen, LPSTR szFileName, UINT *puCopied)
345 {
346     *puCopied = ImmGetIMEFileNameA(hKL, szFileName, uBufLen);
347     return S_OK;
348 }
349
350 static HRESULT WINAPI ActiveIMMApp_GetIMEFileNameW(IActiveIMMApp* This,
351         HKL hKL, UINT uBufLen, LPWSTR szFileName, UINT *puCopied)
352 {
353     *puCopied = ImmGetIMEFileNameW(hKL, szFileName, uBufLen);
354     return S_OK;
355 }
356
357 static HRESULT WINAPI ActiveIMMApp_GetOpenStatus(IActiveIMMApp* This,
358         HIMC hIMC)
359 {
360     return ImmGetOpenStatus(hIMC);
361 }
362
363 static HRESULT WINAPI ActiveIMMApp_GetProperty(IActiveIMMApp* This,
364         HKL hKL, DWORD fdwIndex, DWORD *pdwProperty)
365 {
366     *pdwProperty = ImmGetProperty(hKL, fdwIndex);
367     return S_OK;
368 }
369
370 static HRESULT WINAPI ActiveIMMApp_GetRegisterWordStyleA(IActiveIMMApp* This,
371         HKL hKL, UINT nItem, STYLEBUFA *pStyleBuf, UINT *puCopied)
372 {
373     *puCopied = ImmGetRegisterWordStyleA(hKL, nItem, pStyleBuf);
374     return S_OK;
375 }
376
377 static HRESULT WINAPI ActiveIMMApp_GetRegisterWordStyleW(IActiveIMMApp* This,
378         HKL hKL, UINT nItem, STYLEBUFW *pStyleBuf, UINT *puCopied)
379 {
380     *puCopied = ImmGetRegisterWordStyleW(hKL, nItem, pStyleBuf);
381     return S_OK;
382 }
383
384 static HRESULT WINAPI ActiveIMMApp_GetStatusWindowPos(IActiveIMMApp* This,
385         HIMC hIMC, POINT *pptPos)
386 {
387     BOOL rc;
388     rc = ImmGetStatusWindowPos(hIMC, pptPos);
389
390     if (rc)
391         return S_OK;
392     else
393         return E_FAIL;
394 }
395
396 static HRESULT WINAPI ActiveIMMApp_GetVirtualKey(IActiveIMMApp* This,
397         HWND hWnd, UINT *puVirtualKey)
398 {
399     *puVirtualKey = ImmGetVirtualKey(hWnd);
400     return S_OK;
401 }
402
403 static HRESULT WINAPI ActiveIMMApp_InstallIMEA(IActiveIMMApp* This,
404         LPSTR szIMEFileName, LPSTR szLayoutText, HKL *phKL)
405 {
406     *phKL = ImmInstallIMEA(szIMEFileName,szLayoutText);
407     return S_OK;
408 }
409
410 static HRESULT WINAPI ActiveIMMApp_InstallIMEW(IActiveIMMApp* This,
411         LPWSTR szIMEFileName, LPWSTR szLayoutText, HKL *phKL)
412 {
413     *phKL = ImmInstallIMEW(szIMEFileName,szLayoutText);
414     return S_OK;
415 }
416
417 static HRESULT WINAPI ActiveIMMApp_IsIME(IActiveIMMApp* This,
418         HKL hKL)
419 {
420     return ImmIsIME(hKL);
421 }
422
423 static HRESULT WINAPI ActiveIMMApp_IsUIMessageA(IActiveIMMApp* This,
424         HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
425 {
426     return ImmIsUIMessageA(hWndIME,msg,wParam,lParam);
427 }
428
429 static HRESULT WINAPI ActiveIMMApp_IsUIMessageW(IActiveIMMApp* This,
430         HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
431 {
432     return ImmIsUIMessageW(hWndIME,msg,wParam,lParam);
433 }
434
435 static HRESULT WINAPI ActiveIMMApp_NotifyIME(IActiveIMMApp* This,
436         HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
437 {
438     BOOL rc;
439
440     rc = ImmNotifyIME(hIMC,dwAction,dwIndex,dwValue);
441
442     if (rc)
443         return S_OK;
444     else
445         return E_FAIL;
446 }
447
448 static HRESULT WINAPI ActiveIMMApp_RegisterWordA(IActiveIMMApp* This,
449         HKL hKL, LPSTR szReading, DWORD dwStyle, LPSTR szRegister)
450 {
451     BOOL rc;
452
453     rc = ImmRegisterWordA(hKL,szReading,dwStyle,szRegister);
454
455     if (rc)
456         return S_OK;
457     else
458         return E_FAIL;
459 }
460
461 static HRESULT WINAPI ActiveIMMApp_RegisterWordW(IActiveIMMApp* This,
462         HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szRegister)
463 {
464     BOOL rc;
465
466     rc = ImmRegisterWordW(hKL,szReading,dwStyle,szRegister);
467
468     if (rc)
469         return S_OK;
470     else
471         return E_FAIL;
472 }
473
474 static HRESULT WINAPI ActiveIMMApp_ReleaseContext(IActiveIMMApp* This,
475         HWND hWnd, HIMC hIMC)
476 {
477     BOOL rc;
478
479     rc = ImmReleaseContext(hWnd,hIMC);
480
481     if (rc)
482         return S_OK;
483     else
484         return E_FAIL;
485 }
486
487 static HRESULT WINAPI ActiveIMMApp_SetCandidateWindow(IActiveIMMApp* This,
488         HIMC hIMC, CANDIDATEFORM *pCandidate)
489 {
490     BOOL rc;
491
492     rc = ImmSetCandidateWindow(hIMC,pCandidate);
493
494     if (rc)
495         return S_OK;
496     else
497         return E_FAIL;
498 }
499
500 static HRESULT WINAPI ActiveIMMApp_SetCompositionFontA(IActiveIMMApp* This,
501         HIMC hIMC, LOGFONTA *plf)
502 {
503     BOOL rc;
504
505     rc = ImmSetCompositionFontA(hIMC,plf);
506
507     if (rc)
508         return S_OK;
509     else
510         return E_FAIL;
511 }
512
513 static HRESULT WINAPI ActiveIMMApp_SetCompositionFontW(IActiveIMMApp* This,
514         HIMC hIMC, LOGFONTW *plf)
515 {
516     BOOL rc;
517
518     rc = ImmSetCompositionFontW(hIMC,plf);
519
520     if (rc)
521         return S_OK;
522     else
523         return E_FAIL;
524 }
525
526 static HRESULT WINAPI ActiveIMMApp_SetCompositionStringA(IActiveIMMApp* This,
527         HIMC hIMC, DWORD dwIndex, LPVOID pComp, DWORD dwCompLen,
528         LPVOID pRead, DWORD dwReadLen)
529 {
530     BOOL rc;
531
532     rc = ImmSetCompositionStringA(hIMC,dwIndex,pComp,dwCompLen,pRead,dwReadLen);
533
534     if (rc)
535         return S_OK;
536     else
537         return E_FAIL;
538 }
539
540 static HRESULT WINAPI ActiveIMMApp_SetCompositionStringW(IActiveIMMApp* This,
541         HIMC hIMC, DWORD dwIndex, LPVOID pComp, DWORD dwCompLen,
542         LPVOID pRead, DWORD dwReadLen)
543 {
544     BOOL rc;
545
546     rc = ImmSetCompositionStringW(hIMC,dwIndex,pComp,dwCompLen,pRead,dwReadLen);
547
548     if (rc)
549         return S_OK;
550     else
551         return E_FAIL;
552 }
553
554 static HRESULT WINAPI ActiveIMMApp_SetCompositionWindow(IActiveIMMApp* This,
555         HIMC hIMC, COMPOSITIONFORM *pCompForm)
556 {
557     BOOL rc;
558
559     rc = ImmSetCompositionWindow(hIMC,pCompForm);
560
561     if (rc)
562         return S_OK;
563     else
564         return E_FAIL;
565 }
566
567 static HRESULT WINAPI ActiveIMMApp_SetConversionStatus(IActiveIMMApp* This,
568         HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
569 {
570     BOOL rc;
571
572     rc = ImmSetConversionStatus(hIMC,fdwConversion,fdwSentence);
573
574     if (rc)
575         return S_OK;
576     else
577         return E_FAIL;
578 }
579
580 static HRESULT WINAPI ActiveIMMApp_SetOpenStatus(IActiveIMMApp* This,
581         HIMC hIMC, BOOL fOpen)
582 {
583     BOOL rc;
584
585     rc = ImmSetOpenStatus(hIMC,fOpen);
586
587     if (rc)
588         return S_OK;
589     else
590         return E_FAIL;
591 }
592
593 static HRESULT WINAPI ActiveIMMApp_SetStatusWindowPos(IActiveIMMApp* This,
594         HIMC hIMC, POINT *pptPos)
595 {
596     BOOL rc;
597
598     rc = ImmSetStatusWindowPos(hIMC,pptPos);
599
600     if (rc)
601         return S_OK;
602     else
603         return E_FAIL;
604 }
605
606 static HRESULT WINAPI ActiveIMMApp_SimulateHotKey(IActiveIMMApp* This,
607         HWND hwnd, DWORD dwHotKeyID)
608 {
609     BOOL rc;
610
611     rc = ImmSimulateHotKey(hwnd,dwHotKeyID);
612
613     if (rc)
614         return S_OK;
615     else
616         return E_FAIL;
617 }
618
619 static HRESULT WINAPI ActiveIMMApp_UnregisterWordA(IActiveIMMApp* This,
620         HKL hKL, LPSTR szReading, DWORD dwStyle, LPSTR szUnregister)
621 {
622     BOOL rc;
623
624     rc = ImmUnregisterWordA(hKL,szReading,dwStyle,szUnregister);
625
626     if (rc)
627         return S_OK;
628     else
629         return E_FAIL;
630
631 }
632
633 static HRESULT WINAPI ActiveIMMApp_UnregisterWordW(IActiveIMMApp* This,
634         HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szUnregister)
635 {
636     BOOL rc;
637
638     rc = ImmUnregisterWordW(hKL,szReading,dwStyle,szUnregister);
639
640     if (rc)
641         return S_OK;
642     else
643         return E_FAIL;
644 }
645
646 static HRESULT WINAPI ActiveIMMApp_Activate(IActiveIMMApp* This,
647         BOOL fRestoreLayout)
648 {
649     FIXME("Stub\n");
650     return S_OK;
651 }
652
653 static HRESULT WINAPI ActiveIMMApp_Deactivate(IActiveIMMApp* This)
654 {
655     FIXME("Stub\n");
656     return S_OK;
657 }
658
659 static HRESULT WINAPI ActiveIMMApp_OnDefWindowProc(IActiveIMMApp* This,
660         HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
661 {
662     FIXME("Stub (%p %x %lx %lx)\n",hWnd,Msg,wParam,lParam);
663     return E_FAIL;
664 }
665
666 static HRESULT WINAPI ActiveIMMApp_FilterClientWindows(IActiveIMMApp* This,
667         ATOM *aaClassList, UINT uSize)
668 {
669     FIXME("Stub\n");
670     return S_OK;
671 }
672
673 static HRESULT WINAPI ActiveIMMApp_GetCodePageA(IActiveIMMApp* This,
674         HKL hKL, UINT *uCodePage)
675 {
676     FIXME("Stub\n");
677     return E_NOTIMPL;
678 }
679
680 static HRESULT WINAPI ActiveIMMApp_GetLangId(IActiveIMMApp* This,
681         HKL hKL, LANGID *plid)
682 {
683     FIXME("Stub\n");
684     return E_NOTIMPL;
685 }
686
687 static HRESULT WINAPI ActiveIMMApp_AssociateContextEx(IActiveIMMApp* This,
688         HWND hWnd, HIMC hIMC, DWORD dwFlags)
689 {
690     BOOL rc;
691
692     rc = ImmAssociateContextEx(hWnd,hIMC,dwFlags);
693
694     if (rc)
695         return S_OK;
696     else
697         return E_FAIL;
698 }
699
700 static HRESULT WINAPI ActiveIMMApp_DisableIME(IActiveIMMApp* This,
701         DWORD idThread)
702 {
703     BOOL rc;
704
705     rc = ImmDisableIME(idThread);
706
707     if (rc)
708         return S_OK;
709     else
710         return E_FAIL;
711 }
712
713 static HRESULT WINAPI ActiveIMMApp_GetImeMenuItemsA(IActiveIMMApp* This,
714         HIMC hIMC, DWORD dwFlags, DWORD dwType,
715         IMEMENUITEMINFOA *pImeParentMenu, IMEMENUITEMINFOA *pImeMenu,
716         DWORD dwSize, DWORD *pdwResult)
717 {
718     *pdwResult = ImmGetImeMenuItemsA(hIMC,dwFlags,dwType,pImeParentMenu,pImeMenu,dwSize);
719     return S_OK;
720 }
721
722 static HRESULT WINAPI ActiveIMMApp_GetImeMenuItemsW(IActiveIMMApp* This,
723         HIMC hIMC, DWORD dwFlags, DWORD dwType,
724         IMEMENUITEMINFOW *pImeParentMenu, IMEMENUITEMINFOW *pImeMenu,
725         DWORD dwSize, DWORD *pdwResult)
726 {
727     *pdwResult = ImmGetImeMenuItemsW(hIMC,dwFlags,dwType,pImeParentMenu,pImeMenu,dwSize);
728     return S_OK;
729 }
730
731 static HRESULT WINAPI ActiveIMMApp_EnumInputContext(IActiveIMMApp* This,
732         DWORD idThread, IEnumInputContext **ppEnum)
733 {
734     FIXME("Stub\n");
735     return E_NOTIMPL;
736 }
737
738 static const IActiveIMMAppVtbl ActiveIMMAppVtbl =
739 {
740     ActiveIMMApp_QueryInterface,
741     ActiveIMMApp_AddRef,
742     ActiveIMMApp_Release,
743
744     ActiveIMMApp_AssociateContext,
745     ActiveIMMApp_ConfigureIMEA,
746     ActiveIMMApp_ConfigureIMEW,
747     ActiveIMMApp_CreateContext,
748     ActiveIMMApp_DestroyContext,
749     ActiveIMMApp_EnumRegisterWordA,
750     ActiveIMMApp_EnumRegisterWordW,
751     ActiveIMMApp_EscapeA,
752     ActiveIMMApp_EscapeW,
753     ActiveIMMApp_GetCandidateListA,
754     ActiveIMMApp_GetCandidateListW,
755     ActiveIMMApp_GetCandidateListCountA,
756     ActiveIMMApp_GetCandidateListCountW,
757     ActiveIMMApp_GetCandidateWindow,
758     ActiveIMMApp_GetCompositionFontA,
759     ActiveIMMApp_GetCompositionFontW,
760     ActiveIMMApp_GetCompositionStringA,
761     ActiveIMMApp_GetCompositionStringW,
762     ActiveIMMApp_GetCompositionWindow,
763     ActiveIMMApp_GetContext,
764     ActiveIMMApp_GetConversionListA,
765     ActiveIMMApp_GetConversionListW,
766     ActiveIMMApp_GetConversionStatus,
767     ActiveIMMApp_GetDefaultIMEWnd,
768     ActiveIMMApp_GetDescriptionA,
769     ActiveIMMApp_GetDescriptionW,
770     ActiveIMMApp_GetGuideLineA,
771     ActiveIMMApp_GetGuideLineW,
772     ActiveIMMApp_GetIMEFileNameA,
773     ActiveIMMApp_GetIMEFileNameW,
774     ActiveIMMApp_GetOpenStatus,
775     ActiveIMMApp_GetProperty,
776     ActiveIMMApp_GetRegisterWordStyleA,
777     ActiveIMMApp_GetRegisterWordStyleW,
778     ActiveIMMApp_GetStatusWindowPos,
779     ActiveIMMApp_GetVirtualKey,
780     ActiveIMMApp_InstallIMEA,
781     ActiveIMMApp_InstallIMEW,
782     ActiveIMMApp_IsIME,
783     ActiveIMMApp_IsUIMessageA,
784     ActiveIMMApp_IsUIMessageW,
785     ActiveIMMApp_NotifyIME,
786     ActiveIMMApp_RegisterWordA,
787     ActiveIMMApp_RegisterWordW,
788     ActiveIMMApp_ReleaseContext,
789     ActiveIMMApp_SetCandidateWindow,
790     ActiveIMMApp_SetCompositionFontA,
791     ActiveIMMApp_SetCompositionFontW,
792     ActiveIMMApp_SetCompositionStringA,
793     ActiveIMMApp_SetCompositionStringW,
794     ActiveIMMApp_SetCompositionWindow,
795     ActiveIMMApp_SetConversionStatus,
796     ActiveIMMApp_SetOpenStatus,
797     ActiveIMMApp_SetStatusWindowPos,
798     ActiveIMMApp_SimulateHotKey,
799     ActiveIMMApp_UnregisterWordA,
800     ActiveIMMApp_UnregisterWordW,
801
802     ActiveIMMApp_Activate,
803     ActiveIMMApp_Deactivate,
804     ActiveIMMApp_OnDefWindowProc,
805     ActiveIMMApp_FilterClientWindows,
806     ActiveIMMApp_GetCodePageA,
807     ActiveIMMApp_GetLangId,
808     ActiveIMMApp_AssociateContextEx,
809     ActiveIMMApp_DisableIME,
810     ActiveIMMApp_GetImeMenuItemsA,
811     ActiveIMMApp_GetImeMenuItemsW,
812     ActiveIMMApp_EnumInputContext
813 };
814
815 DECLSPEC_HIDDEN HRESULT ActiveIMMApp_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
816 {
817     ActiveIMMApp *This;
818     if (pUnkOuter)
819         return CLASS_E_NOAGGREGATION;
820
821     This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ActiveIMMApp));
822     if (This == NULL)
823         return E_OUTOFMEMORY;
824
825     This->IActiveIMMApp_iface.lpVtbl = &ActiveIMMAppVtbl;
826     This->refCount = 1;
827
828     TRACE("returning %p\n",This);
829     *ppOut = (IUnknown *)This;
830     return S_OK;
831 }