source: trunk/src/imm32/im32.cpp@ 10605

Last change on this file since 10605 was 10605, checked in by sandervl, 21 years ago

KOM: update

File size: 80.4 KB
Line 
1#define INCL_GPI
2#define INCL_DOSMODULEMGR
3#define INCL_ORDINALS
4#define INCL_WINHOOKS
5#include <os2wrap.h>
6#include <os2im.h>
7#include <os2ime.h>
8#include <win32type.h>
9#include <winuser32.h>
10#include <win32api.h>
11#include <stdlib.h>
12#include <heapstring.h>
13
14#include "im32.h"
15
16#define CP_ACP 0
17
18extern BOOL WINAPI IsDBCSLeadByte(BYTE);
19
20typedef APIRET ( APIENTRY *PFN_IMASSOCIATEINSTANCE )( HWND hwnd, HIMI himi, PHIMI phimiPrev );
21
22typedef APIRET ( APIENTRY *PFN_IMCREATEINSTANCE )( PHIMI phimi );
23
24typedef APIRET ( APIENTRY *PFN_IMDESTROYINSTANCE )( HIMI himi );
25
26typedef APIRET ( APIENTRY *PFN_IMGETINSTANCE )( HWND hwnd, PHIMI phimi );
27
28typedef APIRET ( APIENTRY *PFN_IMQUERYDEFAULTIMWINDOW )( HWND hwnd, PHWND phwnd );
29
30typedef APIRET ( APIENTRY *PFN_IMRELEASEINSTANCE )( HWND hwnd, HIMI himi );
31
32typedef APIRET ( APIENTRY *PFN_IMENUMREGISTERWORD )( HIMI himi,
33 REGISTERWORDENUMPROC pfnEnumProc,
34 PSZ pReading,
35 ULONG ulType,
36 PSZ pRegister,
37 PVOID pData );
38
39typedef APIRET ( APIENTRY *PFN_IMQUERYREGISTERWORDTYPE )( HIMI himi, PULONG pulCount,
40 PWORDTYPE pWordType );
41
42
43typedef APIRET ( APIENTRY *PFN_IMREGISTERWORD )( HIMI himi,
44 PSZ pszReading,
45 ULONG ulType,
46 PSZ pszRegister );
47
48typedef APIRET ( APIENTRY *PFN_IMDEREGISTERWORD )( HIMI himi,
49 PSZ pszReading,
50 ULONG ulType,
51 PSZ pszDeregister );
52
53typedef APIRET ( APIENTRY *PFN_IMSHOWIMEDLG )( HIMI himi,
54 ULONG ulDlgType,
55 PREGISTERWORDHEADER pRegWord );
56
57typedef APIRET ( APIENTRY *PFN_IMESCAPE )( HIMI himi, ULONG ulEscaoe, PVOID pData );
58
59typedef APIRET ( APIENTRY *PFN_IMQUERYCANDIDATELIST )( HIMI himi,
60 ULONG ulIndex,
61 PCANDIDATELISTHEADER pCandidateList,
62 PULONG pulBuffer );
63
64typedef APIRET ( APIENTRY *PFN_IMQUERYCANDIDATEWINDOWPOS )( HIMI himi,
65 PCANDIDATEPOS pCandidatePos );
66
67typedef APIRET ( APIENTRY *PFN_IMSETCANDIDATEWINDOWPOS )( HIMI himi,
68 PCANDIDATEPOS pCandidatePos );
69
70typedef APIRET ( APIENTRY *PFN_IMQUERYCONVERSIONFONT )( HIMI himi,
71 PFATTRS pFontAttrs );
72
73typedef APIRET ( APIENTRY *PFN_IMSETCONVERSIONFONT )( HIMI himi,
74 PFATTRS pFontAttrs );
75
76typedef APIRET ( APIENTRY *PFN_IMQUERYCONVERSIONFONTSIZE )( HIMI himi,
77 PSIZEF psizfxBox );
78
79typedef APIRET ( APIENTRY *PFN_IMSETCONVERSOINFONTSIZE )( HIMI himi,
80 PSIZEF psizfxBox );
81
82typedef APIRET ( APIENTRY *PFN_IMGETCONVERSIONSTRING )( HIMI himi, ULONG ulIndex,
83 PVOID pBuf, PULONG pulBufLen );
84
85typedef APIRET ( APIENTRY *PFN_IMSETCONVERSIONSTRING )( HIMI himi, ULONG ulIndex,
86 PVOID pConv, ULONG ulConvLen,
87 PVOID pReading, ULONG ulReadingLen );
88
89typedef APIRET ( APIENTRY *PFN_IMQUERYCONVERSIONANGLE )( HIMI himi, PGRADIENTL pgradlAngle );
90
91typedef APIRET ( APIENTRY *PFN_IMSETCONVERSIONANGLE )( HIMI himi, PGRADIENTL pgradlAngle );
92
93typedef APIRET ( APIENTRY *PFN_IMQUERYCONVERSIONWINDOWPOS )( HIMI himi,
94 PCONVERSIONPOS pConvPos );
95
96typedef APIRET ( APIENTRY *PFN_IMSETCONVERSIONWINDOWPOS )( HIMI himi,
97 PCONVERSIONPOS pConvPos );
98
99typedef APIRET ( APIENTRY *PFN_IMGETRESULTSTRING )( HIMI himi, ULONG ulIndex,
100 PVOID pBuf, PULONG pulBufLen );
101
102typedef APIRET ( APIENTRY *PFN_IMQUERYINFOMSG )( HIMI himi, ULONG ulIndex,
103 PVOID pBuf, PULONG pulBufLen );
104
105typedef APIRET ( APIENTRY *PFN_IMQUERYSTATUSWINDOWPOS )( HIMI himi, PPOINTL pptPos, PSIZEL pszlSize );
106
107typedef APIRET ( APIENTRY *PFN_IMSETSTATUSWINDOWPOS )( HIMI himi, PPOINTL pptPos );
108
109typedef APIRET ( APIENTRY *PFN_IMSHOWSTATUSWINDOW )( HIMI himi, ULONG fShow );
110
111typedef APIRET ( APIENTRY *PFN_IMGETSTATUSSTRING )( HIMI himi, ULONG ulIndex,
112 PVOID pBuf, PULONG pulBufLen );
113
114typedef APIRET ( APIENTRY *PFN_IMCONVERTSTRING )( HIMI himi,
115 PSZ pSrc,
116 PCANDIDATELISTHEADER pDst,
117 PULONG pulBufLen,
118 ULONG ulFlag );
119
120typedef APIRET ( APIENTRY *PFN_IMQUERYIMMODE )( HIMI himi,
121 PULONG pulInputMode,
122 PULONG pulConversionMode );
123
124typedef APIRET ( APIENTRY *PFN_IMSETIMMODE )( HIMI himi,
125 ULONG ulInputMode,
126 ULONG ulConversionMode );
127
128typedef APIRET ( APIENTRY *PFN_IMQUERYIMEINFO )( ULONG ImeId, PIMEINFOHEADER pImeInfoHeader,
129 PULONG pulBufLen );
130
131typedef APIRET ( APIENTRY *PFN_IMQUERYIMEPROPERTY )( HIMI himi, ULONG ulIndex, PULONG pulProp );
132
133typedef APIRET ( APIENTRY *PFN_IMREQUESTIME )( HIMI himi, ULONG ulAction,
134 ULONG ulIndex, ULONG ulValue );
135
136typedef APIRET ( APIENTRY *PFN_IMISIMEMESSAGE )( HWND hwndIm,
137 ULONG msg,
138 MPARAM mp1,
139 MPARAM mp2,
140 PBOOL pfResult );
141
142typedef APIRET ( APIENTRY *PFN_IMQUERYIMELIST )( ULONG ulCodepage,
143 PULONG aImeId,
144 PULONG pulCount );
145
146typedef APIRET ( APIENTRY *PFN_IMQUERYCURRENTIME )( HIMI himi, PULONG pImeId );
147
148typedef APIRET ( APIENTRY *PFN_IMSETCURRENTIME )( HIMI himi,
149 ULONG ulAction,
150 ULONG ImeId );
151
152typedef APIRET ( APIENTRY *PFN_IMQUERYDEFAULTIME )( ULONG ulCodepage, PULONG pImeId );
153
154typedef APIRET ( APIENTRY *PFN_IMSETDEFAULTIME )( ULONG ulCodepage, ULONG ImeId );
155
156
157typedef APIRET ( APIENTRY *PFN_IMSETIMELISTORDER )( ULONG ulCodepage,
158 ULONG ulAction,
159 ULONG ImeIdTarget,
160 ULONG ImeIdIndex );
161
162typedef APIRET ( APIENTRY *PFN_IMQUERYIMEID )( PSZ pszIMEName, PULONG pImeId );
163
164typedef APIRET ( APIENTRY *PFN_IMQUERYMSGQUEUEPROPERTY )( HMQ hmq, PULONG pulFlag );
165
166typedef APIRET ( APIENTRY *PFN_IMSETMSGQUEUEPROPERTY )( HMQ hmq, ULONG ulFlag );
167
168
169typedef APIRET ( APIENTRY *PFN_IMREQUESTEVENT)( HIMI hImi,
170 ULONG msg,
171 ULONG mp1,
172 ULONG mp2 );
173
174typedef APIRET ( APIENTRY *PFN_IMREQUESTIMINSTANCE)( HIMI hImi,
175 PIMINSTANCE * ppIMInstance );
176
177typedef APIRET ( APIENTRY *PFN_IMRELEASEIMINSTANCE)( HIMI hImi );
178
179typedef APIRET ( APIENTRY *PFN_IMQUERYIMINSTANCEREQCOUNT)( HIMI hImi,
180 PULONG pulCount );
181
182typedef APIRET ( APIENTRY *PFN_IMCREATEIMIPART)( ULONG ulPartSize,
183 PHIMIP phimiPart );
184
185typedef APIRET ( APIENTRY *PFN_IMDESTROYIMIPART)( HIMIP himiPart );
186
187typedef APIRET ( APIENTRY *PFN_IMQUERYIMIPARTSIZE)( HIMIP himiPart,
188 PULONG pulPartSize );
189
190typedef APIRET ( APIENTRY *PFN_IMREQUESTIMIPART)( HIMIP himiPart,
191 PVOID * ppPartData );
192
193typedef APIRET ( APIENTRY *PFN_IMRELEASEIMIPART)( HIMIP himiPart );
194
195typedef APIRET ( APIENTRY *PFN_IMRESIZEIMIPART)( HIMIP himiPart,
196 ULONG ulNewSize );
197
198typedef APIRET ( APIENTRY *PFN_IMQUERYIMIPARTREQCOUNT)( HIMIP himiPart,
199 PULONG pulCount );
200
201
202typedef APIRET ( APIENTRY *PFN_IMBROADCASTDATA)( PSZ pszIMEName,
203 ULONG ulIndex,
204 PBROADCASTDATAHEADER pData );
205
206typedef APIRET ( APIENTRY *PFN_IMGETINSTANCEMQ )( HMQ hmq, PHIMI phimi );
207
208typedef APIRET ( APIENTRY *PFN_IMRELEASEINSTANCEMQ )( HMQ hmq, HIMI himi );
209
210static BOOL fIM32Inited = FALSE;
211
212static HMODULE hIM32Mod = NULLHANDLE;
213
214static PFN_IMASSOCIATEINSTANCE pfnImAssociateInstance = NULL;
215
216static PFN_IMCREATEINSTANCE pfnImCreateInstance = NULL;
217
218static PFN_IMDESTROYINSTANCE pfnImDestroyInstance = NULL;
219
220static PFN_IMGETINSTANCE pfnImGetInstance = NULL;
221
222static PFN_IMQUERYDEFAULTIMWINDOW pfnImQueryDefaultIMWindow = NULL;
223
224static PFN_IMRELEASEINSTANCE pfnImReleaseInstance = NULL;
225
226static PFN_IMENUMREGISTERWORD pfnImEnumRegisterWord = NULL;
227
228static PFN_IMQUERYREGISTERWORDTYPE pfnImQueryRegisterWordType = NULL;
229
230static PFN_IMREGISTERWORD pfnImRegisterWord = NULL;
231
232static PFN_IMDEREGISTERWORD pfnImDeregisterWord = NULL;
233
234static PFN_IMSHOWIMEDLG pfnImShowIMEDlg = NULL;
235
236static PFN_IMESCAPE pfnImEscape = NULL;
237
238static PFN_IMQUERYCANDIDATELIST pfnImQueryCandidateList = NULL;
239
240static PFN_IMQUERYCANDIDATEWINDOWPOS pfnImQueryCandidateWindowPos = NULL;
241
242static PFN_IMSETCANDIDATEWINDOWPOS pfnImSetCandidateWindowPos = NULL;
243
244static PFN_IMQUERYCONVERSIONFONT pfnImQueryConversionFont = NULL;
245
246static PFN_IMSETCONVERSIONFONT pfnImSetConversionFont = NULL;
247
248static PFN_IMQUERYCONVERSIONFONTSIZE pfnImQueryConversionFontSize = NULL;
249
250static PFN_IMSETCONVERSOINFONTSIZE pfnImSetConversionFontSize = NULL;
251
252static PFN_IMGETCONVERSIONSTRING pfnImGetConversionString = NULL;
253
254static PFN_IMSETCONVERSIONSTRING pfnImSetConversionString = NULL;
255
256static PFN_IMQUERYCONVERSIONANGLE pfnImQueryConversionAngle = NULL;
257
258static PFN_IMSETCONVERSIONANGLE pfnImSetConversionAngle = NULL;
259
260static PFN_IMQUERYCONVERSIONWINDOWPOS pfnImQueryConversionWindowPos = NULL;
261
262static PFN_IMSETCONVERSIONWINDOWPOS pfnImSetConversionWindowPos = NULL;
263
264static PFN_IMGETRESULTSTRING pfnImGetResultString = NULL;
265
266static PFN_IMQUERYINFOMSG pfnImQueryInfoMsg = NULL;
267
268static PFN_IMQUERYSTATUSWINDOWPOS pfnImQueryStatusWindowPos = NULL;
269
270static PFN_IMSETSTATUSWINDOWPOS pfnImSetStatusWindowPos = NULL;
271
272static PFN_IMSHOWSTATUSWINDOW pfnImShowStatusWindow = NULL;
273
274static PFN_IMGETSTATUSSTRING pfnImGetStatusString = NULL;
275
276static PFN_IMCONVERTSTRING pfnImConvertString = NULL;
277
278static PFN_IMQUERYIMMODE pfnImQueryIMMode = NULL;
279
280static PFN_IMSETIMMODE pfnImSetIMMode = NULL;
281
282static PFN_IMQUERYIMEINFO pfnImQueryIMEInfo = NULL;
283
284static PFN_IMQUERYIMEPROPERTY pfnImQueryIMEProperty = NULL;
285
286static PFN_IMREQUESTIME pfnImRequestIME = NULL;
287
288static PFN_IMISIMEMESSAGE pfnImIsIMEMessage = NULL;
289
290static PFN_IMQUERYIMELIST pfnImQueryIMEList = NULL;
291
292static PFN_IMQUERYCURRENTIME pfnImQueryCurrentIME = NULL;
293
294static PFN_IMSETCURRENTIME pfnImSetCurrentIME = NULL;
295
296static PFN_IMQUERYDEFAULTIME pfnImQueryDefaultIME = NULL;
297
298static PFN_IMSETDEFAULTIME pfnImSetDefaultIME = NULL;
299
300static PFN_IMSETIMELISTORDER pfnImSetIMEListOrder = NULL;
301
302static PFN_IMQUERYIMEID pfnImQueryIMEID = NULL;
303
304static PFN_IMQUERYMSGQUEUEPROPERTY pfnImQueryMsgQueueProperty = NULL;
305
306static PFN_IMSETMSGQUEUEPROPERTY pfnImSetMsgQueueProperty = NULL;
307
308// Input Method Interfaces for IME
309
310static PFN_IMREQUESTEVENT pfnImRequestEvent = NULL;
311
312static PFN_IMREQUESTIMINSTANCE pfnImRequestIMInstance = NULL;
313
314static PFN_IMRELEASEIMINSTANCE pfnImReleaseIMInstance = NULL;
315
316static PFN_IMQUERYIMINSTANCEREQCOUNT pfnImQueryIMInstanceReqCount = NULL;
317
318static PFN_IMCREATEIMIPART pfnImCreateIMIPart = NULL;
319
320static PFN_IMDESTROYIMIPART pfnImDestroyIMIPart = NULL;
321
322static PFN_IMQUERYIMIPARTSIZE pfnImQueryIMIPartSize = NULL;
323
324static PFN_IMREQUESTIMIPART pfnImRequestIMIPart = NULL;
325
326static PFN_IMRELEASEIMIPART pfnImReleaseIMIPart = NULL;
327
328static PFN_IMRESIZEIMIPART pfnImResizeIMIPart = NULL;
329
330static PFN_IMQUERYIMIPARTREQCOUNT pfnImQueryIMIPartReqCount = NULL;
331
332static PFN_IMBROADCASTDATA pfnImBroadcastData = NULL;
333
334static PFN_IMGETINSTANCEMQ pfnImGetInstanceMQ = NULL;
335
336static PFN_IMRELEASEINSTANCEMQ pfnImReleaseInstanceMQ = NULL;
337
338#define DOSQUERYPROCADDR( ordinal, ppfn ) \
339 DosQueryProcAddr( hIM32Mod, ordinal, NULL, ( PFN * )( ppfn ))
340
341BOOL IM32Init( VOID )
342{
343 UCHAR szErrorName[ 256 ];
344
345 if( fIM32Inited )
346 return TRUE;
347
348 if( !IsDBCSEnv() )
349 return FALSE;
350
351 hIM32Mod = NULLHANDLE;
352
353 if( DosLoadModule(( PSZ )szErrorName, sizeof( szErrorName ), "OS2IM.DLL", &hIM32Mod ))
354 goto error_exit;
355
356 if( DOSQUERYPROCADDR( ORD_IMASSOCIATEINSTANCE, &pfnImAssociateInstance ))
357 goto error_exit;
358
359 if( DOSQUERYPROCADDR( ORD_IMCREATEINSTANCE, &pfnImCreateInstance ))
360 goto error_exit;
361
362 if( DOSQUERYPROCADDR( ORD_IMDESTROYINSTANCE, &pfnImDestroyInstance ))
363 goto error_exit;
364
365 if( DOSQUERYPROCADDR( ORD_IMGETINSTANCE, &pfnImGetInstance ))
366 goto error_exit;
367
368 if( DOSQUERYPROCADDR( ORD_IMQUERYDEFAULTIMWINDOW, &pfnImQueryDefaultIMWindow ))
369 goto error_exit;
370
371 if( DOSQUERYPROCADDR( ORD_IMRELEASEINSTANCE, &pfnImReleaseInstance ))
372 goto error_exit;
373
374 if( DOSQUERYPROCADDR( ORD_IMENUMREGISTERWORD, &pfnImEnumRegisterWord ))
375 goto error_exit;
376
377 if( DOSQUERYPROCADDR( ORD_IMQUERYREGISTERWORDTYPE, &pfnImQueryRegisterWordType ))
378 goto error_exit;
379
380 if( DOSQUERYPROCADDR( ORD_IMREGISTERWORD, &pfnImRegisterWord ))
381 goto error_exit;
382
383 if( DOSQUERYPROCADDR( ORD_IMDEREGISTERWORD, &pfnImDeregisterWord ))
384 goto error_exit;
385
386 if( DOSQUERYPROCADDR( ORD_IMSHOWIMEDLG, &pfnImShowIMEDlg ))
387 goto error_exit;
388
389 if( DOSQUERYPROCADDR( ORD_IMESCAPE, &pfnImEscape ))
390 goto error_exit;
391
392 if( DOSQUERYPROCADDR( ORD_IMQUERYCANDIDATELIST, &pfnImQueryCandidateList ))
393 goto error_exit;
394
395 if( DOSQUERYPROCADDR( ORD_IMQUERYCANDIDATEWINDOWPOS, &pfnImQueryCandidateWindowPos ))
396 goto error_exit;
397
398 if( DOSQUERYPROCADDR( ORD_IMSETCANDIDATEWINDOWPOS, &pfnImSetCandidateWindowPos ))
399 goto error_exit;
400
401 if( DOSQUERYPROCADDR( ORD_IMQUERYCONVERSIONFONT, &pfnImQueryConversionFont ))
402 goto error_exit;
403
404 if( DOSQUERYPROCADDR( ORD_IMSETCONVERSIONFONT, &pfnImSetConversionFont ))
405 goto error_exit;
406
407 if( DOSQUERYPROCADDR( ORD_IMGETCONVERSIONSTRING, &pfnImGetConversionString ))
408 goto error_exit;
409
410 if( DOSQUERYPROCADDR( ORD_IMSETCONVERSIONSTRING, &pfnImSetConversionString ))
411 goto error_exit;
412
413 if( DOSQUERYPROCADDR( ORD_IMQUERYCONVERSIONWINDOWPOS, &pfnImQueryConversionWindowPos ))
414 goto error_exit;
415
416 if( DOSQUERYPROCADDR( ORD_IMSETCONVERSIONWINDOWPOS, &pfnImSetConversionWindowPos ))
417 goto error_exit;
418
419 if( DOSQUERYPROCADDR( ORD_IMGETRESULTSTRING, &pfnImGetResultString ))
420 goto error_exit;
421
422 if( DOSQUERYPROCADDR( ORD_IMQUERYCONVERSIONFONTSIZE, &pfnImQueryConversionFontSize ))
423 goto error_exit;
424
425 if( DOSQUERYPROCADDR( ORD_IMSETCONVERSIONFONTSIZE, &pfnImSetConversionFontSize ))
426 goto error_exit;
427
428 if( DOSQUERYPROCADDR( ORD_IMQUERYCONVERSIONANGLE, &pfnImQueryConversionAngle ))
429 goto error_exit;
430
431 if( DOSQUERYPROCADDR( ORD_IMSETCONVERSIONANGLE, &pfnImSetConversionAngle ))
432 goto error_exit;
433
434 if( DOSQUERYPROCADDR( ORD_IMQUERYINFOMSG, &pfnImQueryInfoMsg ))
435 goto error_exit;
436
437 if( DOSQUERYPROCADDR( ORD_IMQUERYSTATUSWINDOWPOS, &pfnImQueryStatusWindowPos ))
438 goto error_exit;
439
440 if( DOSQUERYPROCADDR( ORD_IMSETSTATUSWINDOWPOS, &pfnImSetStatusWindowPos ))
441 goto error_exit;
442
443 if( DOSQUERYPROCADDR( ORD_IMSHOWSTATUSWINDOW, &pfnImShowStatusWindow ))
444 goto error_exit;
445
446 if( DOSQUERYPROCADDR( ORD_IMGETSTATUSSTRING, &pfnImGetStatusString ))
447 goto error_exit;
448
449 if( DOSQUERYPROCADDR( ORD_IMCONVERTSTRING, &pfnImConvertString ))
450 goto error_exit;
451
452 if( DOSQUERYPROCADDR( ORD_IMQUERYIMMODE, &pfnImQueryIMMode ))
453 goto error_exit;
454
455 if( DOSQUERYPROCADDR( ORD_IMSETIMMODE, &pfnImSetIMMode ))
456 goto error_exit;
457
458 if( DOSQUERYPROCADDR( ORD_IMQUERYIMEINFO, &pfnImQueryIMEInfo ))
459 goto error_exit;
460
461 if( DOSQUERYPROCADDR( ORD_IMQUERYIMEPROPERTY, &pfnImQueryIMEProperty ))
462 goto error_exit;
463
464 if( DOSQUERYPROCADDR( ORD_IMREQUESTIME, &pfnImRequestIME ))
465 goto error_exit;
466
467 if( DOSQUERYPROCADDR( ORD_IMISIMEMESSAGE, &pfnImIsIMEMessage ))
468 goto error_exit;
469
470 if( DOSQUERYPROCADDR( ORD_IMQUERYIMELIST, &pfnImQueryIMEList ))
471 goto error_exit;
472
473 if( DOSQUERYPROCADDR( ORD_IMQUERYCURRENTIME, &pfnImQueryCurrentIME ))
474 goto error_exit;
475
476 if( DOSQUERYPROCADDR( ORD_IMSETCURRENTIME, &pfnImSetCurrentIME ))
477 goto error_exit;
478
479 if( DOSQUERYPROCADDR( ORD_IMQUERYDEFAULTIME, &pfnImQueryDefaultIME ))
480 goto error_exit;
481
482 if( DOSQUERYPROCADDR( ORD_IMSETDEFAULTIME, &pfnImSetDefaultIME ))
483 goto error_exit;
484
485 if( DOSQUERYPROCADDR( ORD_IMSETIMELISTORDER, &pfnImSetIMEListOrder ))
486 goto error_exit;
487
488 if( DOSQUERYPROCADDR( ORD_IMQUERYIMEID, &pfnImQueryIMEID ))
489 goto error_exit;
490
491 if( DOSQUERYPROCADDR( ORD_IMQUERYMSGQUEUEPROPERTY, &pfnImQueryMsgQueueProperty ))
492 goto error_exit;
493
494 if( DOSQUERYPROCADDR( ORD_IMSETMSGQUEUEPROPERTY, &pfnImSetMsgQueueProperty ))
495 goto error_exit;
496
497 if( DOSQUERYPROCADDR( ORD_IMREQUESTEVENT, &pfnImRequestEvent ))
498 goto error_exit;
499
500 if( DOSQUERYPROCADDR( ORD_IMREQUESTIMINSTANCE, &pfnImRequestIMInstance ))
501 goto error_exit;
502
503 if( DOSQUERYPROCADDR( ORD_IMRELEASEIMINSTANCE, &pfnImReleaseIMInstance ))
504 goto error_exit;
505
506 if( DOSQUERYPROCADDR( ORD_IMQUERYIMINSTANCEREQCOUNT, &pfnImQueryIMInstanceReqCount ))
507 goto error_exit;
508
509 if( DOSQUERYPROCADDR( ORD_IMCREATEIMIPART, &pfnImCreateIMIPart ))
510 goto error_exit;
511
512 if( DOSQUERYPROCADDR( ORD_IMDESTROYIMIPART, &pfnImDestroyIMIPart ))
513 goto error_exit;
514
515 if( DOSQUERYPROCADDR( ORD_IMQUERYIMIPARTSIZE, &pfnImQueryIMIPartSize ))
516 goto error_exit;
517
518 if( DOSQUERYPROCADDR( ORD_IMREQUESTIMIPART, &pfnImRequestIMIPart ))
519 goto error_exit;
520
521 if( DOSQUERYPROCADDR( ORD_IMRELEASEIMIPART, &pfnImReleaseIMIPart ))
522 goto error_exit;
523
524 if( DOSQUERYPROCADDR( ORD_IMRESIZEIMIPART, &pfnImResizeIMIPart ))
525 goto error_exit;
526
527 if( DOSQUERYPROCADDR( ORD_IMQUERYIMIPARTREQCOUNT, &pfnImQueryIMIPartReqCount ))
528 goto error_exit;
529
530 if( DOSQUERYPROCADDR( ORD_IMBROADCASTDATA, &pfnImBroadcastData ))
531 goto error_exit;
532
533 if( DOSQUERYPROCADDR( ORD_IMGETINSTANCEMQ, &pfnImGetInstanceMQ ))
534 goto error_exit;
535
536 if( DOSQUERYPROCADDR( ORD_IMRELEASEINSTANCEMQ, &pfnImReleaseInstanceMQ ))
537 goto error_exit;
538
539 fIM32Inited = TRUE;
540
541error_exit:
542
543 if( hIM32Mod && !fIM32Inited )
544 DosFreeModule( hIM32Mod );
545
546 return fIM32Inited;
547}
548
549VOID IM32Term( VOID )
550{
551 if( !fIM32Inited )
552 return;
553
554 DosFreeModule( hIM32Mod );
555
556 fIM32Inited = FALSE;
557}
558
559APIRET APIENTRY ImAssociateInstance( HWND hwnd, HIMI himi, PHIMI phimiPrev )
560{
561 USHORT sel;
562 APIRET rc;
563
564 if( !fIM32Inited )
565 return 1;
566
567 sel = RestoreOS2FS();
568 rc = pfnImAssociateInstance( hwnd, himi, phimiPrev );
569 SetFS( sel );
570
571 return rc;
572}
573
574APIRET APIENTRY ImCreateInstance( PHIMI phimi )
575{
576 USHORT sel;
577 APIRET rc;
578
579 if( !fIM32Inited )
580 return 1;
581
582 sel = RestoreOS2FS();
583 rc = pfnImCreateInstance( phimi );
584 SetFS( sel );
585
586 return rc;
587}
588
589APIRET APIENTRY ImDestroyInstance( HIMI himi )
590{
591 USHORT sel;
592 APIRET rc;
593
594 if( !fIM32Inited )
595 return 1;
596
597 sel = RestoreOS2FS();
598 rc = pfnImDestroyInstance( himi );
599 SetFS( sel );
600
601 return rc;
602}
603
604
605APIRET APIENTRY ImGetInstance( HWND hwnd, PHIMI phimi )
606{
607 USHORT sel;
608 APIRET rc;
609
610 if( !fIM32Inited )
611 return 1;
612
613 sel = RestoreOS2FS();
614 rc = pfnImGetInstance( hwnd, phimi );
615 SetFS( sel );
616
617 return rc;
618}
619
620APIRET APIENTRY ImQueryDefaultIMWindow( HWND hwnd, PHWND phwnd )
621{
622 USHORT sel;
623 APIRET rc;
624
625 if( !fIM32Inited )
626 return 1;
627
628 sel = RestoreOS2FS();
629 rc = pfnImQueryDefaultIMWindow( hwnd, phwnd );
630 SetFS( sel );
631
632 return rc;
633}
634
635APIRET APIENTRY ImReleaseInstance( HWND hwnd, HIMI himi )
636{
637 USHORT sel;
638 APIRET rc;
639
640 if( !fIM32Inited )
641 return 1;
642
643 sel = RestoreOS2FS();
644 rc = pfnImReleaseInstance( hwnd, himi );
645 SetFS( sel );
646
647 return rc;
648}
649
650APIRET APIENTRY ImEnumRegisterWord( HIMI himi,
651 REGISTERWORDENUMPROC pfnEnumProc,
652 PSZ pReading,
653 ULONG ulType,
654 PSZ pRegister,
655 PVOID pData )
656{
657 USHORT sel;
658 APIRET rc;
659
660 if( !fIM32Inited )
661 return 1;
662
663 sel = RestoreOS2FS();
664 rc = pfnImEnumRegisterWord( himi, pfnEnumProc, pReading, ulType, pRegister, pData );
665 SetFS( sel );
666
667 return rc;
668}
669
670APIRET APIENTRY ImQueryRegisterWordType( HIMI himi, PULONG pulCount,
671 PWORDTYPE pWordType )
672{
673 USHORT sel;
674 APIRET rc;
675
676 if( !fIM32Inited )
677 return 1;
678
679 sel = RestoreOS2FS();
680 rc = pfnImQueryRegisterWordType( himi, pulCount, pWordType );
681 SetFS( sel );
682
683 return rc;
684}
685
686
687APIRET APIENTRY ImRegisterWord( HIMI himi,
688 PSZ pszReading,
689 ULONG ulType,
690 PSZ pszRegister )
691{
692 USHORT sel;
693 APIRET rc;
694
695 if( !fIM32Inited )
696 return 1;
697
698 sel = RestoreOS2FS();
699 rc = pfnImRegisterWord( himi, pszReading, ulType, pszRegister );
700 SetFS( sel );
701
702 return rc;
703}
704
705APIRET APIENTRY ImDeregisterWord( HIMI himi,
706 PSZ pszReading,
707 ULONG ulType,
708 PSZ pszDeregister )
709{
710 USHORT sel;
711 APIRET rc;
712
713 if( !fIM32Inited )
714 return 1;
715
716 sel = RestoreOS2FS();
717 rc = pfnImDeregisterWord( himi, pszReading, ulType, pszDeregister );
718 SetFS( sel );
719
720 return rc;
721}
722
723APIRET APIENTRY ImShowIMEDlg( HIMI himi,
724 ULONG ulDlgType,
725 PREGISTERWORDHEADER pRegWord )
726{
727 USHORT sel;
728 APIRET rc;
729
730 if( !fIM32Inited )
731 return 1;
732
733 sel = RestoreOS2FS();
734 rc = pfnImShowIMEDlg( himi, ulDlgType, pRegWord );
735 SetFS( sel );
736
737 return rc;
738}
739
740APIRET APIENTRY ImEscape( HIMI himi, ULONG ulEscape, PVOID pData )
741{
742 USHORT sel;
743 APIRET rc;
744
745 if( !fIM32Inited )
746 return 1;
747
748 sel = RestoreOS2FS();
749 rc = pfnImEscape( himi, ulEscape, pData );
750 SetFS( sel );
751
752 return rc;
753}
754
755APIRET APIENTRY ImQueryCandidateList( HIMI himi,
756 ULONG ulIndex,
757 PCANDIDATELISTHEADER pCandidateList,
758 PULONG pulBuffer )
759{
760 USHORT sel;
761 APIRET rc;
762
763 if( !fIM32Inited )
764 return 1;
765
766 sel = RestoreOS2FS();
767 rc = pfnImQueryCandidateList( himi, ulIndex, pCandidateList, pulBuffer );
768 SetFS( sel );
769
770 return rc;
771}
772
773APIRET APIENTRY ImQueryCandidateWindowPos( HIMI himi,
774 PCANDIDATEPOS pCandidatePos )
775{
776 USHORT sel;
777 APIRET rc;
778
779 if( !fIM32Inited )
780 return 1;
781
782 sel = RestoreOS2FS();
783 rc = pfnImQueryCandidateWindowPos( himi, pCandidatePos );
784 SetFS( sel );
785
786 return rc;
787}
788
789APIRET APIENTRY ImSetCandidateWindowPos( HIMI himi,
790 PCANDIDATEPOS pCandidatePos )
791{
792 USHORT sel;
793 APIRET rc;
794
795 if( !fIM32Inited )
796 return 1;
797
798 sel = RestoreOS2FS();
799 rc = pfnImSetCandidateWindowPos( himi, pCandidatePos );
800 SetFS( sel );
801
802 return rc;
803}
804
805APIRET APIENTRY ImQueryConversionFont( HIMI himi,
806 PFATTRS pFontAttrs )
807{
808 USHORT sel;
809 APIRET rc;
810
811 if( !fIM32Inited )
812 return 1;
813
814 sel = RestoreOS2FS();
815 rc = pfnImQueryConversionFont( himi, pFontAttrs );
816 SetFS( sel );
817
818 return rc;
819}
820
821APIRET APIENTRY ImSetConversionFont( HIMI himi,
822 PFATTRS pFontAttrs )
823{
824 USHORT sel;
825 APIRET rc;
826
827 if( !fIM32Inited )
828 return 1;
829
830 sel = RestoreOS2FS();
831 rc = pfnImSetConversionFont( himi, pFontAttrs );
832 SetFS( sel );
833
834 return rc;
835}
836
837APIRET APIENTRY ImQueryConversionFontSize( HIMI himi,
838 PSIZEF psizfxBox )
839{
840 USHORT sel;
841 APIRET rc;
842
843 if( !fIM32Inited )
844 return 1;
845
846 sel = RestoreOS2FS();
847 rc = pfnImQueryConversionFontSize( himi, psizfxBox );
848 SetFS( sel );
849
850 return rc;
851}
852
853APIRET APIENTRY ImSetConversionFontSize( HIMI himi,
854 PSIZEF psizfxBox )
855{
856 USHORT sel;
857 APIRET rc;
858
859 if( !fIM32Inited )
860 return 1;
861
862 sel = RestoreOS2FS();
863 rc = pfnImSetConversionFontSize( himi, psizfxBox );
864 SetFS( sel );
865
866 return rc;
867}
868
869APIRET APIENTRY ImGetConversionString( HIMI himi, ULONG ulIndex,
870 PVOID pBuf, PULONG pulBufLen )
871{
872 USHORT sel;
873 APIRET rc;
874
875 if( !fIM32Inited )
876 return 1;
877
878 sel = RestoreOS2FS();
879 rc = pfnImGetConversionString( himi, ulIndex, pBuf, pulBufLen );
880 SetFS( sel );
881
882 return rc;
883}
884
885APIRET APIENTRY ImSetConversionString( HIMI himi, ULONG ulIndex,
886 PVOID pConv, ULONG ulConvLen,
887 PVOID pReading, ULONG ulReadingLen )
888{
889 USHORT sel;
890 APIRET rc;
891
892 if( !fIM32Inited )
893 return 1;
894
895 sel = RestoreOS2FS();
896 rc = pfnImSetConversionString( himi, ulIndex, pConv, ulConvLen, pReading, ulReadingLen );
897 SetFS( sel );
898
899 return rc;
900}
901
902APIRET APIENTRY ImQueryConversionAngle( HIMI himi, PGRADIENTL pgradlAngle )
903{
904 USHORT sel;
905 APIRET rc;
906
907 if( !fIM32Inited )
908 return 1;
909
910 sel = RestoreOS2FS();
911 rc = pfnImQueryConversionAngle( himi, pgradlAngle );
912 SetFS( sel );
913
914 return rc;
915}
916
917APIRET APIENTRY ImSetConversionAngle( HIMI himi, PGRADIENTL pgradlAngle )
918{
919 USHORT sel;
920 APIRET rc;
921
922 if( !fIM32Inited )
923 return 1;
924
925 sel = RestoreOS2FS();
926 rc = pfnImSetConversionAngle( himi, pgradlAngle );
927 SetFS( sel );
928
929 return rc;
930}
931
932APIRET APIENTRY ImQueryConversionWindowPos( HIMI himi,
933 PCONVERSIONPOS pConvPos )
934{
935 USHORT sel;
936 APIRET rc;
937
938 if( !fIM32Inited )
939 return 1;
940
941 sel = RestoreOS2FS();
942 rc = pfnImQueryConversionWindowPos( himi, pConvPos );
943 SetFS( sel );
944
945 return rc;
946}
947
948
949APIRET APIENTRY ImSetConversionWindowPos( HIMI himi,
950 PCONVERSIONPOS pConvPos )
951{
952 USHORT sel;
953 APIRET rc;
954
955 if( !fIM32Inited )
956 return 1;
957
958 sel = RestoreOS2FS();
959 rc = pfnImSetConversionWindowPos( himi, pConvPos );
960 SetFS( sel );
961
962 return rc;
963}
964
965APIRET APIENTRY ImGetResultString( HIMI himi, ULONG ulIndex,
966 PVOID pBuf, PULONG pulBufLen )
967{
968 USHORT sel;
969 APIRET rc;
970
971 if( !fIM32Inited )
972 return 1;
973
974 sel = RestoreOS2FS();
975 rc = pfnImGetResultString( himi, ulIndex, pBuf, pulBufLen );
976 SetFS( sel );
977
978 return rc;
979}
980
981APIRET APIENTRY ImQueryInfoMsg( HIMI himi, ULONG ulIndex,
982 PVOID pBuf, PULONG pulBufLen )
983{
984 USHORT sel;
985 APIRET rc;
986
987 if( !fIM32Inited )
988 return 1;
989
990 sel = RestoreOS2FS();
991 rc = pfnImQueryInfoMsg( himi, ulIndex, pBuf, pulBufLen );
992 SetFS( sel );
993
994 return rc;
995}
996
997APIRET APIENTRY ImQueryStatusWindowPos( HIMI himi, PPOINTL pptPos, PSIZEL pszlSize )
998{
999 USHORT sel;
1000 APIRET rc;
1001
1002 if( !fIM32Inited )
1003 return 1;
1004
1005 sel = RestoreOS2FS();
1006 rc = pfnImQueryStatusWindowPos( himi, pptPos, pszlSize );
1007 SetFS( sel );
1008
1009 return rc;
1010}
1011
1012APIRET APIENTRY ImSetStatusWindowPos( HIMI himi, PPOINTL pptPos )
1013{
1014 USHORT sel;
1015 APIRET rc;
1016
1017 if( !fIM32Inited )
1018 return 1;
1019
1020 sel = RestoreOS2FS();
1021 rc = pfnImSetStatusWindowPos( himi, pptPos );
1022 SetFS( sel );
1023
1024 return rc;
1025}
1026
1027APIRET APIENTRY ImShowStatusWindow( HIMI himi, ULONG fShow )
1028{
1029 USHORT sel;
1030 APIRET rc;
1031
1032 if( !fIM32Inited )
1033 return 1;
1034
1035 sel = RestoreOS2FS();
1036 rc = pfnImShowStatusWindow( himi, fShow );
1037 SetFS( sel );
1038
1039 return rc;
1040}
1041
1042APIRET APIENTRY ImGetStatusString( HIMI himi, ULONG ulIndex,
1043 PVOID pBuf, PULONG pulBufLen )
1044{
1045 USHORT sel;
1046 APIRET rc;
1047
1048 if( !fIM32Inited )
1049 return 1;
1050
1051 sel = RestoreOS2FS();
1052 rc = pfnImGetStatusString( himi, ulIndex, pBuf, pulBufLen );
1053 SetFS( sel );
1054
1055 return rc;
1056}
1057
1058APIRET APIENTRY ImConvertString( HIMI himi,
1059 PSZ pSrc,
1060 PCANDIDATELISTHEADER pDst,
1061 PULONG pulBufLen,
1062 ULONG ulFlag )
1063{
1064 USHORT sel;
1065 APIRET rc;
1066
1067 if( !fIM32Inited )
1068 return 1;
1069
1070 sel = RestoreOS2FS();
1071 rc = pfnImConvertString( himi, pSrc, pDst, pulBufLen, ulFlag );
1072 SetFS( sel );
1073
1074 return rc;
1075}
1076
1077APIRET APIENTRY ImQueryIMMode( HIMI himi,
1078 PULONG pulInputMode,
1079 PULONG pulConversionMode )
1080{
1081 USHORT sel;
1082 APIRET rc;
1083
1084 if( !fIM32Inited )
1085 return 1;
1086
1087 sel = RestoreOS2FS();
1088 rc = pfnImQueryIMMode( himi, pulInputMode, pulConversionMode );
1089 SetFS( sel );
1090
1091 return rc;
1092}
1093
1094APIRET APIENTRY ImSetIMMode( HIMI himi,
1095 ULONG ulInputMode,
1096 ULONG ulConversionMode )
1097{
1098 USHORT sel;
1099 APIRET rc;
1100
1101 if( !fIM32Inited )
1102 return 1;
1103
1104 sel = RestoreOS2FS();
1105 rc = pfnImSetIMMode( himi, ulInputMode, ulConversionMode );
1106 SetFS( sel );
1107
1108 return rc;
1109}
1110
1111APIRET APIENTRY ImQueryIMEInfo( ULONG ImeId, PIMEINFOHEADER pImeInfoHeader,
1112 PULONG pulBufLen )
1113{
1114 USHORT sel;
1115 APIRET rc;
1116
1117 if( !fIM32Inited )
1118 return 1;
1119
1120 sel = RestoreOS2FS();
1121 rc = pfnImQueryIMEInfo( ImeId, pImeInfoHeader, pulBufLen );
1122 SetFS( sel );
1123
1124 return rc;
1125}
1126
1127APIRET APIENTRY ImQueryIMEProperty( HIMI himi, ULONG ulIndex, PULONG pulProp )
1128{
1129 USHORT sel;
1130 APIRET rc;
1131
1132 if( !fIM32Inited )
1133 return 1;
1134
1135 sel = RestoreOS2FS();
1136 rc = pfnImQueryIMEProperty( himi, ulIndex, pulProp );
1137 SetFS( sel );
1138
1139 return rc;
1140}
1141
1142APIRET APIENTRY ImRequestIME( HIMI himi, ULONG ulAction,
1143 ULONG ulIndex, ULONG ulValue )
1144{
1145 USHORT sel;
1146 APIRET rc;
1147
1148 if( !fIM32Inited )
1149 return 1;
1150
1151 sel = RestoreOS2FS();
1152 rc = pfnImRequestIME( himi, ulAction, ulIndex, ulValue );
1153 SetFS( sel );
1154
1155 return rc;
1156}
1157
1158APIRET APIENTRY ImIsIMEMessage( HWND hwndIm,
1159 ULONG msg,
1160 MPARAM mp1,
1161 MPARAM mp2,
1162 PBOOL pfResult )
1163{
1164 USHORT sel;
1165 APIRET rc;
1166
1167 if( !fIM32Inited )
1168 return 1;
1169
1170 sel = RestoreOS2FS();
1171 rc = pfnImIsIMEMessage( hwndIm, msg, mp1, mp2, pfResult );
1172 SetFS( sel );
1173
1174 return rc;
1175}
1176
1177APIRET APIENTRY ImQueryIMEList( ULONG ulCodepage,
1178 PULONG aImeId,
1179 PULONG pulCount )
1180{
1181 USHORT sel;
1182 APIRET rc;
1183
1184 if( !fIM32Inited )
1185 return 1;
1186
1187 sel = RestoreOS2FS();
1188 rc = pfnImQueryIMEList( ulCodepage, aImeId, pulCount );
1189 SetFS( sel );
1190
1191 return rc;
1192}
1193
1194APIRET APIENTRY ImQueryCurrentIME( HIMI himi, PULONG pImeId )
1195{
1196 USHORT sel;
1197 APIRET rc;
1198
1199 if( !fIM32Inited )
1200 return 1;
1201
1202 sel = RestoreOS2FS();
1203 rc = pfnImQueryCurrentIME( himi, pImeId );
1204 SetFS( sel );
1205
1206 return rc;
1207}
1208
1209APIRET APIENTRY ImSetCurrentIME( HIMI himi,
1210 ULONG ulAction,
1211 ULONG ImeId )
1212{
1213 USHORT sel;
1214 APIRET rc;
1215
1216 if( !fIM32Inited )
1217 return 1;
1218
1219 sel = RestoreOS2FS();
1220 rc = pfnImSetCurrentIME( himi, ulAction, ImeId );
1221 SetFS( sel );
1222
1223 return rc;
1224}
1225
1226APIRET APIENTRY ImQueryDefaultIME( ULONG ulCodepage, PULONG pImeId )
1227{
1228 USHORT sel;
1229 APIRET rc;
1230
1231 if( !fIM32Inited )
1232 return 1;
1233
1234 sel = RestoreOS2FS();
1235 rc = pfnImQueryDefaultIME( ulCodepage, pImeId );
1236 SetFS( sel );
1237
1238 return rc;
1239}
1240
1241APIRET APIENTRY ImSetDefaultIME( ULONG ulCodepage, ULONG ImeId )
1242{
1243 USHORT sel;
1244 APIRET rc;
1245
1246 if( !fIM32Inited )
1247 return 1;
1248
1249 sel = RestoreOS2FS();
1250 rc = pfnImSetDefaultIME( ulCodepage, ImeId );
1251 SetFS( sel );
1252
1253 return rc;
1254}
1255
1256
1257APIRET APIENTRY ImSetIMEListOrder( ULONG ulCodepage,
1258 ULONG ulAction,
1259 ULONG ImeIdTarget,
1260 ULONG ImeIdIndex )
1261{
1262 USHORT sel;
1263 APIRET rc;
1264
1265 if( !fIM32Inited )
1266 return 1;
1267
1268 sel = RestoreOS2FS();
1269 rc = pfnImSetIMEListOrder( ulCodepage, ulAction, ImeIdTarget, ImeIdIndex );
1270 SetFS( sel );
1271
1272 return rc;
1273}
1274
1275APIRET APIENTRY ImQueryIMEID( PSZ pszIMEName, PULONG pImeId )
1276{
1277 USHORT sel;
1278 APIRET rc;
1279
1280 if( !fIM32Inited )
1281 return 1;
1282
1283 sel = RestoreOS2FS();
1284 rc = pfnImQueryIMEID( pszIMEName, pImeId );
1285 SetFS( sel );
1286
1287 return rc;
1288}
1289
1290APIRET APIENTRY ImQueryMsgQueueProperty( HMQ hmq, PULONG pulFlag )
1291{
1292 USHORT sel;
1293 APIRET rc;
1294
1295 if( !fIM32Inited )
1296 return 1;
1297
1298 sel = RestoreOS2FS();
1299 rc = pfnImQueryMsgQueueProperty( hmq, pulFlag );
1300 SetFS( sel );
1301
1302 return rc;
1303}
1304
1305APIRET APIENTRY ImSetMsgQueueProperty( HMQ hmq, ULONG ulFlag )
1306{
1307 USHORT sel;
1308 APIRET rc;
1309
1310 if( !fIM32Inited )
1311 return 1;
1312
1313 sel = RestoreOS2FS();
1314 rc = pfnImSetMsgQueueProperty( hmq, ulFlag );
1315 SetFS( sel );
1316
1317 return rc;
1318}
1319
1320APIRET APIENTRY ImRequestEvent( HIMI hImi,
1321 ULONG msg,
1322 ULONG mp1,
1323 ULONG mp2 )
1324{
1325 USHORT sel;
1326 APIRET rc;
1327
1328 if( !fIM32Inited )
1329 return 1;
1330
1331 sel = RestoreOS2FS();
1332 rc = pfnImRequestEvent( hImi, msg, mp1, mp2 );
1333 SetFS( sel );
1334
1335 return rc;
1336}
1337
1338
1339APIRET APIENTRY ImRequestIMInstance( HIMI hImi,
1340 PIMINSTANCE * ppIMInstance )
1341{
1342 USHORT sel;
1343 APIRET rc;
1344
1345 if( !fIM32Inited )
1346 return 1;
1347
1348 sel = RestoreOS2FS();
1349 rc = pfnImRequestIMInstance( hImi, ppIMInstance );
1350 SetFS( sel );
1351
1352 return rc;
1353}
1354
1355APIRET APIENTRY ImReleaseIMInstance( HIMI hImi )
1356{
1357 USHORT sel;
1358 APIRET rc;
1359
1360 if( !fIM32Inited )
1361 return 1;
1362
1363 sel = RestoreOS2FS();
1364 rc = pfnImReleaseIMInstance( hImi );
1365 SetFS( sel );
1366
1367 return rc;
1368}
1369
1370APIRET APIENTRY ImQueryIMInstanceReqCount( HIMI hImi,
1371 PULONG pulCount )
1372{
1373 USHORT sel;
1374 APIRET rc;
1375
1376 if( !fIM32Inited )
1377 return 1;
1378
1379 sel = RestoreOS2FS();
1380 rc = pfnImQueryIMInstanceReqCount( hImi, pulCount );
1381 SetFS( sel );
1382
1383 return rc;
1384}
1385
1386APIRET APIENTRY ImCreateIMIPart( ULONG ulPartSize,
1387 PHIMIP phimiPart )
1388{
1389 USHORT sel;
1390 APIRET rc;
1391
1392 if( !fIM32Inited )
1393 return 1;
1394
1395 sel = RestoreOS2FS();
1396 rc = pfnImCreateIMIPart( ulPartSize, phimiPart );
1397 SetFS( sel );
1398
1399 return rc;
1400}
1401
1402APIRET APIENTRY ImDestroyIMIPart( HIMIP himiPart )
1403{
1404 USHORT sel;
1405 APIRET rc;
1406
1407 if( !fIM32Inited )
1408 return 1;
1409
1410 sel = RestoreOS2FS();
1411 rc = pfnImDestroyIMIPart( himiPart );
1412 SetFS( sel );
1413
1414 return rc;
1415}
1416
1417APIRET APIENTRY ImQueryIMIPartSize( HIMIP himiPart,
1418 PULONG pulPartSize )
1419{
1420 USHORT sel;
1421 APIRET rc;
1422
1423 if( !fIM32Inited )
1424 return 1;
1425
1426 sel = RestoreOS2FS();
1427 rc = pfnImQueryIMIPartSize( himiPart, pulPartSize );
1428 SetFS( sel );
1429
1430 return rc;
1431}
1432
1433APIRET APIENTRY ImRequestIMIPart( HIMIP himiPart,
1434 PVOID * ppPartData )
1435{
1436 USHORT sel;
1437 APIRET rc;
1438
1439 if( !fIM32Inited )
1440 return 1;
1441
1442 sel = RestoreOS2FS();
1443 rc = pfnImRequestIMIPart( himiPart, ppPartData );
1444 SetFS( sel );
1445
1446 return rc;
1447}
1448
1449APIRET APIENTRY ImReleaseIMIPart( HIMIP himiPart )
1450{
1451 USHORT sel;
1452 APIRET rc;
1453
1454 if( !fIM32Inited )
1455 return 1;
1456
1457 sel = RestoreOS2FS();
1458 rc = pfnImReleaseIMIPart( himiPart );
1459 SetFS( sel );
1460
1461 return rc;
1462}
1463
1464APIRET APIENTRY ImResizeIMIPart( HIMIP himiPart,
1465 ULONG ulNewSize )
1466{
1467 USHORT sel;
1468 APIRET rc;
1469
1470 if( !fIM32Inited )
1471 return 1;
1472
1473 sel = RestoreOS2FS();
1474 rc = pfnImResizeIMIPart( himiPart, ulNewSize );
1475 SetFS( sel );
1476
1477 return rc;
1478}
1479
1480APIRET APIENTRY ImQueryIMIPartReqCount( HIMIP himiPart,
1481 PULONG pulCount )
1482{
1483 USHORT sel;
1484 APIRET rc;
1485
1486 if( !fIM32Inited )
1487 return 1;
1488
1489 sel = RestoreOS2FS();
1490 rc = pfnImQueryIMIPartReqCount( himiPart, pulCount );
1491 SetFS( sel );
1492
1493 return rc;
1494}
1495
1496APIRET APIENTRY ImBroadcastData( PSZ pszIMEName,
1497 ULONG ulIndex,
1498 PBROADCASTDATAHEADER pData )
1499{
1500 USHORT sel;
1501 APIRET rc;
1502
1503 if( !fIM32Inited )
1504 return 1;
1505
1506 sel = RestoreOS2FS();
1507 rc = pfnImBroadcastData( pszIMEName, ulIndex, pData );
1508 SetFS( sel );
1509
1510 return rc;
1511}
1512
1513
1514APIRET APIENTRY ImGetInstanceMQ( HMQ hmq, PHIMI phimi )
1515{
1516 USHORT sel;
1517 APIRET rc;
1518
1519 if( !fIM32Inited )
1520 return 1;
1521
1522 sel = RestoreOS2FS();
1523 rc = pfnImGetInstanceMQ( hmq, phimi );
1524 SetFS( sel );
1525
1526 return rc;
1527}
1528
1529APIRET APIENTRY ImReleaseInstanceMQ( HMQ hmq, HIMI himi )
1530{
1531 USHORT sel;
1532 APIRET rc;
1533
1534 if( !fIM32Inited )
1535 return 1;
1536
1537 sel = RestoreOS2FS();
1538 rc = pfnImReleaseInstanceMQ( hmq, himi );
1539 SetFS( sel );
1540
1541 return rc;
1542}
1543
1544HIMC IM32AssociateContext(HWND hWnd, HIMC hIMC)
1545{
1546 HWND hwndOS2 = Win32ToOS2Handle( hWnd );
1547 HIMI himiPrev;
1548
1549 if( ImAssociateInstance( hwndOS2, ( HIMI )hIMC, &himiPrev ))
1550 return NULL;
1551
1552 return ( HIMC )himiPrev;
1553}
1554
1555BOOL IM32AssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dword)
1556{
1557 return FALSE;
1558}
1559
1560BOOL IM32ConfigureIME(HKL hKL, HWND hWnd, DWORD dwMode, LPVOID lpData, BOOL fUnicode )
1561{
1562// TODO
1563
1564 return FALSE;
1565}
1566
1567HIMC IM32CreateContext(VOID)
1568{
1569 HIMI himi;
1570
1571 if( ImCreateInstance( &himi ) != 0 )
1572 return NULL;
1573
1574 return ( HIMC )himi;
1575}
1576
1577HIMCC IM32CreateIMCC(DWORD dword)
1578{
1579 return NULL;
1580}
1581
1582HWND IM32CreateSoftKeyboard(UINT uint, HWND hwnd, int in1, int in2)
1583{
1584 return NULL;
1585}
1586
1587BOOL IM32DestroyContext(HIMC hIMC)
1588{
1589 if( ImDestroyInstance(( HIMI )hIMC ) != 0 )
1590 return FALSE;
1591
1592 return TRUE;
1593}
1594
1595HIMCC IM32DestroyIMCC(HIMCC himcc)
1596{
1597 return NULL;
1598}
1599
1600BOOL IM32DestroySoftKeyboard(HWND hwnd)
1601{
1602 return FALSE;
1603}
1604
1605BOOL IM32DisableIME(DWORD dword)
1606{
1607 return FALSE;
1608}
1609
1610UINT IM32EnumRegisterWord( HKL hKL, LPVOID lpfnEnumProc, LPVOID lpszReading, DWORD dwStyle, LPVOID lpszRegister, LPVOID lpData, BOOL fUnicode )
1611{
1612// TODO
1613 return 0;
1614}
1615
1616LRESULT IM32Escape(HKL hKL, HIMC hIMC, UINT uEscape, LPVOID lpData, BOOL fUnicode)
1617{
1618// TODO
1619 return NULL;
1620}
1621
1622BOOL IM32GenerateMessage(HIMC himc)
1623{
1624 return FALSE;
1625}
1626
1627DWORD IM32GetCandidateList(HIMC hIMC, DWORD dwIndex, LPCANDIDATELIST lpCandList, DWORD dwBufLen, BOOL fUnicode)
1628{
1629// TODO
1630
1631 return 0;
1632}
1633
1634DWORD IM32GetCandidateListCount( HIMC hIMC, LPDWORD lpdwListCount, BOOL fUnicode)
1635{
1636// TODO
1637
1638 return 0;
1639}
1640
1641BOOL IM32GetCandidateWindow(HIMC hIMC, DWORD dwBufLen, LPCANDIDATEFORM lpCandidate)
1642{
1643// TODO
1644
1645 return FALSE;
1646}
1647
1648BOOL IM32GetCompositionFont(HIMC hIMC, LPVOID lplf, BOOL fUnicode)
1649{
1650// TODO
1651
1652 return FALSE;
1653}
1654
1655typedef APIRET ( APIENTRY *PFN_GETCOMPOSITIONSTRING )( HIMI, ULONG, PVOID, PULONG );
1656
1657LONG IM32GetCompositionString(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen, BOOL fUnicode)
1658{
1659 PFN_GETCOMPOSITIONSTRING pfnGetCompositionString = ImGetConversionString;
1660 ULONG ulIndex;
1661 PCHAR pBuffer = NULL;
1662 ULONG ulBufLen;
1663 PSZ pszStr = NULL;
1664 ULONG ulStrLen;
1665 APIRET rc;
1666
1667 switch( dwIndex )
1668 {
1669 case GCS_COMPSTR_W :
1670 ulIndex = IMR_CONV_CONVERSIONSTRING;
1671 break;
1672
1673 case GCS_COMPATTR_W :
1674 ulIndex = IMR_CONV_CONVERSIONATTR;
1675 break;
1676
1677 case GCS_COMPCLAUSE_W :
1678 ulIndex = IMR_CONV_CONVERSIONCLAUSE;
1679 break;
1680
1681 case GCS_COMPREADSTR_W :
1682 ulIndex = IMR_CONV_READINGSTRING;
1683 break;
1684
1685 case GCS_COMPREADATTR_W :
1686 ulIndex = IMR_CONV_READINGATTR;
1687 break;
1688
1689 case GCS_COMPREADCLAUSE_W :
1690 ulIndex = IMR_CONV_READINGCLAUSE;
1691 break;
1692
1693 case GCS_CURSORPOS_W :
1694 ulIndex = IMR_CONV_CURSORPOS;
1695 break;
1696
1697 case GCS_DELTASTART_W :
1698 ulIndex = IMR_CONV_CHANGESTART;
1699 break;
1700
1701 case GCS_RESULTSTR_W :
1702 ulIndex = IMR_RESULT_RESULTSTRING;
1703 pfnGetCompositionString = ImGetResultString;
1704 break;
1705
1706 case GCS_RESULTCLAUSE_W :
1707 ulIndex = IMR_RESULT_RESULTCLAUSE;
1708 pfnGetCompositionString = ImGetResultString;
1709 break;
1710
1711 case GCS_RESULTREADSTR_W :
1712 ulIndex = IMR_RESULT_READINGSTRING;
1713 pfnGetCompositionString = ImGetResultString;
1714 break;
1715
1716 case GCS_RESULTREADCLAUSE_W :
1717 ulIndex = IMR_RESULT_READINGCLAUSE;
1718 pfnGetCompositionString = ImGetResultString;
1719 break;
1720
1721 default :
1722 goto error_exit;
1723 }
1724
1725 if( fUnicode )
1726 {
1727 ulBufLen = 0;
1728 rc = pfnGetCompositionString( hIMC, ulIndex, pBuffer, &ulBufLen );
1729 if( rc != 0 )
1730 goto error_exit;
1731
1732 pBuffer = ( PCHAR )malloc( ulBufLen + 1 );
1733 if( !pBuffer )
1734 goto error_exit;
1735
1736 rc = pfnGetCompositionString( hIMC, ulIndex, pBuffer, &ulBufLen );
1737 if( rc != 0 )
1738 goto error_exit;
1739
1740 switch( ulIndex )
1741 {
1742 case IMR_CONV_CONVERSIONSTRING :
1743 case IMR_CONV_READINGSTRING :
1744 case IMR_RESULT_RESULTSTRING :
1745 case IMR_RESULT_READINGSTRING :
1746 /* dwBufLen is always in bytes */
1747 if( ulBufLen > 0 )
1748 {
1749 ulBufLen = MultiByteToWideChar( CP_ACP, 0, pBuffer, ulBufLen, ( LPWSTR )lpBuf, dwBufLen / sizeof( WCHAR ));
1750 if( ulBufLen == 0 )
1751 goto error_exit;
1752 }
1753
1754 ulBufLen *= sizeof( WCHAR );
1755 break;
1756
1757 default :
1758/*
1759 case IMR_CONV_CONVERSIONATTR :
1760 case IMR_CONV_READINGATTR :
1761 case IMR_CONV_CONVERSIONCLAUSE :
1762 case IMR_CONV_READINGCLAUSE :
1763 case IMR_RESULT_RESULTCLAUSE :
1764 case IMR_RESULT_READINGCLAUSE :
1765 case IMR_CONV_CURSORPOS :
1766 case IMR_CONV_CHANGESTART :
1767*/
1768 {
1769 ULONG ulStrIndex;
1770 INT i, j;
1771
1772 switch( ulIndex )
1773 {
1774 case IMR_CONV_CONVERSIONATTR :
1775 case IMR_CONV_CONVERSIONCLAUSE :
1776 case IMR_CONV_CURSORPOS :
1777 case IMR_CONV_CHANGESTART :
1778 ulStrIndex = IMR_CONV_CONVERSIONSTRING;
1779 break;
1780
1781 case IMR_CONV_READINGATTR :
1782 case IMR_CONV_READINGCLAUSE :
1783 ulStrIndex = IMR_CONV_READINGSTRING;
1784 break;
1785
1786 case IMR_RESULT_RESULTCLAUSE :
1787 ulStrIndex = IMR_RESULT_RESULTSTRING;
1788 break;
1789
1790 case IMR_RESULT_READINGCLAUSE :
1791 ulStrIndex = IMR_RESULT_READINGSTRING;
1792 }
1793
1794 ulStrLen = 0;
1795 rc = pfnGetCompositionString( hIMC, ulStrIndex, pszStr, &ulStrLen );
1796 if( rc != 0 )
1797 goto error_exit;
1798
1799 pszStr = ( PSZ )malloc( ulStrLen + 1 );
1800 if( !pszStr )
1801 goto error_exit;
1802
1803 rc = pfnGetCompositionString( hIMC, ulStrIndex, pszStr, &ulStrLen );
1804 if( rc != 0 )
1805 goto error_exit;
1806
1807 switch( ulIndex )
1808 {
1809 case IMR_CONV_CONVERSIONATTR :
1810 case IMR_CONV_READINGATTR :
1811 {
1812 PCHAR pch = ( PCHAR )lpBuf;
1813
1814 for( i = j = 0; ( i < ulBufLen ) && (( dwBufLen == 0 ) || ( j < dwBufLen )); i++, j++ )
1815 {
1816 if( dwBufLen )
1817 pch[ j ] = pBuffer[ i ];
1818
1819 if( IsDBCSLeadByte( pszStr[ i ] ))
1820 i++;
1821 }
1822
1823 ulBufLen = j;
1824 break;
1825 }
1826
1827 case IMR_CONV_CONVERSIONCLAUSE :
1828 case IMR_CONV_READINGCLAUSE :
1829 case IMR_RESULT_RESULTCLAUSE :
1830 case IMR_RESULT_READINGCLAUSE :
1831 {
1832 PULONG pulBufSrc = ( PULONG )pBuffer;
1833 PULONG pulBufDest = ( PULONG )lpBuf;
1834
1835 /* if dwBufLen == 0, then current ulBufLen has what we want */
1836 if( dwBufLen != 0 )
1837 {
1838 if( dwBufLen >= sizeof( ULONG ))
1839 {
1840 pulBufDest[ 0 ] = 0;
1841
1842 for( i = 1; ( i * sizeof( ULONG ) < ulBufLen ) &&
1843 ( i * sizeof( ULONG ) < dwBufLen ); i++ )
1844 {
1845 pulBufDest[ i ] = MultiByteToWideChar( CP_ACP, 0, pszStr, pulBufSrc[ i ], 0, 0 );
1846 if( !pulBufDest[ i ])
1847 goto error_exit;
1848 }
1849
1850 ulBufLen = i * sizeof( ULONG );
1851 }
1852 else
1853 ulBufLen = 0;
1854 }
1855 break;
1856 }
1857
1858 case IMR_CONV_CURSORPOS :
1859 case IMR_CONV_CHANGESTART :
1860 {
1861 ULONG ul = *( PULONG )pBuffer;
1862
1863 ulBufLen = MultiByteToWideChar( CP_ACP, 0, pszStr, ul, 0, 0 );
1864 break;
1865 }
1866 }
1867
1868 free( pszStr );
1869 break;
1870 }
1871 }
1872
1873 free( pBuffer );
1874 }
1875 else
1876 {
1877 if(( ulIndex == IMR_CONV_CURSORPOS ) || ( ulIndex == IMR_CONV_CHANGESTART ))
1878 {
1879 dwBufLen = sizeof( ULONG );
1880 rc = pfnGetCompositionString( hIMC, ulIndex, &ulBufLen, &dwBufLen );
1881 }
1882 else
1883 {
1884 ulBufLen = dwBufLen;
1885 rc = pfnGetCompositionString( hIMC, ulIndex, lpBuf, &ulBufLen );
1886 }
1887
1888 if( rc != 0 )
1889 return IMM_ERROR_GENERAL_W;
1890 }
1891
1892 return ulBufLen;
1893
1894error_exit :
1895 if( pBuffer )
1896 free( pBuffer );
1897
1898 if( pszStr )
1899 free( pszStr );
1900
1901 return IMM_ERROR_GENERAL_W;
1902}
1903
1904BOOL IM32GetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
1905{
1906 PIMINSTANCE pimi;
1907 RECTL rcl;
1908
1909 if( ImRequestIMInstance( hIMC, &pimi ) != 0 )
1910 return FALSE;
1911
1912 if(!( pimi->ulClientInfo & IMI_CI_PMCALLABLE ))
1913 {
1914 ImReleaseIMInstance( hIMC );
1915 return FALSE;
1916 }
1917
1918 lpCompForm->dwStyle = CFS_DEFAULT_W;
1919
1920 if( pimi->cpConversionPos.ulStyle & CPS_FORCE )
1921 lpCompForm->dwStyle |= CFS_FORCE_POSITION_W;
1922
1923 if( pimi->cpConversionPos.ulStyle & CPS_POINT )
1924 lpCompForm->dwStyle |= CFS_POINT_W;
1925
1926 if( pimi->cpConversionPos.ulStyle & CPS_RECT )
1927 lpCompForm->dwStyle |= CFS_RECT_W;
1928
1929 WinQueryWindowRect( pimi->hwnd, &rcl );
1930
1931 lpCompForm->ptCurrentPos.x = pimi->cpConversionPos.ptCurrentPos.x;
1932 lpCompForm->ptCurrentPos.y = rcl.yTop -
1933 ( pimi->cpConversionPos.ptCurrentPos.y + pimi->faConversionWindow.lMaxBaselineExt );
1934
1935 lpCompForm->rcArea.left = pimi->cpConversionPos.rcArea.xLeft;
1936 lpCompForm->rcArea.right = pimi->cpConversionPos.rcArea.xRight;
1937 lpCompForm->rcArea.top = rcl.yTop - pimi->cpConversionPos.rcArea.yTop;
1938 lpCompForm->rcArea.bottom = rcl.yTop - pimi->cpConversionPos.rcArea.yBottom;
1939
1940 ImReleaseIMInstance( hIMC );
1941
1942 return TRUE;
1943}
1944
1945HIMC IM32GetContext(HWND hWnd)
1946{
1947 HWND hwndOS2 = Win32ToOS2Handle( hWnd );
1948 HIMI himi;
1949
1950 if( ImGetInstance( hwndOS2, &himi ) != 0 )
1951 return NULL;
1952
1953 return himi;
1954}
1955
1956DWORD IM32GetConversionList( HKL hKL, HIMC hIMC, LPVOID pSrc, LPCANDIDATELIST lpDst, DWORD dwBufLen, UINT uFlag, BOOL fUnicode)
1957{
1958// TODO
1959
1960 return 0;
1961}
1962
1963BOOL IM32GetConversionStatus(HIMC hIMC, LPDWORD lpfdwConversion, LPDWORD lpfdwSentence)
1964{
1965 ULONG ulInputMode;
1966 ULONG ulConversionMode;
1967
1968 if( ImQueryIMMode( hIMC, &ulInputMode, &ulConversionMode ) != 0 )
1969 return FALSE;
1970
1971 *lpfdwConversion = IME_CMODE_ALPHANUMERIC_W;
1972
1973 if( ulInputMode & IMI_IM_NLS_HANGEUL )
1974 *lpfdwConversion |= IME_CMODE_NATIVE_W;
1975
1976 if(( ulInputMode & IMI_IM_NLS_KATAKANA ) == IMI_IM_NLS_KATAKANA )
1977 *lpfdwConversion |= IME_CMODE_KATAKANA_W;
1978
1979 if( ulInputMode & IMI_IM_WIDTH_FULL )
1980 *lpfdwConversion |= IME_CMODE_FULLSHAPE_W;
1981
1982 if( ulInputMode & IMI_IM_ROMAJI_ON )
1983 *lpfdwConversion |= IME_CMODE_ROMAN_W;
1984
1985 if( ulInputMode & IMI_IM_SYSTEMROMAJI_DISABLE )
1986 *lpfdwConversion |= 0;
1987
1988 if( ulInputMode & IMI_IM_IME_ON )
1989 *lpfdwConversion |= IME_CMODE_HANJACONVERT_W; // right ?
1990
1991 if( ulInputMode & IMI_IM_IME_DISABLE )
1992 *lpfdwConversion |= IME_CMODE_NOCONVERSION_W; // right ?
1993
1994 if( ulInputMode & IMI_IM_IME_SOFTKBD_ON )
1995 *lpfdwConversion |= IME_CMODE_SOFTKBD_W;
1996
1997 if( ulInputMode & IMI_IM_IME_CSYMBOL_ON )
1998 *lpfdwConversion |= IME_CMODE_SYMBOL_W; // right ?
1999
2000 if( ulInputMode & IMI_IM_2NDCONV )
2001 *lpfdwConversion |= 0;
2002
2003 *lpfdwSentence = IME_SMODE_NONE_W;
2004
2005 if( ulConversionMode & IMI_CM_PLURALCLAUSE )
2006 *lpfdwSentence |= IME_SMODE_PLAURALCLAUSE_W;
2007
2008 if( ulConversionMode & IMI_CM_SINGLE )
2009 *lpfdwSentence |= IME_SMODE_SINGLECONVERT_W;
2010
2011 if( ulConversionMode & IMI_CM_AUTOMATIC )
2012 *lpfdwSentence |= IME_SMODE_AUTOMATIC_W;
2013
2014 if( ulConversionMode & IMI_CM_PREDICT )
2015 *lpfdwSentence |= IME_SMODE_PHRASEPREDICT_W;
2016
2017 return TRUE;
2018}
2019
2020HWND IM32GetDefaultIMEWnd(HWND hWnd)
2021{
2022 HWND hwndOS2 = Win32ToOS2Handle( hWnd );
2023 HWND hwndIm;
2024 HWND hwndWin32;
2025
2026 if( ImQueryDefaultIMWindow( hwndOS2, &hwndIm ) != 0 )
2027 return NULL;
2028
2029 hwndWin32 = OS2ToWin32Handle( hwndIm );
2030
2031 return hwndWin32 ? hwndWin32 : hwndIm;
2032}
2033
2034UINT IM32GetDescription(HKL hKL, LPVOID lpszDescription, UINT uBufLen, BOOL fUnicode)
2035{
2036 return 0;
2037}
2038
2039DWORD IM32GetGuideLine(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen, BOOL fUnicode)
2040{
2041// TODO
2042
2043 return 0;
2044}
2045
2046BOOL IM32GetHotKey(DWORD dword, LPUINT lpuModifiers, LPUINT lpuVKey, LPHKL lphkl)
2047{
2048 return FALSE;
2049}
2050
2051DWORD IM32GetIMCCLockCount(HIMCC himcc)
2052{
2053 return 0;
2054}
2055
2056DWORD IM32GetIMCCSize(HIMCC himcc)
2057{
2058 return 0;
2059}
2060
2061DWORD IM32GetIMCLockCount(HIMC himc)
2062{
2063 return 0;
2064}
2065
2066UINT IM32GetIMEFileName( HKL hKL, LPVOID lpszFileName, UINT uBufLen, BOOL fUnicode)
2067{
2068// TODO
2069
2070 return 0;
2071}
2072
2073DWORD IM32GetImeMenuItems(HIMC himc, DWORD dword, DWORD dword2, LPVOID pimen, LPVOID lpimen2, DWORD dword3, BOOL fUnicode)
2074{
2075 return 0;
2076}
2077
2078BOOL IM32GetOpenStatus(HIMC hIMC)
2079{
2080 ULONG ulInputMode;
2081 ULONG ulConversionMode;
2082
2083 if( ImQueryIMMode(( HIMI )hIMC, &ulInputMode, &ulConversionMode ) != 0 )
2084 return FALSE;
2085
2086 return !( ulInputMode & IMI_IM_IME_DISABLE );
2087}
2088
2089// FIXME : hKL is ignored, instead, return the property of IM Instance attached to
2090// current thread, maybe default locale.
2091DWORD IM32GetProperty(HKL hKL, DWORD fdwIndex)
2092{
2093 HIMI himi;
2094 ULONG ulIndex;
2095 ULONG ulProp;
2096 DWORD result;
2097
2098
2099 switch( fdwIndex )
2100 {
2101 case IGP_GETIMEVERSION_W :
2102 return IMEVER_0400_W;
2103
2104 case IGP_PROPERTY_W :
2105 ulIndex = QIP_PROPERTY;
2106 break;
2107
2108 case IGP_CONVERSION_W :
2109 ulIndex = QIP_INPUTMODE;
2110 break;
2111
2112 case IGP_SENTENCE_W :
2113 ulIndex = QIP_CONVERSIONMODE;
2114 break;
2115
2116 case IGP_UI_W :
2117 ulIndex = QIP_UI;
2118 break;
2119
2120 case IGP_SETCOMPSTR_W :
2121 ulIndex = QIP_SETCONVSTR;
2122 break;
2123
2124 case IGP_SELECT_W :
2125 ulIndex = QIP_SELECT;
2126 break;
2127 }
2128
2129 if( ImGetInstanceMQ( HMQ_CURRENT, &himi ) != 0 )
2130 return 0;
2131
2132 if( ImQueryIMEProperty( himi, ulIndex, &ulProp ) != 0 )
2133 ulProp = 0;
2134
2135 ImReleaseInstanceMQ( HMQ_CURRENT, himi );
2136
2137 result = 0;
2138 switch( ulIndex )
2139 {
2140 case QIP_PROPERTY :
2141 if( ulProp & PRP_SPECIALUI )
2142 result |= IME_PROP_SPECIAL_UI_W;
2143
2144 if( ulProp & PRP_UNICODE )
2145 result |= IME_PROP_UNICODE_W;
2146
2147 if( ulProp & PRP_FORCEPOSITION )
2148 result |= IME_PROP_AT_CARET_W;
2149 break;
2150
2151 case QIP_INPUTMODE :
2152 if( ulProp & IMI_IM_NLS_HANGEUL )
2153 result |= IME_CMODE_NATIVE_W;
2154
2155 if(( ulProp & IMI_IM_NLS_KATAKANA ) == IMI_IM_NLS_KATAKANA )
2156 result |= IME_CMODE_KATAKANA_W;
2157
2158 if( ulProp & IMI_IM_WIDTH_FULL )
2159 result |= IME_CMODE_FULLSHAPE_W;
2160
2161 if( ulProp & IMI_IM_ROMAJI_ON )
2162 result |= IME_CMODE_ROMAN_W;
2163
2164 if( ulProp & IMI_IM_SYSTEMROMAJI_DISABLE )
2165 result |= 0;
2166
2167 if( ulProp & IMI_IM_IME_ON )
2168 result |= IME_CMODE_HANJACONVERT_W; // right ?
2169
2170 if( ulProp & IMI_IM_IME_DISABLE )
2171 result |= IME_CMODE_NOCONVERSION_W; // right ?
2172
2173 if( ulProp & IMI_IM_IME_SOFTKBD_ON )
2174 result |= IME_CMODE_SOFTKBD_W;
2175
2176 if( ulProp & IMI_IM_IME_CSYMBOL_ON )
2177 result |= IME_CMODE_SYMBOL_W; // right ?
2178
2179 if( ulProp & IMI_IM_2NDCONV )
2180 result |= 0;
2181 break;
2182
2183 case QIP_CONVERSIONMODE :
2184 if( ulProp & IMI_CM_PLURALCLAUSE )
2185 result |= IME_SMODE_PLAURALCLAUSE_W;
2186
2187 if( ulProp & IMI_CM_SINGLE )
2188 result |= IME_SMODE_SINGLECONVERT_W;
2189
2190 if( ulProp & IMI_CM_AUTOMATIC )
2191 result |= IME_SMODE_AUTOMATIC_W;
2192
2193 if( ulProp & IMI_CM_PREDICT )
2194 result |= IME_SMODE_PHRASEPREDICT_W;
2195 break;
2196
2197 case QIP_UI :
2198 if( ulProp & UIC_270 )
2199 result |= UI_CAP_2700_W;
2200
2201 if( ulProp & UIC_ANGLE90 )
2202 result |= UI_CAP_ROT90_W;
2203
2204 if( ulProp & UIC_ANGLEANY )
2205 result |= UI_CAP_ROTANY_W;
2206 break;
2207
2208 case QIP_SETCONVSTR :
2209 if( ulProp & SCSC_CONVSTR )
2210 result |= SCS_CAP_COMPSTR_W;
2211
2212 if( ulProp & SCSC_MAKEREAD )
2213 result |= SCS_CAP_MAKEREAD_W;
2214 break;
2215
2216 case QIP_SELECT :
2217 if( ulProp & SLC_INPUTMODE )
2218 result |= SELECT_CAP_CONVERSION_W;
2219
2220 if( ulProp & SLC_CONVERSIONMODE )
2221 result |= SELECT_CAP_SENTENCE_W;
2222 break;
2223 }
2224
2225 return result;
2226}
2227
2228UINT IM32GetRegisterWordStyle(HKL hKL, UINT nItem, LPVOID lpStyleBuf, BOOL fUnicode)
2229{
2230// TODO
2231
2232 return 0;
2233}
2234
2235BOOL IM32GetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
2236{
2237// TODO
2238
2239 return FALSE;
2240}
2241
2242UINT IM32GetVirtualKey(HWND hWnd)
2243{
2244// TODO
2245
2246 return 0;
2247}
2248
2249HKL IM32InstallIME(LPVOID lpszIMEFileName, LPVOID lpszLayoutText, BOOL fUnicode)
2250{
2251 return NULL;
2252}
2253
2254BOOL IM32IsIME(HKL hKL)
2255{
2256// TODO
2257
2258 return FALSE;
2259}
2260
2261BOOL IM32IsUIMessage(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
2262{
2263 HWND hwndIm;
2264 ULONG ulMsg;
2265 ULONG mp1;
2266 ULONG mp2 = 0;
2267 BOOL rc;
2268
2269 switch( msg )
2270 {
2271 case WM_IME_CHAR_W :
2272 // todo
2273 return FALSE;
2274
2275 case WM_IME_COMPOSITION_W :
2276#if 0
2277 if( lParam & GCS_TYPINGINFO_W )
2278 // todo
2279 return FALSE;
2280#endif
2281
2282 ulMsg = WM_IMEREQUEST;
2283 mp1 = IMR_CONVRESULT;
2284
2285 if( lParam & GCS_COMPSTR_W )
2286 mp2 |= IMR_CONV_CONVERSIONSTRING;
2287
2288 if( lParam & GCS_COMPATTR_W )
2289 mp2 |= IMR_CONV_CONVERSIONATTR;
2290
2291 if( lParam & GCS_COMPCLAUSE_W )
2292 mp2 |= IMR_CONV_CONVERSIONCLAUSE;
2293
2294 if( lParam & GCS_COMPREADSTR_W )
2295 mp2 |= IMR_CONV_READINGSTRING;
2296
2297 if( lParam & GCS_COMPREADATTR_W )
2298 mp2 |= IMR_CONV_READINGATTR;
2299
2300 if( lParam & GCS_COMPREADCLAUSE_W )
2301 mp2 |= IMR_CONV_READINGCLAUSE;
2302
2303 if( lParam & GCS_CURSORPOS_W )
2304 mp2 |= IMR_CONV_CURSORPOS;
2305
2306 if( lParam & GCS_DELTASTART_W )
2307 mp2 |= IMR_CONV_CHANGESTART;
2308
2309 if( lParam & GCS_RESULTSTR_W )
2310 mp2 |= IMR_RESULT_RESULTSTRING | IMR_CONV_CURSORPOS;
2311
2312 if( lParam & GCS_RESULTCLAUSE_W )
2313 mp2 |= IMR_RESULT_RESULTCLAUSE;
2314
2315 if( lParam & GCS_RESULTREADSTR_W )
2316 mp2 |= IMR_RESULT_READINGSTRING;
2317
2318 if( lParam & GCS_RESULTREADCLAUSE_W )
2319 mp2 |= IMR_RESULT_READINGCLAUSE;
2320
2321 if( lParam & CS_INSERTCHAR_W )
2322 mp2 |= IMR_CONV_INSERTCHAR;
2323
2324 if( lParam & CS_NOMOVECARET_W )
2325 mp2 |= IMR_CONV_NOMOVECARET;
2326 break;
2327
2328 case WM_IME_COMPOSITIONFULL_W :
2329 ulMsg = WM_IMENOTIFY;
2330 mp1 = IMN_CONVERSIONFULL;
2331 break;
2332
2333 case WM_IME_CONTROL_W :
2334 ulMsg = WM_IMECONTROL;
2335
2336 switch( wParam )
2337 {
2338 case IMC_CLOSESTATUSWINDOW_W :
2339 mp1 = IMC_HIDESTATUSWINDOW;
2340 break;
2341
2342 case IMC_GETCANDIDATEPOS_W :
2343 mp1 = IMC_QUERYCANDIDATEPOS;
2344 // todo
2345 return FALSE;
2346
2347 case IMC_GETCOMPOSITIONFONT_W :
2348 mp1 = IMC_QUERYCONVERSIONFONT;
2349 // TODO
2350 return FALSE;
2351
2352 case IMC_GETCOMPOSITIONWINDOW_W :
2353 mp1 = IMC_QUERYCONVERSIONWINDOWPOS;
2354 // todo
2355 return FALSE;
2356
2357 case IMC_GETSTATUSWINDOWPOS_W :
2358 mp1 = IMC_QUERYSTATUSWINDOWPOS;
2359 // todo
2360 return FALSE;
2361
2362 case IMC_OPENSTATUSWINDOW_W :
2363 mp1 = IMC_SHOWSTATUSWINDOW;
2364 break;
2365
2366 case IMC_SETCANDIDATEPOS_W :
2367 mp1 = IMC_SETCANDIDATEPOS;
2368 // todo
2369 return FALSE;
2370
2371 case IMC_SETCOMPOSITIONFONT_W :
2372 mp1 = IMC_SETCONVERSIONFONT;
2373 // todo
2374 return FALSE;
2375
2376 case IMC_SETCOMPOSITIONWINDOW_W :
2377 mp1 = IMC_SETCONVERSIONWINDOWPOS;
2378 // todo
2379 return FALSE;
2380
2381 case IMC_SETSTATUSWINDOWPOS_W :
2382 mp1 = IMC_SETSTATUSWINDOWPOS;
2383 // todo
2384 return FALSE;
2385
2386 default :
2387 return FALSE;
2388 }
2389 break;
2390
2391 case WM_IME_ENDCOMPOSITION_W :
2392 ulMsg = WM_IMENOTIFY;
2393 mp1 = IMN_ENDCONVERSION;
2394 break;
2395
2396 case WM_IME_KEYDOWN_W :
2397 // todo
2398 return FALSE;
2399
2400 case WM_IME_KEYUP_W :
2401 // todo
2402 return FALSE;
2403
2404 case WM_IME_NOTIFY_W :
2405 ulMsg = WM_IMEREQUEST;
2406
2407 switch( wParam )
2408 {
2409 case IMN_CHANGECANDIDATE_W :
2410 mp1 = IMR_CANDIDATE;
2411 mp2 = IMR_CANDIDATE_CHANGE;
2412 // todo
2413 return FALSE;
2414
2415 case IMN_CLOSECANDIDATE_W :
2416 mp1 = IMR_CANDIDATE;
2417 mp2 = IMR_CANDIDATE_HIDE;
2418 // todo
2419 return FALSE;
2420
2421 case IMN_CLOSESTATUSWINDOW_W :
2422 mp1 = IMR_STATUS;
2423 mp2 = IMR_STATUS_HIDE;
2424 break;
2425
2426 case IMN_GUIDELINE_W :
2427 mp1 = IMR_INFOMSG;
2428 break;
2429
2430 case IMN_OPENCANDIDATE_W :
2431 mp1 = IMR_CANDIDATE;
2432 mp2 = IMR_CANDIDATE_SHOW;
2433 // todo
2434 return FALSE;
2435
2436 case IMN_OPENSTATUSWINDOW_W :
2437 mp1 = IMR_STATUS;
2438 mp2 = IMR_STATUS_SHOW;
2439 break;
2440
2441 case IMN_SETCANDIDATEPOS_W :
2442 mp1 = IMR_CANDIDATE;
2443 mp2 = IMR_CANDIDATE_CANDIDATEPOS;
2444 // todo
2445 return FALSE;
2446
2447 case IMN_SETCOMPOSITIONFONT_W :
2448 mp1 = IMR_CONVRESULT;
2449 mp2 = IMR_CONV_CONVERSIONFONT;
2450 break;
2451
2452 case IMN_SETCOMPOSITIONWINDOW_W :
2453 mp1 = IMR_CONVRESULT;
2454 mp2 = IMR_CONV_CONVERSIONPOS;
2455 break;
2456
2457 case IMN_SETCONVERSIONMODE_W :
2458 mp1 = IMR_STATUS;
2459 mp2 = IMR_STATUS_INPUTMODE;
2460 break;
2461
2462 case IMN_SETOPENSTATUS_W :
2463 mp1 = IMR_STATUS;
2464 mp2 = IMR_STATUS_INPUTMODE;
2465 break;
2466
2467 case IMN_SETSENTENCEMODE_W :
2468 mp1 = IMR_STATUS;
2469 mp2 = IMR_STATUS_CONVERSIONMODE;
2470 break;
2471
2472 case IMN_SETSTATUSWINDOWPOS_W :
2473 mp1 = IMR_STATUS;
2474 mp2 = IMR_STATUS_STATUSPOS;
2475 break;
2476
2477 default :
2478 return FALSE;
2479 }
2480 break;
2481
2482#if 0 // todo
2483 case WM_IME_REQUEST_W :
2484 switch( wParam )
2485 {
2486 case IMR_CANDIDATEWINDOW_W :
2487 return FALSE;
2488
2489 case IMR_COMPOSITIONFONT_W :
2490 return FALSE;
2491
2492 case IMR_COMPOSITIONWINDOW_W :
2493 return FALSE;
2494
2495 case IMR_CONFIRMRECONVERTSTRING_W :
2496 return FALSE;
2497
2498 case IMR_DOCUMENTFEED_W :
2499 return FALSE;
2500
2501 case IMR_QUERYCHARPOSITION_W :
2502 return FALSE;
2503
2504 case IMR_RECONVERTSTRING_W :
2505 return FALSE;
2506
2507 default :
2508 return FALSE;
2509 }
2510 break;
2511#endif
2512
2513 case WM_IME_SELECT_W :
2514 ulMsg = WM_IMENOTIFY;
2515 mp1 = IMN_IMECHANGED;
2516 // todo
2517 return FALSE;
2518
2519 case WM_IME_SETCONTEXT_W :
2520 ulMsg = WM_IMEREQUEST;
2521 mp1 = IMR_INSTANCEACTIVATE;
2522 mp2 = MAKEULONG( 0, wParam );
2523
2524 if( lParam & ISC_SHOWUIALLCANDIDATEWINDOW_W )
2525 mp2 |= IMR_IA_CANDIDATE;
2526
2527 if( lParam & ISC_SHOWUICOMPOSITIONWINDOW_W )
2528 mp2 |= IMR_IA_CONVERSION;
2529
2530 if( lParam & ISC_SHOWUIGUIDELINE_W )
2531 mp2 |= IMR_IA_STATUS;
2532
2533 // following bits are always cleared, so should be set
2534 lParam |= IMR_IA_INFOMSG;
2535 lParam |= IMR_IA_REGWORD;
2536 break;
2537
2538 case WM_IME_STARTCOMPOSITION_W :
2539 ulMsg = WM_IMENOTIFY;
2540 mp1 = IMN_STARTCONVERSION;
2541 break;
2542
2543 default :
2544 return FALSE;
2545 }
2546
2547 if( hWndIME == NULL )
2548 return TRUE;
2549
2550 hwndIm = Win32ToOS2Handle( hWndIME );
2551 if( ImIsIMEMessage( hwndIm, ulMsg, ( MPARAM )mp1, ( MPARAM )mp2, &rc ) != 0 )
2552 return FALSE;
2553
2554 switch( msg )
2555 {
2556 case WM_IME_CONTROL_W :
2557 ulMsg = WM_IMECONTROL;
2558
2559 switch( wParam )
2560 {
2561 case IMC_GETCANDIDATEPOS_W :
2562 // todo
2563 break;
2564
2565 case IMC_GETCOMPOSITIONFONT_W :
2566 // TODO
2567 break;
2568
2569 case IMC_GETCOMPOSITIONWINDOW_W :
2570 // todo
2571 break;
2572
2573 case IMC_GETSTATUSWINDOWPOS_W :
2574 // todo
2575 break;
2576
2577 case IMC_SETCANDIDATEPOS_W :
2578 // todo
2579 break;
2580
2581 case IMC_SETCOMPOSITIONFONT_W :
2582 // todo
2583 break;
2584
2585 case IMC_SETCOMPOSITIONWINDOW_W :
2586 // todo
2587 break;
2588
2589 case IMC_SETSTATUSWINDOWPOS_W :
2590 // todo
2591 break;
2592 }
2593 break;
2594 }
2595
2596 return rc;
2597}
2598
2599LPINPUTCONTEXT IM32LockIMC(HIMC himc)
2600{
2601 return NULL;
2602}
2603
2604LPVOID IM32LockIMCC(HIMCC himcc)
2605{
2606 return NULL;
2607}
2608
2609BOOL IM32NotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
2610{
2611// TODO
2612
2613 return FALSE;
2614}
2615
2616HIMCC IM32ReSizeIMCC(HIMCC himcc, DWORD dword)
2617{
2618 return NULL;
2619}
2620
2621BOOL IM32RegisterWord( HKL hKL, LPVOID lpszReading, DWORD dwStyle, LPVOID lpszRegister, BOOL fUnicode)
2622{
2623// TODO
2624
2625 return FALSE;
2626}
2627
2628BOOL IM32ReleaseContext(HWND hWnd, HIMC hIMC)
2629{
2630 HWND hwndOS2 = Win32ToOS2Handle( hWnd );
2631
2632 if( ImReleaseInstance( hwndOS2, ( HIMI )hIMC ) != 0 )
2633 return FALSE;
2634
2635 return TRUE;
2636}
2637
2638LRESULT IM32RequestMessage(HIMC himc, WPARAM wparam, LPARAM lparam, BOOL fUnicode)
2639{
2640 return NULL;
2641}
2642
2643BOOL IM32SetCandidateWindow(HIMC hIMC, LPCANDIDATEFORM lpCandidate)
2644{
2645 CANDIDATEPOS cp;
2646 PIMINSTANCE pimi;
2647 RECTL rcl;
2648
2649 if( ImRequestIMInstance( hIMC, &pimi ) != 0 )
2650 return FALSE;
2651
2652 if(!( pimi->ulClientInfo & IMI_CI_PMCALLABLE ))
2653 {
2654 ImReleaseIMInstance( hIMC );
2655 return FALSE;
2656 }
2657
2658 WinQueryWindowRect( pimi->hwnd, &rcl );
2659
2660 cp.ulIndex = lpCandidate->dwIndex;
2661
2662 cp.ulStyle = 0;
2663 if( lpCandidate->dwStyle & CFS_CANDIDATEPOS_W )
2664 cp.ulStyle |= CPS_CANDIDATEPOS;
2665
2666 if( lpCandidate->dwStyle & CFS_EXCLUDE_W )
2667 cp.ulStyle |= CPS_EXCLUDE;
2668
2669 cp.ptCurrentPos.x = lpCandidate->ptCurrentPos.x;
2670 cp.ptCurrentPos.y = rcl.yTop - lpCandidate->ptCurrentPos.y;
2671
2672 cp.rcArea.xLeft = lpCandidate->rcArea.left;
2673 cp.rcArea.xRight = lpCandidate->rcArea.right;
2674 cp.rcArea.yTop = rcl.yTop - lpCandidate->rcArea.top;
2675 cp.rcArea.yBottom = rcl.yTop - lpCandidate->rcArea.bottom;
2676
2677 ImReleaseIMInstance( hIMC );
2678
2679 if( ImSetCandidateWindowPos( hIMC, &cp ) != 0 )
2680 return FALSE;
2681
2682 return TRUE;
2683}
2684
2685BOOL IM32SetCompositionFont(HIMC hIMC, LPVOID lplf, BOOL fUnicode)
2686{
2687// TODO
2688
2689 return FALSE;
2690}
2691
2692BOOL IM32SetCompositionString( HIMC hIMC, DWORD dwIndex, LPCVOID lpComp, DWORD dwCompLen, LPCVOID lpRead, DWORD dwReadLen, BOOL fUnicode)
2693{
2694 ULONG ulIndex;
2695
2696 switch( dwIndex )
2697 {
2698 case SCS_SETSTR_W :
2699 ulIndex = IME_SCS_STRING;
2700 break;
2701
2702 case SCS_CHANGEATTR_W :
2703 ulIndex = IME_SCS_ATTRIBUTE;
2704 break;
2705
2706 case SCS_CHANGECLAUSE_W :
2707 ulIndex = IME_SCS_CLAUSEINFO;
2708 break;
2709
2710 default :
2711 return FALSE;
2712
2713 }
2714
2715 if( fUnicode )
2716 {
2717 LPSTR compStrA = NULL;
2718 ULONG compStrLenA = 0;
2719 LPSTR readStrA = NULL;
2720 ULONG readStrLenA = 0;
2721 BOOL rc = FALSE;
2722
2723 switch( ulIndex )
2724 {
2725 case IME_SCS_STRING :
2726 {
2727 if( lpComp )
2728 {
2729 compStrLenA = WideCharToMultiByte( CP_ACP, 0, ( LPWSTR )lpComp, dwCompLen / sizeof( WCHAR ), 0, 0, 0, 0 );
2730 if( compStrLenA != 0 )
2731 {
2732 compStrA = ( LPSTR )malloc( compStrLenA );
2733 WideCharToMultiByte( CP_ACP, 0, ( LPWSTR )lpComp, dwCompLen / sizeof( WCHAR ), compStrA, compStrLenA, 0, 0 );
2734 }
2735 }
2736
2737 if( lpRead )
2738 {
2739 readStrLenA = WideCharToMultiByte( CP_ACP, 0, ( LPWSTR )lpRead, dwReadLen / sizeof( WCHAR ), 0, 0, 0, 0 );
2740 if( readStrLenA != 0 )
2741 {
2742 readStrA = ( LPSTR )malloc( readStrLenA );
2743 WideCharToMultiByte( CP_ACP, 0, ( LPWSTR )lpRead, dwReadLen / sizeof( WCHAR ), readStrA, readStrLenA, 0, 0 );
2744 }
2745 }
2746
2747 rc = ( ImSetConversionString( hIMC, ulIndex, compStrA, compStrLenA, readStrA, readStrLenA ) == 0 );
2748
2749 if( compStrA )
2750 free( compStrA );
2751
2752 if( readStrA )
2753 free( readStrA );
2754
2755 return rc;
2756 }
2757
2758 case IME_SCS_ATTRIBUTE :
2759 {
2760 PCHAR compAttrA = NULL;
2761 PCHAR readAttrA = NULL;
2762 PCHAR pchAttr;
2763 INT i, j;
2764
2765 if( lpComp )
2766 {
2767 if( ImGetConversionString( hIMC, IMR_CONV_CONVERSIONSTRING, compStrA, &compStrLenA ) != 0 )
2768 goto attr_exit;
2769
2770 compStrA = ( LPSTR )malloc( compStrLenA + 1 );
2771 if( !compStrA )
2772 goto attr_exit;
2773
2774 compStrA[ compStrLenA ] = 0;
2775
2776 if( ImGetConversionString( hIMC, IMR_CONV_CONVERSIONSTRING, compStrA, &compStrLenA ) != 0 )
2777 goto attr_exit;
2778
2779 compAttrA = ( PCHAR )malloc( compStrLenA + 1 );
2780 if( !compAttrA )
2781 goto attr_exit;
2782
2783 compAttrA[ compStrLenA ] = 0;
2784
2785 pchAttr = ( PCHAR )lpComp;
2786
2787 for( i = j = 0; ( i < dwCompLen ) && ( j < compStrLenA ); i++, j++ )
2788 {
2789 compAttrA[ j ] = pchAttr[ i ];
2790 if( IsDBCSLeadByte( compStrA[ j ] ))
2791 compAttrA[ ++j ] = pchAttr[ i ];
2792 }
2793
2794 if( compStrLenA > j )
2795 compStrLenA = j;
2796 }
2797
2798 if( lpRead )
2799 {
2800 if( ImGetConversionString( hIMC, IMR_CONV_READINGSTRING, readStrA, &readStrLenA ) != 0 )
2801 goto attr_exit;
2802
2803 readStrA = ( LPSTR )malloc( readStrLenA + 1 );
2804 if( !readStrA )
2805 goto attr_exit;
2806
2807 readStrA[ readStrLenA ] = 0;
2808
2809 if( ImGetConversionString( hIMC, IMR_CONV_READINGSTRING, readStrA, &readStrLenA ) != 0 )
2810 goto attr_exit;
2811
2812 readAttrA = ( PCHAR )malloc( readStrLenA + 1 );
2813 if( !readAttrA )
2814 goto attr_exit;
2815
2816 readAttrA[ readStrLenA ] = 0;
2817
2818 pchAttr = ( PCHAR )lpRead;
2819
2820 for( i = j = 0; ( i < dwReadLen ) && ( j < readStrLenA ); i++, j++ )
2821 {
2822 readAttrA[ j ] = pchAttr[ i ];
2823 if( IsDBCSLeadByte( readStrA[ j ] ))
2824 readAttrA[ ++j ] = pchAttr[ i ];
2825 }
2826
2827 if( readStrLenA > j )
2828 readStrLenA = j;
2829 }
2830
2831 if( ImSetConversionString( hIMC, ulIndex, compAttrA, compStrLenA, readAttrA, readStrLenA ) != 0 )
2832 goto attr_exit;
2833
2834 rc = TRUE;
2835
2836attr_exit :
2837 if( compStrA )
2838 free( compStrA );
2839
2840 if( compAttrA )
2841 free( compAttrA );
2842
2843 if( readStrA )
2844 free( readStrA );
2845
2846 if( readAttrA )
2847 free( readAttrA );
2848
2849 return rc;
2850 }
2851
2852 case IME_SCS_CLAUSEINFO :
2853 {
2854 LPWSTR compStrW = NULL;
2855 INT compStrLenW = 0;
2856 PULONG compClauseA = NULL;
2857 LPWSTR readStrW = NULL;
2858 INT readStrLenW = 0;
2859 PULONG readClauseA = NULL;
2860 PULONG pulClause;
2861 INT i, j;
2862
2863 if( lpComp )
2864 {
2865 if( ImGetConversionString( hIMC, IMR_CONV_CONVERSIONSTRING, compStrA, &compStrLenA ) != 0 )
2866 goto clause_exit;
2867
2868 compStrA = ( LPSTR )malloc( compStrLenA + 1 );
2869 if( !compStrA )
2870 goto clause_exit;
2871
2872 compStrA[ compStrLenA ] = 0;
2873
2874 if( ImGetConversionString( hIMC, IMR_CONV_CONVERSIONSTRING, compStrA, &compStrLenA ) != 0 )
2875 goto clause_exit;
2876
2877 compStrLenW = MultiByteToWideChar( CP_ACP, 0, compStrA, compStrLenA, 0, 0 );
2878 compStrW = ( LPWSTR )malloc(( compStrLenW + 1 ) * sizeof( WCHAR ));
2879 MultiByteToWideChar( CP_ACP, 0, compStrA, compStrLenA, compStrW, compStrLenW );
2880
2881 compClauseA = ( PULONG )malloc( dwCompLen );
2882 if( !compClauseA )
2883 goto clause_exit;
2884
2885 pulClause = ( PULONG )lpComp;
2886
2887 for( i = 0; ( i * sizeof( ULONG )) < dwCompLen; i++ )
2888 compClauseA[ i ] = WideCharToMultiByte( CP_ACP, 0, compStrW, pulClause[ i ], 0, 0, 0, 0 );
2889 }
2890
2891 if( lpRead )
2892 {
2893 if( ImGetConversionString( hIMC, IMR_CONV_READINGSTRING, readStrA, &readStrLenA ) != 0 )
2894 goto clause_exit;
2895
2896 readStrA = ( LPSTR )malloc( readStrLenA + 1 );
2897 if( !readStrA )
2898 goto clause_exit;
2899
2900 readStrA[ readStrLenA ] = 0;
2901
2902 if( ImGetConversionString( hIMC, IMR_CONV_READINGSTRING, readStrA, &readStrLenA ) != 0 )
2903 goto clause_exit;
2904
2905 readStrLenW = MultiByteToWideChar( CP_ACP, 0, readStrA, readStrLenA, 0, 0 );
2906 readStrW = ( LPWSTR )malloc(( readStrLenW + 1 ) * sizeof( WCHAR ));
2907 MultiByteToWideChar( CP_ACP, 0, readStrA, readStrLenA, readStrW, readStrLenW );
2908
2909 readClauseA = ( PULONG )malloc( dwReadLen );
2910 if( !readClauseA )
2911 goto clause_exit;
2912
2913 pulClause = ( PULONG )lpRead;
2914
2915 for( i = 0; ( i * sizeof( ULONG )) < dwReadLen; i++ )
2916 readClauseA[ i ] = WideCharToMultiByte( CP_ACP, 0, readStrW, pulClause[ i ], 0, 0, 0, 0 );
2917 }
2918
2919 if( ImSetConversionString( hIMC, ulIndex, compClauseA, dwCompLen, readClauseA, dwReadLen ) != 0 )
2920 goto clause_exit;
2921
2922 rc = TRUE;
2923
2924clause_exit :
2925 if( compStrA )
2926 free( compStrA );
2927
2928 if( compStrW )
2929 free( compStrW );
2930
2931 if( compClauseA )
2932 free( compClauseA );
2933
2934 if( readStrA )
2935 free( readStrA );
2936
2937 if( readStrW )
2938 free( readStrW );
2939
2940 if( readClauseA )
2941 free( readClauseA );
2942
2943 return rc;
2944 }
2945 }
2946 }
2947 else
2948 {
2949 if( ImSetConversionString( hIMC, ulIndex, ( PVOID )lpComp, dwCompLen, ( PVOID )lpRead, dwReadLen ) != 0 )
2950 return FALSE;
2951 }
2952
2953 return TRUE;
2954}
2955
2956BOOL IM32SetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
2957{
2958 CONVERSIONPOS cp;
2959 PIMINSTANCE pimi;
2960 RECTL rcl;
2961 SIZEF sizef;
2962
2963 if( ImRequestIMInstance( hIMC, &pimi ) != 0 )
2964 return FALSE;
2965
2966 if(!( pimi->ulClientInfo & IMI_CI_PMCALLABLE ))
2967 {
2968 ImReleaseIMInstance( hIMC );
2969 return FALSE;
2970 }
2971
2972 cp.ulStyle = CPS_DEFAULT;
2973
2974 if( lpCompForm->dwStyle & CFS_FORCE_POSITION_W )
2975 cp.ulStyle |= CPS_FORCE;
2976
2977 if( lpCompForm->dwStyle & CFS_POINT_W )
2978 cp.ulStyle |= CPS_POINT;
2979
2980 if( lpCompForm->dwStyle & CFS_RECT_W )
2981 cp.ulStyle |= CPS_RECT;
2982
2983 WinQueryWindowRect( pimi->hwnd, &rcl );
2984
2985 cp.ptCurrentPos.x = lpCompForm->ptCurrentPos.x;
2986 cp.ptCurrentPos.y = rcl.yTop -
2987 ( lpCompForm->ptCurrentPos.y + pimi->faConversionWindow.lMaxBaselineExt );
2988
2989 cp.rcArea.xLeft = lpCompForm->rcArea.left;
2990 cp.rcArea.xRight = lpCompForm->rcArea.right;
2991 cp.rcArea.yTop = rcl.yTop - rcl.yBottom - lpCompForm->rcArea.top;
2992 cp.rcArea.yBottom = rcl.yTop - rcl.yBottom - lpCompForm->rcArea.bottom;
2993
2994 ImReleaseIMInstance( hIMC );
2995
2996 if( ImSetConversionWindowPos( hIMC, &cp ) != 0 )
2997 return FALSE;
2998
2999 return TRUE;
3000}
3001
3002BOOL IM32SetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
3003{
3004 ULONG ulCurIM = 0;
3005 ULONG ulInputMode;
3006 ULONG ulConversionMode;
3007
3008 if( ImQueryIMMode( hIMC, &ulCurIM, &ulConversionMode ) != 0 )
3009 return FALSE;
3010
3011 ulInputMode = IMI_IM_NLS_ALPHANUMERIC;
3012
3013 if( fdwConversion & IME_CMODE_NATIVE_W )
3014 ulInputMode |= IMI_IM_NLS_HANGEUL;
3015
3016 if( fdwConversion & IME_CMODE_KATAKANA_W )
3017 ulInputMode |= IMI_IM_NLS_KATAKANA;
3018
3019 if( fdwConversion & IME_CMODE_FULLSHAPE_W )
3020 ulInputMode |= IMI_IM_WIDTH_FULL;
3021
3022 if( fdwConversion & IME_CMODE_ROMAN_W )
3023 ulInputMode |= IMI_IM_ROMAJI_ON;
3024
3025 if( ulCurIM & IMI_IM_SYSTEMROMAJI_DISABLE )
3026 ulInputMode |= IMI_IM_SYSTEMROMAJI_DISABLE;
3027
3028 if( ulCurIM & IMI_IM_2NDCONV )
3029 ulInputMode |= IMI_IM_2NDCONV;
3030
3031 if( fdwConversion & IME_CMODE_CHARCODE_W )
3032 ulInputMode |= 0;
3033
3034 if( fdwConversion & IME_CMODE_HANJACONVERT_W )
3035 ulInputMode |= IMI_IM_IME_ON; // right ?
3036
3037 if( fdwConversion & IME_CMODE_SOFTKBD_W )
3038 ulInputMode |= IMI_IM_IME_SOFTKBD_ON;
3039
3040 if( fdwConversion & IME_CMODE_NOCONVERSION_W )
3041 ulInputMode |= IMI_IM_IME_DISABLE; // right ?
3042
3043 if( fdwConversion & IME_CMODE_EUDC_W )
3044 ulInputMode |= 0;
3045
3046 if( fdwConversion & IME_CMODE_SYMBOL_W )
3047 ulInputMode |= IMI_IM_IME_CSYMBOL_ON; // right ?
3048
3049 ulConversionMode = IMI_CM_NONE;
3050
3051 if( fdwSentence & IME_SMODE_PLAURALCLAUSE_W )
3052 ulConversionMode |= IMI_CM_PLURALCLAUSE;
3053
3054 if( fdwSentence & IME_SMODE_SINGLECONVERT_W )
3055 ulConversionMode |= IMI_CM_SINGLE;
3056
3057 if( fdwSentence & IME_SMODE_AUTOMATIC_W )
3058 ulConversionMode |= IMI_CM_AUTOMATIC;
3059
3060 if( fdwSentence & IME_SMODE_PHRASEPREDICT_W )
3061 ulConversionMode |= IMI_CM_PREDICT;
3062
3063 if( ImSetIMMode( hIMC, ulInputMode, ulConversionMode ) != 0 )
3064 return FALSE;
3065
3066 return TRUE;
3067}
3068
3069BOOL IM32SetHotKey(DWORD dword, UINT uint, UINT uint2, HKL hkl)
3070{
3071 return FALSE;
3072}
3073
3074BOOL IM32SetOpenStatus(HIMC hIMC, BOOL fOpen)
3075{
3076 ULONG ulInputMode;
3077 ULONG ulConversionMode;
3078
3079 if( ImQueryIMMode(( HIMI )hIMC, &ulInputMode, &ulConversionMode ) != 0 )
3080 return FALSE;
3081
3082 if( fOpen )
3083 ulInputMode &= ~IMI_IM_IME_DISABLE;
3084 else
3085 ulInputMode |= IMI_IM_IME_DISABLE;
3086
3087 if( ImSetIMMode(( HIMI )hIMC, ulInputMode, ulConversionMode ) != 0 )
3088 return FALSE;
3089
3090 return TRUE;
3091}
3092
3093BOOL IM32SetStatusWindowPos(HIMC hIMC, LPPOINT lpptPos)
3094{
3095// TODO
3096
3097 return FALSE;
3098}
3099
3100BOOL IM32ShowSoftKeyboard(HWND hwnd, int in1)
3101{
3102 return FALSE;
3103}
3104
3105BOOL IM32SimulateHotKey(HWND hWnd, DWORD dwHotKeyID)
3106{
3107 HWND hwndOS2 = Win32ToOS2Handle( hWnd );
3108 HIMI himi;
3109 ULONG ulInputMode;
3110 ULONG ulConversionMode;
3111 BOOL rc = FALSE;
3112
3113 if( ImGetInstance( hwndOS2, &himi ))
3114 return FALSE;
3115
3116 if( ImQueryIMMode( himi, &ulInputMode, &ulConversionMode ))
3117 goto IM32SimulateHotKey_exit;
3118
3119 switch( dwHotKeyID )
3120 {
3121 case IME_CHOTKEY_IME_NONIME_TOGGLE_W :
3122 ulInputMode ^= IMI_IM_IME_DISABLE;
3123 break;
3124
3125 case IME_CHOTKEY_SHAPE_TOGGLE_W :
3126 case IME_CHOTKEY_SYMBOL_TOGGLE_W :
3127 // not supported
3128 goto IM32SimulateHotKey_exit;
3129
3130 case IME_JHOTKEY_CLOSE_OPEN_W :
3131 ulInputMode ^= IMI_IM_IME_ON;
3132 break;
3133
3134 case IME_KHOTKEY_SHAPE_TOGGLE_W :
3135 // not supported
3136 goto IM32SimulateHotKey_exit;
3137
3138 case IME_KHOTKEY_HANJACONVERT_W :
3139 ulInputMode ^= IMI_IM_IME_ON; // right ?
3140
3141 case IME_KHOTKEY_ENGLISH_W :
3142 ulInputMode ^= IMI_IM_NLS_HANGEUL;
3143 break;
3144
3145 case IME_THOTKEY_IME_NONIME_TOGGLE_W :
3146 ulInputMode ^= IMI_IM_IME_DISABLE;
3147 break;
3148
3149 case IME_THOTKEY_SHAPE_TOGGLE_W :
3150 case IME_THOTKEY_SYMBOL_TOGGLE_W :
3151 // not supported
3152 goto IM32SimulateHotKey_exit;
3153 break;
3154 }
3155
3156 rc = !ImSetIMMode( himi, ulInputMode, ulConversionMode );
3157
3158IM32SimulateHotKey_exit:
3159
3160 ImReleaseInstance( hwndOS2, himi );
3161
3162 return rc;
3163}
3164
3165BOOL IM32UnlockIMC(HIMC himc)
3166{
3167 return FALSE;
3168}
3169
3170BOOL IM32UnlockIMCC(HIMCC himcc)
3171{
3172 return FALSE;
3173}
3174
3175BOOL IM32UnregisterWord(HKL hKL, LPVOID lpszReading, DWORD dwStyle, LPVOID lpszUnregister, BOOL fUnicode)
3176{
3177// TODO
3178
3179 return FALSE;
3180}
3181
3182
Note: See TracBrowser for help on using the repository browser.