OptionsCopyBuffers.cpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // OptionsCopyBuffers.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CP_Main.h"
  5. #include "OptionsCopyBuffers.h"
  6. // COptionsCopyBuffers dialog
  7. IMPLEMENT_DYNCREATE(COptionsCopyBuffers, CPropertyPage)
  8. COptionsCopyBuffers::COptionsCopyBuffers() : CPropertyPage(COptionsCopyBuffers::IDD)
  9. {
  10. m_csTitle = theApp.m_Language.GetString("CopyBuffers", "Copy Buffers");
  11. m_psp.pszTitle = m_csTitle;
  12. m_psp.dwFlags |= PSP_USETITLE;
  13. }
  14. COptionsCopyBuffers::~COptionsCopyBuffers()
  15. {
  16. }
  17. void COptionsCopyBuffers::DoDataExchange(CDataExchange* pDX)
  18. {
  19. CDialog::DoDataExchange(pDX);
  20. DDX_Control(pDX, IDC_COPY_1, m_CopyBuffer1);
  21. DDX_Control(pDX, IDC_PASTE_1, m_PasteBuffer1);
  22. DDX_Control(pDX, IDC_CUT_1, m_CutBuffer1);
  23. DDX_Control(pDX, IDC_COPY_2, m_CopyBuffer2);
  24. DDX_Control(pDX, IDC_PASTE_2, m_PasteBuffer2);
  25. DDX_Control(pDX, IDC_CUT_2, m_CutBuffer2);
  26. DDX_Control(pDX, IDC_COPY_3, m_CopyBuffer3);
  27. DDX_Control(pDX, IDC_PASTE_3, m_PasteBuffer3);
  28. DDX_Control(pDX, IDC_CUT_3, m_CutBuffer3);
  29. DDX_Control(pDX, IDC_COPY_4, m_CopyBuffer4);
  30. DDX_Control(pDX, IDC_PASTE_4, m_PasteBuffer4);
  31. DDX_Control(pDX, IDC_CUT_4, m_CutBuffer4);
  32. DDX_Control(pDX, IDC_COPY_5, m_CopyBuffer5);
  33. DDX_Control(pDX, IDC_PASTE_5, m_PasteBuffer5);
  34. DDX_Control(pDX, IDC_CUT_5, m_CutBuffer5);
  35. }
  36. BEGIN_MESSAGE_MAP(COptionsCopyBuffers, CPropertyPage)
  37. END_MESSAGE_MAP()
  38. BOOL COptionsCopyBuffers::OnInitDialog()
  39. {
  40. CPropertyPage::OnInitDialog();
  41. CCopyBufferItem Item;
  42. g_Opt.GetCopyBufferItem(0, Item);
  43. theApp.m_pCopyBuffer1->CopyToCtrl(m_CopyBuffer1, m_hWnd, IDC_WIN_COPY_1);
  44. theApp.m_pPasteBuffer1->CopyToCtrl(m_PasteBuffer1, m_hWnd, IDC_WIN_PASTE_1);
  45. theApp.m_pCutBuffer1->CopyToCtrl(m_CutBuffer1, m_hWnd, IDC_WIN_CUT_1);
  46. CheckDlgButton(IDC_PLAY_SOUND_1, Item.m_bPlaySoundOnCopy);
  47. g_Opt.GetCopyBufferItem(1, Item);
  48. theApp.m_pCopyBuffer2->CopyToCtrl(m_CopyBuffer2, m_hWnd, IDC_WIN_COPY_2);
  49. theApp.m_pPasteBuffer2->CopyToCtrl(m_PasteBuffer2, m_hWnd, IDC_WIN_PASTE_2);
  50. theApp.m_pCutBuffer2->CopyToCtrl(m_CutBuffer2, m_hWnd, IDC_WIN_CUT_2);
  51. CheckDlgButton(IDC_PLAY_SOUND_2, Item.m_bPlaySoundOnCopy);
  52. g_Opt.GetCopyBufferItem(2, Item);
  53. theApp.m_pCopyBuffer3->CopyToCtrl(m_CopyBuffer3, m_hWnd, IDC_WIN_COPY_3);
  54. theApp.m_pPasteBuffer3->CopyToCtrl(m_PasteBuffer3, m_hWnd, IDC_WIN_PASTE_3);
  55. theApp.m_pCutBuffer3->CopyToCtrl(m_CutBuffer3, m_hWnd, IDC_WIN_CUT_3);
  56. CheckDlgButton(IDC_PLAY_SOUND_3, Item.m_bPlaySoundOnCopy);
  57. g_Opt.GetCopyBufferItem(3, Item);
  58. theApp.m_pCopyBuffer4->CopyToCtrl(m_CopyBuffer4, m_hWnd, IDC_WIN_COPY_4);
  59. theApp.m_pPasteBuffer4->CopyToCtrl(m_PasteBuffer4, m_hWnd, IDC_WIN_PASTE_4);
  60. theApp.m_pCutBuffer4->CopyToCtrl(m_CutBuffer4, m_hWnd, IDC_WIN_CUT_4);
  61. CheckDlgButton(IDC_PLAY_SOUND_4, Item.m_bPlaySoundOnCopy);
  62. g_Opt.GetCopyBufferItem(4, Item);
  63. theApp.m_pCopyBuffer5->CopyToCtrl(m_CopyBuffer5, m_hWnd, IDC_WIN_COPY_5);
  64. theApp.m_pPasteBuffer5->CopyToCtrl(m_PasteBuffer5, m_hWnd, IDC_WIN_PASTE_5);
  65. theApp.m_pCutBuffer5->CopyToCtrl(m_CutBuffer5, m_hWnd, IDC_WIN_CUT_5);
  66. CheckDlgButton(IDC_PLAY_SOUND_5, Item.m_bPlaySoundOnCopy);
  67. theApp.m_Language.UpdateOptionCopyBuffers(this);
  68. return TRUE;
  69. }
  70. BOOL COptionsCopyBuffers::OnApply()
  71. {
  72. ARRAY keys;
  73. g_HotKeys.GetKeys(keys); // save old keys just in case new ones are invalid
  74. theApp.m_pCopyBuffer1->CopyFromCtrl(m_CopyBuffer1, m_hWnd, IDC_WIN_COPY_1);
  75. theApp.m_pPasteBuffer1->CopyFromCtrl(m_PasteBuffer1, m_hWnd, IDC_WIN_PASTE_1);
  76. theApp.m_pCutBuffer1->CopyFromCtrl(m_CutBuffer1, m_hWnd, IDC_WIN_CUT_1);
  77. theApp.m_pCopyBuffer2->CopyFromCtrl(m_CopyBuffer2, m_hWnd, IDC_WIN_COPY_2);
  78. theApp.m_pPasteBuffer2->CopyFromCtrl(m_PasteBuffer2, m_hWnd, IDC_WIN_PASTE_2);
  79. theApp.m_pCutBuffer2->CopyFromCtrl(m_CutBuffer2, m_hWnd, IDC_WIN_CUT_2);
  80. theApp.m_pCopyBuffer3->CopyFromCtrl(m_CopyBuffer3, m_hWnd, IDC_WIN_COPY_3);
  81. theApp.m_pPasteBuffer3->CopyFromCtrl(m_PasteBuffer3, m_hWnd, IDC_WIN_PASTE_3);
  82. theApp.m_pCutBuffer3->CopyFromCtrl(m_CutBuffer3, m_hWnd, IDC_WIN_CUT_3);
  83. theApp.m_pCopyBuffer4->CopyFromCtrl(m_CopyBuffer4, m_hWnd, IDC_WIN_COPY_4);
  84. theApp.m_pPasteBuffer4->CopyFromCtrl(m_PasteBuffer4, m_hWnd, IDC_WIN_PASTE_4);
  85. theApp.m_pCutBuffer4->CopyFromCtrl(m_CutBuffer4, m_hWnd, IDC_WIN_CUT_4);
  86. theApp.m_pCopyBuffer5->CopyFromCtrl(m_CopyBuffer5, m_hWnd, IDC_WIN_COPY_5);
  87. theApp.m_pPasteBuffer5->CopyFromCtrl(m_PasteBuffer5, m_hWnd, IDC_WIN_PASTE_5);
  88. theApp.m_pCutBuffer5->CopyFromCtrl(m_CutBuffer5, m_hWnd, IDC_WIN_CUT_5);
  89. CCopyBufferItem Item;
  90. g_Opt.GetCopyBufferItem(0, Item);
  91. Item.m_bPlaySoundOnCopy = IsDlgButtonChecked(IDC_PLAY_SOUND_1);
  92. g_Opt.SetCopyBufferItem(0, Item);
  93. g_Opt.GetCopyBufferItem(1, Item);
  94. Item.m_bPlaySoundOnCopy = IsDlgButtonChecked(IDC_PLAY_SOUND_2);
  95. g_Opt.SetCopyBufferItem(1, Item);
  96. g_Opt.GetCopyBufferItem(2, Item);
  97. Item.m_bPlaySoundOnCopy = IsDlgButtonChecked(IDC_PLAY_SOUND_3);
  98. g_Opt.SetCopyBufferItem(2, Item);
  99. g_Opt.GetCopyBufferItem(3, Item);
  100. Item.m_bPlaySoundOnCopy = IsDlgButtonChecked(IDC_PLAY_SOUND_4);
  101. g_Opt.SetCopyBufferItem(3, Item);
  102. g_Opt.GetCopyBufferItem(4, Item);
  103. Item.m_bPlaySoundOnCopy = IsDlgButtonChecked(IDC_PLAY_SOUND_5);
  104. g_Opt.SetCopyBufferItem(4, Item);
  105. INT_PTR x;
  106. INT_PTR y;
  107. ARRAY NewKeys;
  108. g_HotKeys.GetKeys(NewKeys);
  109. if(g_HotKeys.FindFirstConflict(NewKeys, &x, &y))
  110. {
  111. CString str = g_HotKeys.ElementAt(x)->GetName();
  112. str += " and ";
  113. str += g_HotKeys.ElementAt(y)->GetName();
  114. str += " cannot be the same.";
  115. MessageBox(str);
  116. g_HotKeys.SetKeys(keys); // restore the original values
  117. return FALSE;
  118. }
  119. g_HotKeys.SaveAllKeys();
  120. g_HotKeys.RegisterAll(true);
  121. return CPropertyPage::OnApply();
  122. }