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.

823 lines
26 KiB

  1. /*++
  2. Copyright (c) 2001, Microsoft Corporation
  3. Module Name:
  4. dimmex.h
  5. Abstract:
  6. This file defines the CActiveIMMAppEx Interface Class.
  7. Author:
  8. Revision History:
  9. Notes:
  10. --*/
  11. #ifndef _DIMMEX_H_
  12. #define _DIMMEX_H_
  13. #include "resource.h"
  14. #include "globals.h"
  15. #include "list.h"
  16. #include "atom.h"
  17. #include "delay.h"
  18. #include "oldaimm.h"
  19. extern CGuidMapList *g_pGuidMapList;
  20. BOOL InitFilterList();
  21. void UninitFilterList();
  22. extern CAtomObject *g_pAimmAtom;
  23. BOOL InitAimmAtom();
  24. void UninitAimmAtom();
  25. //
  26. // 4955DD32-B159-11d0-8FCF-00AA006BCC59
  27. //
  28. static const IID IID_IActiveIMMAppTrident4x = {
  29. 0x4955DD32,
  30. 0xB159,
  31. 0x11d0,
  32. { 0x8F, 0xCF, 0x00, 0xaa, 0x00, 0x6b, 0xcc, 0x59 }
  33. };
  34. //
  35. // c839a84c-8036-11d3-9270-0060b067b86e
  36. //
  37. static const IID IID_IActiveIMMAppPostNT4 = {
  38. 0xc839a84c,
  39. 0x8036,
  40. 0x11d3,
  41. {0x92, 0x70, 0x00, 0x60, 0xb0, 0x67, 0xb8, 0x6e}
  42. };
  43. //+---------------------------------------------------------------------------
  44. //
  45. // CComActiveIMMApp
  46. //
  47. //----------------------------------------------------------------------------
  48. class CComActiveIMMApp : public IActiveIMMAppEx,
  49. public IActiveIMMMessagePumpOwner,
  50. public IAImmThreadCompartment,
  51. public IServiceProvider
  52. {
  53. public:
  54. CComActiveIMMApp()
  55. {
  56. _fEnableGuidMap = FALSE;
  57. m_hModCtfIme = NULL;
  58. }
  59. static BOOL VerifyCreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj)
  60. {
  61. //
  62. // Look up disabling Text Services status from the registry.
  63. // If it is disabled, return fail not to support Text Services.
  64. //
  65. if (IsDisabledTextServices())
  66. return FALSE;
  67. if (RunningInExcludedModule())
  68. return FALSE;
  69. if (!IsInteractiveUserLogon())
  70. return FALSE;
  71. if (NoTipsInstalled(NULL))
  72. return FALSE;
  73. return TRUE;
  74. }
  75. //
  76. // IActiveIMMMessagePumpOwner
  77. //
  78. STDMETHODIMP Start() { return E_NOTIMPL; }
  79. STDMETHODIMP End() { return E_NOTIMPL; }
  80. STDMETHODIMP OnTranslateMessage(const MSG *pMsg) { return E_NOTIMPL; }
  81. STDMETHODIMP Pause(DWORD *pdwCookie) { return E_NOTIMPL; }
  82. STDMETHODIMP Resume(DWORD dwCookie) { return E_NOTIMPL; }
  83. //
  84. // IActiveIMMApp/IActiveIMM methods
  85. //
  86. /*
  87. * AIMM Input Context (hIMC) Methods.
  88. */
  89. STDMETHODIMP CreateContext(HIMC *phIMC)
  90. {
  91. HIMC hIMC = imm32::ImmCreateContext();
  92. if (hIMC) {
  93. *phIMC = hIMC;
  94. return S_OK;
  95. }
  96. return E_FAIL;
  97. }
  98. STDMETHODIMP DestroyContext(HIMC hIMC)
  99. {
  100. return (imm32::ImmDestroyContext(hIMC)) ? S_OK
  101. : E_FAIL;
  102. }
  103. STDMETHODIMP AssociateContext(HWND hWnd, HIMC hIMC, HIMC *phPrev)
  104. {
  105. *phPrev = imm32::ImmAssociateContext(hWnd, hIMC);
  106. return S_OK;
  107. }
  108. STDMETHODIMP AssociateContextEx(HWND hWnd, HIMC hIMC, DWORD dwFlags)
  109. {
  110. return (imm32::ImmAssociateContextEx(hWnd, hIMC, dwFlags)) ? S_OK
  111. : E_FAIL;
  112. }
  113. STDMETHODIMP GetContext(HWND hWnd, HIMC *phIMC)
  114. {
  115. *phIMC = imm32::ImmGetContext(hWnd);
  116. return S_OK;
  117. }
  118. STDMETHODIMP ReleaseContext(HWND hWnd, HIMC hIMC)
  119. {
  120. return (imm32::ImmReleaseContext(hWnd, hIMC)) ? S_OK
  121. : E_FAIL;
  122. }
  123. STDMETHODIMP GetIMCLockCount(HIMC hIMC, DWORD *pdwLockCount)
  124. {
  125. *pdwLockCount = imm32::ImmGetIMCLockCount(hIMC);
  126. return S_OK;
  127. }
  128. STDMETHODIMP LockIMC(HIMC hIMC, INPUTCONTEXT **ppIMC)
  129. {
  130. return (*ppIMC = imm32::ImmLockIMC(hIMC)) ? S_OK
  131. : E_FAIL;
  132. }
  133. STDMETHODIMP UnlockIMC(HIMC hIMC)
  134. {
  135. imm32::ImmUnlockIMC(hIMC);
  136. return S_OK;
  137. }
  138. /*
  139. * AIMM Input Context Components (hIMCC) API Methods.
  140. */
  141. STDMETHODIMP CreateIMCC(DWORD dwSize, HIMCC *phIMCC)
  142. {
  143. HIMCC hIMCC = imm32::ImmCreateIMCC(dwSize);
  144. if (hIMCC) {
  145. *phIMCC = hIMCC;
  146. return S_OK;
  147. }
  148. return E_FAIL;
  149. }
  150. STDMETHODIMP DestroyIMCC(HIMCC hIMCC)
  151. {
  152. /*
  153. * ImmDestroyIMCC maped to LocalFree.
  154. * if the function fails, the return value is equal to a handle to the local memory object.
  155. * if the function succeeds, the return value is NULL.
  156. */
  157. return (imm32::ImmDestroyIMCC(hIMCC)) ? E_FAIL
  158. : S_OK;
  159. }
  160. STDMETHODIMP GetIMCCSize(HIMCC hIMCC, DWORD *pdwSize)
  161. {
  162. *pdwSize = imm32::ImmGetIMCCSize(hIMCC);
  163. return S_OK;
  164. }
  165. STDMETHODIMP ReSizeIMCC(HIMCC hIMCC, DWORD dwSize, HIMCC *phIMCC)
  166. {
  167. HIMCC hNewIMCC = imm32::ImmReSizeIMCC(hIMCC, dwSize);
  168. if (hNewIMCC) {
  169. *phIMCC = hNewIMCC;
  170. return S_OK;
  171. }
  172. return E_FAIL;
  173. }
  174. STDMETHODIMP GetIMCCLockCount(HIMCC hIMCC, DWORD *pdwLockCount)
  175. {
  176. *pdwLockCount = imm32::ImmGetIMCCLockCount(hIMCC);
  177. return S_OK;
  178. }
  179. STDMETHODIMP LockIMCC(HIMCC hIMCC, void **ppv)
  180. {
  181. return (*ppv = imm32::ImmLockIMCC(hIMCC)) ? S_OK
  182. : E_FAIL;
  183. }
  184. STDMETHODIMP UnlockIMCC(HIMCC hIMCC)
  185. {
  186. if (imm32::ImmUnlockIMCC(hIMCC)) {
  187. // memory object still locked.
  188. return S_OK;
  189. }
  190. else {
  191. DWORD err = GetLastError();
  192. if (err == NO_ERROR)
  193. // memory object is unlocked.
  194. return S_OK;
  195. else if (err == ERROR_NOT_LOCKED)
  196. // memory object is already unlocked.
  197. return S_OK;
  198. }
  199. return E_FAIL;
  200. }
  201. /*
  202. * AIMM Open Status API Methods
  203. */
  204. STDMETHODIMP GetOpenStatus(HIMC hIMC)
  205. {
  206. return imm32::ImmGetOpenStatus(hIMC) ? S_OK : S_FALSE;
  207. }
  208. STDMETHODIMP SetOpenStatus(HIMC hIMC, BOOL fOpen)
  209. {
  210. return (imm32::ImmSetOpenStatus(hIMC, fOpen)) ? S_OK
  211. : E_FAIL;
  212. }
  213. /*
  214. * AIMM Conversion Status API Methods
  215. */
  216. STDMETHODIMP GetConversionStatus(HIMC hIMC, DWORD *lpfdwConversion, DWORD *lpfdwSentence)
  217. {
  218. return (imm32::ImmGetConversionStatus(hIMC, lpfdwConversion, lpfdwSentence)) ? S_OK
  219. : E_FAIL;
  220. }
  221. STDMETHODIMP SetConversionStatus(HIMC hIMC, DWORD fdwConversion, DWORD fdwSentence)
  222. {
  223. return (imm32::ImmSetConversionStatus(hIMC, fdwConversion, fdwSentence)) ? S_OK
  224. : E_FAIL;
  225. }
  226. /*
  227. * AIMM Status Window Pos API Methods
  228. */
  229. STDMETHODIMP GetStatusWindowPos(HIMC hIMC, POINT *lpptPos)
  230. {
  231. return (imm32::ImmGetStatusWindowPos(hIMC, lpptPos)) ? S_OK
  232. : E_FAIL;
  233. }
  234. STDMETHODIMP SetStatusWindowPos(HIMC hIMC, POINT *lpptPos)
  235. {
  236. return (imm32::ImmSetStatusWindowPos(hIMC, lpptPos)) ? S_OK
  237. : E_FAIL;
  238. }
  239. /*
  240. * AIMM Composition String API Methods
  241. */
  242. STDMETHODIMP GetCompositionStringA(HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LONG *plCopied, LPVOID lpBuf)
  243. {
  244. LONG lRet;
  245. if ((dwIndex & GCS_COMPATTR) && IsGuidMapEnable(hIMC))
  246. {
  247. dwIndex &= ~GCS_COMPATTR;
  248. dwIndex |= GCS_COMPGUIDATTR;
  249. }
  250. lRet = imm32::ImmGetCompositionStringA(hIMC, dwIndex, lpBuf, dwBufLen);
  251. if (lRet < 0)
  252. return E_FAIL;
  253. else {
  254. *plCopied = lRet;
  255. return S_OK;
  256. }
  257. }
  258. STDMETHODIMP GetCompositionStringW(HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LONG *plCopied, LPVOID lpBuf)
  259. {
  260. LONG lRet;
  261. if ((dwIndex & GCS_COMPATTR) && IsGuidMapEnable(hIMC))
  262. {
  263. dwIndex &= ~GCS_COMPATTR;
  264. dwIndex |= GCS_COMPGUIDATTR;
  265. }
  266. lRet = imm32::ImmGetCompositionStringW(hIMC, dwIndex, lpBuf, dwBufLen);
  267. if (lRet < 0)
  268. return E_FAIL;
  269. else {
  270. *plCopied = lRet;
  271. return S_OK;
  272. }
  273. }
  274. STDMETHODIMP SetCompositionStringA(HIMC hIMC, DWORD dwIndex, LPVOID lpComp, DWORD dwCompLen, LPVOID lpRead, DWORD dwReadLen)
  275. {
  276. if (imm32::ImmSetCompositionStringA(hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen))
  277. return S_OK;
  278. else
  279. return E_FAIL;
  280. }
  281. STDMETHODIMP SetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpComp, DWORD dwCompLen, LPVOID lpRead, DWORD dwReadLen)
  282. {
  283. if (imm32::ImmSetCompositionStringW(hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen))
  284. return S_OK;
  285. else
  286. return E_FAIL;
  287. }
  288. /*
  289. * AIMM Composition Font API Methods
  290. */
  291. STDMETHODIMP GetCompositionFontA(HIMC hIMC, LOGFONTA *lplf)
  292. {
  293. if (imm32::ImmGetCompositionFontA(hIMC, lplf))
  294. return S_OK;
  295. else
  296. return E_FAIL;
  297. }
  298. STDMETHODIMP GetCompositionFontW(HIMC hIMC, LOGFONTW *lplf)
  299. {
  300. if (imm32::ImmGetCompositionFontW(hIMC, lplf))
  301. return S_OK;
  302. else
  303. return E_FAIL;
  304. }
  305. STDMETHODIMP SetCompositionFontA(HIMC hIMC, LOGFONTA *lplf)
  306. {
  307. if (imm32::ImmSetCompositionFontA(hIMC, lplf))
  308. return S_OK;
  309. else
  310. return E_FAIL;
  311. }
  312. STDMETHODIMP SetCompositionFontW(HIMC hIMC, LOGFONTW *lplf)
  313. {
  314. if (imm32::ImmSetCompositionFontW(hIMC, lplf))
  315. return S_OK;
  316. else
  317. return E_FAIL;
  318. }
  319. /*
  320. * AIMM Composition Window API Methods
  321. */
  322. STDMETHODIMP GetCompositionWindow(HIMC hIMC, COMPOSITIONFORM *lpCompForm)
  323. {
  324. return (imm32::ImmGetCompositionWindow(hIMC, lpCompForm)) ? S_OK
  325. : E_FAIL;
  326. }
  327. STDMETHODIMP SetCompositionWindow(HIMC hIMC, COMPOSITIONFORM *lpCompForm)
  328. {
  329. return (imm32::ImmSetCompositionWindow(hIMC, lpCompForm)) ? S_OK
  330. : E_FAIL;
  331. }
  332. /*
  333. * AIMM Candidate List API Methods
  334. */
  335. STDMETHODIMP GetCandidateListA(HIMC hIMC, DWORD dwIndex, UINT uBufLen, CANDIDATELIST *lpCandList, UINT *puCopied)
  336. {
  337. DWORD dwRet;
  338. dwRet = imm32::ImmGetCandidateListA(hIMC, dwIndex, lpCandList, uBufLen);
  339. if (dwRet) {
  340. *puCopied = dwRet;
  341. return S_OK;
  342. }
  343. return E_FAIL;
  344. }
  345. STDMETHODIMP GetCandidateListW(HIMC hIMC, DWORD dwIndex, UINT uBufLen, CANDIDATELIST *lpCandList, UINT *puCopied)
  346. {
  347. DWORD dwRet;
  348. dwRet = imm32::ImmGetCandidateListW(hIMC, dwIndex, lpCandList, uBufLen);
  349. if (dwRet) {
  350. *puCopied = dwRet;
  351. return S_OK;
  352. }
  353. return E_FAIL;
  354. }
  355. STDMETHODIMP GetCandidateListCountA(HIMC hIMC, DWORD *lpdwListSize, DWORD *pdwBufLen)
  356. {
  357. DWORD dwRet;
  358. dwRet = imm32::ImmGetCandidateListCountA(hIMC, lpdwListSize);
  359. if (dwRet) {
  360. *pdwBufLen = dwRet;
  361. return S_OK;
  362. }
  363. return E_FAIL;
  364. }
  365. STDMETHODIMP GetCandidateListCountW(HIMC hIMC, DWORD *lpdwListSize, DWORD *pdwBufLen)
  366. {
  367. DWORD dwRet;
  368. dwRet = imm32::ImmGetCandidateListCountW(hIMC, lpdwListSize);
  369. if (dwRet) {
  370. *pdwBufLen = dwRet;
  371. return S_OK;
  372. }
  373. return E_FAIL;
  374. }
  375. /*
  376. * AIMM Candidate Window API Methods
  377. */
  378. STDMETHODIMP GetCandidateWindow(HIMC hIMC, DWORD dwIndex, CANDIDATEFORM *lpCandidate)
  379. {
  380. return (imm32::ImmGetCandidateWindow(hIMC, dwIndex, lpCandidate)) ? S_OK
  381. : E_FAIL;
  382. }
  383. STDMETHODIMP SetCandidateWindow(HIMC hIMC, CANDIDATEFORM *lpCandidate)
  384. {
  385. return (imm32::ImmSetCandidateWindow(hIMC, lpCandidate)) ? S_OK
  386. : E_FAIL;
  387. }
  388. /*
  389. * AIMM Guide Line API Methods
  390. */
  391. STDMETHODIMP GetGuideLineA(HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LPSTR pBuf, DWORD *pdwResult)
  392. {
  393. *pdwResult = imm32::ImmGetGuideLineA(hIMC, dwIndex, pBuf, dwBufLen);
  394. return S_OK;
  395. }
  396. STDMETHODIMP GetGuideLineW(HIMC hIMC, DWORD dwIndex, DWORD dwBufLen, LPWSTR pBuf, DWORD *pdwResult)
  397. {
  398. *pdwResult = imm32::ImmGetGuideLineW(hIMC, dwIndex, pBuf, dwBufLen);
  399. return S_OK;
  400. }
  401. /*
  402. * AIMM Notify IME API Method
  403. */
  404. STDMETHODIMP NotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue)
  405. {
  406. return (imm32::ImmNotifyIME(hIMC, dwAction, dwIndex, dwValue)) ? S_OK
  407. : E_FAIL;
  408. }
  409. /*
  410. * AIMM Menu Items API Methods
  411. */
  412. STDMETHODIMP GetImeMenuItemsA(HIMC hIMC, DWORD dwFlags, DWORD dwType, IMEMENUITEMINFOA *pImeParentMenu, IMEMENUITEMINFOA *pImeMenu, DWORD dwSize, DWORD *pdwResult)
  413. {
  414. *pdwResult = imm32::ImmGetImeMenuItemsA(hIMC, dwFlags, dwType, pImeParentMenu, pImeMenu, dwSize);
  415. return S_OK;
  416. }
  417. STDMETHODIMP GetImeMenuItemsW(HIMC hIMC, DWORD dwFlags, DWORD dwType, IMEMENUITEMINFOW *pImeParentMenu, IMEMENUITEMINFOW *pImeMenu, DWORD dwSize, DWORD *pdwResult)
  418. {
  419. *pdwResult = imm32::ImmGetImeMenuItemsW(hIMC, dwFlags, dwType, pImeParentMenu, pImeMenu, dwSize);
  420. return S_OK;
  421. }
  422. /*
  423. * AIMM Register Word API Methods
  424. */
  425. STDMETHODIMP RegisterWordA(HKL hKL, LPSTR lpszReading, DWORD dwStyle, LPSTR lpszRegister)
  426. {
  427. return imm32::ImmRegisterWordA(hKL, lpszReading, dwStyle, lpszRegister) ? S_OK : E_FAIL;
  428. }
  429. STDMETHODIMP RegisterWordW(HKL hKL, LPWSTR lpszReading, DWORD dwStyle, LPWSTR lpszRegister)
  430. {
  431. return imm32::ImmRegisterWordW(hKL, lpszReading, dwStyle, lpszRegister) ? S_OK : E_FAIL;
  432. }
  433. STDMETHODIMP UnregisterWordA(HKL hKL, LPSTR lpszReading, DWORD dwStyle, LPSTR lpszUnregister)
  434. {
  435. return imm32::ImmUnregisterWordA(hKL, lpszReading, dwStyle, lpszUnregister) ? S_OK : E_FAIL;
  436. }
  437. STDMETHODIMP UnregisterWordW(HKL hKL, LPWSTR lpszReading, DWORD dwStyle, LPWSTR lpszUnregister)
  438. {
  439. return imm32::ImmUnregisterWordW(hKL, lpszReading, dwStyle, lpszUnregister) ? S_OK : E_FAIL;
  440. }
  441. STDMETHODIMP EnumRegisterWordA(HKL hKL, LPSTR szReading, DWORD dwStyle, LPSTR szRegister, LPVOID lpData, IEnumRegisterWordA **pEnum)
  442. {
  443. return E_FAIL;
  444. }
  445. STDMETHODIMP EnumRegisterWordW(HKL hKL, LPWSTR szReading, DWORD dwStyle, LPWSTR szRegister, LPVOID lpData, IEnumRegisterWordW **pEnum)
  446. {
  447. return E_FAIL;
  448. }
  449. STDMETHODIMP GetRegisterWordStyleA(HKL hKL, UINT nItem, STYLEBUFA *lpStyleBuf, UINT *puCopied)
  450. {
  451. *puCopied = imm32::ImmGetRegisterWordStyleA(hKL, nItem, lpStyleBuf);
  452. return S_OK;
  453. }
  454. STDMETHODIMP GetRegisterWordStyleW(HKL hKL, UINT nItem, STYLEBUFW *lpStyleBuf, UINT *puCopied)
  455. {
  456. *puCopied = imm32::ImmGetRegisterWordStyleW(hKL, nItem, lpStyleBuf);
  457. return S_OK;
  458. }
  459. /*
  460. * AIMM Configuration API Methods.
  461. */
  462. STDMETHODIMP ConfigureIMEA(HKL hKL, HWND hWnd, DWORD dwMode, REGISTERWORDA *lpdata)
  463. {
  464. return imm32::ImmConfigureIMEA(hKL, hWnd, dwMode, lpdata) ? S_OK : E_FAIL;
  465. }
  466. STDMETHODIMP ConfigureIMEW(HKL hKL, HWND hWnd, DWORD dwMode, REGISTERWORDW *lpdata)
  467. {
  468. return imm32::ImmConfigureIMEW(hKL, hWnd, dwMode, lpdata) ? S_OK : E_FAIL;
  469. }
  470. STDMETHODIMP GetDescriptionA(HKL hKL, UINT uBufLen, LPSTR lpszDescription, UINT *puCopied)
  471. {
  472. *puCopied = imm32::ImmGetDescriptionA(hKL, lpszDescription, uBufLen);
  473. return *puCopied ? S_OK : E_FAIL;
  474. }
  475. STDMETHODIMP GetDescriptionW(HKL hKL, UINT uBufLen, LPWSTR lpszDescription, UINT *puCopied)
  476. {
  477. *puCopied = imm32::ImmGetDescriptionW(hKL, lpszDescription, uBufLen);
  478. return *puCopied ? S_OK : E_FAIL;
  479. }
  480. STDMETHODIMP GetIMEFileNameA(HKL hKL, UINT uBufLen, LPSTR lpszFileName, UINT *puCopied)
  481. {
  482. *puCopied = imm32::ImmGetIMEFileNameA(hKL, lpszFileName, uBufLen);
  483. return S_OK;
  484. }
  485. STDMETHODIMP GetIMEFileNameW(HKL hKL, UINT uBufLen, LPWSTR lpszFileName, UINT *puCopied)
  486. {
  487. *puCopied = imm32::ImmGetIMEFileNameW(hKL, lpszFileName, uBufLen);
  488. return S_OK;
  489. }
  490. STDMETHODIMP InstallIMEA(LPSTR lpszIMEFileName, LPSTR lpszLayoutText, HKL *phKL)
  491. {
  492. *phKL = imm32::ImmInstallIMEA(lpszIMEFileName, lpszLayoutText);
  493. return S_OK;
  494. }
  495. STDMETHODIMP InstallIMEW(LPWSTR lpszIMEFileName, LPWSTR lpszLayoutText, HKL *phKL)
  496. {
  497. *phKL = imm32::ImmInstallIMEW(lpszIMEFileName, lpszLayoutText);
  498. return S_OK;
  499. }
  500. STDMETHODIMP GetProperty(HKL hKL, DWORD fdwIndex, DWORD *pdwProperty)
  501. {
  502. *pdwProperty = imm32::ImmGetProperty(hKL, fdwIndex);
  503. return S_OK;
  504. }
  505. STDMETHODIMP IsIME(HKL hKL)
  506. {
  507. //
  508. //
  509. //
  510. //
  511. if (!imm32prev::CtfAImmIsIME(hKL))
  512. return S_FALSE;
  513. return imm32::ImmIsIME(hKL) ? S_OK : E_FAIL;
  514. }
  515. // others
  516. STDMETHODIMP EscapeA(HKL hKL, HIMC hIMC, UINT uEscape, LPVOID lpData, LRESULT *plResult)
  517. {
  518. *plResult = imm32::ImmEscapeA(hKL, hIMC, uEscape, lpData);
  519. return S_OK;
  520. }
  521. STDMETHODIMP EscapeW(HKL hKL, HIMC hIMC, UINT uEscape, LPVOID lpData, LRESULT *plResult)
  522. {
  523. *plResult = imm32::ImmEscapeW(hKL, hIMC, uEscape, lpData);
  524. return S_OK;
  525. }
  526. STDMETHODIMP GetConversionListA(HKL hKL, HIMC hIMC, LPSTR lpSrc, UINT uBufLen, UINT uFlag, CANDIDATELIST *lpDst, UINT *puCopied)
  527. {
  528. *puCopied = imm32::ImmGetConversionListA(hKL, hIMC, lpSrc, lpDst, uBufLen, uFlag);
  529. return S_OK;
  530. }
  531. STDMETHODIMP GetConversionListW(HKL hKL, HIMC hIMC, LPWSTR lpSrc, UINT uBufLen, UINT uFlag, CANDIDATELIST *lpDst, UINT *puCopied)
  532. {
  533. *puCopied = imm32::ImmGetConversionListW(hKL, hIMC, lpSrc, lpDst, uBufLen, uFlag);
  534. return S_OK;
  535. }
  536. STDMETHODIMP GetDefaultIMEWnd(HWND hWnd, HWND *phDefWnd)
  537. {
  538. *phDefWnd = imm32::ImmGetDefaultIMEWnd(hWnd);
  539. return S_OK;
  540. }
  541. STDMETHODIMP GetVirtualKey(HWND hWnd, UINT *puVirtualKey)
  542. {
  543. *puVirtualKey = imm32::ImmGetVirtualKey(hWnd);
  544. return S_OK;
  545. }
  546. STDMETHODIMP IsUIMessageA(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
  547. {
  548. return imm32::ImmIsUIMessageA(hWndIME, msg, wParam, lParam) ? S_OK : S_FALSE;
  549. }
  550. STDMETHODIMP IsUIMessageW(HWND hWndIME, UINT msg, WPARAM wParam, LPARAM lParam)
  551. {
  552. return imm32::ImmIsUIMessageW(hWndIME, msg, wParam, lParam) ? S_OK : S_FALSE;
  553. }
  554. // ime helper methods
  555. STDMETHODIMP GenerateMessage(HIMC hIMC)
  556. {
  557. return (imm32::ImmGenerateMessage(hIMC)) ? S_OK
  558. : E_FAIL;
  559. }
  560. // hot key manipulation api's
  561. STDMETHODIMP GetHotKey(DWORD dwHotKeyID, UINT *puModifiers, UINT *puVKey, HKL *phKL)
  562. {
  563. return (imm32::ImmGetHotKey(dwHotKeyID, puModifiers, puVKey, phKL)) ? S_OK
  564. : E_FAIL;
  565. }
  566. STDMETHODIMP SetHotKey(DWORD dwHotKeyID, UINT uModifiers, UINT uVKey, HKL hKL)
  567. {
  568. return (imm32::ImmSetHotKey(dwHotKeyID, uModifiers, uVKey, hKL)) ? S_OK
  569. : E_FAIL;
  570. }
  571. STDMETHODIMP SimulateHotKey(HWND hWnd, DWORD dwHotKeyID)
  572. {
  573. return imm32::ImmSimulateHotKey(hWnd, dwHotKeyID) ? S_OK : S_FALSE;
  574. }
  575. // soft keyboard api's
  576. STDMETHODIMP CreateSoftKeyboard(UINT uType, HWND hOwner, int x, int y, HWND *phSoftKbdWnd);
  577. STDMETHODIMP DestroySoftKeyboard(HWND hSoftKbdWnd);
  578. STDMETHODIMP ShowSoftKeyboard(HWND hSoftKbdWnd, int nCmdShow);
  579. // win98/nt5 apis
  580. STDMETHODIMP DisableIME(DWORD idThread)
  581. {
  582. return imm32::ImmDisableIME(idThread) ? S_OK : E_FAIL;
  583. }
  584. STDMETHODIMP RequestMessageA(HIMC hIMC, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
  585. {
  586. *plResult = imm32::ImmRequestMessageA(hIMC, wParam, lParam);
  587. return S_OK;
  588. }
  589. STDMETHODIMP RequestMessageW(HIMC hIMC, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
  590. {
  591. *plResult = imm32::ImmRequestMessageW(hIMC, wParam, lParam);
  592. return S_OK;
  593. }
  594. STDMETHODIMP EnumInputContext(DWORD idThread, IEnumInputContext **ppEnum)
  595. {
  596. Assert(0);
  597. return E_NOTIMPL;
  598. }
  599. // methods without corresponding IMM APIs
  600. //
  601. // IActiveIMMApp methods
  602. //
  603. STDMETHODIMP Activate(BOOL fRestoreLayout);
  604. STDMETHODIMP Deactivate();
  605. STDMETHODIMP OnDefWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, LRESULT *plResult);
  606. //
  607. // FilterClientWindows
  608. //
  609. STDMETHODIMP FilterClientWindows(ATOM *aaWindowClasses, UINT uSize);
  610. //
  611. //
  612. //
  613. STDMETHODIMP GetCodePageA(HKL hKL, UINT *uCodePage);
  614. STDMETHODIMP GetLangId(HKL hKL, LANGID *plid);
  615. //
  616. // IActiveIMMAppEx
  617. //
  618. STDMETHODIMP FilterClientWindowsEx(HWND hWnd, BOOL fGuidMap);
  619. STDMETHODIMP FilterClientWindowsGUIDMap(ATOM *aaWindowClasses, UINT uSize, BOOL *aaGuidMap);
  620. STDMETHODIMP GetGuidAtom(HIMC hImc, BYTE bAttr, TfGuidAtom *pGuidAtom);
  621. STDMETHODIMP UnfilterClientWindowsEx(HWND hWnd);
  622. //
  623. // IServiceProvider
  624. //
  625. STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void **ppv);
  626. //
  627. // IAImmThreadCompartment,
  628. //
  629. STDMETHODIMP SetThreadCompartmentValue(REFGUID rguid, VARIANT *pvar);
  630. STDMETHODIMP GetThreadCompartmentValue(REFGUID rguid, VARIANT *pvar);
  631. protected:
  632. VOID _EnableGuidMap(BOOL fEnableGuidMap)
  633. {
  634. _fEnableGuidMap = fEnableGuidMap;
  635. }
  636. private:
  637. BOOL IsGuidMapEnable(HIMC hIMC)
  638. {
  639. if (!InitFilterList())
  640. return FALSE;
  641. if (_fEnableGuidMap)
  642. {
  643. BOOL fGuidMap;
  644. if (g_pGuidMapList->_IsGuidMapEnable(hIMC, &fGuidMap))
  645. {
  646. if (fGuidMap)
  647. {
  648. return imm32prev::CtfImmIsGuidMapEnable(hIMC);
  649. }
  650. }
  651. }
  652. return FALSE;
  653. }
  654. private:
  655. BOOL _fEnableGuidMap : 1; // TRUE: Enable GUID Map attribute
  656. HMODULE m_hModCtfIme;
  657. };
  658. //+---------------------------------------------------------------------------
  659. //
  660. // CActiveIMMAppEx
  661. //
  662. //----------------------------------------------------------------------------
  663. class CActiveIMMAppEx : public CComActiveIMMApp,
  664. public CComObjectRoot_CreateInstance_Verify<CActiveIMMAppEx>
  665. {
  666. public:
  667. BEGIN_COM_MAP_IMMX(CActiveIMMAppEx)
  668. COM_INTERFACE_ENTRY_IID(IID_IActiveIMMAppTrident4x, CActiveIMMAppEx)
  669. COM_INTERFACE_ENTRY_IID(IID_IActiveIMMAppPostNT4, CActiveIMMAppEx)
  670. COM_INTERFACE_ENTRY(IActiveIMMApp)
  671. COM_INTERFACE_ENTRY_FUNC(IID_IActiveIMMAppEx, TRUE, CActiveIMMAppEx::EnableGuidMap)
  672. COM_INTERFACE_ENTRY(IActiveIMMMessagePumpOwner)
  673. COM_INTERFACE_ENTRY(IAImmThreadCompartment)
  674. COM_INTERFACE_ENTRY(IServiceProvider)
  675. END_COM_MAP_IMMX()
  676. static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj)
  677. {
  678. if (IsOldAImm())
  679. {
  680. // aimm12 has some whacky CreateIntance rules to support trident
  681. return CActiveIMM_CreateInstance(pUnkOuter, riid, ppvObj);
  682. }
  683. else
  684. {
  685. return CComObjectRoot_CreateInstance_Verify<CActiveIMMAppEx>::CreateInstance(pUnkOuter, riid, ppvObj);
  686. }
  687. }
  688. static void PostCreateInstance(REFIID riid, void *pvObj)
  689. {
  690. imm32prev::CtfImmSetAppCompatFlags(IMECOMPAT_AIMM12);
  691. }
  692. static HRESULT WINAPI EnableGuidMap(void* pv, REFIID riid, LPVOID* ppv, DWORD dw)
  693. {
  694. if (IsEqualIID(riid, IID_IActiveIMMAppEx))
  695. {
  696. CActiveIMMAppEx* _pActiveIMM = (CActiveIMMAppEx*) pv;
  697. *ppv = SAFECAST(_pActiveIMM, IActiveIMMAppEx*);
  698. if (*ppv)
  699. {
  700. _pActiveIMM->AddRef();
  701. _pActiveIMM->_EnableGuidMap((BOOL)dw);
  702. return S_OK;
  703. }
  704. return E_NOINTERFACE;
  705. }
  706. else
  707. {
  708. *ppv = NULL;
  709. return E_NOINTERFACE;
  710. }
  711. }
  712. };
  713. //+---------------------------------------------------------------------------
  714. //
  715. // CActiveIMMAppEx_Trident
  716. //
  717. //----------------------------------------------------------------------------
  718. class CActiveIMMAppEx_Trident : public CComActiveIMMApp,
  719. public CComObjectRoot_CreateInstance_Verify<CActiveIMMAppEx_Trident>
  720. {
  721. public:
  722. BEGIN_COM_MAP_IMMX(CActiveIMMAppEx_Trident)
  723. COM_INTERFACE_ENTRY_IID(IID_IActiveIMMAppTrident4x, CActiveIMMAppEx_Trident)
  724. COM_INTERFACE_ENTRY_IID(IID_IActiveIMMAppPostNT4, CActiveIMMAppEx_Trident)
  725. COM_INTERFACE_ENTRY(IActiveIMMApp)
  726. COM_INTERFACE_ENTRY(IActiveIMMAppEx)
  727. COM_INTERFACE_ENTRY(IActiveIMMMessagePumpOwner)
  728. COM_INTERFACE_ENTRY(IAImmThreadCompartment)
  729. COM_INTERFACE_ENTRY(IServiceProvider)
  730. END_COM_MAP_IMMX()
  731. static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj)
  732. {
  733. if (IsOldAImm())
  734. {
  735. // aimm12 has some whacky CreateIntance rules to support trident
  736. return CActiveIMM_CreateInstance_Trident(pUnkOuter, riid, ppvObj);
  737. }
  738. else
  739. {
  740. return CComObjectRoot_CreateInstance_Verify<CActiveIMMAppEx_Trident>::CreateInstance(pUnkOuter, riid, ppvObj);
  741. }
  742. }
  743. static void PostCreateInstance(REFIID riid, void *pvObj)
  744. {
  745. imm32prev::CtfImmSetAppCompatFlags(IMECOMPAT_AIMM12_TRIDENT);
  746. }
  747. };
  748. #endif // _DIMMEX_H_