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.

156 lines
4.3 KiB

  1. /****************************************************************************
  2. HJMODE.CPP : HJMode class managing Hanja button on the Cicero Toolbar
  3. History:
  4. 25-FEB-2000 CSLim Created
  5. ****************************************************************************/
  6. #include "precomp.h"
  7. #include "hjmode.h"
  8. #include "gdata.h"
  9. #include "winex.h"
  10. #include "resource.h"
  11. // {F7410340-28E0-4aeb-ADBC-C579FD00B43D}
  12. const GUID GUID_LBI_KORIME_HJMODE =
  13. {
  14. 0xf7410340,
  15. 0x28e0,
  16. 0x4aeb,
  17. { 0xad, 0xbc, 0xc5, 0x79, 0xfd, 0x0, 0xb4, 0x3d }
  18. };
  19. /*---------------------------------------------------------------------------
  20. HJMode::HJMode
  21. ---------------------------------------------------------------------------*/
  22. HJMode::HJMode(CToolBar *ptb)
  23. {
  24. WCHAR szText[256];
  25. szText[0] = L'\0';
  26. m_pTb = ptb;
  27. // Set Add/Remove text and tootip text
  28. OurLoadStringW(vpInstData->hInst, IDS_STATUS_TT_HANJA_CONV, szText, sizeof(szText)/sizeof(WCHAR));
  29. InitInfo(CLSID_SYSTEMLANGBARITEM_KEYBOARD,
  30. GUID_LBI_KORIME_HJMODE,
  31. TF_LBI_STYLE_BTN_BUTTON | TF_LBI_STYLE_TEXTCOLORICON,
  32. 220,
  33. szText);
  34. SetToolTip(szText);
  35. // Set button text
  36. szText[0] = L'\0';
  37. OurLoadStringW(vpInstData->hInst, IDS_STATUS_BUTTON_HANJA_CONV, szText, sizeof(szText)/sizeof(WCHAR));
  38. SetText(szText);
  39. }
  40. /*---------------------------------------------------------------------------
  41. HJMode::Release
  42. ---------------------------------------------------------------------------*/
  43. STDAPI_(ULONG) HJMode::Release()
  44. {
  45. long cr;
  46. cr = --m_cRef;
  47. DbgAssert(cr >= 0);
  48. if (cr == 0)
  49. {
  50. delete this;
  51. }
  52. return cr;
  53. }
  54. /*---------------------------------------------------------------------------
  55. HJMode::GetIcon
  56. Get Button face Icon
  57. ---------------------------------------------------------------------------*/
  58. STDAPI HJMode::GetIcon(HICON *phIcon)
  59. {
  60. UINT uiIcon;
  61. if (IsHighContrastBlack())
  62. uiIcon = IDI_CMODE_HANJAW;
  63. else
  64. uiIcon = IDI_CMODE_HANJA;
  65. *phIcon = (HICON)LoadImage(vpInstData->hInst, MAKEINTRESOURCE(uiIcon), IMAGE_ICON, 16, 16, LR_LOADMAP3DCOLORS);
  66. return S_OK;
  67. }
  68. /*---------------------------------------------------------------------------
  69. HJMode::InitMenu
  70. No need, this is just toggle button
  71. ---------------------------------------------------------------------------*/
  72. STDAPI HJMode::InitMenu(ITfMenu *pMenu)
  73. {
  74. return E_NOTIMPL;
  75. }
  76. /*---------------------------------------------------------------------------
  77. HJMode::OnMenuSelect
  78. No need, this is just toggle button
  79. ---------------------------------------------------------------------------*/
  80. STDAPI HJMode::OnMenuSelect(UINT wID)
  81. {
  82. return E_NOTIMPL;
  83. }
  84. /*---------------------------------------------------------------------------
  85. HJMode::OnLButtonUp
  86. ---------------------------------------------------------------------------*/
  87. HRESULT HJMode::OnLButtonUp(const POINT pt, const RECT* prcArea)
  88. {
  89. keybd_event(VK_HANJA, 0, 0, 0);
  90. keybd_event(VK_HANJA, 0, KEYEVENTF_KEYUP, 0);
  91. return S_OK;
  92. }
  93. /*---------------------------------------------------------------------------
  94. HJMode::OnRButtonUp
  95. ---------------------------------------------------------------------------*/
  96. HRESULT HJMode::OnRButtonUp(const POINT pt, const RECT* prcArea)
  97. {
  98. /*
  99. HMENU hMenu;
  100. DWORD dwConvMode;
  101. hMenu = CreatePopupMenu();
  102. char *pszStatus = (GetCMode() & TIP_JUNJA_MODE) ? "Banja mode" : "Junja mode";
  103. InsertMenu(hMenu, -1, MF_BYPOSITION | MF_STRING, 1, pszStatus);
  104. InsertMenu(hMenu, -1, MF_BYPOSITION | MF_STRING, 0, "Cancel");
  105. int nRet = TrackPopupMenuEx(hMenu,
  106. TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD,
  107. pt.x, pt.y, m_pTb->GetOwnerWnd(), NULL);
  108. switch (nRet)
  109. {
  110. case 1:
  111. dwConvMode = GetCMode();
  112. // Toggle Full/Half mode
  113. if (dwConvMode & TIP_JUNJA_MODE)
  114. dwConvMode &= ~TIP_JUNJA_MODE;
  115. else
  116. dwConvMode |= TIP_JUNJA_MODE;
  117. SetCMode(dwConvMode);
  118. break;
  119. }
  120. DestroyMenu(hMenu);
  121. */
  122. return S_OK;
  123. }