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.

615 lines
20 KiB

  1. //
  2. // KORIMX.H : CKorIMX class declaration
  3. //
  4. // History:
  5. // 15-NOV-1999 CSLim Created
  6. #if !defined (__KORIMX_H__INCLUDED_)
  7. #define __KORIMX_H__INCLUDED_
  8. #include "globals.h"
  9. #include "proputil.h"
  10. #include "computil.h"
  11. #include "dap.h"
  12. #include "tes.h"
  13. #include "kes.h"
  14. #include "hauto.h"
  15. #include "candlstx.h"
  16. #include "mscandui.h"
  17. #include "toolbar.h"
  18. #include "editssn.h"
  19. #include "immxutil.h"
  20. #include "softkbd.h"
  21. #include "skbdkor.h"
  22. #include "pad.h"
  23. #include "resource.h"
  24. ///////////////////////////////////////////////////////////////////////////////
  25. // Class forward declarations
  26. class CEditSession;
  27. class CICPriv;
  28. class CThreadMgrEventSink;
  29. class CFunctionProvider;
  30. class CHanja;
  31. class CCompositionInsertHelper;
  32. ///////////////////////////////////////////////////////////////////////////////
  33. // Edit callback state values
  34. #define ESCB_FINALIZECONVERSION 1
  35. #define ESCB_COMPLETE 2
  36. #define ESCB_INSERT_PAD_STRING 3
  37. #define ESCB_KEYSTROKE 4
  38. #define ESCB_TEXTEVENT 5
  39. //#define ESCB_RANGEBROKEN 6
  40. #define ESCB_CANDUI_CLOSECANDUI 6
  41. #define ESCB_HANJA_CONV 7
  42. #define ESCB_FINALIZERECONVERSION 8
  43. #define ESCB_ONSELECTRECONVERSION 9
  44. #define ESCB_ONCANCELRECONVERSION 10
  45. #define ESCB_RECONV_QUERYRECONV 11
  46. #define ESCB_RECONV_GETRECONV 12
  47. #define ESCB_RECONV_SHOWCAND 13
  48. #define ESCB_INIT_MODEBIAS 14
  49. // Conversion modes(bit field for bit op)
  50. #define TIP_ALPHANUMERIC_MODE 0
  51. #define TIP_HANGUL_MODE 1
  52. #define TIP_JUNJA_MODE 2
  53. #define TIP_NULL_CONV_MODE 0x8000
  54. //
  55. // Text Direction
  56. //
  57. typedef enum
  58. {
  59. TEXTDIRECTION_TOPTOBOTTOM = 1,
  60. TEXTDIRECTION_RIGHTTOLEFT,
  61. TEXTDIRECTION_BOTTOMTOTOP,
  62. TEXTDIRECTION_LEFTTORIGHT,
  63. } TEXTDIRECTION;
  64. ///////////////////////////////////////////////////////////////////////////////
  65. // CKorIMX class
  66. class CKorIMX : public ITfTextInputProcessor,
  67. public ITfFnConfigure,
  68. public ITfThreadFocusSink,
  69. public ITfCompositionSink,
  70. public ITfCleanupContextSink,
  71. public ITfCleanupContextDurationSink,
  72. public ITfActiveLanguageProfileNotifySink,
  73. public ITfTextEditSink,
  74. public ITfEditTransactionSink,
  75. public CDisplayAttributeProvider
  76. {
  77. public:
  78. CKorIMX();
  79. ~CKorIMX();
  80. static HRESULT CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj);
  81. //
  82. // IUnknown methods
  83. //
  84. virtual STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  85. virtual STDMETHODIMP_(ULONG) AddRef(void);
  86. virtual STDMETHODIMP_(ULONG) Release(void);
  87. private:
  88. long m_cRef;
  89. public:
  90. //
  91. // ITfX methods
  92. //
  93. STDMETHODIMP Activate(ITfThreadMgr *ptim, TfClientId tid);
  94. STDMETHODIMP Deactivate();
  95. // ITfThreadFocusSink
  96. STDMETHODIMP OnSetThreadFocus();
  97. STDMETHODIMP OnKillThreadFocus();
  98. // ITfCompositionSink
  99. STDMETHODIMP OnCompositionTerminated(TfEditCookie ecWrite, ITfComposition *pComposition);
  100. // ITfCleanupContextDurationSink
  101. STDMETHODIMP OnStartCleanupContext();
  102. STDMETHODIMP OnEndCleanupContext();
  103. // ITfCleanupContextSink
  104. STDMETHODIMP OnCleanupContext(TfEditCookie ecWrite, ITfContext *pic);
  105. // ITfActiveLanguageProfileNotifySink
  106. STDMETHODIMP OnActivated(REFCLSID clsid, REFGUID guidProfile, BOOL fActivated);
  107. // ITFFnConfigure
  108. STDMETHODIMP GetDisplayName(BSTR *pbstrCand);
  109. STDMETHODIMP Show(HWND hwnd, LANGID langid, REFGUID rguidProfile);
  110. // ITfTextEditSink
  111. STDMETHODIMP OnEndEdit(ITfContext *pic, TfEditCookie ecReadOnly, ITfEditRecord *pEditRecord);
  112. // ITfEditTransactionSink
  113. STDMETHODIMP OnStartEditTransaction(ITfContext *pic);
  114. STDMETHODIMP OnEndEditTransaction(ITfContext *pic);
  115. // Operations
  116. public:
  117. // Get/Set On off status
  118. BOOL IsOn(ITfContext *pic);
  119. void SetOnOff(ITfContext *pic, BOOL fOn);
  120. static HRESULT _EditSessionCallback2(TfEditCookie ec, CEditSession2 *pes);
  121. HRESULT MakeResultString(TfEditCookie ec, ITfContext *pic, ITfRange *pRange);
  122. // REVIEW: IC related functions
  123. ITfContext* GetRootIC(ITfDocumentMgr* pDim = NULL);
  124. static BOOL IsDisabledIC(ITfContext *pic);
  125. static BOOL IsEmptyIC(ITfContext *pic);
  126. static BOOL IsCandidateIC(ITfContext *pic);
  127. static HWND GetAppWnd(ITfContext *pic);
  128. BOOL IsPendingCleanup();
  129. // Get AIMM or not?
  130. static BOOL GetAIMM(ITfContext *pic);
  131. // Get/Set conversion mode
  132. DWORD GetConvMode(ITfContext *pic);
  133. DWORD SetConvMode(ITfContext *pic, DWORD dwConvMode);
  134. // Retun current Automata object
  135. CHangulAutomata* GetAutomata(ITfContext *pic);
  136. // Cand UI functions
  137. void OpenCandidateUI(TfEditCookie ec, ITfContext *pic, ITfRange *pRange, CCandidateListEx *pCandList);
  138. void CloseCandidateUI(ITfContext *pic);
  139. void CancelCandidate(TfEditCookie ec, ITfContext *pic);
  140. // Soft Kbd functions
  141. HRESULT InitializeSoftKbd();
  142. BOOL IsSoftKbdEnabled() { return m_fSoftKbdEnabled; }
  143. void TerminateSoftKbd();
  144. BOOL GetSoftKBDOnOff();
  145. void SetSoftKBDOnOff(BOOL fOn);
  146. DWORD GetSoftKBDLayout();
  147. void SetSoftKBDLayout(DWORD dwKbdLayout);
  148. HRESULT GetSoftKBDPosition(int *xWnd, int *yWnd);
  149. void SetSoftKBDPosition(int xWnd, int yWnd);
  150. SOFTLAYOUT* GetHangulSKbd() { return &m_KbdHangul; }
  151. // Data access functins
  152. ITfDocumentMgr* GetDIM() { return m_pCurrentDim; }
  153. HRESULT GetFocusDIM(ITfDocumentMgr **ppdim);
  154. ITfThreadMgr* GetTIM() { return m_ptim; }
  155. TfClientId GetTID() { return m_tid; }
  156. ITfContext* GetIC();
  157. CThreadMgrEventSink* GetTIMEventSink() { return m_ptimEventSink; }
  158. static CICPriv* GetInputContextPriv(ITfContext *pic);
  159. void OnFocusChange(ITfContext *pic, BOOL fActivate);
  160. // Window object member access functions
  161. HWND GetOwnerWnd() { return m_hOwnerWnd; }
  162. // Get IImeIPoint
  163. IImeIPoint1* GetIPoint (ITfContext *pic);
  164. // KES_CODE_FOCUS set fForeground?
  165. BOOL IsKeyFocus() { return m_fKeyFocus; }
  166. // Get Pad Core
  167. CPadCore* GetPadCore() { return m_pPadCore; }
  168. // Update Toolbar button
  169. void UpdateToolbar(DWORD dwUpdate) { m_pToolBar->Update(dwUpdate); }
  170. static LRESULT CALLBACK _OwnerWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  171. CFunctionProvider* GetFunctionProvider() { return m_pFuncPrv; }
  172. // Cand UI helper
  173. BOOL IsCandUIOpen() { return m_fCandUIOpen; }
  174. // Get TLS
  175. LIBTHREAD *_GetLibTLS() { return &m_libTLS; }
  176. // Implementation
  177. protected:
  178. // Helper functions
  179. HRESULT SetInputString(TfEditCookie ec, ITfContext *pic, ITfRange *pRange, WCHAR *psz, LANGID langid);
  180. static LANGID GetLangID();
  181. static WCHAR Banja2Junja(WCHAR bChar);
  182. // Cand UI function
  183. void GetCandidateFontInternal(TfEditCookie ec, ITfContext *pic, ITfRange *pRange, LOGFONTW *plf, LONG lFontPoint, BOOL fCandList);
  184. //////////////////////////////////////////////////////////////////////////////
  185. // Internal functions
  186. private:
  187. // Callbacks
  188. static HRESULT _KeyEventCallback(UINT uCode, ITfContext *pic, WPARAM wParam, LPARAM lParam, BOOL *pfEaten, void *pv);
  189. static HRESULT _PreKeyCallback(ITfContext *pic, REFGUID rguid, BOOL *pfEaten, void *pv);
  190. static HRESULT _DIMCallback(UINT uCode, ITfDocumentMgr *pdimNew, ITfDocumentMgr *pdimPrev, void *pv);
  191. static HRESULT _ICCallback(UINT uCode, ITfContext *pic, void *pv);
  192. static HRESULT _CompEventSinkCallback(void *pv, REFGUID rguid);
  193. static void _CleanupCompositionsCallback(TfEditCookie ecWrite, ITfRange *rangeComposition, void *pvPrivate);
  194. void HAutoMata(TfEditCookie ec, ITfContext *pIIC, ITfRange *pIRange, LPBYTE lpbKeyState, WORD wVKey);
  195. BOOL _IsKeyEaten(ITfContext *pic, CKorIMX *pimx, WPARAM wParam, LPARAM lParam, const BYTE abKeyState[256]);
  196. HRESULT _Keystroke(TfEditCookie ec, ITfContext *pic, WPARAM wParam, LPARAM lParam, const BYTE abKeyState[256]);
  197. // IC helpers
  198. HRESULT _InitICPriv(ITfContext *pic);
  199. HRESULT _DeleteICPriv(ITfContext *pic);
  200. // Hanja conversion
  201. HRESULT DoHanjaConversion(TfEditCookie ec, ITfContext *pic, ITfRange *pRange);
  202. HRESULT Reconvert(ITfRange *pSelection);
  203. // Composition
  204. ITfComposition *GetIPComposition(ITfContext *pic);
  205. ITfComposition *CreateIPComposition(TfEditCookie ec, ITfContext *pic, ITfRange* pRangeComp);
  206. void SetIPComposition(ITfContext *pic, ITfComposition *pComposition);
  207. BOOL EndIPComposition(TfEditCookie ec, ITfContext *pic);
  208. // Candidate list
  209. CCandidateListEx *CreateCandidateList(ITfContext *pic, ITfRange *pRange, LPWSTR wchHangul);
  210. TEXTDIRECTION GetTextDirection(TfEditCookie ec, ITfContext *pic, ITfRange *pRange);
  211. CANDUIUIDIRECTION GetCandUIDirection(TfEditCookie ec, ITfContext *pic, ITfRange *pRange);
  212. void CloseCandidateUIProc();
  213. void SelectCandidate(TfEditCookie ec, ITfContext *pic, INT idxCand, BOOL fFinalize);
  214. HMENU CreateCandidateMenu(ITfContext *pic);
  215. static HRESULT CandidateUICallBack(ITfContext *pic, ITfRange *pRange, CCandidateListEx *pCandList, CCandidateStringEx *pCand, TfCandidateResult imcr);
  216. // Cand key
  217. void SetCandidateKeyTable(ITfContext *pic, CANDUIUIDIRECTION dir);
  218. static BOOL IsCandKey(WPARAM wParam, const BYTE abKeyState[256]);
  219. #if 0
  220. // Range functions
  221. void BackupRange(TfEditCookie ec, ITfContext *pic, ITfRange* pRange );
  222. void RestoreRange(TfEditCookie ec, ITfContext *pic );
  223. ITfRange* CreateIPRange(TfEditCookie ec, ITfContext *pic, ITfRange* pRangeOrg);
  224. void SetIPRange(TfEditCookie ec, ITfContext *pic, ITfRange* pRange);
  225. ITfRange* GetIPRange(TfEditCookie ec, ITfContext *pic);
  226. BOOL FlushIPRange(TfEditCookie ec, ITfContext *pic);
  227. #endif
  228. // Modebias(ImmSetConversionStatus() API AIMM compatebility)
  229. BOOL InitializeModeBias(TfEditCookie ec, ITfContext *pic);
  230. void CheckModeBias(ITfContext* pic);
  231. BOOL CheckModeBias(TfEditCookie ec, ITfContext *pic, ITfRange *pSelection);
  232. // SoftKeyboard
  233. //void OnActivatedSoftKbd(BOOl bActivated);
  234. HRESULT ShowSoftKBDWindow(BOOL fShow);
  235. void SoftKbdOnThreadFocusChange(BOOL fSet);
  236. // Helpers
  237. BOOL MySetText(TfEditCookie ec, ITfContext *pic, ITfRange *pRange, const WCHAR *psz, LONG cchText, LANGID langid, GUID *pattr);
  238. BOOL IsKorIMX_GUID_ATOM(TfGuidAtom attr);
  239. ///////////////////////////////////////////////////////////////////////////////
  240. // Internal data
  241. private:
  242. ITfDocumentMgr *m_pCurrentDim;
  243. ITfThreadMgr *m_ptim;
  244. TfClientId m_tid;
  245. CThreadMgrEventSink *m_ptimEventSink;
  246. CKeyEventSink *m_pkes;
  247. HWND m_hOwnerWnd;
  248. BOOL m_fKeyFocus;
  249. CPadCore *m_pPadCore;
  250. CToolBar *m_pToolBar;
  251. DWORD m_dwThreadFocusCookie;
  252. DWORD m_dwProfileNotifyCookie;
  253. BOOL m_fPendingCleanup;
  254. CFunctionProvider* m_pFuncPrv;
  255. // For overtyping
  256. CCompositionInsertHelper *m_pInsertHelper;
  257. // Candidate UI
  258. ITfCandidateUI* m_pCandUI;
  259. BOOL m_fCandUIOpen;
  260. // SoftKbd
  261. BOOL m_fSoftKbdEnabled;
  262. ISoftKbd *m_pSoftKbd;
  263. SOFTLAYOUT m_KbdStandard;
  264. SOFTLAYOUT m_KbdHangul;
  265. CSoftKbdWindowEventSink *m_psftkbdwndes;
  266. DWORD m_dwSftKbdwndesCookie;
  267. BOOL m_fSoftKbdOnOffSave;
  268. // Tls for our helper library, we're apt threaded so tls can live in this object
  269. LIBTHREAD m_libTLS;
  270. BOOL m_fNoKorKbd;
  271. };
  272. /*---------------------------------------------------------------------------
  273. CKorIMX::IsPendingCleanup
  274. ---------------------------------------------------------------------------*/
  275. inline
  276. BOOL CKorIMX::IsPendingCleanup()
  277. {
  278. return m_fPendingCleanup;
  279. }
  280. /*---------------------------------------------------------------------------
  281. CKorIMX::GetFocusDIM
  282. ---------------------------------------------------------------------------*/
  283. inline
  284. HRESULT CKorIMX::GetFocusDIM(ITfDocumentMgr **ppdim)
  285. {
  286. Assert(ppdim);
  287. *ppdim = NULL;
  288. if (m_ptim != NULL)
  289. m_ptim->GetFocus(ppdim);
  290. return *ppdim ? S_OK : E_FAIL;
  291. }
  292. #include "icpriv.h"
  293. /*---------------------------------------------------------------------------
  294. CKorIMX::GetAutomata
  295. ---------------------------------------------------------------------------*/
  296. inline
  297. CHangulAutomata* CKorIMX::GetAutomata(ITfContext *pic)
  298. {
  299. CICPriv* picp = GetInputContextPriv(pic);
  300. return (picp) ? GetInputContextPriv(pic)->GetAutomata() : NULL;
  301. }
  302. /*---------------------------------------------------------------------------
  303. CKorIMX::IsOn
  304. ---------------------------------------------------------------------------*/
  305. inline
  306. BOOL CKorIMX::IsOn(ITfContext *pic)
  307. {
  308. DWORD dw = 0;
  309. if (pic == NULL)
  310. return fFalse;
  311. GetCompartmentDWORD(GetTIM(), GUID_COMPARTMENT_KEYBOARD_OPENCLOSE, &dw, fFalse);
  312. return dw ? fTrue : fFalse;
  313. }
  314. /*---------------------------------------------------------------------------
  315. CKorIMX::GetConvMode
  316. ---------------------------------------------------------------------------*/
  317. inline
  318. DWORD CKorIMX::GetConvMode(ITfContext *pic)
  319. {
  320. DWORD dw = 0;
  321. if (pic == NULL)
  322. return TIP_ALPHANUMERIC_MODE;
  323. GetCompartmentDWORD(GetTIM(), GUID_COMPARTMENT_KORIMX_CONVMODE, &dw, fFalse);
  324. return dw;
  325. }
  326. /*---------------------------------------------------------------------------
  327. CKorIMX::SetOnOff
  328. ---------------------------------------------------------------------------*/
  329. inline
  330. void CKorIMX::SetOnOff(ITfContext *pic, BOOL fOn)
  331. {
  332. if (pic)
  333. SetCompartmentDWORD(m_tid, GetTIM(), GUID_COMPARTMENT_KEYBOARD_OPENCLOSE, fOn ? 0x01 : 0x00, fFalse);
  334. }
  335. /*---------------------------------------------------------------------------
  336. CKorIMX::GetLangID
  337. ---------------------------------------------------------------------------*/
  338. inline
  339. LANGID CKorIMX::GetLangID()
  340. {
  341. return MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT);
  342. }
  343. /*---------------------------------------------------------------------------
  344. CKorIMX::IsKorIMX_GUID_ATOM
  345. ---------------------------------------------------------------------------*/
  346. inline
  347. BOOL CKorIMX::IsKorIMX_GUID_ATOM(TfGuidAtom attr)
  348. {
  349. if (IsEqualTFGUIDATOM(&m_libTLS, attr, GUID_ATTR_KORIMX_INPUT))
  350. return fTrue;
  351. return fFalse;
  352. }
  353. /////////////////////////////////////////////////////////////////////////////
  354. // S O F T K E Y B O A R D F U N C T I O N S
  355. /////////////////////////////////////////////////////////////////////////////
  356. /*---------------------------------------------------------------------------
  357. CKorIMX::GetSoftKBDOnOff
  358. ---------------------------------------------------------------------------*/
  359. inline
  360. BOOL CKorIMX::GetSoftKBDOnOff()
  361. {
  362. DWORD dw;
  363. if (GetTIM() == NULL)
  364. return fFalse;
  365. GetCompartmentDWORD(GetTIM(), GUID_COMPARTMENT_KOR_SOFTKBD_OPENCLOSE , &dw, fFalse);
  366. return dw ? TRUE : fFalse;
  367. }
  368. /*---------------------------------------------------------------------------
  369. CKorIMX::SetSoftKBDOnOff
  370. ---------------------------------------------------------------------------*/
  371. inline
  372. void CKorIMX::SetSoftKBDOnOff(BOOL fOn)
  373. {
  374. // check to see if the m_pSoftKbd and soft keyboard related members are initialized.
  375. if (m_fSoftKbdEnabled == fFalse)
  376. InitializeSoftKbd();
  377. if (m_pSoftKbd == NULL || GetTIM() == NULL)
  378. return;
  379. if (fOn == GetSoftKBDOnOff())
  380. return;
  381. SetCompartmentDWORD(GetTID(), GetTIM(), GUID_COMPARTMENT_KOR_SOFTKBD_OPENCLOSE,
  382. fOn ? 0x01 : 0x00 , fFalse);
  383. }
  384. /*---------------------------------------------------------------------------
  385. CKorIMX::GetSoftKBDLayout
  386. ---------------------------------------------------------------------------*/
  387. inline
  388. DWORD CKorIMX::GetSoftKBDLayout( )
  389. {
  390. DWORD dw;
  391. if (m_pSoftKbd == NULL || GetTIM() == NULL)
  392. return NON_LAYOUT;
  393. GetCompartmentDWORD(GetTIM(), GUID_COMPARTMENT_SOFTKBD_KBDLAYOUT, &dw, fFalse);
  394. return dw;
  395. }
  396. /*---------------------------------------------------------------------------
  397. CKorIMX::SetSoftKBDLayout
  398. ---------------------------------------------------------------------------*/
  399. inline
  400. void CKorIMX::SetSoftKBDLayout(DWORD dwKbdLayout)
  401. {
  402. // check to see if the _SoftKbd and soft keyboard related members are initialized.
  403. if (m_fSoftKbdEnabled == fFalse )
  404. InitializeSoftKbd();
  405. if ((m_pSoftKbd == NULL) || (GetTIM() == NULL))
  406. return;
  407. SetCompartmentDWORD(GetTID(), GetTIM(), GUID_COMPARTMENT_SOFTKBD_KBDLAYOUT,
  408. dwKbdLayout , fFalse);
  409. }
  410. /*---------------------------------------------------------------------------
  411. CKorIMX::GetSoftKBDPosition
  412. ---------------------------------------------------------------------------*/
  413. inline
  414. HRESULT CKorIMX::GetSoftKBDPosition(int *xWnd, int *yWnd)
  415. {
  416. DWORD dwPos;
  417. HRESULT hr = S_OK;
  418. if ((m_pSoftKbd == NULL) || (GetTIM() == NULL))
  419. return E_FAIL;
  420. if (!xWnd || !yWnd)
  421. return E_FAIL;
  422. hr = GetCompartmentDWORD(GetTIM(), GUID_COMPARTMENT_SOFTKBD_WNDPOSITION, &dwPos, TRUE);
  423. if (hr == S_OK)
  424. {
  425. *xWnd = dwPos & 0x0000ffff;
  426. *yWnd = (dwPos >> 16) & 0x0000ffff;
  427. hr = S_OK;
  428. }
  429. else
  430. {
  431. *xWnd = 0;
  432. *yWnd = 0;
  433. hr = E_FAIL;
  434. }
  435. return hr;
  436. }
  437. /*---------------------------------------------------------------------------
  438. CKorIMX::SetSoftKBDPosition
  439. ---------------------------------------------------------------------------*/
  440. inline
  441. void CKorIMX::SetSoftKBDPosition(int xWnd, int yWnd )
  442. {
  443. DWORD dwPos;
  444. DWORD left, top;
  445. if ((m_pSoftKbd == NULL) || (GetTIM() == NULL))
  446. return;
  447. if (xWnd < 0)
  448. left = 0;
  449. else
  450. left = (WORD)xWnd;
  451. if (yWnd < 0)
  452. top = 0;
  453. else
  454. top = (WORD)yWnd;
  455. dwPos = ((DWORD)top << 16) + left;
  456. SetCompartmentDWORD(GetTID(), GetTIM(), GUID_COMPARTMENT_SOFTKBD_WNDPOSITION,
  457. dwPos, TRUE);
  458. }
  459. /////////////////////////////////////////////////////////////////////////////
  460. // H E L P E R F U N C T I O N S
  461. /////////////////////////////////////////////////////////////////////////////
  462. /*---------------------------------------------------------------------------
  463. SetSelectionBlock
  464. Wrapper for SetSelection that takes only a single range and sets default style values.
  465. ---------------------------------------------------------------------------*/
  466. inline
  467. HRESULT SetSelectionBlock(TfEditCookie ec, ITfContext *pic, ITfRange *range)
  468. {
  469. TF_SELECTION sel;
  470. sel.range = range;
  471. sel.style.ase = TF_AE_NONE;
  472. sel.style.fInterimChar = fTrue;
  473. return pic->SetSelection(ec, 1, &sel);
  474. }
  475. /*---------------------------------------------------------------------------
  476. SetThis
  477. ---------------------------------------------------------------------------*/
  478. inline
  479. void SetThis(HWND hWnd, LPARAM lParam)
  480. {
  481. SetWindowLongPtr(hWnd, GWLP_USERDATA,
  482. (LONG_PTR)((CREATESTRUCT *)lParam)->lpCreateParams);
  483. }
  484. /*---------------------------------------------------------------------------
  485. GetThis
  486. ---------------------------------------------------------------------------*/
  487. inline
  488. CKorIMX *GetThis(HWND hWnd)
  489. {
  490. CKorIMX *p = (CKorIMX *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
  491. Assert(p != NULL);
  492. return p;
  493. }
  494. #endif // __KORIMX_H__INCLUDED_