GlobalClips.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. // GlobalClips.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CP_Main.h"
  5. #include "GlobalClips.h"
  6. #include "afxdialogex.h"
  7. #include "CopyProperties.h"
  8. // GlobalClips dialog
  9. IMPLEMENT_DYNAMIC(GlobalClips, CDialogEx)
  10. GlobalClips::GlobalClips(CWnd* pParent /*=NULL*/)
  11. : CDialogEx(GlobalClips::IDD, pParent)
  12. {
  13. }
  14. GlobalClips::~GlobalClips()
  15. {
  16. }
  17. void GlobalClips::DoDataExchange(CDataExchange* pDX)
  18. {
  19. CDialogEx::DoDataExchange(pDX);
  20. DDX_Control(pDX, IDC_LIST2, m_List);
  21. }
  22. BEGIN_MESSAGE_MAP(GlobalClips, CDialogEx)
  23. ON_WM_CLOSE()
  24. ON_WM_SIZE()
  25. ON_WM_NCDESTROY()
  26. END_MESSAGE_MAP()
  27. BOOL GlobalClips::OnInitDialog()
  28. {
  29. CDialogEx::OnInitDialog();
  30. theApp.m_Language.UpdateGlobalHotKeys(this);
  31. m_Resize.SetParent(m_hWnd);
  32. m_Resize.AddControl(IDC_LIST2, DR_SizeHeight | DR_SizeWidth);
  33. m_Resize.AddControl(IDCANCEL, DR_MoveTop | DR_MoveLeft);
  34. InitListCtrlCols();
  35. LoadItems();
  36. return TRUE;
  37. }
  38. void GlobalClips::LoadItems()
  39. {
  40. m_List.DeleteAllItems();
  41. // Use the LV_ITEM structure to insert the items
  42. LVITEM lvi;
  43. CString strItem;
  44. int count = (int)g_HotKeys.GetCount();
  45. int row = 0;
  46. for (int i = 0; i < count; i++)
  47. {
  48. CHotKey *pHotKey = g_HotKeys[i];
  49. if(pHotKey->m_Key <= 0)
  50. {
  51. continue;
  52. }
  53. // Insert the first item
  54. lvi.mask = LVIF_TEXT;
  55. lvi.iItem = row;
  56. strItem = pHotKey->m_Name;
  57. if(pHotKey->m_clipId > 0)
  58. {
  59. strItem = pHotKey->m_description;
  60. if(pHotKey->m_hkType == CHotKey::PASTE_OPEN_CLIP)
  61. {
  62. strItem.Insert(0, theApp.m_Language.GetGlobalHotKeyString("(Clip)", "(Clip) "));
  63. }
  64. else if(pHotKey->m_hkType == CHotKey::MOVE_TO_GROUP)
  65. {
  66. strItem.Insert(0, _T("(Move To Group) "));
  67. }
  68. }
  69. lvi.iSubItem = 0;
  70. lvi.pszText = (LPTSTR)(LPCTSTR)(strItem);
  71. m_List.InsertItem(&lvi);
  72. strItem = pHotKey->GetHotKeyDisplay();
  73. m_List.SetItemText(row, 1, strItem);
  74. strItem = theApp.m_Language.GetGlobalHotKeyString("Error", "Error");
  75. if(pHotKey->IsRegistered())
  76. {
  77. strItem = theApp.m_Language.GetGlobalHotKeyString("Yes", "Yes");
  78. }
  79. m_List.SetItemText(row, 2, strItem);
  80. m_List.SetItemData(row, pHotKey->m_globalId);
  81. row++;
  82. }
  83. }
  84. void GlobalClips::InitListCtrlCols()
  85. {
  86. m_List.SetExtendedStyle(LVS_EX_FULLROWSELECT);
  87. m_List.InsertColumn(0, theApp.m_Language.GetGlobalHotKeyString("Description", "Description"), LVCFMT_LEFT, 200);
  88. m_List.InsertColumn(1, theApp.m_Language.GetGlobalHotKeyString("HotKey", "Hot Key"), LVCFMT_LEFT, 100);
  89. m_List.InsertColumn(2, theApp.m_Language.GetGlobalHotKeyString("Registered", "Registered"), LVCFMT_LEFT, 100);
  90. }
  91. void GlobalClips::SetNotifyWnd(HWND hWnd)
  92. {
  93. m_hWndParent = hWnd;
  94. }
  95. void GlobalClips::OnClose()
  96. {
  97. DestroyWindow();
  98. }
  99. void GlobalClips::OnCancel()
  100. {
  101. DestroyWindow();
  102. }
  103. void GlobalClips::OnSize(UINT nType, int cx, int cy)
  104. {
  105. CDialogEx::OnSize(nType, cx, cy);
  106. m_Resize.MoveControls(CSize(cx, cy));
  107. }
  108. //void GlobalClips::OnBnClickedButtonRefresh()
  109. //{
  110. // LoadItems();
  111. //}
  112. //
  113. //void GlobalClips::OnNMDblclkList2(NMHDR *pNMHDR, LRESULT *pResult)
  114. //{
  115. // LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
  116. // // TODO: Add your control notification handler code here
  117. //
  118. // int id = (int)m_List.GetItemData(pNMItemActivate->iItem);
  119. //
  120. // int count = (int)g_HotKeys.GetCount();
  121. //
  122. // int row = 0;
  123. // for (int i = 0; i < count; i++)
  124. // {
  125. // CHotKey *pHotKey = g_HotKeys[i];
  126. //
  127. // if(pHotKey->m_globalId == id)
  128. // {
  129. // if(pHotKey->m_clipId > 0)
  130. // {
  131. // CCopyProperties props(pHotKey->m_clipId, this);
  132. // props.SetToTopMost(false);
  133. // INT_PTR doModalRet = props.DoModal();
  134. //
  135. // if(doModalRet == IDOK)
  136. // {
  137. // }
  138. // }
  139. // else
  140. // {
  141. //
  142. // }
  143. // break;
  144. // }
  145. // }
  146. //
  147. // *pResult = 0;
  148. //}
  149. void GlobalClips::OnNcDestroy()
  150. {
  151. CDialogEx::OnNcDestroy();
  152. ::PostMessage(m_hWndParent, WM_GLOBAL_CLIPS_CLOSED, 0, 0);
  153. }