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.

804 lines
23 KiB

  1. /*++
  2. Copyright (c) 2001, Microsoft Corporation
  3. Module Name:
  4. uiwndhd.cpp
  5. Abstract:
  6. This file implements the IME UI window handler Class.
  7. Author:
  8. Revision History:
  9. Notes:
  10. --*/
  11. #include "private.h"
  12. #include "uiwndhd.h"
  13. #include "tls.h"
  14. #include "profile.h"
  15. #include "msime.h"
  16. #include "setmode.h"
  17. #include "ui.h"
  18. #define UIWND_TIMERID_IME_COMPOSITION 0
  19. #define UIWND_TIMERID_IME_SETCONTEXTAFTER 1
  20. #define UIWND_TIMERID_IME_DELAYUNDORECONV 2
  21. /* static */
  22. LRESULT
  23. CIMEUIWindowHandler::ImeUIWndProcWorker(
  24. HWND hUIWnd,
  25. UINT uMsg,
  26. WPARAM wParam,
  27. LPARAM lParam)
  28. {
  29. LONG lRet = 0L;
  30. TLS* ptls = TLS::GetTLS();
  31. if (ptls && (ptls->GetSystemInfoFlags() & IME_SYSINFO_WINLOGON))
  32. {
  33. if (uMsg == WM_CREATE)
  34. return -1L;
  35. else
  36. return DefWindowProc(hUIWnd, uMsg, wParam, lParam);
  37. }
  38. switch (uMsg) {
  39. case WM_CREATE:
  40. UI::OnCreate(hUIWnd);
  41. break;
  42. case WM_IME_NOTIFY:
  43. return ImeUINotifyHandler(hUIWnd, uMsg, wParam, lParam);
  44. case WM_ENDSESSION:
  45. if (wParam && lParam)
  46. {
  47. UI::OnDestroy(hUIWnd);
  48. break;
  49. }
  50. case WM_DESTROY:
  51. UI::OnDestroy(hUIWnd);
  52. break;
  53. case WM_IME_SETCONTEXT:
  54. case WM_IME_SELECT:
  55. case WM_IME_STARTCOMPOSITION:
  56. case WM_IME_COMPOSITION:
  57. case WM_IME_ENDCOMPOSITION:
  58. case WM_TIMER:
  59. {
  60. UI* pv = (UI*)GetWindowLongPtr(hUIWnd, IMMGWLP_PRIVATE);
  61. if (pv == NULL)
  62. {
  63. DebugMsg(TF_ERROR, TEXT("CIMEUIWindowHandler::ImeUIWndProcWorker. pv==NULL"));
  64. break;
  65. }
  66. HIMC hImc = (HIMC)GetWindowLongPtr(hUIWnd, IMMGWLP_IMC);
  67. IMCLock imc(hImc);
  68. //
  69. // Should not return when IMCLock failed.
  70. // If application associate NULL hIMC, below method never work.
  71. // Inside of each method must validate check of imc object.
  72. //
  73. // if (FAILED(imc.GetResult()))
  74. // {
  75. // DebugMsg(TF_ERROR, TEXT("ImeUIWndProcWorker. imc==NULL"));
  76. // break;
  77. // }
  78. switch (uMsg)
  79. {
  80. case WM_IME_SETCONTEXT:
  81. pv->OnImeSetContext(imc, (BOOL)wParam, (DWORD)lParam);
  82. KillTimer(hUIWnd, UIWND_TIMERID_IME_SETCONTEXTAFTER);
  83. SetTimer(hUIWnd,
  84. UIWND_TIMERID_IME_SETCONTEXTAFTER,
  85. 300,
  86. NULL);
  87. break;
  88. case WM_IME_SELECT:
  89. pv->OnImeSelect((BOOL)wParam);
  90. break;
  91. case WM_IME_STARTCOMPOSITION:
  92. pv->OnImeStartComposition(imc);
  93. break;
  94. case WM_IME_COMPOSITION:
  95. //
  96. // use time to delay to calc the size of the window.
  97. //
  98. if (lParam & GCS_COMPSTR)
  99. {
  100. pv->OnImeCompositionUpdate(imc);
  101. SetTimer(hUIWnd, UIWND_TIMERID_IME_COMPOSITION, 10, NULL);
  102. pv->OnSetCompositionTimerStatus(TRUE);
  103. }
  104. break;
  105. case WM_TIMER:
  106. switch (wParam)
  107. {
  108. case UIWND_TIMERID_IME_COMPOSITION:
  109. KillTimer(hUIWnd, UIWND_TIMERID_IME_COMPOSITION);
  110. pv->OnSetCompositionTimerStatus(FALSE);
  111. pv->OnImeCompositionUpdateByTimer(imc);
  112. break;
  113. case UIWND_TIMERID_IME_SETCONTEXTAFTER:
  114. KillTimer(hUIWnd, UIWND_TIMERID_IME_SETCONTEXTAFTER);
  115. pv->OnImeSetContextAfter(imc);
  116. break;
  117. case UIWND_TIMERID_IME_DELAYUNDORECONV:
  118. KillTimer(hUIWnd, UIWND_TIMERID_IME_DELAYUNDORECONV);
  119. ImeUIDelayedReconvertFuncCall(hUIWnd);
  120. break;
  121. }
  122. break;
  123. case WM_IME_ENDCOMPOSITION:
  124. KillTimer(hUIWnd, UIWND_TIMERID_IME_COMPOSITION);
  125. pv->OnSetCompositionTimerStatus(FALSE);
  126. pv->OnImeEndComposition();
  127. break;
  128. }
  129. }
  130. break;
  131. default:
  132. if (IsMsImeMessage(uMsg))
  133. return ImeUIMsImeHandler(hUIWnd, uMsg, wParam, lParam);
  134. else
  135. return DefWindowProc(hUIWnd, uMsg, wParam, lParam);
  136. }
  137. return lRet;
  138. }
  139. /* static */
  140. LRESULT
  141. CIMEUIWindowHandler::ImeUINotifyHandler(
  142. HWND hUIWnd,
  143. UINT uMsg,
  144. WPARAM wParam,
  145. LPARAM lParam)
  146. {
  147. DebugMsg(TF_FUNC, TEXT("ImeUINotifyHandler"));
  148. HRESULT hr;
  149. IMCLock imc((HIMC)GetWindowLongPtr(hUIWnd, IMMGWLP_IMC));
  150. if (FAILED(hr=imc.GetResult()))
  151. {
  152. DebugMsg(TF_ERROR, TEXT("ImeUINotifyHandler. imc==NULL"));
  153. return 0L;
  154. }
  155. IMCCLock<CTFIMECONTEXT> imc_ctfime(imc->hCtfImeContext);
  156. if (FAILED(hr=imc_ctfime.GetResult()))
  157. {
  158. DebugMsg(TF_ERROR, TEXT("ImeUINotifyHandler. imc_ctfime==NULL"));
  159. return 0L;
  160. }
  161. CicInputContext* _pCicContext = imc_ctfime->m_pCicContext;
  162. if (_pCicContext == NULL)
  163. {
  164. DebugMsg(TF_ERROR, TEXT("ImeUINotifyHandler. _pCicContext==NULL"));
  165. return 0L;
  166. }
  167. switch (wParam) {
  168. case IMN_SETOPENSTATUS:
  169. //
  170. // we can track this in SetOpenStatus().
  171. // Don't have to sync when IMM32 is called.
  172. //
  173. // _pImmIfIME->OnSetOpenStatus(imc);
  174. break;
  175. case IMN_SETSTATUSWINDOWPOS:
  176. case IMN_OPENSTATUSWINDOW:
  177. case IMN_CLOSESTATUSWINDOW:
  178. break;
  179. case IMN_SETCONVERSIONMODE:
  180. case IMN_SETSENTENCEMODE:
  181. //
  182. // we can track this in SetConversionMode().
  183. // Don't have to sync when IMM32 is called.
  184. //
  185. // _pImmIfIME->OnSetConversionSentenceMode(imc);
  186. break;
  187. case IMN_OPENCANDIDATE:
  188. _pCicContext->m_fOpenCandidateWindow.SetFlag();
  189. _pCicContext->ClearPrevCandidatePos();
  190. // fall through to call OnSetCandidatePos().
  191. case IMN_SETCANDIDATEPOS:
  192. case IMN_CHANGECANDIDATE:
  193. {
  194. TLS* ptls = TLS::GetTLS();
  195. if (ptls == NULL)
  196. {
  197. DebugMsg(TF_ERROR, TEXT("CIMEUIWindowHandler::ImeUINotifyHandler. ptls==NULL."));
  198. return FALSE;
  199. }
  200. _pCicContext->OnSetCandidatePos(ptls, imc);
  201. }
  202. break;
  203. case IMN_CLOSECANDIDATE:
  204. _pCicContext->m_fOpenCandidateWindow.ResetFlag();
  205. {
  206. HWND hDefImeWnd;
  207. /*
  208. * A-Synchronize call ImmIfIME::ClearDocFeedBuffer
  209. * because this method had a protected.
  210. */
  211. if (IsWindow(hDefImeWnd=ImmGetDefaultIMEWnd(NULL)))
  212. {
  213. PostMessage(hDefImeWnd, WM_IME_NOTIFY, IMN_PRIVATE_ONCLEARDOCFEEDBUFFER, (LPARAM)(HIMC)imc);
  214. }
  215. }
  216. break;
  217. case IMN_SETCOMPOSITIONWINDOW:
  218. _pCicContext->ResetIMECharPosition();
  219. {
  220. UI* pv = (UI*)GetWindowLongPtr(hUIWnd, IMMGWLP_PRIVATE);
  221. if (pv == NULL)
  222. {
  223. DebugMsg(TF_ERROR, TEXT("CIMEUIWindowHandler::ImeUINotifyHandler. pv==NULL"));
  224. break;
  225. }
  226. pv->OnImeNotifySetCompositionWindow(imc);
  227. ImeUIOnLayoutChange((HIMC)imc);
  228. }
  229. break;
  230. case IMN_SETCOMPOSITIONFONT:
  231. {
  232. UI* pv = (UI*)GetWindowLongPtr(hUIWnd, IMMGWLP_PRIVATE);
  233. if (pv == NULL)
  234. {
  235. DebugMsg(TF_ERROR, TEXT("CIMEUIWindowHandler::ImeUINotifyHandler. pv==NULL"));
  236. break;
  237. }
  238. pv->OnImeNotifySetCompositionFont(imc);
  239. //
  240. // Get IME level and call ImeUIOnLayoutChange for only Level1 and Level2 cases.
  241. //
  242. IME_UIWND_STATE uists;
  243. hr = pv->OnPrivateGetContextFlag(imc, _pCicContext->m_fStartComposition.IsSetFlag(), &uists);
  244. if (hr == S_OK && ((uists == IME_UIWND_LEVEL1) || (uists == IME_UIWND_LEVEL2)))
  245. ImeUIOnLayoutChange((HIMC)imc);
  246. }
  247. break;
  248. case IMN_GUIDELINE:
  249. break;
  250. case WM_IME_STARTCOMPOSITION:
  251. {
  252. TLS* ptls = TLS::GetTLS();
  253. if (ptls != NULL)
  254. {
  255. LANGID langid;
  256. CicProfile* _pProfile = ptls->GetCicProfile();
  257. if (_pProfile != NULL)
  258. {
  259. _pProfile->GetLangId(&langid);
  260. _pCicContext->InquireIMECharPosition(langid, imc, NULL);
  261. }
  262. }
  263. }
  264. break;
  265. case WM_IME_ENDCOMPOSITION:
  266. _pCicContext->ResetIMECharPosition();
  267. break;
  268. case IMN_PRIVATE_ONLAYOUTCHANGE:
  269. ImeUIOnLayoutChange((HIMC)lParam);
  270. break;
  271. case IMN_PRIVATE_ONCLEARDOCFEEDBUFFER:
  272. ImeUIPrivateHandler(uMsg, wParam, lParam);
  273. break;
  274. case IMN_PRIVATE_GETCONTEXTFLAG:
  275. case IMN_PRIVATE_GETCANDRECTFROMCOMPOSITION:
  276. case IMN_PRIVATE_GETTEXTEXT:
  277. {
  278. UI* pv = (UI*)GetWindowLongPtr(hUIWnd, IMMGWLP_PRIVATE);
  279. if (pv == NULL)
  280. {
  281. DebugMsg(TF_ERROR, TEXT("CIMEUIWindowHandler::ImeUINotifyHandler. pv==NULL"));
  282. break;
  283. }
  284. switch (wParam)
  285. {
  286. case IMN_PRIVATE_GETCONTEXTFLAG:
  287. {
  288. IME_UIWND_STATE uists;
  289. pv->OnPrivateGetContextFlag(imc, _pCicContext->m_fStartComposition.IsSetFlag(), &uists);
  290. return (LRESULT)uists;
  291. }
  292. break;
  293. case IMN_PRIVATE_GETCANDRECTFROMCOMPOSITION:
  294. return pv->OnPrivateGetCandRectFromComposition(imc, (UIComposition::CandRectFromComposition*)lParam);
  295. case IMN_PRIVATE_GETTEXTEXT:
  296. {
  297. pv->OnPrivateGetTextExtent(imc, (UIComposition::TEXTEXT*)lParam);
  298. return 1L;
  299. }
  300. }
  301. }
  302. break;
  303. case IMN_PRIVATE_STARTLAYOUTCHANGE:
  304. ImeUIOnLayoutChange((HIMC)imc);
  305. break;
  306. case IMN_PRIVATE_DELAYRECONVERTFUNCCALL:
  307. SetTimer(hUIWnd,
  308. UIWND_TIMERID_IME_DELAYUNDORECONV,
  309. 100,
  310. NULL);
  311. break;
  312. case IMN_PRIVATE_GETUIWND:
  313. return (LRESULT)hUIWnd;
  314. }
  315. return 0L;
  316. }
  317. /* static */
  318. LRESULT
  319. CIMEUIWindowHandler::ImeUIDelayedReconvertFuncCall(
  320. HWND hUIWnd)
  321. {
  322. DebugMsg(TF_FUNC, TEXT("ImeUINotifyHandler"));
  323. HRESULT hr;
  324. IMCLock imc((HIMC)GetWindowLongPtr(hUIWnd, IMMGWLP_IMC));
  325. if (FAILED(hr=imc.GetResult()))
  326. {
  327. DebugMsg(TF_ERROR, TEXT("ImeUIDelayedReconvertFuncCall. imc==NULL"));
  328. return 0L;
  329. }
  330. IMCCLock<CTFIMECONTEXT> imc_ctfime(imc->hCtfImeContext);
  331. if (FAILED(hr=imc_ctfime.GetResult()))
  332. {
  333. DebugMsg(TF_ERROR, TEXT("ImeUIDelayedReconvertFuncCall. imc_ctfime==NULL"));
  334. return 0L;
  335. }
  336. CicInputContext* _pCicContext = imc_ctfime->m_pCicContext;
  337. if (_pCicContext == NULL)
  338. {
  339. DebugMsg(TF_ERROR, TEXT("ImeUIDelayedReconvertFuncCall. _pCicContext==NULL"));
  340. return 0L;
  341. }
  342. _pCicContext->DelayedReconvertFuncCall(imc);
  343. return 0L;
  344. }
  345. /* static */
  346. LRESULT
  347. CIMEUIWindowHandler::ImeUIMsImeHandler(
  348. HWND hUIWnd,
  349. UINT uMsg,
  350. WPARAM wParam,
  351. LPARAM lParam)
  352. {
  353. if (uMsg == WM_MSIME_MOUSE) {
  354. return ImeUIMsImeMouseHandler(hUIWnd, uMsg, wParam, lParam);
  355. }
  356. else if (uMsg == WM_MSIME_MODEBIAS)
  357. {
  358. return ImeUIMsImeModeBiasHandler(hUIWnd, wParam, lParam);
  359. }
  360. else if (uMsg == WM_MSIME_RECONVERTREQUEST)
  361. {
  362. return ImeUIMsImeReconvertRequest(hUIWnd, uMsg, wParam, lParam);
  363. }
  364. else if (uMsg == WM_MSIME_SERVICE)
  365. {
  366. TLS* ptls = TLS::GetTLS();
  367. if (ptls != NULL)
  368. {
  369. LANGID langid;
  370. CicProfile* _pProfile = ptls->GetCicProfile();
  371. if (_pProfile != NULL)
  372. {
  373. _pProfile->GetLangId(&langid);
  374. if (PRIMARYLANGID(langid) == LANG_KOREAN)
  375. return 0L;
  376. }
  377. }
  378. return 1L; // Win32 Layer support WM_MSIME_xxxx message.
  379. }
  380. return 0L;
  381. }
  382. /* static */
  383. LRESULT
  384. CIMEUIWindowHandler::ImeUIMsImeMouseHandler(
  385. HWND hUIWnd,
  386. UINT uMsg,
  387. WPARAM wParam,
  388. LPARAM lParam)
  389. /*++
  390. Method:
  391. WM_MSIME_MOUSE
  392. Routine Description:
  393. Mouse Operation on Composition String
  394. Arguments:
  395. wParam - Mouse operation code.
  396. LOBYTE(LOWORD(wParam))
  397. IMEMOUSE_VERSION
  398. IMEMOUSE_NONE
  399. IMEMOUSE_LDOWN
  400. IMEMOUSE_RDOWN
  401. IMEMOUSE_MDOWN
  402. IMEMOUSE_WUP
  403. IMEMOUSE_WDOWN
  404. HIBYTE(LOWORD(wParam))
  405. Mouse Position
  406. HIWORD(wParam)
  407. Clicked position
  408. lParam - Input Context handle (HIMC).
  409. Return Value:
  410. Returns 1 if IME handled this message.
  411. IMEMOUSERET_NOTHANDLED if IME did not handled this message.
  412. --*/
  413. {
  414. DebugMsg(TF_FUNC, TEXT("ImeUIMsImeMouseHandler"));
  415. ULONG dwBtnStatus;
  416. // special case: version check
  417. if (LOBYTE(LOWORD(wParam)) == IMEMOUSE_VERSION)
  418. return 1; // we support version 1.0
  419. HRESULT hr;
  420. IMCLock imc((HIMC)lParam);
  421. if (FAILED(hr=imc.GetResult()))
  422. {
  423. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeMouseHandler. imc==NULL"));
  424. return IMEMOUSERET_NOTHANDLED;
  425. }
  426. IMCCLock<CTFIMECONTEXT> imc_ctfime(imc->hCtfImeContext);
  427. if (FAILED(hr=imc_ctfime.GetResult()))
  428. {
  429. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeMouseHandler. imc_ctfime==NULL"));
  430. return IMEMOUSERET_NOTHANDLED;
  431. }
  432. CicInputContext* _pCicContext = imc_ctfime->m_pCicContext;
  433. if (_pCicContext == NULL)
  434. {
  435. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeMouseHandler. _pCicContext==NULL"));
  436. return IMEMOUSERET_NOTHANDLED;
  437. }
  438. ULONG uEdge = HIWORD(wParam);
  439. ULONG uQuadrant = HIBYTE(LOWORD(wParam));
  440. ULONG dwBtnStatusIme = LOBYTE(LOWORD(wParam));
  441. //
  442. // need to xlate dwBtnStatus from WM_MSIME_MOUSE flags to WM_MOUSE flags
  443. //
  444. dwBtnStatus = 0;
  445. if (dwBtnStatusIme & IMEMOUSE_LDOWN)
  446. {
  447. dwBtnStatus |= MK_LBUTTON;
  448. }
  449. if (dwBtnStatusIme & IMEMOUSE_MDOWN)
  450. {
  451. dwBtnStatus |= MK_MBUTTON;
  452. }
  453. if (dwBtnStatusIme & IMEMOUSE_RDOWN)
  454. {
  455. dwBtnStatus |= MK_RBUTTON;
  456. }
  457. // mouse wheel needs to be xlated from IMEMOUSE_WUP/IMEMOUSE_WDOWN to WHEEL_DELTA units
  458. if (dwBtnStatusIme & IMEMOUSE_WUP)
  459. {
  460. dwBtnStatus |= (WHEEL_DELTA << 16);
  461. }
  462. else if (dwBtnStatusIme & IMEMOUSE_WDOWN)
  463. {
  464. dwBtnStatus |= (((unsigned long)(-WHEEL_DELTA)) << 16);
  465. }
  466. return _pCicContext->MsImeMouseHandler(uEdge, uQuadrant, dwBtnStatus, imc);
  467. }
  468. /*++
  469. Method:
  470. CIMEUIWindowHandler::ImeUIMsImeModeBiasHandler
  471. Routine Description:
  472. Handles WM_MSIME_MODEBIAS messages sent to the ui window.
  473. Arguments:
  474. wParam - [in] operation: get version, get mode, set mode
  475. lParam - [in] for set mode, the new bias
  476. otherwise ignored
  477. Return Value:
  478. If wParam is MODEBIAS_GETVERSION, returns version number of interface.
  479. If wParam is MODEBIAS_SETVALUE, returns non-zero value if succeeded. Returns 0 if fail.
  480. If wParam is MODEBIAS_GETVALUE, returns current bias mode.
  481. --*/
  482. /* static */
  483. LRESULT
  484. CIMEUIWindowHandler::ImeUIMsImeModeBiasHandler(
  485. HWND hUIWnd,
  486. WPARAM wParam,
  487. LPARAM lParam)
  488. {
  489. DebugMsg(TF_FUNC, TEXT("ImeUIMsImeModeBiasHandler"));
  490. if (wParam == MODEBIAS_GETVERSION)
  491. return 1; // version 1
  492. HRESULT hr;
  493. IMCLock imc((HIMC)GetWindowLongPtr(hUIWnd, IMMGWLP_IMC));
  494. if (FAILED(hr=imc.GetResult()))
  495. {
  496. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeModeBiasHandler. imc==NULL"));
  497. return 0;
  498. }
  499. IMCCLock<CTFIMECONTEXT> imc_ctfime(imc->hCtfImeContext);
  500. if (FAILED(hr=imc_ctfime.GetResult()))
  501. {
  502. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeModeBiasHandler. imc_ctfime==NULL"));
  503. return 0;
  504. }
  505. CicInputContext* _pCicContext = imc_ctfime->m_pCicContext;
  506. if (_pCicContext == NULL)
  507. {
  508. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeModeBiasHandler. _pCicContext==NULL"));
  509. return 0;
  510. }
  511. GUID guidModeBias;
  512. switch (wParam)
  513. {
  514. case MODEBIAS_GETVALUE:
  515. guidModeBias = _pCicContext->m_ModeBias.GetModeBias();
  516. return _pCicContext->m_ModeBias.ConvertModeBias(guidModeBias);
  517. case MODEBIAS_SETVALUE:
  518. // check lParam
  519. if (lParam != MODEBIASMODE_DEFAULT &&
  520. lParam != MODEBIASMODE_FILENAME &&
  521. lParam != MODEBIASMODE_DIGIT &&
  522. lParam != MODEBIASMODE_URLHISTORY )
  523. {
  524. Assert(0); // bogus mode bias!
  525. return 0; // failure
  526. }
  527. // set the new value
  528. guidModeBias = _pCicContext->m_ModeBias.ConvertModeBias(lParam);
  529. _pCicContext->m_ModeBias.SetModeBias(guidModeBias);
  530. _pCicContext->m_fOnceModeChanged.SetFlag();
  531. // let cicero know the mode bias has changed
  532. Interface_Attach<ITfContextOwnerServices> iccb = _pCicContext->GetInputContextOwnerSink();
  533. iccb->OnAttributeChange(GUID_PROP_MODEBIAS);
  534. return 1; // success
  535. }
  536. Assert(0); // should never get here; bogus wParam
  537. return 0;
  538. }
  539. /* static */
  540. LRESULT
  541. CIMEUIWindowHandler::ImeUIPrivateHandler(
  542. UINT uMsg,
  543. WPARAM wParam,
  544. LPARAM lParam)
  545. /*++
  546. Method:
  547. CIMEUIWindowHandler::ImeUIPrivateHandler
  548. Routine Description:
  549. Handles WM_PRIVATE_xxx messages sent to the ui window.
  550. Arguments:
  551. lParam - [in] HIMC : input context handle
  552. Return Value:
  553. --*/
  554. {
  555. DebugMsg(TF_FUNC, TEXT("ImeUIPrivateHandler"));
  556. HRESULT hr;
  557. IMCLock imc((HIMC)lParam);
  558. if (FAILED(hr=imc.GetResult()))
  559. {
  560. DebugMsg(TF_ERROR, TEXT("ImeUIPrivateHandler. imc==NULL"));
  561. return 0;
  562. }
  563. IMCCLock<CTFIMECONTEXT> imc_ctfime(imc->hCtfImeContext);
  564. if (FAILED(hr=imc_ctfime.GetResult()))
  565. {
  566. DebugMsg(TF_ERROR, TEXT("ImeUIPrivateHandler. imc_ctfime==NULL"));
  567. return 0;
  568. }
  569. CicInputContext* _pCicContext = imc_ctfime->m_pCicContext;
  570. if (_pCicContext == NULL)
  571. {
  572. DebugMsg(TF_ERROR, TEXT("ImeUIPrivateHandler. _pCicContext==NULL"));
  573. return 0;
  574. }
  575. if (wParam == IMN_PRIVATE_ONCLEARDOCFEEDBUFFER) {
  576. //
  577. // Clear DocFeed buffer
  578. // Find GUID_PROP_MSIMTF_READONLY property and SetText(NULL).
  579. //
  580. _pCicContext->ClearDocFeedBuffer(imc); // TF_ES_SYNC
  581. }
  582. return S_OK;
  583. }
  584. /* static */
  585. LRESULT
  586. CIMEUIWindowHandler::ImeUIOnLayoutChange(HIMC hIMC)
  587. {
  588. DebugMsg(TF_FUNC, TEXT("OnLayoutChange"));
  589. HRESULT hr;
  590. IMCLock imc(hIMC);
  591. if (FAILED(hr=imc.GetResult()))
  592. {
  593. DebugMsg(TF_ERROR, TEXT("OnLayoutChange. imc==NULL"));
  594. return 0;
  595. }
  596. IMCCLock<CTFIMECONTEXT> imc_ctfime(imc->hCtfImeContext);
  597. if (FAILED(hr=imc_ctfime.GetResult()))
  598. {
  599. DebugMsg(TF_ERROR, TEXT("OnLayoutChange. imc_ctfime==NULL"));
  600. return 0;
  601. }
  602. CicInputContext* _pCicContext = imc_ctfime->m_pCicContext;
  603. if (_pCicContext == NULL)
  604. {
  605. DebugMsg(TF_ERROR, TEXT("OnLayoutChange. _pCicContext==NULL"));
  606. return 0;
  607. }
  608. Interface_Attach<ITfContextOwnerServices> iccb = _pCicContext->GetInputContextOwnerSink();
  609. iccb->AddRef();
  610. /*
  611. * Repositioning candidate window
  612. */
  613. iccb->OnLayoutChange();
  614. iccb->Release();
  615. return S_OK;
  616. }
  617. /* static */
  618. LRESULT
  619. CIMEUIWindowHandler::ImeUIMsImeReconvertRequest(
  620. HWND hUIWnd,
  621. UINT uMsg,
  622. WPARAM wParam,
  623. LPARAM lParam)
  624. {
  625. DebugMsg(TF_FUNC, TEXT("ImeUIMsImeReconvertRequest"));
  626. if (wParam == FID_RECONVERT_VERSION)
  627. {
  628. // they're asking for version # so return something
  629. return 1L;
  630. }
  631. HRESULT hr;
  632. IMCLock imc((HIMC)GetWindowLongPtr(hUIWnd, IMMGWLP_IMC));
  633. if (FAILED(hr=imc.GetResult()))
  634. {
  635. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeReconvertRequest. imc==NULL"));
  636. return 0L;
  637. }
  638. IMCCLock<CTFIMECONTEXT> imc_ctfime(imc->hCtfImeContext);
  639. if (FAILED(hr=imc_ctfime.GetResult()))
  640. {
  641. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeReconvertRequest. imc_ctfime==NULL"));
  642. return 0L;
  643. }
  644. CicInputContext* _pCicContext = imc_ctfime->m_pCicContext;
  645. if (_pCicContext == NULL)
  646. {
  647. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeReconvertRequest. _pCicContext==NULL"));
  648. return 0L;
  649. }
  650. TLS* ptls = TLS::GetTLS();
  651. if (ptls == NULL)
  652. {
  653. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeReconvertRequest. ptls==NULL."));
  654. return 0L;
  655. }
  656. ITfThreadMgr_P* ptim_P = ptls->GetTIM();
  657. if (ptim_P == NULL)
  658. {
  659. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeReconvertRequest. ptim_P==NULL."));
  660. return 0L;
  661. }
  662. UINT cp = CP_ACP;
  663. CicProfile* _pProfile = ptls->GetCicProfile();
  664. if (_pProfile == NULL)
  665. {
  666. DebugMsg(TF_ERROR, TEXT("ImeUIMsImeReconvertRequest. _pProfile==NULL."));
  667. return 0L;
  668. }
  669. _pProfile->GetCodePageA(&cp);
  670. _pCicContext->SetupReconvertString(imc, ptim_P, cp, WM_MSIME_RECONVERT, FALSE);
  671. _pCicContext->EndReconvertString(imc);
  672. return 1L;
  673. }