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.

3143 lines
78 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // File: immapp.cpp
  4. //
  5. // Contents: IActiveIMM methods with application win32 mappings.
  6. //
  7. //----------------------------------------------------------------------------
  8. #include "private.h"
  9. #include "globals.h"
  10. #include "cdimm.h"
  11. #include "defs.h"
  12. #include "enum.h"
  13. extern HRESULT CAImmProfile_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj);
  14. //+---------------------------------------------------------------------------
  15. //
  16. //
  17. // Input Context Group
  18. //
  19. //
  20. //----------------------------------------------------------------------------
  21. STDAPI
  22. CActiveIMM::CreateContext(
  23. OUT HIMC *phIMC
  24. )
  25. /*++
  26. Method:
  27. IActiveIMMApp::CreateContext
  28. IActiveIMMIME::CreateContext
  29. Routine Description:
  30. Creates a new input context, allocating memory for the context and initializing it.
  31. Arguments:
  32. phIMC - [out] Address of a handle to receive the new input context.
  33. Return Value:
  34. Returns S_OK if successful, or an error code otherwise.
  35. --*/
  36. {
  37. TraceMsg(TF_API, "CActiveIMM::CreateContext");
  38. HRESULT hr;
  39. if (FAILED(hr = _InputContext.CreateContext(_GetIMEProperty(PROP_PRIVATE_DATA_SIZE),
  40. (_GetIMEProperty(PROP_IME_PROPERTY) & IME_PROP_UNICODE) ? TRUE : FALSE,
  41. phIMC, _IsAlreadyActivate())))
  42. {
  43. return hr;
  44. }
  45. if (_IsAlreadyActivate() && !_IsRealIme())
  46. {
  47. _AImeSelect(*phIMC, TRUE);
  48. }
  49. return hr;
  50. }
  51. STDAPI
  52. CActiveIMM::DestroyContext(
  53. IN HIMC hIMC
  54. )
  55. /*++
  56. Method:
  57. IActiveIMMApp::DestroyContext
  58. IActiveIMMIME::DestroyContext
  59. Routine Description:
  60. Releases the input context and frees any memory associated with it.
  61. Arguments:
  62. hIMC - [in] Handle to the input context.
  63. Return Value:
  64. Returns S_OK if successful, or an error code otherwise.
  65. --*/
  66. {
  67. TraceMsg(TF_API, "CActiveIMM::DestroyContext");
  68. if (_IsAlreadyActivate() && !_IsRealIme()) {
  69. _AImeSelect(hIMC, FALSE);
  70. }
  71. return _InputContext.DestroyContext(hIMC);
  72. }
  73. STDAPI
  74. CActiveIMM::AssociateContext(
  75. IN HWND hWnd,
  76. IN HIMC hIMC,
  77. OUT HIMC *phPrev
  78. )
  79. /*++
  80. Method:
  81. IActiveIMMApp::AssociateContext
  82. IActiveIMMIME::AssociateContext
  83. Routine Description:
  84. Associates the specified input context with the specified window.
  85. Arguments:
  86. hWnd - [in] Handle to the window to be associated with the input context.
  87. hIMC - [in] Handle to the input context. If hIMC is NULL, the method removed any
  88. association the window may have had with input context.
  89. phPrev - [out] Address of the handle to the input context previously associated
  90. with the window.
  91. Return Value:
  92. Returns S_OK if successful, or an error code otherwise.
  93. --*/
  94. {
  95. HRESULT hr;
  96. TraceMsg(TF_API, "CActiveIMM::AssociateContext");
  97. hr = _InputContext.AssociateContext(hWnd, hIMC, phPrev);
  98. if (FAILED(hr))
  99. return hr;
  100. if (!_IsRealIme())
  101. {
  102. if (_hFocusWnd == hWnd)
  103. {
  104. _AImeAssociateFocus(hWnd, *phPrev, 0);
  105. _ResetMapWndFocus(hWnd);
  106. _AImeAssociateFocus(hWnd, hIMC, AIMMP_AFF_SETFOCUS);
  107. _SetMapWndFocus(hWnd);
  108. }
  109. }
  110. return IsOnImm() ? Imm32_AssociateContext(hWnd, hIMC, phPrev) : hr;
  111. }
  112. STDAPI
  113. CActiveIMM::AssociateContextEx(
  114. IN HWND hWnd,
  115. IN HIMC hIMC,
  116. IN DWORD dwFlags
  117. )
  118. /*++
  119. Method:
  120. IActiveIMMApp::AssociateContextEx
  121. IActiveIMMIME::AssociateContextEx
  122. Routine Description:
  123. Changes the association between the input method context and the specified window
  124. or its children.
  125. Arguments:
  126. hWnd - [in] Handle to the window to be associated with the input context.
  127. hIMC - [in] Handle to the input context.
  128. dwFlags - [in] Unsigned long integer value that contains the type of association
  129. between the window and the input method context.
  130. Return Value:
  131. Returns S_OK if successful, or an error code otherwise.
  132. --*/
  133. {
  134. HRESULT hr;
  135. HIMC hImcFocusOld;
  136. TraceMsg(TF_API, "CActiveIMM::AssociateContextEx");
  137. hr = _InputContext.AssociateContextEx(hWnd, hIMC, dwFlags);
  138. if (FAILED(hr))
  139. return hr;
  140. if (!_IsRealIme())
  141. {
  142. hr = _InputContext.GetContext(hWnd, &hImcFocusOld);
  143. if (FAILED(hr))
  144. hImcFocusOld = NULL;
  145. hr = _InputContext.AssociateContextEx(hWnd, hIMC, dwFlags);
  146. if (SUCCEEDED(hr))
  147. {
  148. if (_hFocusWnd == hWnd)
  149. {
  150. _AImeAssociateFocus(hWnd, hImcFocusOld, 0);
  151. _ResetMapWndFocus(hWnd);
  152. _AImeAssociateFocus(hWnd, hIMC, AIMMP_AFF_SETFOCUS);
  153. _SetMapWndFocus(hWnd);
  154. }
  155. }
  156. }
  157. if (FAILED(hr))
  158. return hr;
  159. return IsOnImm() ? Imm32_AssociateContextEx(hWnd, hIMC, dwFlags) : hr;
  160. }
  161. STDAPI
  162. CActiveIMM::GetContext(
  163. HWND hWnd,
  164. HIMC *phIMC
  165. )
  166. /*++
  167. Method:
  168. IActiveIMMApp::GetContext
  169. IActiveIMMIME::GetContext
  170. Routine Description:
  171. Retrieves the input context associated with the specified window. An application must
  172. release each context retrieved by calling IActiveIMMApp::ReleaseContext.
  173. Arguments:
  174. hWnd - [in] Handle to the window that is retrieving an input context.
  175. Return Value:
  176. Returns S_OK if successful, or an error code otherwise.
  177. --*/
  178. {
  179. return GetContextInternal(hWnd, phIMC, TRUE);
  180. }
  181. HRESULT
  182. CActiveIMM::GetContextInternal(
  183. HWND hWnd,
  184. HIMC *phIMC,
  185. BOOL fGetDefIMC
  186. )
  187. {
  188. TraceMsg(TF_API, "CActiveIMM::GetContext");
  189. *phIMC = 0;
  190. if (!IsWindow(hWnd))
  191. return E_INVALIDARG;
  192. if (!fGetDefIMC && !IsPresent(hWnd, FALSE) && !_IsRealIme())
  193. return S_FALSE;
  194. return _InputContext.GetContext(hWnd, phIMC);
  195. }
  196. STDAPI
  197. CActiveIMM::ReleaseContext(
  198. IN HWND hWnd,
  199. IN HIMC hIMC
  200. )
  201. /*++
  202. Method:
  203. IActiveIMMApp::ReleaseContext
  204. IActiveIMMIME::ReleaseContext
  205. Routine Description:
  206. Release the input context and unlocks the memory associated in the context.
  207. An application must call this method for each call to the IActiveIMMApp::GetContext
  208. method.
  209. Arguments:
  210. hWnd - [in] Handle to the window for which the input context was previously retrieved.
  211. hIMC - [in] Handle to the input context.
  212. Return Value:
  213. Returns S_OK if successful, or an error code otherwise.
  214. --*/
  215. {
  216. TraceMsg(TF_API, "CActiveIMM::ReleaseContext");
  217. return S_OK;
  218. }
  219. STDAPI
  220. CActiveIMM::GetOpenStatus(
  221. IN HIMC hIMC
  222. )
  223. /*++
  224. Method:
  225. IActiveIMMApp::GetOpenStatus
  226. IActiveIMMIME::GetOpenStatus
  227. Routine Description:
  228. Arguments:
  229. hIMC - [in] Handle to the input context.
  230. Return Value:
  231. Returns a nonzero value if the IME is open, or zero otherwise.
  232. --*/
  233. {
  234. TraceMsg(TF_API, "CActiveIMM::GetOpenStatus");
  235. if (_IsRealIme())
  236. {
  237. return Imm32_GetOpenStatus(hIMC);
  238. }
  239. return _InputContext.GetOpenStatus(hIMC);
  240. }
  241. STDAPI
  242. CActiveIMM::SetOpenStatus(
  243. HIMC hIMC,
  244. BOOL fOpen
  245. )
  246. /*++
  247. Method:
  248. IActiveIMMApp::SetOpenStatus
  249. IActiveIMMIME::SetOpenStatus
  250. Routine Description:
  251. Open or close the IME.
  252. Arguments:
  253. hIMC - [in] Handle to the input context.
  254. fOpen - [in] Boolean value that contains the status. If TRUE, the IMM is opened:
  255. otherwize the IMM is closed.
  256. Return Value:
  257. Returns S_OK if successful, or an error code otherwise.
  258. --*/
  259. {
  260. HRESULT hr;
  261. BOOL fOpenChg;
  262. HWND hWnd;
  263. TraceMsg(TF_API, "CActiveIMM::SetOpenStatus");
  264. if (_IsRealIme())
  265. {
  266. return Imm32_SetOpenStatus(hIMC, fOpen);
  267. }
  268. {
  269. DIMM_IMCLock lpIMC(hIMC);
  270. if (FAILED(hr = lpIMC.GetResult()))
  271. return hr;
  272. hr = _InputContext.SetOpenStatus(lpIMC, fOpen, &fOpenChg);
  273. hWnd = lpIMC->hWnd;
  274. }
  275. /*
  276. * inform IME and Apps Wnd about the conversion mode changes.
  277. */
  278. if (SUCCEEDED(hr) && fOpenChg) {
  279. _SendIMENotify(hIMC, hWnd,
  280. NI_CONTEXTUPDATED, (DWORD)0, IMC_SETOPENSTATUS,
  281. IMN_SETOPENSTATUS, 0L);
  282. /*
  283. * notify shell and keyboard the conversion mode change
  284. */
  285. // NtUserNotifyIMEStatus( hWnd, dwOpenStatus, dwConversion );
  286. }
  287. return hr;
  288. }
  289. STDAPI
  290. CActiveIMM::GetConversionStatus(
  291. IN HIMC hIMC,
  292. OUT DWORD *lpfdwConversion,
  293. OUT DWORD *lpfdwSentence
  294. )
  295. /*++
  296. Method:
  297. IActiveIMMApp::GetConversionStatus
  298. IActiveIMMIME::GetConversionStatus
  299. Routine Description:
  300. Retrieves the current conversion status.
  301. Arguments:
  302. hIMC - [in] Handle to the input context for which to retrieve information.
  303. lpfdwConversion - [out] Address of an unsigned long integer value that receives a
  304. combination of conversion mode.
  305. lpfwSentence - [out] Address of an unsigned long integer value that receives a sentence
  306. mode value.
  307. Return Value:
  308. Returns S_OK if successful, or an error code otherwise.
  309. --*/
  310. {
  311. TraceMsg(TF_API, "CActiveIMM::GetConversionStatus");
  312. if (_IsRealIme())
  313. {
  314. return Imm32_GetConversionStatus(hIMC, lpfdwConversion, lpfdwSentence);
  315. }
  316. return _InputContext.GetConversionStatus(hIMC, lpfdwConversion, lpfdwSentence);
  317. }
  318. STDAPI
  319. CActiveIMM::SetConversionStatus(
  320. IN HIMC hIMC,
  321. IN DWORD fdwConversion,
  322. IN DWORD fdwSentence
  323. )
  324. /*++
  325. Method:
  326. IActiveIMMApp::SetConversionStatus
  327. IActiveIMMIME::SetConversionStatus
  328. Routine Description:
  329. Sets the current conversion status.
  330. Arguments:
  331. hIMC - [in] Handle to the input context.
  332. fdwConversion - [in] Unsigned long value that contains the conversion mode values.
  333. fdwSentence - [in] Unsigned long integer value that contains the sentence mode values.
  334. Return Value:
  335. Returns S_OK if successful, or an error code otherwise.
  336. --*/
  337. {
  338. BOOL fConvModeChg = FALSE;
  339. BOOL fSentenceChg = FALSE;
  340. HWND hWnd;
  341. DWORD fdwOldConversion;
  342. DWORD fdwOldSentence;
  343. HRESULT hr;
  344. TraceMsg(TF_API, "CActiveIMM::SetConversionStatus");
  345. if (_IsRealIme())
  346. {
  347. return Imm32_SetConversionStatus(hIMC, fdwConversion, fdwSentence);
  348. }
  349. DIMM_IMCLock lpIMC(hIMC);
  350. if (FAILED(hr = lpIMC.GetResult()))
  351. return hr;
  352. hr = _InputContext.SetConversionStatus(lpIMC, fdwConversion, fdwSentence,
  353. &fConvModeChg, &fSentenceChg, &fdwOldConversion, &fdwOldSentence);
  354. hWnd = lpIMC->hWnd;
  355. /*
  356. * inform IME and Apps Wnd about the conversion mode changes.
  357. */
  358. if (fConvModeChg) {
  359. _SendIMENotify(hIMC, hWnd,
  360. NI_CONTEXTUPDATED, fdwOldConversion, IMC_SETCONVERSIONMODE,
  361. IMN_SETCONVERSIONMODE, 0L);
  362. /*
  363. * notify shell and keyboard the conversion mode change
  364. */
  365. // NtUserNotifyIMEStatus( hWnd, dwOpenStatus, dwConversion );
  366. }
  367. /*
  368. * inform IME and Apps Wnd about the sentence mode changes.
  369. */
  370. if (fSentenceChg) {
  371. _SendIMENotify(hIMC, hWnd,
  372. NI_CONTEXTUPDATED, fdwOldSentence, IMC_SETSENTENCEMODE,
  373. IMN_SETSENTENCEMODE, 0L);
  374. }
  375. return hr;
  376. }
  377. STDAPI
  378. CActiveIMM::GetStatusWindowPos(
  379. IN HIMC hIMC,
  380. OUT POINT *lpptPos
  381. )
  382. /*++
  383. Method:
  384. IActiveIMMApp::GetStatusWindowPos
  385. IActiveIMMIME::GetStatusWindowPos
  386. Routine Description:
  387. Retrieves the position of the status window.
  388. Arguments:
  389. hIMC - [in] Handle to the input context.
  390. lpptPos - [out] Address of the POINT structure that receives the position coordinates.
  391. These are screen coordinates, relative to the upper-left corner of the screen.
  392. Return Value:
  393. Returns S_OK if successful, or an error code otherwise.
  394. --*/
  395. {
  396. TraceMsg(TF_API, "CActiveIMM::GetStatusWindowPos");
  397. if (_IsRealIme())
  398. {
  399. return Imm32_GetStatusWindowPos(hIMC, lpptPos);
  400. }
  401. return _InputContext.GetStatusWindowPos(hIMC, lpptPos);
  402. }
  403. STDAPI
  404. CActiveIMM::SetStatusWindowPos(
  405. IN HIMC hIMC,
  406. IN POINT *lpptPos
  407. )
  408. /*++
  409. Method:
  410. IActiveIMMApp::SetStatusWindowPos
  411. Routine Description:
  412. Sets the position of the status window.
  413. Arguments:
  414. hIMC - [in] Handle to the input context.
  415. lpptPos - [in] Address of the POINT structure that receives the new position of the status
  416. window.
  417. Return Value:
  418. Returns S_OK if successful, or an error code otherwise.
  419. --*/
  420. {
  421. HRESULT hr;
  422. HWND hWnd;
  423. TraceMsg(TF_API, "CActiveIMM::SetStatusWindowPos");
  424. if (_IsRealIme())
  425. {
  426. return Imm32_SetStatusWindowPos(hIMC, lpptPos);
  427. }
  428. {
  429. DIMM_IMCLock lpIMC(hIMC);
  430. if (FAILED(hr = lpIMC.GetResult()))
  431. return hr;
  432. hr = _InputContext.SetStatusWindowPos(lpIMC, lpptPos);
  433. hWnd = lpIMC->hWnd;
  434. }
  435. /*
  436. * inform IME and Apps Wnd about the change of composition window position.
  437. */
  438. _SendIMENotify(hIMC, hWnd,
  439. NI_CONTEXTUPDATED, 0L, IMC_SETSTATUSWINDOWPOS,
  440. IMN_SETSTATUSWINDOWPOS, 0L);
  441. return hr;
  442. }
  443. STDAPI
  444. CActiveIMM::GetCompositionStringA(
  445. IN HIMC hIMC,
  446. IN DWORD dwIndex,
  447. IN DWORD dwBufLen,
  448. OUT LONG *plCopied,
  449. OUT LPVOID lpBuf
  450. )
  451. /*++
  452. Method:
  453. IActiveIMMApp::GetCompositionStringA
  454. IActiveIMMIME::GetCompositionStringA
  455. Routine Description:
  456. Retrieves information about the composition string. ANSI implementation.
  457. Arguments:
  458. hIMC - [in] Handle to the input context.
  459. dwIndex - [in] Unsigned long integer value that contains the index of the information
  460. to retrieve.
  461. dwBufLen - [in] Unsigned long integer value that contains the size of the buffer, in bytes.
  462. plCopied - [out] Address of long integer value that receives the number of bytes copied to
  463. the buffer. If dwBufLen is zero, plCopied receives the number of bytes
  464. needed to receive all of the requested information.
  465. lpBuf - [out] Address of the buffer to receive the information.
  466. Return Value:
  467. Returns S_OK if successful, or an error code otherwise.
  468. --*/
  469. {
  470. TraceMsg(TF_API, "CActiveIMM::GetCompositionStringA");
  471. //
  472. // Specified hKL since hIMC updated by IME property and it synchronized by ImeSelectHandler().
  473. //
  474. // Especially, GetCompositionString() calls from application when changed keyboard layout.
  475. // In this timing, Cicero's profile already updeted to Cicero's hKL but ImeSelectHandler(FALSE)
  476. // is not yet received in IMM32.
  477. // If IMM32 IME were ASCII style IME, then it hIMC is also ASCII and hIMC's A->W conversion
  478. // occurred by ImeSelectHandler().
  479. // For below ::GetKeyboardLayout() call, When IMM32 IME has been selected, we retreive
  480. // composition string from IMM32 even while changing keyboard layout.
  481. //
  482. if (_IsRealIme(::GetKeyboardLayout(0)))
  483. {
  484. return Imm32_GetCompositionString(hIMC, dwIndex, dwBufLen, plCopied, lpBuf, FALSE);
  485. }
  486. return _GetCompositionString(hIMC, dwIndex, dwBufLen, plCopied, lpBuf, FALSE);
  487. }
  488. STDAPI
  489. CActiveIMM::GetCompositionStringW(
  490. IN HIMC hIMC,
  491. IN DWORD dwIndex,
  492. IN DWORD dwBufLen,
  493. OUT LONG *plCopied,
  494. OUT LPVOID lpBuf
  495. )
  496. /*++
  497. Method:
  498. IActiveIMMApp::GetCompositionStringW
  499. IActiveIMMIME::GetCompositionStringW
  500. Routine Description:
  501. Retrieves information about the composition string. Unicode implementation.
  502. Arguments:
  503. hIMC - [in] Handle to the input context.
  504. dwIndex - [in] Unsigned long integer value that contains the index of the information
  505. to retrieve.
  506. dwBufLen - [in] Unsigned long integer value that contains the size of the buffer, in bytes.
  507. plCopied - [out] Address of long integer value that receives the number of bytes copied to
  508. the buffer. If dwBufLen is zero, plCopied receives the number of bytes
  509. needed to receive all of the requested information.
  510. lpBuf - [out] Address of the buffer to receive the information.
  511. Return Value:
  512. Returns S_OK if successful, or an error code otherwise.
  513. --*/
  514. {
  515. TraceMsg(TF_API, "CActiveIMM::GetCompositionStringW");
  516. //
  517. // Specified hKL since hIMC updated by IME property and it synchronized by ImeSelectHandler().
  518. //
  519. if (_IsRealIme(::GetKeyboardLayout(0)))
  520. {
  521. return Imm32_GetCompositionString(hIMC, dwIndex, dwBufLen, plCopied, lpBuf, TRUE);
  522. }
  523. return _GetCompositionString(hIMC, dwIndex, dwBufLen, plCopied, lpBuf, TRUE);
  524. }
  525. STDAPI
  526. CActiveIMM::SetCompositionStringA(
  527. IN HIMC hIMC,
  528. IN DWORD dwIndex,
  529. IN LPVOID lpComp,
  530. IN DWORD dwCompLen,
  531. IN LPVOID lpRead,
  532. IN DWORD dwReadLen
  533. )
  534. /*++
  535. Method:
  536. IActiveIMMApp::SetCompositionStringA
  537. IActiveIMMIME::SetCompositionStringA
  538. Routine Description:
  539. Sets the characters, attributes, and clauses of the composition and reading strings.
  540. ANSI implementation.
  541. Arguments:
  542. hIMC - [in] Handle to the input context.
  543. dwIndex - [in] Unsigned long integer value that contains the type of information
  544. to set.
  545. lpComp - [in] Address of the buffer containing the information to set for the composition
  546. string. The information is as specified by the dwIndex value.
  547. dwCompLen - [in] Unsigned long integer value that contains the size, in bytes, of the
  548. information buffer for the composition string.
  549. lpRead - [in] Address of the buffer containing the information to set for the reading
  550. string. The information is as specified by the dwIndex value.
  551. dwReadLen - [in] Unsigned long integer value that contains the size, in bytes, of the
  552. information buffer for the reading string.
  553. Return Value:
  554. Returns S_OK if successful, or an error code otherwise.
  555. --*/
  556. {
  557. TraceMsg(TF_FUNC, TEXT("CActiveIMM::SetCompositionStringA"));
  558. //
  559. // Specified hKL since hIMC updated by IME property and it synchronized by ImeSelectHandler().
  560. //
  561. if (_IsRealIme(::GetKeyboardLayout(0)))
  562. {
  563. return Imm32_SetCompositionString(hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen, FALSE);
  564. }
  565. return _SetCompositionString(hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen, FALSE);
  566. }
  567. STDAPI
  568. CActiveIMM::SetCompositionStringW(
  569. IN HIMC hIMC,
  570. IN DWORD dwIndex,
  571. IN LPVOID lpComp,
  572. IN DWORD dwCompLen,
  573. IN LPVOID lpRead,
  574. IN DWORD dwReadLen
  575. )
  576. /*++
  577. Method:
  578. IActiveIMMApp::SetCompositionStringW
  579. IActiveIMMIME::SetCompositionStringW
  580. Routine Description:
  581. Sets the characters, attributes, and clauses of the composition and reading strings.
  582. Unicode implementation.
  583. Arguments:
  584. hIMC - [in] Handle to the input context.
  585. dwIndex - [in] Unsigned long integer value that contains the type of information
  586. to set.
  587. lpComp - [in] Address of the buffer containing the information to set for the composition
  588. string. The information is as specified by the dwIndex value.
  589. dwCompLen - [in] Unsigned long integer value that contains the size, in bytes, of the
  590. information buffer for the composition string.
  591. lpRead - [in] Address of the buffer containing the information to set for the reading
  592. string. The information is as specified by the dwIndex value.
  593. dwReadLen - [in] Unsigned long integer value that contains the size, in bytes, of the
  594. information buffer for the reading string.
  595. Return Value:
  596. Returns S_OK if successful, or an error code otherwise.
  597. --*/
  598. {
  599. //
  600. // Specified hKL since hIMC updated by IME property and it synchronized by ImeSelectHandler().
  601. //
  602. if (_IsRealIme(::GetKeyboardLayout(0)))
  603. {
  604. return Imm32_SetCompositionString(hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen, TRUE);
  605. }
  606. return _SetCompositionString(hIMC, dwIndex, lpComp, dwCompLen, lpRead, dwReadLen, TRUE);
  607. }
  608. STDAPI
  609. CActiveIMM::GetCompositionFontA(
  610. IN HIMC hIMC,
  611. OUT LOGFONTA *lplf
  612. )
  613. /*++
  614. Method:
  615. IActiveIMMApp::GetCompositeFontA
  616. IActiveIMMIME::GetCompositeFontA
  617. Routine Description:
  618. Retrieves information about the logical font currently used to display character
  619. in the composition window. ANSI implementation.
  620. Arguments:
  621. hIMC - [in] Handle to the input context.
  622. lplf - [out] Address of a LOGFONTA structure that receives the fontinformation.
  623. Return Value:
  624. Returns S_OK if successful, or an error code otherwise.
  625. --*/
  626. {
  627. TraceMsg(TF_API, "CActiveIMM::GetCompositionFontA");
  628. //
  629. // Specified hKL since hIMC updated by IME property and it synchronized by ImeSelectHandler().
  630. //
  631. if (_IsRealIme(::GetKeyboardLayout(0)))
  632. {
  633. return Imm32_GetCompositionFont(hIMC, (LOGFONTAW*)lplf, FALSE);
  634. }
  635. return _GetCompositionFont(hIMC, (LOGFONTAW*)lplf, FALSE);
  636. }
  637. STDAPI
  638. CActiveIMM::GetCompositionFontW(
  639. IN HIMC hIMC,
  640. IN LOGFONTW *lplf
  641. )
  642. /*++
  643. Method:
  644. IActiveIMMApp::GetCompositeFontW
  645. IActiveIMMIME::GetCompositeFontW
  646. Routine Description:
  647. Retrieves information about the logical font currently used to display character
  648. in the composition window. Unicode implementation.
  649. Arguments:
  650. hIMC - [in] Handle to the input context.
  651. lplf - [out] Address of a LOGFONTW structure that receives the fontinformation.
  652. Return Value:
  653. Returns S_OK if successful, or an error code otherwise.
  654. --*/
  655. {
  656. TraceMsg(TF_API, "CActiveIMM::GetCompositionFontW");
  657. //
  658. // Specified hKL since hIMC updated by IME property and it synchronized by ImeSelectHandler().
  659. //
  660. if (_IsRealIme(::GetKeyboardLayout(0)))
  661. {
  662. return Imm32_GetCompositionFont(hIMC, (LOGFONTAW*)lplf, TRUE);
  663. }
  664. return _GetCompositionFont(hIMC, (LOGFONTAW*)lplf, TRUE);
  665. }
  666. STDAPI
  667. CActiveIMM::SetCompositionFontA(
  668. IN HIMC hIMC,
  669. IN LOGFONTA *lplf
  670. )
  671. /*++
  672. Method:
  673. IActiveIMMApp::SetCompositionFontA
  674. IActiveIMMIME::SetCompositionFontA
  675. Routine Description:
  676. Sets the logocal font used to display characters in the composition window.
  677. ANSI implementaion.
  678. Arguments:
  679. hIMC - [in] Handle to the input context.
  680. lplf - [in] Address of the LOGFONTA structure containing the font information to set.
  681. Return Value:
  682. Returns S_OK if successful, or an error code otherwise.
  683. --*/
  684. {
  685. TraceMsg(TF_API, "CActiveIMM::SetCompositionFontA");
  686. //
  687. // Specified hKL since hIMC updated by IME property and it synchronized by ImeSelectHandler().
  688. //
  689. if (_IsRealIme(::GetKeyboardLayout(0)))
  690. {
  691. return Imm32_SetCompositionFont(hIMC, (LOGFONTAW*)lplf, FALSE);
  692. }
  693. return _SetCompositionFont(hIMC, (LOGFONTAW*)lplf, FALSE);
  694. }
  695. STDAPI
  696. CActiveIMM::SetCompositionFontW(
  697. IN HIMC hIMC,
  698. IN LOGFONTW *lplf
  699. )
  700. /*++
  701. Method:
  702. IActiveIMMApp::SetCompositionFontW
  703. IActiveIMMIME::SetCompositionFontW
  704. Routine Description:
  705. Sets the logocal font used to display characters in the composition window.
  706. Unicode implementaion.
  707. Arguments:
  708. hIMC - [in] Handle to the input context.
  709. lplf - [in] Address of the LOGFONTW structure containing the font information to set.
  710. Return Value:
  711. Returns S_OK if successful, or an error code otherwise.
  712. --*/
  713. {
  714. TraceMsg(TF_API, "CActiveIMM::SetCompositionFontW");
  715. //
  716. // Specified hKL since hIMC updated by IME property and it synchronized by ImeSelectHandler().
  717. //
  718. if (_IsRealIme(::GetKeyboardLayout(0)))
  719. {
  720. return Imm32_SetCompositionFont(hIMC, (LOGFONTAW*)lplf, TRUE);
  721. }
  722. return _SetCompositionFont(hIMC, (LOGFONTAW*)lplf, TRUE);
  723. }
  724. STDAPI
  725. CActiveIMM::GetCompositionWindow(
  726. IN HIMC hIMC,
  727. OUT COMPOSITIONFORM *lpCompForm
  728. )
  729. /*++
  730. Method:
  731. IActiveIMMApp::GetCompositionWindow
  732. IActiveIMMIME::GetCompositionWindow
  733. Routine Description:
  734. Retrieves information about the composition window.
  735. Arguments:
  736. hIMC - [in] Handle to the input context.
  737. lpCompForm - [out] Address of the COMPOSITIONFORM structure that receives information
  738. about the composition.
  739. Return Value:
  740. Returns S_OK if successful, or an error code otherwise.
  741. --*/
  742. {
  743. TraceMsg(TF_API, "CActiveIMM::GetCompositionWindow");
  744. if (_IsRealIme())
  745. {
  746. return Imm32_GetCompositionWindow(hIMC, lpCompForm);
  747. }
  748. return _InputContext.GetCompositionWindow(hIMC, lpCompForm);
  749. }
  750. STDAPI
  751. CActiveIMM::SetCompositionWindow(
  752. IN HIMC hIMC,
  753. IN COMPOSITIONFORM *lpCompForm
  754. )
  755. /*++
  756. Method:
  757. IActiveIMMApp::SetCompositionWindow
  758. Routine Description:
  759. Sets the position of the composition window.
  760. Arguments:
  761. hIMC - [in] Handle to the input context.
  762. lpCompForm - [in] Address of the COMPOSITIONFORM structure that contains the new position
  763. and other related information about the composition window.
  764. Return Value:
  765. Returns S_OK if successful, or an error code otherwise.
  766. --*/
  767. {
  768. HWND hWnd;
  769. HRESULT hr;
  770. TraceMsg(TF_API, "CActiveIMM::SetCompositionWindow");
  771. if (_IsRealIme())
  772. {
  773. return Imm32_SetCompositionWindow(hIMC, lpCompForm);
  774. }
  775. {
  776. DIMM_IMCLock lpIMC(hIMC);
  777. if (FAILED(hr = lpIMC.GetResult()))
  778. return hr;
  779. hr = _InputContext.SetCompositionWindow(lpIMC, lpCompForm);
  780. hWnd = lpIMC->hWnd;
  781. }
  782. /*
  783. * inform IME and Apps Wnd about the change of composition window.
  784. */
  785. _SendIMENotify(hIMC, hWnd,
  786. NI_CONTEXTUPDATED, 0L, IMC_SETCOMPOSITIONWINDOW,
  787. IMN_SETCOMPOSITIONWINDOW, 0L);
  788. return hr;
  789. }
  790. STDAPI
  791. CActiveIMM::GetCandidateListA(
  792. IN HIMC hIMC,
  793. IN DWORD dwIndex,
  794. IN UINT uBufLen,
  795. OUT CANDIDATELIST *lpCandList,
  796. OUT UINT *puCopied
  797. )
  798. /*++
  799. Method:
  800. IActiveIMMApp::GetCandidateListA
  801. IActiveIMMIME::GetCandidateListA
  802. Routine Description:
  803. Retrieves a specified candidate list, copying the list to the specified buffer.
  804. ANSI implementaion.
  805. Arguments:
  806. hIMC - [in] Handle to the input context.
  807. dwIndex - [in] Unsigned long integer value that contains the zero-based index of
  808. the candidate list.
  809. uBufLen - [in] Unsigned integer value that contains the size of the buffer, in bytes.
  810. If this is zero or if the buffer is insufficient to receive the candidate
  811. list, the method returns the size in bytes required to receive the complete
  812. candidate list to the variable specified by puCopied.
  813. lpCandList - [out] Address of the CANDIDATELIST structure that receives the candidate list.
  814. puCopied - [out] Address of an unsigned integer valiable that receives the number of bytes
  815. copied to the specified buffer if the buffer is sufficient, otherwise it
  816. receives the size in bytes required to receive the complete candidate list.
  817. Return Value:
  818. Returns S_OK if successful, or an error code otherwise.
  819. --*/
  820. {
  821. TraceMsg(TF_API, "CActiveIMM::GetCandidateListA");
  822. if (_IsRealIme())
  823. {
  824. return Imm32_GetCandidateList(hIMC, dwIndex, uBufLen, lpCandList, puCopied, FALSE);
  825. }
  826. return _InputContext.GetCandidateList(hIMC, dwIndex, uBufLen, lpCandList, puCopied, FALSE);
  827. }
  828. STDAPI
  829. CActiveIMM::GetCandidateListW(
  830. IN HIMC hIMC,
  831. IN DWORD dwIndex,
  832. IN UINT uBufLen,
  833. OUT CANDIDATELIST *lpCandList,
  834. OUT UINT *puCopied
  835. )
  836. /*++
  837. Method:
  838. IActiveIMMApp::GetCandidateListW
  839. IActiveIMMIME::GetCandidateListW
  840. Routine Description:
  841. Retrieves a specified candidate list, copying the list to the specified buffer.
  842. Unicode implementaion.
  843. Arguments:
  844. hIMC - [in] Handle to the input context.
  845. dwIndex - [in] Unsigned long integer value that contains the zero-based index of
  846. the candidate list.
  847. uBufLen - [in] Unsigned integer value that contains the size of the buffer, in bytes.
  848. If this is zero or if the buffer is insufficient to receive the candidate
  849. list, the method returns the size in bytes required to receive the complete
  850. candidate list to the variable specified by puCopied.
  851. lpCandList - [out] Address of the CANDIDATELIST structure that receives the candidate list.
  852. puCopied - [out] Address of an unsigned integer valiable that receives the number of bytes
  853. copied to the specified buffer if the buffer is sufficient, otherwise it
  854. receives the size in bytes required to receive the complete candidate list.
  855. Return Value:
  856. Returns S_OK if successful, or an error code otherwise.
  857. --*/
  858. {
  859. TraceMsg(TF_API, "CActiveIMM::GetCandidateListW");
  860. if (_IsRealIme())
  861. {
  862. return Imm32_GetCandidateList(hIMC, dwIndex, uBufLen, lpCandList, puCopied, TRUE);
  863. }
  864. return _InputContext.GetCandidateList(hIMC, dwIndex, uBufLen, lpCandList, puCopied, TRUE);
  865. }
  866. STDAPI
  867. CActiveIMM::GetCandidateListCountA(
  868. IN HIMC hIMC,
  869. OUT DWORD *lpdwListSize,
  870. OUT DWORD *pdwBufLen
  871. )
  872. /*++
  873. Method:
  874. IActiveIMMApp::GetCandidateListCountA
  875. IActiveIMMIME::GetCandidateListCountA
  876. Routine Description:
  877. Retrieves the size, in bytes, of the candidate list. ANSI inplementaion.
  878. Arguments:
  879. hIMC - [in] Handle to the input context.
  880. lpdwListSize - [out] Address of an unsigned long integer value that receives the size of
  881. the candidate list.
  882. pdwBufLen - [out] Address of an unsigned long integer value that contains the number of
  883. bytes required to receive all candidate lists.
  884. Return Value:
  885. Returns S_OK if successful, or an error code otherwise.
  886. --*/
  887. {
  888. TraceMsg(TF_API, "CActiveIMM::GetCandidateListCountA");
  889. if (_IsRealIme())
  890. {
  891. return Imm32_GetCandidateListCount(hIMC, lpdwListSize, pdwBufLen, FALSE);
  892. }
  893. return _InputContext.GetCandidateListCount(hIMC, lpdwListSize, pdwBufLen, FALSE);
  894. }
  895. STDAPI
  896. CActiveIMM::GetCandidateListCountW(
  897. IN HIMC hIMC,
  898. OUT DWORD *lpdwListSize,
  899. OUT DWORD *pdwBufLen
  900. )
  901. /*++
  902. Method:
  903. IActiveIMMApp::GetCandidateListCountW
  904. IActiveIMMIME::GetCandidateListCountW
  905. Routine Description:
  906. Retrieves the size, in bytes, of the candidate list. Unicode inplementaion.
  907. Arguments:
  908. hIMC - [in] Handle to the input context.
  909. lpdwListSize - [out] Address of an unsigned long integer value that receives the size of
  910. the candidate list.
  911. pdwBufLen - [out] Address of an unsigned long integer value that contains the number of
  912. bytes required to receive all candidate lists.
  913. Return Value:
  914. Returns S_OK if successful, or an error code otherwise.
  915. --*/
  916. {
  917. TraceMsg(TF_API, "CActiveIMM::GetCandidateListCountW");
  918. if (_IsRealIme())
  919. {
  920. return Imm32_GetCandidateListCount(hIMC, lpdwListSize, pdwBufLen, TRUE);
  921. }
  922. return _InputContext.GetCandidateListCount(hIMC, lpdwListSize, pdwBufLen, TRUE);
  923. }
  924. STDAPI
  925. CActiveIMM::GetCandidateWindow(
  926. IN HIMC hIMC,
  927. IN DWORD dwIndex,
  928. OUT CANDIDATEFORM *lpCandidate
  929. )
  930. /*++
  931. Method:
  932. IActiveIMMApp::GetCandidateWindow
  933. IActiveIMMIME::GetCandidateWindow
  934. Routine Description:
  935. Retrieves information about the candidate list window.
  936. Arguments:
  937. hIMC - [in] Handle to the input context.
  938. dwIndex - [in] Unsigned long integer value that contains the size, in byte, of the buffer.
  939. lpCandidate - [out] Address of a CANDIDATEFORM structire that receives information about
  940. the candidate window.
  941. Return Value:
  942. Returns S_OK if successful, or an error code otherwise.
  943. --*/
  944. {
  945. TraceMsg(TF_API, "CActiveIMM::GetCandidateWindow");
  946. if (_IsRealIme())
  947. {
  948. return Imm32_GetCandidateWindow(hIMC, dwIndex, lpCandidate);
  949. }
  950. return _InputContext.GetCandidateWindow(hIMC, dwIndex, lpCandidate);
  951. }
  952. STDAPI
  953. CActiveIMM::SetCandidateWindow(
  954. IN HIMC hIMC,
  955. IN CANDIDATEFORM *lpCandForm
  956. )
  957. /*++
  958. Method:
  959. IActiveIMMApp::SetCandidateWindow
  960. IActiveIMMIME::SetCandidateWindow
  961. Routine Description:
  962. Sets information about the candidate list window.
  963. Arguments:
  964. hIMC - [in] Handle to the input context.
  965. lpCandForm - [in] Address of the CANDIDATEFORM structure that contains information about
  966. the candidate window.
  967. Return Value:
  968. Returns S_OK if successful, or an error code otherwise.
  969. --*/
  970. {
  971. HWND hWnd;
  972. HRESULT hr;
  973. TraceMsg(TF_API, "CActiveIMM::SetCandidateWindow");
  974. if (lpCandForm->dwIndex >= 4) // over flow candidate index
  975. return E_INVALIDARG;
  976. if (_IsRealIme())
  977. {
  978. return Imm32_SetCandidateWindow(hIMC, lpCandForm);
  979. }
  980. {
  981. DIMM_IMCLock lpIMC(hIMC);
  982. if (FAILED(hr = lpIMC.GetResult()))
  983. return hr;
  984. hr = _InputContext.SetCandidateWindow(lpIMC, lpCandForm);
  985. hWnd = lpIMC->hWnd;
  986. }
  987. /*
  988. * inform IME and Apps Wnd about the change of composition window.
  989. */
  990. _SendIMENotify(hIMC, hWnd,
  991. NI_CONTEXTUPDATED, 0L, IMC_SETCANDIDATEPOS,
  992. IMN_SETCANDIDATEPOS, (LPARAM)(0x01 << lpCandForm->dwIndex));
  993. return hr;
  994. }
  995. STDAPI
  996. CActiveIMM::GetGuideLineA(
  997. IN HIMC hIMC,
  998. IN DWORD dwIndex,
  999. IN DWORD dwBufLen,
  1000. OUT LPSTR pBuf,
  1001. OUT DWORD *pdwResult
  1002. )
  1003. /*++
  1004. Method:
  1005. IActiveIMMApp::GetGuideLineA
  1006. IActiveIMMIME::GetGuideLineA
  1007. Routine Description:
  1008. Retrieves information about errors. Applications use this information to notify users.
  1009. ANSI implementation.
  1010. Arguments:
  1011. hIMC - [in] Handle to the input context.
  1012. dwIndex - [in] Unsigned long integer value that contains the guideline information to
  1013. retrieve.
  1014. dwBufLen - [in] Unsigned long integer value that contains the size, in bytes, of the
  1015. buffer referenced by pBuf.
  1016. pBuf - [out] Address of a string value that receives the error message string.
  1017. pdwResult - [out] Address of an unsigned long integer value that receives the error level,
  1018. error index, or size of an error message string, depending on the value
  1019. of dwIndex. If dwBufLen is set to zero, pdwResult receives the buffer size,
  1020. in bytes, needed to receive the requested information.
  1021. Return Value:
  1022. Returns S_OK if successful, or an error code otherwise.
  1023. --*/
  1024. {
  1025. TraceMsg(TF_API, "CActiveIMM::GetGuideLineA");
  1026. if (_IsRealIme())
  1027. {
  1028. return Imm32_GetGuideLine(hIMC, dwIndex, dwBufLen, (CHARAW *)pBuf, pdwResult, FALSE);
  1029. }
  1030. return _InputContext.GetGuideLine(hIMC, dwIndex, dwBufLen, (CHARAW *)pBuf, pdwResult, FALSE);
  1031. }
  1032. STDAPI
  1033. CActiveIMM::GetGuideLineW(
  1034. IN HIMC hIMC,
  1035. IN DWORD dwIndex,
  1036. IN DWORD dwBufLen,
  1037. OUT LPWSTR pBuf,
  1038. OUT DWORD *pdwResult
  1039. )
  1040. /*++
  1041. Method:
  1042. IActiveIMMApp::GetGuideLineW
  1043. IActiveIMMIME::GetGuideLineW
  1044. Routine Description:
  1045. Retrieves information about errors. Applications use this information to notify users.
  1046. Unicode implementation.
  1047. Arguments:
  1048. hIMC - [in] Handle to the input context.
  1049. dwIndex - [in] Unsigned long integer value that contains the guideline information to
  1050. retrieve.
  1051. dwBufLen - [in] Unsigned long integer value that contains the size, in bytes, of the
  1052. buffer referenced by pBuf.
  1053. pBuf - [out] Address of a string value that receives the error message string.
  1054. pdwResult - [out] Address of an unsigned long integer value that receives the error level,
  1055. error index, or size of an error message string, depending on the value
  1056. of dwIndex. If dwBufLen is set to zero, pdwResult receives the buffer size,
  1057. in bytes, needed to receive the requested information.
  1058. Return Value:
  1059. Returns S_OK if successful, or an error code otherwise.
  1060. --*/
  1061. {
  1062. TraceMsg(TF_API, "CActiveIMM::GetGuideLineW");
  1063. if (_IsRealIme())
  1064. {
  1065. return Imm32_GetGuideLine(hIMC, dwIndex, dwBufLen, (CHARAW *)pBuf, pdwResult, TRUE);
  1066. }
  1067. return _InputContext.GetGuideLine(hIMC, dwIndex, dwBufLen, (CHARAW *)pBuf, pdwResult, TRUE);
  1068. }
  1069. STDAPI
  1070. CActiveIMM::NotifyIME(
  1071. IN HIMC hIMC,
  1072. IN DWORD dwAction,
  1073. IN DWORD dwIndex,
  1074. IN DWORD dwValue
  1075. )
  1076. /*++
  1077. Method:
  1078. IActiveIMMApp::NotifyIME
  1079. Routine Description:
  1080. Notifies the IME about changes to the status of the input context.
  1081. Arguments:
  1082. hIMC - [in] Handle to the input context.
  1083. dwAction - [in] Unsigined long integer value that contains the notification code.
  1084. dwIndex - [in] Unsigned long integer value that contains the index of a candidate list or,
  1085. if dwAction is set to NI_COMPOSITIONSTR, one of the following values:
  1086. CPS_CANCEL: Clear the composition string and set the status to no composition
  1087. string.
  1088. CPS_COMPLETE: Set the composition string as the result string.
  1089. CPS_CONVERT: Convert the composition string.
  1090. CPS_REVERT: Cancel the current composition string and revert to the unconverted
  1091. string.
  1092. dwValue - [in] Unsigned long integer value that contains the index of a candidate string or
  1093. is not used, depending on the value of the dwAction parameter.
  1094. Return Value:
  1095. Returns S_OK if successful, or an error code otherwise.
  1096. --*/
  1097. {
  1098. TraceMsg(TF_API, "CActiveIMM::NotifyIME");
  1099. return (!_IsRealIme()) ? _AImeNotifyIME(hIMC, dwAction, dwIndex, dwValue) :
  1100. Imm32_NotifyIME(hIMC, dwAction, dwIndex, dwValue);
  1101. }
  1102. STDAPI
  1103. CActiveIMM::GetImeMenuItemsA(
  1104. IN HIMC hIMC,
  1105. IN DWORD dwFlags,
  1106. IN DWORD dwType,
  1107. IN IMEMENUITEMINFOA *pImeParentMenu,
  1108. OUT IMEMENUITEMINFOA *pImeMenu,
  1109. IN DWORD dwSize,
  1110. OUT DWORD *pdwResult
  1111. )
  1112. /*++
  1113. Method:
  1114. IActiveIMMApp::GetImeMenuItemsA
  1115. IActiveIMMIME::GetImeMenuItemsA
  1116. Routine Description:
  1117. Retrieves the menu items that are registerd in the IME menu.
  1118. ANSI implementation.
  1119. Arguments:
  1120. hIMC - [in] Handle to the input context.
  1121. dwFlags - [in] Unsigned long integer value that contains the menu infomation flags.
  1122. dwType - [in] Unsigned long integer value that contains the type of menu returned by this
  1123. method.
  1124. pImeParentMenu - [in] Address of an IMEMENUITEMINFOA structure that has the fType member
  1125. set to MFT_SUBMENU to return informaion about the submenu items
  1126. of this parent menu, If this parameter is NULL, the function returns
  1127. only top-level menu items.
  1128. pImeMenu - [out] Address of an array of IMEMENUITEMINFOA structure to reveive the
  1129. contents of the memu items.
  1130. dwSize - [in] Unsigned long integer value that contains the size of the buffer to receive
  1131. the structures.
  1132. pdwResult - [out] Address of an unsigned long integer value that receives the number of
  1133. menu items copied into pImeMenu. If pImeMenu is null, the function returns
  1134. the number of registered menu items.
  1135. Return Value:
  1136. Returns S_OK if successful, or an error code otherwise.
  1137. --*/
  1138. {
  1139. TraceMsg(TF_API, "CActiveIMM::GetImeMenuItemsA");
  1140. if (_IsRealIme())
  1141. {
  1142. return Imm32_GetImeMenuItems(hIMC, dwFlags, dwType, (IMEMENUITEMINFOAW *)pImeParentMenu, (IMEMENUITEMINFOAW *)pImeMenu, dwSize, pdwResult, FALSE);
  1143. }
  1144. return _InputContext.GetImeMenuItems(hIMC, dwFlags, dwType, (IMEMENUITEMINFOAW *)pImeParentMenu, (IMEMENUITEMINFOAW *)pImeMenu, dwSize, pdwResult, FALSE);
  1145. }
  1146. STDAPI
  1147. CActiveIMM::GetImeMenuItemsW(
  1148. HIMC hIMC,
  1149. DWORD dwFlags,
  1150. DWORD dwType,
  1151. IMEMENUITEMINFOW *pImeParentMenu,
  1152. IMEMENUITEMINFOW *pImeMenu,
  1153. DWORD dwSize,
  1154. DWORD *pdwResult
  1155. )
  1156. /*++
  1157. Method:
  1158. IActiveIMMApp::GetImeMenuItemsW
  1159. IActiveIMMIME::GetImeMenuItemsW
  1160. Routine Description:
  1161. Retrieves the menu items that are registerd in the IME menu.
  1162. Unicode implementation.
  1163. Arguments:
  1164. hIMC - [in] Handle to the input context.
  1165. dwFlags - [in] Unsigned long integer value that contains the menu infomation flags.
  1166. dwType - [in] Unsigned long integer value that contains the type of menu returned by this
  1167. method.
  1168. pImeParentMenu - [in] Address of an IMEMENUITEMINFOW structure that has the fType member
  1169. set to MFT_SUBMENU to return informaion about the submenu items
  1170. of this parent menu, If this parameter is NULL, the function returns
  1171. only top-level menu items.
  1172. pImeMenu - [out] Address of an array of IMEMENUITEMINFOW structure to reveive the
  1173. controls of the memu items.
  1174. dwSize - [in] Unsigned long integer value that contains the size of the buffer to receive
  1175. the structures.
  1176. pdwResult - [out] Address of an unsigned long integer value that receives the number of
  1177. menu items copied into pImeMenu. If pImeMenu is null, the function returns
  1178. the number of registered menu items.
  1179. Return Value:
  1180. Returns S_OK if successful, or an error code otherwise.
  1181. --*/
  1182. {
  1183. TraceMsg(TF_API, "CActiveIMM::GetImeMenuItemsW");
  1184. if (_IsRealIme())
  1185. {
  1186. return Imm32_GetImeMenuItems(hIMC, dwFlags, dwType, (IMEMENUITEMINFOAW *)pImeParentMenu, (IMEMENUITEMINFOAW *)pImeMenu, dwSize, pdwResult, TRUE);
  1187. }
  1188. return _InputContext.GetImeMenuItems(hIMC, dwFlags, dwType, (IMEMENUITEMINFOAW *)pImeParentMenu, (IMEMENUITEMINFOAW *)pImeMenu, dwSize, pdwResult, TRUE);
  1189. }
  1190. STDAPI
  1191. CActiveIMM::EnumInputContext(
  1192. DWORD idThread,
  1193. IEnumInputContext **ppEnum
  1194. )
  1195. /*++
  1196. Method:
  1197. IActiveIMMApp::EnumInputContext
  1198. IActiveIMMIME::EnumInputContext
  1199. Routine Description:
  1200. Enumerates the input contexts on a thread.
  1201. Arguments:
  1202. idThread - [in] Unsigned long integer value that specifies the thread.
  1203. ppEnum - [out] Address of a pointer to the IEnumInputContext interface of the enumeration
  1204. object.
  1205. Return Value:
  1206. Returns S_OK if successful, or an error code otherwise.
  1207. --*/
  1208. {
  1209. TraceMsg(TF_API, "CActiveIMM::EnumInputContext");
  1210. CContextList _hIMC_List;
  1211. CEnumInputContext* pEnumInputContext = NULL;
  1212. _InputContext.EnumInputContext(idThread, _EnumContextProc, (LPARAM)&_hIMC_List);
  1213. if ((pEnumInputContext = new CEnumInputContext(_hIMC_List)) == NULL) {
  1214. return E_OUTOFMEMORY;
  1215. }
  1216. *ppEnum = pEnumInputContext;
  1217. return S_OK;
  1218. }
  1219. //+---------------------------------------------------------------------------
  1220. //
  1221. //
  1222. // Window Handle Group
  1223. //
  1224. //
  1225. //----------------------------------------------------------------------------
  1226. STDAPI
  1227. CActiveIMM::GetDefaultIMEWnd(
  1228. IN HWND hWnd,
  1229. OUT HWND *phDefWnd
  1230. )
  1231. /*++
  1232. Method:
  1233. IActiveIMMApp::GetDefaultIMEWnd
  1234. IActiveIMMIME::GetDefaultIMEWnd
  1235. Routine Description:
  1236. Retrieves the default window handle to the IME class.
  1237. Arguments:
  1238. hWnd - [in] Handle to the window for the application.
  1239. phDefWnd - [out] Address of the default window handle to the IME class.
  1240. Return Value:
  1241. Returns S_OK if successful, or an error code otherwise.
  1242. --*/
  1243. {
  1244. TraceMsg(TF_API, "CActiveIMM::GetDefaultIMEWnd");
  1245. if (_IsRealIme())
  1246. {
  1247. return Imm32_GetDefaultIMEWnd(hWnd, phDefWnd);
  1248. }
  1249. return _DefaultIMEWindow.GetDefaultIMEWnd(hWnd, phDefWnd);
  1250. }
  1251. STDAPI
  1252. CActiveIMM::GetVirtualKey(
  1253. HWND hWnd,
  1254. UINT *puVirtualKey
  1255. )
  1256. /*++
  1257. Method:
  1258. IActiveIMMApp::GetVirtualKey
  1259. IActiveIMMIME::GetVirtualKey
  1260. Routine Description:
  1261. Recovers the original virtual-key value associated with a key input message that has already
  1262. been processed by the IME.
  1263. Arguments:
  1264. hWnd - [in] Handle to the window that receives the key message.
  1265. puVirtualKey - [out] Address of an unsigned integer value that receives the original
  1266. virtual-key value.
  1267. Return Value:
  1268. Returns S_OK if successful, or an error code otherwise.
  1269. --*/
  1270. {
  1271. TraceMsg(TF_API, "CActiveIMM::GetVirtualKey");
  1272. if (_IsRealIme())
  1273. {
  1274. return Imm32_GetVirtualKey(hWnd, puVirtualKey);
  1275. }
  1276. return E_FAIL;
  1277. }
  1278. STDAPI
  1279. CActiveIMM::IsUIMessageA(
  1280. HWND hWndIME,
  1281. UINT msg,
  1282. WPARAM wParam,
  1283. LPARAM lParam
  1284. )
  1285. /*++
  1286. Method:
  1287. IActiveIMMApp::IsUIMessageA
  1288. IActiveIMMIME::IsUIMessageA
  1289. Routine Description:
  1290. Checks for messages intended for the IME window and sends those messages to the specified
  1291. window. ANSI implementation.
  1292. Arguments:
  1293. hWndIME - [in] Handle to a window belonging to the IME window class.
  1294. msg - [in] Unsigned integer value that contains the message to be checked.
  1295. wParam - [in] Message-specific parameter.
  1296. lParam - [in] Message-specific parameter.
  1297. Return Value:
  1298. Returns S_OK if successful, or an error code otherwise.
  1299. --*/
  1300. {
  1301. TraceMsg(TF_API, "CActiveIMM::IsUIMessageA");
  1302. if (_IsRealIme())
  1303. {
  1304. return Imm32_IsUIMessageA(hWndIME, msg, wParam, lParam);
  1305. }
  1306. return E_FAIL;
  1307. }
  1308. STDAPI
  1309. CActiveIMM::IsUIMessageW(
  1310. HWND hWndIME,
  1311. UINT msg,
  1312. WPARAM wParam,
  1313. LPARAM lParam
  1314. )
  1315. /*++
  1316. Method:
  1317. IActiveIMMApp::IsUIMessageW
  1318. IActiveIMMIME::IsUIMessageW
  1319. Routine Description:
  1320. Checks for messages intended for the IME window and sends those messages to the specified
  1321. window. Unicode implementation.
  1322. Arguments:
  1323. hWndIME - [in] Handle to a window belonging to the IME window class.
  1324. msg - [in] Unsigned integer value that contains the message to be checked.
  1325. wParam - [in] Message-specific parameter.
  1326. lParam - [in] Message-specific parameter.
  1327. Return Value:
  1328. Returns S_OK if successful, or an error code otherwise.
  1329. --*/
  1330. {
  1331. TraceMsg(TF_API, "CActiveIMM::IsUIMessageW");
  1332. if (_IsRealIme())
  1333. {
  1334. return Imm32_IsUIMessageW(hWndIME, msg, wParam, lParam);
  1335. }
  1336. return E_FAIL;
  1337. }
  1338. STDAPI
  1339. CActiveIMM::SimulateHotKey(
  1340. HWND hWnd,
  1341. DWORD dwHotKeyID
  1342. )
  1343. /*++
  1344. Method:
  1345. IActiveIMMApp::SimulateHotKey
  1346. IActiveIMMIME::SimulateHotKey
  1347. Routine Description:
  1348. Simulates the specified IME hot key, causing the same response as if the user had pressed the
  1349. hot key in the specified window.
  1350. Arguments:
  1351. hWnd - [in] Handle to the window.
  1352. dwHotKeyID - [in] Unsigned long integer value that contains the identifier for the IME hot key.
  1353. Return Value:
  1354. Returns S_OK if successful, or an error code otherwise.
  1355. --*/
  1356. {
  1357. TraceMsg(TF_API, "CActiveIMM::SimulateHotKey");
  1358. if (_IsRealIme())
  1359. {
  1360. return Imm32_SimulateHotKey(hWnd, dwHotKeyID);
  1361. }
  1362. return E_FAIL;
  1363. }
  1364. //+---------------------------------------------------------------------------
  1365. //
  1366. //
  1367. // Keyboard Layout Group
  1368. //
  1369. //
  1370. //----------------------------------------------------------------------------
  1371. STDAPI
  1372. CActiveIMM::EnumRegisterWordA(
  1373. HKL hKL,
  1374. LPSTR szReading,
  1375. DWORD dwStyle,
  1376. LPSTR szRegister,
  1377. LPVOID lpData,
  1378. IEnumRegisterWordA **pEnum
  1379. )
  1380. /*++
  1381. Method:
  1382. IActiveIMMApp::EnumRegisterWordA
  1383. IActiveIMMIME::EnumRegisterWordA
  1384. Routine Description:
  1385. Creates an enumeration object that will enumerate the register strings having the specified
  1386. reading string, style, and register string. ANSI implementation.
  1387. Arguments:
  1388. hKL - [in] Handle to the keyboard layout.
  1389. szReading - [in] Address of a string value that contains the reading string to be enumerated.
  1390. If NULL, this method enumerates all available reading strings that match
  1391. with the values specified by dwStyle and szRegister.
  1392. dwStyle - [in] Unsigned long integer value that contains the style to be enumerated. If set
  1393. to zero, this method enumerates all available styles that match with the
  1394. values specified by szReading and szRegister.
  1395. szRegister - [in] Address of a string value that contains the register string to enumerate.
  1396. If NULL, this method enumerates all register strings that match with the
  1397. values specified by szReading and dwStyle.
  1398. lpData - [in] Address of a buffer containing data supplied by the application.
  1399. pEnum - [out] Address of a pointer to the IEnumRegisterWordA interface of the enumeration
  1400. object.
  1401. Return Value:
  1402. Returns S_OK if successful, or an error code otherwise.
  1403. --*/
  1404. {
  1405. TraceMsg(TF_API, "CActiveIMM::EnumRegisterWordA");
  1406. if (_IsRealIme())
  1407. {
  1408. return Imm32_EnumRegisterWordA(hKL, szReading, dwStyle, szRegister, lpData, pEnum);
  1409. }
  1410. return E_NOTIMPL;
  1411. }
  1412. STDAPI
  1413. CActiveIMM::EnumRegisterWordW(
  1414. HKL hKL,
  1415. LPWSTR szReading,
  1416. DWORD dwStyle,
  1417. LPWSTR szRegister,
  1418. LPVOID lpData,
  1419. IEnumRegisterWordW **pEnum
  1420. )
  1421. /*++
  1422. Method:
  1423. IActiveIMMApp::EnumRegisterWordW
  1424. IActiveIMMIME::EnumRegisterWordW
  1425. Routine Description:
  1426. Creates an enumeration object that will enumerate the register strings having the specified
  1427. reading string, style, and register string. Unicode implementation.
  1428. Arguments:
  1429. hKL - [in] Handle to the keyboard layout.
  1430. szReading - [in] Address of a string value that contains the reading string to be enumerated.
  1431. If NULL, this method enumerates all available reading strings that match
  1432. with the values specified by dwStyle and szRegister.
  1433. dwStyle - [in] Unsigned long integer value that contains the style to be enumerated. If set
  1434. to zero, this method enumerates all available styles that match with the
  1435. values specified by szReading and szRegister.
  1436. szRegister - [in] Address of a string value that contains the register string to enumerate.
  1437. If NULL, this method enumerates all register strings that match with the
  1438. values specified by szReading and dwStyle.
  1439. lpData - [in] Address of a buffer containing data supplied by the application.
  1440. pEnum - [out] Address of a pointer to the IEnumRegisterWordW interface of the enumeration
  1441. object.
  1442. Return Value:
  1443. Returns S_OK if successful, or an error code otherwise.
  1444. --*/
  1445. {
  1446. TraceMsg(TF_API, "CActiveIMM::EnumRegisterWordW");
  1447. if (_IsRealIme())
  1448. {
  1449. return Imm32_EnumRegisterWordW(hKL, szReading, dwStyle, szRegister, lpData, pEnum);
  1450. }
  1451. return E_NOTIMPL;
  1452. }
  1453. STDAPI
  1454. CActiveIMM::GetRegisterWordStyleA(
  1455. HKL hKL,
  1456. UINT nItem,
  1457. STYLEBUFA *lpStyleBuf,
  1458. UINT *puCopied
  1459. )
  1460. /*++
  1461. Method:
  1462. IActiveIMMApp::GetRegisterWordStyleA
  1463. IActiveIMMIME::GetRegisterWordStyleA
  1464. Routine Description:
  1465. Retrieves a list of the styles supported by the IME associated with the specified keyboard
  1466. layout. ANSI implementaion.
  1467. Arguments:
  1468. hKL - [in] Handle to the keyboard layout.
  1469. nItem - [in] Unsigned integer value that contains the maximum number of styles that the buffer
  1470. can hold.
  1471. lpStyleBuf - [out] Address of a STYLEBUFA structure that receives the style information.
  1472. puCopied - [out] Address of an unsigned integer value that receives the number of layout
  1473. handles copied to the buffer, or if nItem is zero, receives the buffer size
  1474. in array elements needed to receive all available style information.
  1475. Return Value:
  1476. Returns S_OK if successful, or an error code otherwise.
  1477. --*/
  1478. {
  1479. TraceMsg(TF_API, "CActiveIMM::GetRegisterWordStyleA");
  1480. if (_IsRealIme())
  1481. {
  1482. return Imm32_GetRegisterWordStyleA(hKL, nItem, lpStyleBuf, puCopied);
  1483. }
  1484. return E_NOTIMPL;
  1485. }
  1486. STDAPI
  1487. CActiveIMM::GetRegisterWordStyleW(
  1488. HKL hKL,
  1489. UINT nItem,
  1490. STYLEBUFW *lpStyleBuf,
  1491. UINT *puCopied
  1492. )
  1493. /*++
  1494. Method:
  1495. IActiveIMMApp::GetRegisterWordStyleW
  1496. IActiveIMMIME::GetRegisterWordStyleW
  1497. Routine Description:
  1498. Retrieves a list of the styles supported by the IME associated with the specified keyboard
  1499. layout. Unicode implementaion.
  1500. Arguments:
  1501. hKL - [in] Handle to the keyboard layout.
  1502. nItem - [in] Unsigned integer value that contains the maximum number of styles that the buffer
  1503. can hold.
  1504. lpStyleBuf - [out] Address of a STYLEBUFW structure that receives the style information.
  1505. puCopied - [out] Address of an unsigned integer value that receives the number of layout
  1506. handles copied to the buffer, or if nItem is zero, receives the buffer size
  1507. in array elements needed to receive all available style information.
  1508. Return Value:
  1509. Returns S_OK if successful, or an error code otherwise.
  1510. --*/
  1511. {
  1512. TraceMsg(TF_API, "CActiveIMM::GetRegisterWordStyleW");
  1513. if (_IsRealIme())
  1514. {
  1515. return Imm32_GetRegisterWordStyleW(hKL, nItem, lpStyleBuf, puCopied);
  1516. }
  1517. return E_NOTIMPL;
  1518. }
  1519. STDAPI
  1520. CActiveIMM::RegisterWordA(
  1521. HKL hKL,
  1522. LPSTR lpszReading,
  1523. DWORD dwStyle,
  1524. LPSTR lpszRegister
  1525. )
  1526. /*++
  1527. Method:
  1528. IActiveIMMApp::RegisterWordA
  1529. IActiveIMMIME::RegisterWordA
  1530. Routine Description:
  1531. Registers a string into the dictionary of the IME associated with the specified keyboard
  1532. layout. ANSI implementation.
  1533. Arguments:
  1534. hKL - [in] Handle to the keyboard layout.
  1535. lpszReading - [in] Address of a string value that contains a null-terminated string specifying
  1536. the reading string associated with the string to register.
  1537. dwStyle - [in] Unsigned long integer value that contains the style of the register string.
  1538. lpszRegister - [in] Address of a string value that contains a null-terminated string specifying
  1539. the string to register.
  1540. Return Value:
  1541. Returns S_OK if successful, or an error code otherwise.
  1542. --*/
  1543. {
  1544. TraceMsg(TF_API, "CActiveIMM::RegisterWordA");
  1545. if (_IsRealIme())
  1546. {
  1547. return Imm32_RegisterWordA(hKL, lpszReading, dwStyle, lpszRegister);
  1548. }
  1549. return E_NOTIMPL;
  1550. }
  1551. STDAPI
  1552. CActiveIMM::RegisterWordW(
  1553. HKL hKL,
  1554. LPWSTR lpszReading,
  1555. DWORD dwStyle,
  1556. LPWSTR lpszRegister
  1557. )
  1558. /*++
  1559. Method:
  1560. IActiveIMMApp::RegisterWordW
  1561. IActiveIMMIME::RegisterWordW
  1562. Routine Description:
  1563. Registers a string into the dictionary of the IME associated with the specified keyboard
  1564. layout. Unicode implementation.
  1565. Arguments:
  1566. hKL - [in] Handle to the keyboard layout.
  1567. lpszReading - [in] Address of a string value that contains a null-terminated string specifying
  1568. the reading string associated with the string to register.
  1569. dwStyle - [in] Unsigned long integer value that contains the style of the register string.
  1570. lpszRegister - [in] Address of a string value that contains a null-terminated string specifying
  1571. the string to register.
  1572. Return Value:
  1573. Returns S_OK if successful, or an error code otherwise.
  1574. --*/
  1575. {
  1576. TraceMsg(TF_API, "CActiveIMM::RegisterWordW");
  1577. if (_IsRealIme())
  1578. {
  1579. return Imm32_RegisterWordW(hKL, lpszReading, dwStyle, lpszRegister);
  1580. }
  1581. return E_NOTIMPL;
  1582. }
  1583. STDAPI
  1584. CActiveIMM::UnregisterWordA(
  1585. HKL hKL,
  1586. LPSTR lpszReading,
  1587. DWORD dwStyle,
  1588. LPSTR lpszUnregister
  1589. )
  1590. /*++
  1591. Method:
  1592. IActiveIMMApp::UnregisterWordA
  1593. IActiveIMMIME::UnregisterWordA
  1594. Routine Description:
  1595. Removes a register string from the dictionary of the IME associated with the specified
  1596. keyboard layout. ANSI implementaion.
  1597. Arguments:
  1598. hKL - [in] Handle to the keyboard layout.
  1599. lpszReading - [in] Address of a string value that contains a null-terminated string specifying
  1600. the reading string associated with the string to remove.
  1601. dwStyle - [in] Unsigned long integer value that contains the style of the register string.
  1602. lpszUnregister - [in] Address of a string value that contains a null-terminated string
  1603. specifying the register string to remove.
  1604. Return Value:
  1605. Returns S_OK if successful, or an error code otherwise.
  1606. --*/
  1607. {
  1608. TraceMsg(TF_API, "CActiveIMM::UnregisterWordA");
  1609. if (_IsRealIme())
  1610. {
  1611. return Imm32_UnregisterWordA(hKL, lpszReading, dwStyle, lpszUnregister);
  1612. }
  1613. return E_NOTIMPL;
  1614. }
  1615. STDAPI
  1616. CActiveIMM::UnregisterWordW(
  1617. HKL hKL,
  1618. LPWSTR lpszReading,
  1619. DWORD dwStyle,
  1620. LPWSTR lpszUnregister
  1621. )
  1622. /*++
  1623. Method:
  1624. IActiveIMMApp::UnregisterWordW
  1625. IActiveIMMIME::UnregisterWordW
  1626. Routine Description:
  1627. Removes a register string from the dictionary of the IME associated with the specified
  1628. keyboard layout. Unicode implementaion.
  1629. Arguments:
  1630. hKL - [in] Handle to the keyboard layout.
  1631. lpszReading - [in] Address of a string value that contains a null-terminated string specifying
  1632. the reading string associated with the string to remove.
  1633. dwStyle - [in] Unsigned long integer value that contains the style of the register string.
  1634. lpszUnregister - [in] Address of a string value that contains a null-terminated string
  1635. specifying the register string to remove.
  1636. Return Value:
  1637. Returns S_OK if successful, or an error code otherwise.
  1638. --*/
  1639. {
  1640. TraceMsg(TF_API, "CActiveIMM::UnregisterWordW");
  1641. if (_IsRealIme())
  1642. {
  1643. return Imm32_UnregisterWordW(hKL, lpszReading, dwStyle, lpszUnregister);
  1644. }
  1645. return E_NOTIMPL;
  1646. }
  1647. STDAPI
  1648. CActiveIMM::ConfigureIMEA(
  1649. HKL hKL,
  1650. HWND hWnd,
  1651. DWORD dwMode,
  1652. REGISTERWORDA *lpdata
  1653. )
  1654. /*++
  1655. Method:
  1656. IActiveIMMApp::ConfigureIMEA
  1657. IActiveIMMIME::ConfigureIMEA
  1658. Routine Description:
  1659. Displays the configuration dialog box for the IME. ANSI implementation.
  1660. Arguments:
  1661. hKL - [in] Handle to the keyboard layout.
  1662. hWnd - [in] Handle to the parent window for the dialog box.
  1663. dwMode - [in] Unsigned long integer value that contains the type of dialog box to display.
  1664. This can be one of the following values:
  1665. IME_CONFIG_GENERAL: Displays the general purpose configuration dialog box.
  1666. IME_CONFIG_REGISTERWORD: Displays the register word dialog box.
  1667. IME_CONFIG_SELECTDICTIONARY: Displays the dictionary selection dialog box.
  1668. lpdata - [in] Address of a REGISTERWORDA structure. This structure will be used if dwMode is
  1669. set to IME_CONFIG_REGISTERWORD. Otherwise this parameter is ignored.
  1670. Return Value:
  1671. Returns S_OK if successful, or an error code otherwise.
  1672. --*/
  1673. {
  1674. TraceMsg(TF_API, "CActiveIMM::ConfigureIMEA");
  1675. if (_IsRealIme())
  1676. {
  1677. return Imm32_ConfigureIMEA(hKL, hWnd, dwMode, lpdata);
  1678. }
  1679. else
  1680. {
  1681. HRESULT hr;
  1682. IAImeProfile* pAImeProfile;
  1683. hr = CAImmProfile_CreateInstance(NULL, IID_IAImeProfile, (void**)&pAImeProfile);
  1684. if (FAILED(hr)) {
  1685. TraceMsg(TF_ERROR, "CreateInstance(ConfigureIMEA) failed");
  1686. return hr;
  1687. }
  1688. hr = _ConfigureIMEA(hKL, hWnd, dwMode, lpdata);
  1689. pAImeProfile->Release();
  1690. return hr;
  1691. }
  1692. }
  1693. STDAPI
  1694. CActiveIMM::ConfigureIMEW(
  1695. HKL hKL,
  1696. HWND hWnd,
  1697. DWORD dwMode,
  1698. REGISTERWORDW *lpdata
  1699. )
  1700. /*++
  1701. Method:
  1702. IActiveIMMApp::ConfigureIMEW
  1703. IActiveIMMIME::ConfigureIMEW
  1704. Routine Description:
  1705. Displays the configuration dialog box for the IME. Unicode implementation.
  1706. Arguments:
  1707. hKL - [in] Handle to the keyboard layout.
  1708. hWnd - [in] Handle to the parent window for the dialog box.
  1709. dwMode - [in] Unsigned long integer value that contains the type of dialog box to display.
  1710. This can be one of the following values:
  1711. IME_CONFIG_GENERAL: Displays the general purpose configuration dialog box.
  1712. IME_CONFIG_REGISTERWORD: Displays the register word dialog box.
  1713. IME_CONFIG_SELECTDICTIONARY: Displays the dictionary selection dialog box.
  1714. lpdata - [in] Address of a REGISTERWORDW structure. This structure will be used if dwMode is
  1715. set to IME_CONFIG_REGISTERWORD. Otherwise this parameter is ignored.
  1716. Return Value:
  1717. Returns S_OK if successful, or an error code otherwise.
  1718. --*/
  1719. {
  1720. TraceMsg(TF_API, "CActiveIMM::ConfigureIMEW");
  1721. if (_IsRealIme())
  1722. {
  1723. return Imm32_ConfigureIMEW(hKL, hWnd, dwMode, lpdata);
  1724. }
  1725. else
  1726. {
  1727. HRESULT hr;
  1728. IAImeProfile* pAImeProfile;
  1729. hr = CAImmProfile_CreateInstance(NULL, IID_IAImeProfile, (void**)&pAImeProfile);
  1730. if (FAILED(hr)) {
  1731. TraceMsg(TF_ERROR, "CreateInstance(ConfigureIMEW) failed");
  1732. return hr;
  1733. }
  1734. hr = _ConfigureIMEW(hKL, hWnd, dwMode, lpdata);
  1735. pAImeProfile->Release();
  1736. return hr;
  1737. }
  1738. }
  1739. STDAPI
  1740. CActiveIMM::EscapeA(
  1741. HKL hKL,
  1742. HIMC hIMC,
  1743. UINT uEscape,
  1744. LPVOID lpData,
  1745. LRESULT *plResult
  1746. )
  1747. /*++
  1748. Method:
  1749. IActiveIMMApp::EscapeA
  1750. IActiveIMMIME::EscapeA
  1751. Routine Description:
  1752. Executes IME-specific subfunctions and is used mainly for country-specific function.
  1753. ANSI implementaion.
  1754. Arguments:
  1755. hKL - [in] Handle to the keyboard layout.
  1756. hIMC - [in] Handle to the input context.
  1757. uEscape - [in] Unsigned integer that contains the index of the subfunction.
  1758. lpData - [in, out] Address of a buffer containing subfunction-specific data.
  1759. plResult - [out] Address of the LRESULT variable that received the escape-specific value
  1760. returned by the operation.
  1761. Return Value:
  1762. Returns S_OK if successful, or an error code otherwise.
  1763. --*/
  1764. {
  1765. TraceMsg(TF_API, "CActiveIMM::EscapeA");
  1766. if (_IsRealIme())
  1767. {
  1768. return Imm32_Escape(hKL, hIMC, uEscape, lpData, plResult, FALSE);
  1769. }
  1770. else
  1771. {
  1772. HRESULT hr;
  1773. IAImeProfile* pAImeProfile;
  1774. hr = CAImmProfile_CreateInstance(NULL, IID_IAImeProfile, (void**)&pAImeProfile);
  1775. if (FAILED(hr)) {
  1776. TraceMsg(TF_ERROR, "CreateInstance(EscapeA) failed");
  1777. return hr;
  1778. }
  1779. if (SUCCEEDED(hr=pAImeProfile->ChangeCurrentKeyboardLayout(hKL)))
  1780. {
  1781. hr = _Escape(hKL, hIMC, uEscape, lpData, plResult, FALSE);
  1782. }
  1783. pAImeProfile->Release();
  1784. return hr;
  1785. }
  1786. }
  1787. STDAPI
  1788. CActiveIMM::EscapeW(
  1789. HKL hKL,
  1790. HIMC hIMC,
  1791. UINT uEscape,
  1792. LPVOID lpData,
  1793. LRESULT *plResult
  1794. )
  1795. /*++
  1796. Method:
  1797. IActiveIMMApp::EscapeW
  1798. IActiveIMMIME::EscapeW
  1799. Routine Description:
  1800. Executes IME-specific subfunctions and is used mainly for country-specific function.
  1801. Unicode implementaion.
  1802. Arguments:
  1803. hKL - [in] Handle to the keyboard layout.
  1804. hIMC - [in] Handle to the input context.
  1805. uEscape - [in] Unsigned integer that contains the index of the subfunction.
  1806. lpData - [in, out] Address of a buffer containing subfunction-specific data.
  1807. plResult - [out] Address of the LRESULT variable that received the escape-specific value
  1808. returned by the operation.
  1809. Return Value:
  1810. Returns S_OK if successful, or an error code otherwise.
  1811. --*/
  1812. {
  1813. TraceMsg(TF_API, "CActiveIMM::EscapeW");
  1814. if (_IsRealIme())
  1815. {
  1816. return Imm32_Escape(hKL, hIMC, uEscape, lpData, plResult, TRUE);
  1817. }
  1818. else
  1819. {
  1820. HRESULT hr;
  1821. IAImeProfile* pAImeProfile;
  1822. hr = CAImmProfile_CreateInstance(NULL, IID_IAImeProfile, (void**)&pAImeProfile);
  1823. if (FAILED(hr)) {
  1824. TraceMsg(TF_ERROR, "CreateInstance(EscapeW) failed");
  1825. return hr;
  1826. }
  1827. if (SUCCEEDED(hr=pAImeProfile->ChangeCurrentKeyboardLayout(hKL)))
  1828. {
  1829. hr = _Escape(hKL, hIMC, uEscape, lpData, plResult, TRUE);
  1830. }
  1831. pAImeProfile->Release();
  1832. return hr;
  1833. }
  1834. }
  1835. STDAPI
  1836. CActiveIMM::GetConversionListA(
  1837. HKL hKL,
  1838. HIMC hIMC,
  1839. LPSTR lpSrc,
  1840. UINT uBufLen,
  1841. UINT uFlag,
  1842. CANDIDATELIST *lpDst,
  1843. UINT *puCopied
  1844. )
  1845. /*++
  1846. Method:
  1847. IActiveIMMApp::GetConversionListA
  1848. IActiveIMMIME::GetConversionListA
  1849. Routine Description:
  1850. Retrieves the list of characters or words from one character or word. ANSI implementation.
  1851. Arguments:
  1852. hKL - [in] Handle to the keyboard layout.
  1853. hIMC - [in] Handle to the input context.
  1854. lpSrc - [in] Address of a string value containing a null-terminated character string.
  1855. uBufLen - [in] Unsigned integer value that contains the size of the destination buffer,
  1856. in bytes.
  1857. uFlag - [in] Unsigned integer value that contains action flags.
  1858. lpDst - [out] Address of the CANDIDATELIST structure that receives the conversion result.
  1859. puCopied - [out] Address of an unsigned integer value that receives the number of bytes
  1860. copied to the specified buffer. If uBufLen is zero, puCopied receives the
  1861. number of bytes needed to receive the list.
  1862. Return Value:
  1863. Returns S_OK if successful, or an error code otherwise.
  1864. --*/
  1865. {
  1866. TraceMsg(TF_API, "CActiveIMM::GetConversionListA");
  1867. if (_IsRealIme())
  1868. {
  1869. return Imm32_GetConversionListA(hKL, hIMC, lpSrc, uBufLen, uFlag, lpDst, puCopied);
  1870. }
  1871. return E_NOTIMPL;
  1872. }
  1873. STDAPI
  1874. CActiveIMM::GetConversionListW(
  1875. HKL hKL,
  1876. HIMC hIMC,
  1877. LPWSTR lpSrc,
  1878. UINT uBufLen,
  1879. UINT uFlag,
  1880. CANDIDATELIST *lpDst,
  1881. UINT *puCopied
  1882. )
  1883. /*++
  1884. Method:
  1885. IActiveIMMApp::GetConversionListW
  1886. IActiveIMMIME::GetConversionListW
  1887. Routine Description:
  1888. Retrieves the list of characters or words from one character or word. Unicode implementation.
  1889. Arguments:
  1890. hKL - [in] Handle to the keyboard layout.
  1891. hIMC - [in] Handle to the input context.
  1892. lpSrc - [in] Address of a string value containing a null-terminated character string.
  1893. uBufLen - [in] Unsigned integer value that contains the size of the destination buffer,
  1894. in bytes.
  1895. uFlag - [in] Unsigned integer value that contains action flags.
  1896. lpDst - [out] Address of the CANDIDATELIST structure that receives the conversion result.
  1897. puCopied - [out] Address of an unsigned integer value that receives the number of bytes
  1898. copied to the specified buffer. If uBufLen is zero, puCopied receives the
  1899. number of bytes needed to receive the list.
  1900. Return Value:
  1901. Returns S_OK if successful, or an error code otherwise.
  1902. --*/
  1903. {
  1904. TraceMsg(TF_API, "CActiveIMM::GetConversionListW");
  1905. if (_IsRealIme())
  1906. {
  1907. return Imm32_GetConversionListW(hKL, hIMC, lpSrc, uBufLen, uFlag, lpDst, puCopied);
  1908. }
  1909. return E_NOTIMPL;
  1910. }
  1911. STDAPI
  1912. CActiveIMM::GetDescriptionA(
  1913. HKL hKL,
  1914. UINT uBufLen,
  1915. LPSTR lpszDescription,
  1916. UINT *puCopied
  1917. )
  1918. /*++
  1919. Method:
  1920. IActiveIMMApp::GetDescriptionA
  1921. IActiveIMMIME::GetDescriptionA
  1922. Routine Description:
  1923. Copies the description of the IME to the specified buffer (ANSI implementation).
  1924. Arguments:
  1925. hKL - [in] Handle to the keyboard layout.
  1926. uBufLen - [in] Unsigned long integer value that contains the size of the buffer in characters.
  1927. lpszDescription - [out] Address of a string buffer that receives the null-terminated string
  1928. describing the IME.
  1929. puCopied - [out] Address of an unsigned long integer that receives the number of characters
  1930. copied to the buffer. If uBufLen is zero, puCopied receives the buffer size,
  1931. in characters, needed to receive the description.
  1932. Return Value:
  1933. Returns S_OK if successful, or an error code otherwise.
  1934. --*/
  1935. {
  1936. TraceMsg(TF_API, "CActiveIMM::GetDescriptionA");
  1937. if (_IsRealIme())
  1938. {
  1939. return Imm32_GetDescriptionA(hKL, uBufLen, lpszDescription, puCopied);
  1940. }
  1941. return E_NOTIMPL;
  1942. }
  1943. STDAPI
  1944. CActiveIMM::GetDescriptionW(
  1945. HKL hKL,
  1946. UINT uBufLen,
  1947. LPWSTR lpszDescription,
  1948. UINT *puCopied
  1949. )
  1950. /*++
  1951. Method:
  1952. IActiveIMMApp::GetDescriptionW
  1953. IActiveIMMIME::GetDescriptionW
  1954. Routine Description:
  1955. Copies the description of the IME to the specified buffer (Unicode implementation).
  1956. Arguments:
  1957. hKL - [in] Handle to the keyboard layout.
  1958. uBufLen - [in] Unsigned long integer value that contains the size of the buffer in characters.
  1959. lpszDescription - [out] Address of a string buffer that receives the null-terminated string
  1960. describing the IME.
  1961. puCopied - [out] Address of an unsigned long integer that receives the number of characters
  1962. copied to the buffer. If uBufLen is zero, puCopied receives the buffer size,
  1963. in characters, needed to receive the description.
  1964. Return Value:
  1965. Returns S_OK if successful, or an error code otherwise.
  1966. --*/
  1967. {
  1968. TraceMsg(TF_API, "CActiveIMM::GetDescriptionW");
  1969. if (_IsRealIme())
  1970. {
  1971. return Imm32_GetDescriptionW(hKL, uBufLen, lpszDescription, puCopied);
  1972. }
  1973. return E_NOTIMPL;
  1974. }
  1975. STDAPI
  1976. CActiveIMM::GetIMEFileNameA(
  1977. HKL hKL,
  1978. UINT uBufLen,
  1979. LPSTR lpszFileName,
  1980. UINT *puCopied
  1981. )
  1982. /*++
  1983. Method:
  1984. IActiveIMMApp::GetIMEFileNameA
  1985. IActiveIMMIME::GetIMEFileNameA
  1986. Routine Description:
  1987. Retrieves the file name of the IME associated with the specified keyboard layout
  1988. (ANSI implementation).
  1989. Arguments:
  1990. hKL - [in] Handle to the keyboard layout.
  1991. uBufLen - [in] Unsigned integer value that contains the size, in bytes, of the buffer.
  1992. lpszFileName - [out] Address of a string buffer that receives the file name.
  1993. puCopied - [out] Address of an unsigned integer that receives the number of bytes
  1994. copied to the buffer. If uBufLen is zero, puCopied receives the buffer size,
  1995. in bytes, required to receive the file name.
  1996. Return Value:
  1997. Returns S_OK if successful, or an error code otherwise.
  1998. --*/
  1999. {
  2000. TraceMsg(TF_API, "CActiveIMM::GetIMEFileNameA");
  2001. if (_IsRealIme())
  2002. {
  2003. return Imm32_GetIMEFileNameA(hKL, uBufLen, lpszFileName, puCopied);
  2004. }
  2005. return E_NOTIMPL;
  2006. }
  2007. STDAPI
  2008. CActiveIMM::GetIMEFileNameW(
  2009. HKL hKL,
  2010. UINT uBufLen,
  2011. LPWSTR lpszFileName,
  2012. UINT *puCopied
  2013. )
  2014. /*++
  2015. Method:
  2016. IActiveIMMApp::GetIMEFileNameW
  2017. IActiveIMMIME::GetIMEFileNameW
  2018. Routine Description:
  2019. Retrieves the file name of the IME associated with the specified keyboard layout
  2020. (Unicode implementation).
  2021. Arguments:
  2022. hKL - [in] Handle to the keyboard layout.
  2023. uBufLen - [in] Unsigned integer value that contains the size, in bytes, of the buffer.
  2024. lpszFileName - [out] Address of a string buffer that receives the file name.
  2025. puCopied - [out] Address of an unsigned integer that receives the number of bytes
  2026. copied to the buffer. If uBufLen is zero, puCopied receives the buffer size,
  2027. in bytes, required to receive the file name.
  2028. Return Value:
  2029. Returns S_OK if successful, or an error code otherwise.
  2030. --*/
  2031. {
  2032. TraceMsg(TF_API, "CActiveIMM::GetIMEFileNameW");
  2033. if (_IsRealIme())
  2034. {
  2035. return Imm32_GetIMEFileNameW(hKL, uBufLen, lpszFileName, puCopied);
  2036. }
  2037. return E_NOTIMPL;
  2038. }
  2039. STDAPI
  2040. CActiveIMM::GetProperty(
  2041. IN HKL hKL,
  2042. IN DWORD dwIndex,
  2043. OUT DWORD *pdwProperty
  2044. )
  2045. /*++
  2046. Method:
  2047. IActiveIMMApp::GetProperty
  2048. IActiveIMMIME::GetProperty
  2049. Routine Description:
  2050. Retrieves the property and capabilities of the IME associated with specified
  2051. keyboard layout.
  2052. Arguments:
  2053. hKL - [in] Handle of the keyboard layout.
  2054. dwIndex - [in] Unsigned long integer value that contains the type of property
  2055. information to retrieve.
  2056. pdwProperty - [out] Address of an unsigned long integer value that receives the
  2057. property or capability value, depending on the value of the
  2058. dwIndex parameter.
  2059. Return Value:
  2060. Returns S_OK if successful, or an error code otherwise.
  2061. --*/
  2062. {
  2063. TraceMsg(TF_API, "CActiveIMM::GetProperty");
  2064. if (_IsRealIme(hKL))
  2065. {
  2066. return Imm32_GetProperty(hKL, dwIndex, pdwProperty);
  2067. }
  2068. if (dwIndex != IGP_GETIMEVERSION &&
  2069. ( (dwIndex & 3) || dwIndex > IGP_LAST))
  2070. {
  2071. // bad fdwIndex
  2072. return E_FAIL;
  2073. }
  2074. if (dwIndex == IGP_GETIMEVERSION) {
  2075. *pdwProperty = IMEVER_0400;
  2076. return S_OK;
  2077. }
  2078. // Inquire IME's information and UI class name.
  2079. if (_pActiveIME)
  2080. _pActiveIME->Inquire(FALSE, &_IMEInfoEx.ImeInfo, _IMEInfoEx.achWndClass, &_IMEInfoEx.dwPrivate);
  2081. *pdwProperty = *(DWORD *)((BYTE *)&_IMEInfoEx.ImeInfo + dwIndex);
  2082. return S_OK;
  2083. }
  2084. STDAPI
  2085. CActiveIMM::InstallIMEA(
  2086. LPSTR lpszIMEFileName,
  2087. LPSTR lpszLayoutText,
  2088. HKL *phKL
  2089. )
  2090. /*++
  2091. Method:
  2092. IActiveIMMApp::InstallIMEA
  2093. IActiveIMMIME::InstallIMEA
  2094. Routine Description:
  2095. Installs an IME into the system. ANSI implementaion.
  2096. Arguments:
  2097. lpszIMEFileName - [in] Address of a null-terminated string value that specifies the full path
  2098. of the IME.
  2099. lpszLayoutText - [in] Address of a null-terminated string value that specifies the name of the
  2100. IME. This name also specifies the layout text of the IME.
  2101. phKL - [out] Address of the handle to the keyboard layout for the IME.
  2102. Return Value:
  2103. Returns S_OK if successful, or an error code otherwise.
  2104. --*/
  2105. {
  2106. TraceMsg(TF_API, "CActiveIMM::InstallIMEA");
  2107. if (_IsRealIme())
  2108. {
  2109. return Imm32_InstallIMEA(lpszIMEFileName, lpszLayoutText, phKL);
  2110. }
  2111. return E_NOTIMPL;
  2112. }
  2113. STDAPI
  2114. CActiveIMM::InstallIMEW(
  2115. LPWSTR lpszIMEFileName,
  2116. LPWSTR lpszLayoutText,
  2117. HKL *phKL
  2118. )
  2119. /*++
  2120. Method:
  2121. IActiveIMMApp::InstallIMEW
  2122. IActiveIMMIME::InstallIMEW
  2123. Routine Description:
  2124. Installs an IME into the system. Unicode implementaion.
  2125. Arguments:
  2126. lpszIMEFileName - [in] Address of a null-terminated string value that specifies the full path
  2127. of the IME.
  2128. lpszLayoutText - [in] Address of a null-terminated string value that specifies the name of the
  2129. IME. This name also specifies the layout text of the IME.
  2130. phKL - [out] Address of the handle to the keyboard layout for the IME.
  2131. Return Value:
  2132. Returns S_OK if successful, or an error code otherwise.
  2133. --*/
  2134. {
  2135. TraceMsg(TF_API, "CActiveIMM::InstallIMEW");
  2136. if (_IsRealIme())
  2137. {
  2138. return Imm32_InstallIMEW(lpszIMEFileName, lpszLayoutText, phKL);
  2139. }
  2140. return E_NOTIMPL;
  2141. }
  2142. STDAPI
  2143. CActiveIMM::IsIME(
  2144. HKL hKL
  2145. )
  2146. /*++
  2147. Method:
  2148. IActiveIMMApp::IsIME
  2149. IActiveIMMIME::IsIME
  2150. Routine Description:
  2151. Checks whether the specified handle identifies an IME.
  2152. Arguments:
  2153. hKL - [in] Handle to the keyboard layout to check.
  2154. Return Value:
  2155. Returns a S_OK value if the handle identifies an IME, or S_FALSE otherwise.
  2156. --*/
  2157. {
  2158. TraceMsg(TF_API, "CActiveIMM::IsIME");
  2159. if (_IsRealIme(hKL))
  2160. {
  2161. return Imm32_IsIME(hKL);
  2162. }
  2163. HRESULT hr;
  2164. IAImeProfile* pAImeProfile;
  2165. extern HRESULT CAImmProfile_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj);
  2166. hr = CAImmProfile_CreateInstance(NULL, IID_IAImeProfile, (void**)&pAImeProfile);
  2167. if (FAILED(hr)) {
  2168. TraceMsg(TF_ERROR, "CreateInstance(IsIME) failed");
  2169. return hr;
  2170. }
  2171. hr = pAImeProfile->IsIME(hKL);
  2172. pAImeProfile->Release();
  2173. return hr;
  2174. }
  2175. STDAPI
  2176. CActiveIMM::DisableIME(
  2177. DWORD idThread
  2178. )
  2179. /*++
  2180. Method:
  2181. IActiveIMMApp::DisableIME
  2182. IActiveIMMIME::DisableIME
  2183. Routine Description:
  2184. Disables the Input Method Editor (IME) for a thread or all threads in a process.
  2185. Arguments:
  2186. idThread - [in] Unsigned long integer value that contains the thread identifier for which
  2187. the IME will be disabled. If idThread is zero, the IME for the current thread
  2188. is disabled. If idThread is -1, the IME is disabled for all threads in the
  2189. current process.
  2190. Return Value:
  2191. Returns S_OK if successful, or an error code otherwise.
  2192. --*/
  2193. {
  2194. TraceMsg(TF_API, "CActiveIMM::DisableIME");
  2195. if (_IsRealIme())
  2196. {
  2197. return Imm32_DisableIME(idThread);
  2198. }
  2199. return E_NOTIMPL;
  2200. }