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.

122 lines
2.9 KiB

  1. /****************************************************************************
  2. CIMECB.CPP
  3. Owner: cslim
  4. Copyright (c) 1997-1999 Microsoft Corporation
  5. IME PAD wrapper functions
  6. History:
  7. 23-APR-1999 cslim Created
  8. *****************************************************************************/
  9. #include "precomp.h"
  10. #include "cimecb.h"
  11. #include "pad.h"
  12. #include "UI.h"
  13. static LPCImeCallback g_lpCImeCallback = NULL;
  14. LPCImeCallback CImeCallback::Fetch(VOID)
  15. {
  16. if(g_lpCImeCallback) {
  17. return g_lpCImeCallback;
  18. }
  19. g_lpCImeCallback = new CImeCallback();
  20. return g_lpCImeCallback;
  21. }
  22. VOID
  23. CImeCallback::Destroy(VOID)
  24. {
  25. //OutputDebugString("CImeCallback::Destroy START\n");
  26. if(g_lpCImeCallback) {
  27. //OutputDebugString("--> g_lpCImeCallback is allocated\n");
  28. delete g_lpCImeCallback;
  29. g_lpCImeCallback = NULL;
  30. }
  31. //OutputDebugString("CImeCallback::Destroy END\n");
  32. }
  33. CImeCallback::CImeCallback()
  34. {
  35. m_cRef = 1;
  36. }
  37. CImeCallback::~CImeCallback()
  38. {
  39. }
  40. HRESULT __stdcall CImeCallback::QueryInterface(REFIID refiid, LPVOID* ppv)
  41. {
  42. if (ppv == NULL)
  43. return E_POINTER;
  44. if(refiid == IID_IUnknown) {
  45. *ppv = static_cast<IUnknown *>(this);
  46. }
  47. else if(refiid == IID_IImeCallback) {
  48. *ppv = static_cast<IImeCallback *>(this);
  49. }
  50. else {
  51. *ppv = NULL;
  52. return E_NOINTERFACE;
  53. }
  54. reinterpret_cast<IUnknown *>(*ppv)->AddRef();
  55. return S_OK;
  56. }
  57. ULONG __stdcall CImeCallback::AddRef()
  58. {
  59. return InterlockedIncrement(&m_cRef);
  60. }
  61. ULONG __stdcall CImeCallback::Release()
  62. {
  63. if(InterlockedDecrement(&m_cRef) == 0) {
  64. //Delete this;
  65. return 0;
  66. }
  67. return m_cRef;
  68. }
  69. HRESULT __stdcall CImeCallback::GetApplicationHWND(HWND *pHwnd)
  70. {
  71. //----------------------------------------------------------------
  72. //Get Application's Window Handle.
  73. //----------------------------------------------------------------
  74. if(pHwnd) {
  75. *pHwnd = GetActiveUIWnd();
  76. return S_OK;
  77. }
  78. return S_FALSE;
  79. }
  80. HRESULT __stdcall CImeCallback::Notify(UINT notify, WPARAM wParam, LPARAM lParam)
  81. {
  82. HWND hUIWnd;
  83. #ifdef _DEBUG
  84. CHAR szBuf[256];
  85. wsprintf(szBuf, "Cimecallback::NOtify notify [%d]\n", notify);
  86. OutputDebugString(szBuf);
  87. #endif
  88. switch(notify) {
  89. case IMECBNOTIFY_IMEPADCLOSED:
  90. //----------------------------------------------------------------
  91. //ImePad has Closed. repaint toolbar...
  92. //----------------------------------------------------------------
  93. // UI::IMEPadNotify();
  94. hUIWnd = GetActiveUIWnd();
  95. if (hUIWnd)
  96. {
  97. OurPostMessage(hUIWnd, WM_MSIME_UPDATETOOLBAR, 0, 0);
  98. }
  99. break;
  100. default:
  101. break;
  102. }
  103. return S_OK;
  104. UNREFERENCED_PARAMETER(wParam);
  105. UNREFERENCED_PARAMETER(lParam);
  106. }