Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

470 lines
13 KiB

  1. /****************************************************************************
  2. IMMSYS.CPP
  3. Owner: cslim
  4. Copyright (c) 1997-1999 Microsoft Corporation
  5. Load/Unload IMM Apis dynamically not link with imm32.lib
  6. Inlcude Immdev.h and Indicml.h
  7. History:
  8. 14-JUL-1999 cslim Copied from KKIME2001 source tree
  9. *****************************************************************************/
  10. #ifndef UNDER_CE // Windows CE does not use private way.
  11. /* -- IMMSYS support as following APIs --
  12. OurImmSetOpenStatus
  13. OurImmGetOpenStatus
  14. OurImmGetContext
  15. OurImmGetConversionStatus
  16. OurImmSetConversionStatus
  17. OurImmSetStatusWindowPos
  18. OurImmConfigureIMEA
  19. OurImmEscapeA
  20. OurImmNotifyIME
  21. OurImmLockIMCC
  22. OurImmReSizeIMCC
  23. OurImmUnlockIMCC
  24. OurImmGetIMCCSize
  25. OurImmGenerateMessage
  26. OurImmLockIMC
  27. OurImmUnlockIMC
  28. // OurImmRequestMessageW: Commented becuase used only by KK IME(Reconversion, document feed)
  29. OurImmGetDefaultIMEWnd
  30. OurImmGetIMEFileNameA
  31. OutImmIsIME()
  32. ----------------------------------------*/
  33. #define LIBNAME TEXT("imm32.dll")
  34. #include "precomp.h"
  35. typedef BOOL(WINAPI* FPOurImmSetOpenStatus)(HIMC hIMC, BOOL fOpen);
  36. typedef BOOL(WINAPI* FPOurImmGetOpenStatus)(HIMC hIMC);
  37. typedef HIMC(WINAPI* FPOurImmGetContext)(HWND hWnd);
  38. typedef BOOL(WINAPI* FPOurImmGetConversionStatus)(HIMC hIMC, LPDWORD pdwConv, LPDWORD pdwSent);
  39. typedef BOOL(WINAPI* FPOurImmSetConversionStatus)(HIMC hIMC, DWORD dwConv, DWORD dwSent);
  40. typedef BOOL(WINAPI* FPOurImmSetStatusWindowPos)(HIMC hIMC, LPPOINT pPt);
  41. typedef BOOL(WINAPI* FPOurImmConfigureIME)(HKL hKL, HWND hWnd, DWORD dw, LPVOID pv);
  42. typedef LRESULT(WINAPI* FPOurImmEscapeA)(HKL hKL, HIMC hIMC, UINT ui, LPVOID pv);
  43. typedef BOOL(WINAPI* FPOurImmNotifyIME)(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue);
  44. typedef LPVOID(WINAPI* FPOurImmLockIMCC)(HIMCC hIMCC);
  45. typedef HIMCC(WINAPI* FPOurImmReSizeIMCC)(HIMCC hIMCC, DWORD dw);
  46. typedef BOOL(WINAPI* FPOurImmUnlockIMCC)(HIMCC hIMCC);
  47. typedef DWORD(WINAPI* FPOurImmGetIMCCSize)(HIMCC hIMCC);
  48. typedef BOOL(WINAPI* FPOurImmGenerateMessage)(HIMC hIMC);
  49. typedef LPINPUTCONTEXT(WINAPI* FPOurImmLockIMC)(HIMC hIMC);
  50. typedef BOOL(WINAPI* FPOurImmUnlockIMC)(HIMC hIMC);
  51. //typedef LRESULT(WINAPI* FPOurImmRequestMessageW)(HIMC hIMC, WPARAM wParam, LPARAM lParam);
  52. typedef HWND(WINAPI* FPOurImmGetDefaultIMEWnd)(HWND hWnd);
  53. typedef UINT(WINAPI* FPOurImmGetIMEFileNameA)(HKL hKL, CHAR* psz, UINT uBufLen);
  54. typedef BOOL(WINAPI* FPOurImmIsIME)(HKL hKL);
  55. static FPOurImmSetOpenStatus pFPOurImmSetOpenStatus = 0;
  56. static FPOurImmGetOpenStatus pFPOurImmGetOpenStatus = 0;
  57. static FPOurImmGetContext pFPOurImmGetContext = 0;
  58. static FPOurImmGetConversionStatus pFPOurImmGetConversionStatus = 0;
  59. static FPOurImmSetConversionStatus pFPOurImmSetConversionStatus = 0;
  60. static FPOurImmSetStatusWindowPos pFPOurImmSetStatusWindowPos = 0;
  61. static FPOurImmConfigureIME pFPOurImmConfigureIME = 0;
  62. static FPOurImmEscapeA pFPOurImmEscapeA = 0;
  63. static FPOurImmNotifyIME pFPOurImmNotifyIME = 0;
  64. static FPOurImmLockIMCC pFPOurImmLockIMCC = 0;
  65. static FPOurImmReSizeIMCC pFPOurImmReSizeIMCC = 0;
  66. static FPOurImmUnlockIMCC pFPOurImmUnlockIMCC = 0;
  67. static FPOurImmGetIMCCSize pFPOurImmGetIMCCSize = 0;
  68. static FPOurImmGenerateMessage pFPOurImmGenerateMessage = 0;
  69. static FPOurImmLockIMC pFPOurImmLockIMC = 0;
  70. static FPOurImmUnlockIMC pFPOurImmUnlockIMC = 0;
  71. //static FPOurImmRequestMessageW pFPOurImmRequestMessageW = 0;
  72. static FPOurImmGetDefaultIMEWnd pFPOurImmGetDefaultIMEWnd = 0;
  73. static FPOurImmGetIMEFileNameA pFPOurImmGetIMEFileNameA = 0;
  74. static FPOurImmIsIME pFPOurImmIsIME = 0;
  75. static HMODULE hImmLib = (HMODULE)0;
  76. BOOL StartIMM(VOID)
  77. {
  78. if( hImmLib != (HANDLE)0 ) {
  79. return TRUE;
  80. }
  81. hImmLib = LoadLibrary( LIBNAME );
  82. if( hImmLib == (HANDLE)0 ) {
  83. return TRUE;
  84. }
  85. pFPOurImmSetOpenStatus = (FPOurImmSetOpenStatus)GetProcAddress( hImmLib, "ImmSetOpenStatus" );
  86. pFPOurImmGetOpenStatus = (FPOurImmGetOpenStatus)GetProcAddress( hImmLib, "ImmGetOpenStatus" );
  87. pFPOurImmGetContext = (FPOurImmGetContext)GetProcAddress( hImmLib, "ImmGetContext" );
  88. pFPOurImmGetConversionStatus = (FPOurImmGetConversionStatus)GetProcAddress( hImmLib, "ImmGetConversionStatus" );
  89. pFPOurImmSetConversionStatus = (FPOurImmSetConversionStatus)GetProcAddress( hImmLib, "ImmSetConversionStatus" );
  90. pFPOurImmSetStatusWindowPos = (FPOurImmSetStatusWindowPos)GetProcAddress( hImmLib, "ImmSetStatusWindowPos" );
  91. pFPOurImmConfigureIME = (FPOurImmConfigureIME)GetProcAddress( hImmLib, "ImmConfigureIMEA" );
  92. pFPOurImmEscapeA = (FPOurImmEscapeA)GetProcAddress( hImmLib, "ImmEscapeA" );
  93. pFPOurImmNotifyIME = (FPOurImmNotifyIME)GetProcAddress( hImmLib, "ImmNotifyIME" );
  94. pFPOurImmLockIMCC = (FPOurImmLockIMCC)GetProcAddress( hImmLib, "ImmLockIMCC" );
  95. pFPOurImmReSizeIMCC = (FPOurImmReSizeIMCC)GetProcAddress( hImmLib, "ImmReSizeIMCC" );
  96. pFPOurImmUnlockIMCC = (FPOurImmUnlockIMCC)GetProcAddress( hImmLib, "ImmUnlockIMCC" );
  97. pFPOurImmGetIMCCSize = (FPOurImmGetIMCCSize)GetProcAddress( hImmLib, "ImmGetIMCCSize" );
  98. pFPOurImmGenerateMessage = (FPOurImmGenerateMessage)GetProcAddress( hImmLib, "ImmGenerateMessage" );
  99. pFPOurImmLockIMC = (FPOurImmLockIMC)GetProcAddress( hImmLib, "ImmLockIMC" );
  100. pFPOurImmUnlockIMC = (FPOurImmUnlockIMC)GetProcAddress( hImmLib, "ImmUnlockIMC" );
  101. // pFPOurImmRequestMessageW = (FPOurImmRequestMessageW)GetProcAddress( hImmLib, "ImmRequestMessageW" );
  102. pFPOurImmGetDefaultIMEWnd = (FPOurImmGetDefaultIMEWnd)GetProcAddress( hImmLib, "ImmGetDefaultIMEWnd" );
  103. pFPOurImmGetIMEFileNameA = (FPOurImmGetIMEFileNameA)GetProcAddress( hImmLib, "ImmGetIMEFileNameA" );
  104. pFPOurImmIsIME = (FPOurImmIsIME)GetProcAddress( hImmLib, "ImmIsIME" );
  105. return FALSE;
  106. }
  107. VOID EndIMM(VOID)
  108. {
  109. FreeLibrary( hImmLib );
  110. }
  111. //
  112. // OurImmSetOpenStatus
  113. //
  114. BOOL OurImmSetOpenStatus(HIMC hIMC, BOOL fOpen)
  115. {
  116. #ifdef _AIMM_
  117. if( IsAIME() == TRUE && vpAIMM) {
  118. return (vpAIMM->SetOpenStatus( hIMC, fOpen ) == S_OK) ? TRUE : FALSE;
  119. }
  120. #endif
  121. if( pFPOurImmSetOpenStatus ) {
  122. return pFPOurImmSetOpenStatus(hIMC, fOpen );
  123. }
  124. return FALSE;
  125. }
  126. //
  127. // OurImmGetOpenStatus
  128. //
  129. BOOL OurImmGetOpenStatus(HIMC hIMC)
  130. {
  131. #ifdef _AIMM_
  132. if( IsAIME() == TRUE && vpAIMM) {
  133. return (vpAIMM->GetOpenStatus( hIMC ) == S_OK ? TRUE : FALSE);
  134. }
  135. #endif
  136. if( pFPOurImmGetOpenStatus ) {
  137. // * check *
  138. //
  139. // sometime IMM sets 0xffffffff as TRUE
  140. //
  141. return (pFPOurImmGetOpenStatus( hIMC ) ? TRUE : FALSE);
  142. }
  143. return FALSE;
  144. }
  145. //
  146. // OurImmGetContext
  147. //
  148. HIMC OurImmGetContext(HWND hWnd)
  149. {
  150. #ifdef _AIMM_
  151. if( IsAIME() == TRUE && vpAIMM) {
  152. HIMC hIMC = (HIMC)0;
  153. vpAIMM->GetContext( hWnd, &hIMC );
  154. return hIMC;
  155. }
  156. #endif
  157. if( pFPOurImmGetContext ) {
  158. return pFPOurImmGetContext(hWnd );
  159. }
  160. return NULL;
  161. }
  162. //
  163. // OurImmGetConversionStatus
  164. //
  165. BOOL OurImmGetConversionStatus(HIMC hIMC, LPDWORD pdwConv, LPDWORD pdwSent)
  166. {
  167. #ifdef _AIMM_
  168. if( IsAIME() == TRUE && vpAIMM) {
  169. return (vpAIMM->GetConversionStatus(hIMC, pdwConv, pdwSent ) == S_OK) ? TRUE : FALSE;
  170. }
  171. #endif
  172. if( pFPOurImmGetConversionStatus ) {
  173. return pFPOurImmGetConversionStatus(hIMC, pdwConv, pdwSent );
  174. }
  175. return NULL;
  176. }
  177. //
  178. // OurImmSetConversionStatus
  179. //
  180. BOOL OurImmSetConversionStatus(HIMC hIMC, DWORD dwConv, DWORD dwSent)
  181. {
  182. #ifdef _AIMM_
  183. if( IsAIME() == TRUE && vpAIMM) {
  184. return (vpAIMM->SetConversionStatus(hIMC, dwConv, dwSent) == S_OK) ? TRUE : FALSE;
  185. }
  186. #endif
  187. if( pFPOurImmSetConversionStatus ) {
  188. return pFPOurImmSetConversionStatus(hIMC, dwConv, dwSent);
  189. }
  190. return NULL;
  191. }
  192. //
  193. // OurImmSetStatusWindowPos
  194. //
  195. BOOL OurImmSetStatusWindowPos(HIMC hIMC, LPPOINT pPt)
  196. {
  197. #ifdef _AIMM_
  198. if( IsAIME() == TRUE && vpAIMM) {
  199. return (vpAIMM->SetStatusWindowPos( hIMC, pPt) == S_OK) ? TRUE : FALSE;
  200. }
  201. #endif
  202. if( pFPOurImmSetStatusWindowPos ) {
  203. return pFPOurImmSetStatusWindowPos( hIMC, pPt);
  204. }
  205. return NULL;
  206. }
  207. //
  208. // OurImmConfigureIME
  209. //
  210. BOOL OurImmConfigureIME(HKL hKL, HWND hWnd, DWORD dw, LPVOID pv)
  211. {
  212. #ifdef _AIMM_
  213. if( IsAIME() == TRUE && vpAIMM) {
  214. return (vpAIMM->ConfigureIMEA(hKL, hWnd, dw, (REGISTERWORDA*)pv ) == S_OK) ? TRUE : FALSE;
  215. }
  216. #endif
  217. if( pFPOurImmConfigureIME ) {
  218. return pFPOurImmConfigureIME(hKL, hWnd, dw, pv );
  219. }
  220. return NULL;
  221. }
  222. //
  223. // OurImmEscapeA
  224. //
  225. LRESULT OurImmEscapeA(HKL hKL, HIMC hIMC, UINT ui, LPVOID pv)
  226. {
  227. #ifdef _AIMM_
  228. if( IsAIME() == TRUE && vpAIMM) {
  229. LRESULT lRet = 0;
  230. vpAIMM->EscapeA(hKL, hIMC, ui, pv, &lRet );
  231. return lRet;
  232. }
  233. #endif
  234. if( pFPOurImmEscapeA ) {
  235. return pFPOurImmEscapeA(hKL, hIMC, ui, pv );
  236. }
  237. return NULL;
  238. }
  239. //
  240. // OurImmNotifyIME
  241. //
  242. BOOL OurImmNotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
  243. {
  244. #ifdef _AIMM_
  245. if( IsAIME() == TRUE && vpAIMM) {
  246. return (vpAIMM->NotifyIME(hIMC, dwAction, dwIndex, dwValue ) == S_OK) ? TRUE : FALSE;
  247. }
  248. #endif
  249. if( pFPOurImmNotifyIME ) {
  250. return pFPOurImmNotifyIME(hIMC, dwAction, dwIndex, dwValue );
  251. }
  252. return NULL;
  253. }
  254. //
  255. // OurImmLockIMCC
  256. //
  257. LPVOID OurImmLockIMCC(HIMCC hIMCC)
  258. {
  259. #ifdef _AIMM_
  260. if( IsAIME() == TRUE && vpAIMM) {
  261. VOID* pv = NULL;
  262. vpAIMM->LockIMCC( hIMCC, &pv);
  263. return pv;
  264. }
  265. #endif
  266. if( pFPOurImmLockIMCC ) {
  267. return pFPOurImmLockIMCC( hIMCC);
  268. }
  269. return NULL;
  270. }
  271. //
  272. // OurImmReSizeIMCC
  273. //
  274. HIMCC OurImmReSizeIMCC(HIMCC hIMCC, DWORD dw)
  275. {
  276. #ifdef _AIMM_
  277. if( IsAIME() == TRUE && vpAIMM) {
  278. HIMCC hIMCC2 = (HIMCC)0;
  279. vpAIMM->ReSizeIMCC(hIMCC, dw, &hIMCC2 );
  280. return hIMCC2;
  281. }
  282. #endif
  283. if( pFPOurImmReSizeIMCC ) {
  284. return pFPOurImmReSizeIMCC(hIMCC, dw );
  285. }
  286. return NULL;
  287. }
  288. //
  289. // OurImmUnlockIMCC
  290. //
  291. BOOL OurImmUnlockIMCC(HIMCC hIMCC)
  292. {
  293. #ifdef _AIMM_
  294. if( IsAIME() == TRUE && vpAIMM) {
  295. return (vpAIMM->UnlockIMCC(hIMCC ) == S_OK) ? TRUE : FALSE;
  296. }
  297. #endif
  298. if( pFPOurImmUnlockIMCC ) {
  299. return pFPOurImmUnlockIMCC(hIMCC );
  300. }
  301. return NULL;
  302. }
  303. //
  304. // OurImmGetIMCCSize
  305. //
  306. DWORD OurImmGetIMCCSize(HIMCC hIMCC)
  307. {
  308. #ifdef _AIMM_
  309. if( IsAIME() == TRUE && vpAIMM) {
  310. DWORD dwSize = 0;
  311. vpAIMM->GetIMCCSize(hIMCC, &dwSize );
  312. return dwSize;
  313. }
  314. #endif
  315. if( pFPOurImmGetIMCCSize ) {
  316. return pFPOurImmGetIMCCSize(hIMCC );
  317. }
  318. return NULL;
  319. }
  320. //
  321. // OurImmGenerateMessage
  322. //
  323. BOOL OurImmGenerateMessage(HIMC hIMC)
  324. {
  325. #ifdef _AIMM_
  326. if( IsAIME() == TRUE && vpAIMM) {
  327. return (vpAIMM->GenerateMessage( hIMC) == S_OK) ? TRUE : FALSE;
  328. }
  329. #endif
  330. if( pFPOurImmGenerateMessage ) {
  331. return pFPOurImmGenerateMessage( hIMC);
  332. }
  333. return NULL;
  334. }
  335. //
  336. // OurImmLockIMC
  337. //
  338. LPINPUTCONTEXT OurImmLockIMC(HIMC hIMC)
  339. {
  340. #ifdef _AIMM_
  341. if( IsAIME() == TRUE && vpAIMM) {
  342. LPINPUTCONTEXT pI = NULL;
  343. vpAIMM->LockIMC( hIMC, &pI);
  344. return pI;
  345. }
  346. #endif
  347. if( pFPOurImmLockIMC ) {
  348. return pFPOurImmLockIMC( hIMC);
  349. }
  350. return NULL;
  351. }
  352. //
  353. // OurImmUnlockIMC
  354. //
  355. BOOL OurImmUnlockIMC(HIMC hIMC)
  356. {
  357. #ifdef _AIMM_
  358. if( IsAIME() == TRUE && vpAIMM) {
  359. return (vpAIMM->UnlockIMC( hIMC ) == S_OK) ? TRUE : FALSE;
  360. }
  361. #endif
  362. if( pFPOurImmUnlockIMC ) {
  363. return pFPOurImmUnlockIMC( hIMC );
  364. }
  365. return NULL;
  366. }
  367. #if NOTUSED
  368. //
  369. // OurImmRequestMessageW
  370. //
  371. LRESULT OurImmRequestMessageW(HIMC hIMC, WPARAM wParam, LPARAM lParam)
  372. {
  373. #ifdef _AIMM_
  374. if( IsAIME() == TRUE && vpAIMM) {
  375. return 0; //vpAIMM->UnlockIMC( hIMC );
  376. }
  377. #endif
  378. if( pFPOurImmRequestMessageW ) {
  379. return pFPOurImmRequestMessageW( hIMC, wParam, lParam );
  380. }
  381. return NULL;
  382. }
  383. #endif
  384. //
  385. // OurImmGetDefaultIMEWnd
  386. //
  387. HWND OurImmGetDefaultIMEWnd(HWND hWnd )
  388. {
  389. #ifdef _AIMM_
  390. if( IsAIME() == TRUE && vpAIMM) {
  391. HWND hWndDef = (HWND)0;
  392. vpAIMM->GetDefaultIMEWnd(hWnd, &hWndDef);
  393. return hWndDef;
  394. }
  395. #endif
  396. if( pFPOurImmGetDefaultIMEWnd ) {
  397. return pFPOurImmGetDefaultIMEWnd(hWnd);
  398. }
  399. return NULL;
  400. }
  401. UINT OurImmGetIMEFileNameA(HKL hKL, LPSTR pszName, UINT uBufLen)
  402. {
  403. #ifdef _AIMM_
  404. if( IsAIME() == TRUE && vpAIMM) {
  405. UINT ui = 0;
  406. vpAIMM->GetIMEFileNameA(hKL, uBufLen, pszName, &ui);
  407. return ui;
  408. }
  409. #endif
  410. if( pFPOurImmGetIMEFileNameA ) {
  411. return pFPOurImmGetIMEFileNameA(hKL, pszName, uBufLen);
  412. }
  413. return NULL;
  414. }
  415. //
  416. // OurImmIsIME
  417. //
  418. BOOL OurImmIsIME(HKL hKL)
  419. {
  420. #ifdef _AIMM_
  421. if( IsAIME() == TRUE && vpAIMM) {
  422. // why? BOOL fRet = FALSE;
  423. return (vpAIMM->IsIME(hKL) == S_OK) ? TRUE : FALSE;
  424. //return fRet;
  425. }
  426. #endif
  427. if( pFPOurImmIsIME ) {
  428. return pFPOurImmIsIME(hKL );
  429. }
  430. return FALSE;
  431. }
  432. #endif // UNDER_CE