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.

139 lines
3.5 KiB

  1. /****************************************************************************
  2. IMCSUB.H
  3. Owner: cslim
  4. Copyright (c) 1997-1999 Microsoft Corporation
  5. Subroutines related to HIMC.
  6. !!! NEED FULL REVIEW ALL FUNCTIONS NEED TO USE AND WORKS CORRECTLY !!!
  7. History:
  8. 21-JUL-1999 cslim Created(Borrowed almost part from KKIME)
  9. *****************************************************************************/
  10. #if !defined (_IMCSUB_H__INCLUDED_)
  11. #define _IMCSUB_H__INCLUDED_
  12. #include "ipoint.h"
  13. //////////////////////////////////////////////////////////////////////////////
  14. // IME private data for each context
  15. typedef struct tagIMCPRIVATE
  16. {
  17. HIMC hIMC;
  18. // DWORD fdwImeMsg; // what messages should be generated
  19. // DWORD dwCompChar; // wParam of WM_IME_COMPOSITION
  20. // DWORD dwCmpltChar; // wParam of WM_IME_COMPOSITION with GCS_RESULTSTR
  21. // DWORD fdwGcsFlag; // lParam for WM_IME_COMPOSITION
  22. IImeIPoint1* pIPoint;
  23. CIMECtx* pImeCtx; // same as pIPoint->GetImeCtx(x)
  24. } IMCPRIVATE ;
  25. typedef IMCPRIVATE *PIMCPRIVATE;
  26. typedef IMCPRIVATE *LPIMCPRIVATE;
  27. /*
  28. typedef struct tagIMCPRIVATE
  29. {
  30. HIMC hIMC;
  31. IImeKbd* pImeKbd;
  32. IImeIPoint* pIPoint;
  33. IImeConvert* pConvert;
  34. IImePadInternal* pImePad;
  35. IMECtx* pImeCtx; // same as pIPoint->GetImeCtx( x )
  36. } IMCPRIVATE;
  37. */
  38. PUBLIC VOID SetPrivateBuffer(HIMC hIMC, VOID* pv, DWORD dwSize);
  39. PUBLIC BOOL CloseInputContext(HIMC hIMC);
  40. //////////////////////////////////////////////////////////////////////////////
  41. // Inline functions
  42. PUBLIC CIMECtx* GetIMECtx(HIMC hIMC); // in api.cpp
  43. // CIMCPriv class Handle IME Private buffer
  44. class CIMCPriv
  45. {
  46. public:
  47. CIMCPriv() { m_hIMC = NULL; m_inputcontext = NULL; m_priv = NULL; }
  48. CIMCPriv(HIMC hIMC);
  49. ~CIMCPriv() { UnLockIMC(); }
  50. public:
  51. BOOL LockIMC(HIMC hIMC);
  52. void UnLockIMC();
  53. void ResetPrivateBuffer();
  54. operator LPIMCPRIVATE() { return m_priv; }
  55. LPIMCPRIVATE operator->() { AST(m_priv != NULL); return m_priv; }
  56. private:
  57. HIMC m_hIMC;
  58. LPINPUTCONTEXT m_inputcontext;
  59. LPIMCPRIVATE m_priv;
  60. };
  61. //
  62. // Inline functions
  63. //
  64. inline CIMCPriv::CIMCPriv(HIMC hIMC)
  65. {
  66. AST(hIMC != NULL);
  67. m_hIMC = NULL;
  68. m_inputcontext = NULL;
  69. m_priv = NULL;
  70. LockIMC(hIMC);
  71. }
  72. inline BOOL CIMCPriv::LockIMC(HIMC hIMC)
  73. {
  74. if (hIMC != NULL)
  75. {
  76. m_hIMC = hIMC;
  77. m_inputcontext = (LPINPUTCONTEXT)OurImmLockIMC(hIMC);
  78. if (m_inputcontext)
  79. {
  80. // hIMC->hPrivate was not allocated properly. e.g ImeSelect(TRUE)was not called.
  81. if (OurImmGetIMCCSize(m_inputcontext->hPrivate) != sizeof(IMCPRIVATE))
  82. return fFalse;
  83. m_priv = (LPIMCPRIVATE)OurImmLockIMCC(m_inputcontext->hPrivate);
  84. }
  85. }
  86. return (hIMC != NULL && m_priv != NULL);
  87. }
  88. inline void CIMCPriv::UnLockIMC()
  89. {
  90. if (m_hIMC != NULL && m_inputcontext != NULL)
  91. {
  92. OurImmUnlockIMCC(m_inputcontext->hPrivate);
  93. OurImmUnlockIMC(m_hIMC);
  94. }
  95. }
  96. inline void CIMCPriv::ResetPrivateBuffer()
  97. {
  98. AST(m_hIMC != NULL);
  99. if (m_inputcontext && m_priv)
  100. {
  101. m_priv->hIMC = (HIMC)0;
  102. }
  103. }
  104. __inline IImeIPoint1* GetImeIPoint(HIMC hIMC)
  105. {
  106. CIMCPriv ImcPriv;
  107. if (ImcPriv.LockIMC(hIMC) == fFalse)
  108. {
  109. return NULL;
  110. }
  111. return ImcPriv->pIPoint;
  112. }
  113. #endif // _IMCSUB_H__INCLUDED_