OptionsCopyBuffers.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. }
  11. COptionsCopyBuffers::~COptionsCopyBuffers()
  12. {
  13. }
  14. void COptionsCopyBuffers::DoDataExchange(CDataExchange* pDX)
  15. {
  16. CDialog::DoDataExchange(pDX);
  17. DDX_Control(pDX, IDC_COPY_1, m_CopyBuffer1);
  18. DDX_Control(pDX, IDC_PASTE_1, m_PasteBuffer1);
  19. DDX_Control(pDX, IDC_CUT_1, m_CutBuffer1);
  20. DDX_Control(pDX, IDC_COPY_2, m_CopyBuffer2);
  21. DDX_Control(pDX, IDC_PASTE_2, m_PasteBuffer2);
  22. DDX_Control(pDX, IDC_CUT_2, m_CutBuffer2);
  23. DDX_Control(pDX, IDC_COPY_3, m_CopyBuffer3);
  24. DDX_Control(pDX, IDC_PASTE_3, m_PasteBuffer3);
  25. DDX_Control(pDX, IDC_CUT_3, m_CutBuffer3);
  26. }
  27. BEGIN_MESSAGE_MAP(COptionsCopyBuffers, CPropertyPage)
  28. END_MESSAGE_MAP()
  29. BOOL COptionsCopyBuffers::OnInitDialog()
  30. {
  31. CPropertyPage::OnInitDialog();
  32. CCopyBufferItem Item;
  33. g_Opt.GetCopyBufferItem(0, Item);
  34. theApp.m_pCopyBuffer1->CopyToCtrl(m_CopyBuffer1, m_hWnd, IDC_WIN_COPY_1);
  35. theApp.m_pPasteBuffer1->CopyToCtrl(m_PasteBuffer1, m_hWnd, IDC_WIN_PASTE_1);
  36. theApp.m_pCutBuffer1->CopyToCtrl(m_CutBuffer1, m_hWnd, IDC_WIN_CUT_1);
  37. CheckDlgButton(IDC_PLAY_SOUND_1, Item.m_bPlaySoundOnCopy);
  38. g_Opt.GetCopyBufferItem(1, Item);
  39. theApp.m_pCopyBuffer2->CopyToCtrl(m_CopyBuffer2, m_hWnd, IDC_WIN_COPY_2);
  40. theApp.m_pPasteBuffer2->CopyToCtrl(m_PasteBuffer2, m_hWnd, IDC_WIN_PASTE_2);
  41. theApp.m_pCutBuffer2->CopyToCtrl(m_CutBuffer2, m_hWnd, IDC_WIN_CUT_2);
  42. CheckDlgButton(IDC_PLAY_SOUND_2, Item.m_bPlaySoundOnCopy);
  43. g_Opt.GetCopyBufferItem(2, Item);
  44. theApp.m_pCopyBuffer3->CopyToCtrl(m_CopyBuffer3, m_hWnd, IDC_WIN_COPY_3);
  45. theApp.m_pPasteBuffer3->CopyToCtrl(m_PasteBuffer3, m_hWnd, IDC_WIN_PASTE_3);
  46. theApp.m_pCutBuffer3->CopyToCtrl(m_CutBuffer3, m_hWnd, IDC_WIN_CUT_3);
  47. CheckDlgButton(IDC_PLAY_SOUND_3, Item.m_bPlaySoundOnCopy);
  48. return TRUE;
  49. }
  50. BOOL COptionsCopyBuffers::OnApply()
  51. {
  52. ARRAY keys;
  53. g_HotKeys.GetKeys(keys); // save old keys just in case new ones are invalid
  54. theApp.m_pCopyBuffer1->CopyFromCtrl(m_CopyBuffer1, m_hWnd, IDC_WIN_COPY_1);
  55. theApp.m_pPasteBuffer1->CopyFromCtrl(m_PasteBuffer1, m_hWnd, IDC_WIN_PASTE_1);
  56. theApp.m_pCutBuffer1->CopyFromCtrl(m_CutBuffer1, m_hWnd, IDC_WIN_CUT_1);
  57. theApp.m_pCopyBuffer2->CopyFromCtrl(m_CopyBuffer2, m_hWnd, IDC_WIN_COPY_2);
  58. theApp.m_pPasteBuffer2->CopyFromCtrl(m_PasteBuffer2, m_hWnd, IDC_WIN_PASTE_2);
  59. theApp.m_pCutBuffer2->CopyFromCtrl(m_CutBuffer2, m_hWnd, IDC_WIN_CUT_2);
  60. theApp.m_pCopyBuffer3->CopyFromCtrl(m_CopyBuffer3, m_hWnd, IDC_WIN_COPY_3);
  61. theApp.m_pPasteBuffer3->CopyFromCtrl(m_PasteBuffer3, m_hWnd, IDC_WIN_PASTE_3);
  62. theApp.m_pCutBuffer3->CopyFromCtrl(m_CutBuffer3, m_hWnd, IDC_WIN_CUT_3);
  63. CCopyBufferItem Item;
  64. g_Opt.GetCopyBufferItem(0, Item);
  65. Item.m_bPlaySoundOnCopy = IsDlgButtonChecked(IDC_PLAY_SOUND_1);
  66. g_Opt.SetCopyBufferItem(0, Item);
  67. g_Opt.GetCopyBufferItem(1, Item);
  68. Item.m_bPlaySoundOnCopy = IsDlgButtonChecked(IDC_PLAY_SOUND_2);
  69. g_Opt.SetCopyBufferItem(1, Item);
  70. g_Opt.GetCopyBufferItem(2, Item);
  71. Item.m_bPlaySoundOnCopy = IsDlgButtonChecked(IDC_PLAY_SOUND_3);
  72. g_Opt.SetCopyBufferItem(2, Item);
  73. int x;
  74. int y;
  75. ARRAY NewKeys;
  76. g_HotKeys.GetKeys(NewKeys);
  77. if(g_HotKeys.FindFirstConflict(NewKeys, &x, &y))
  78. {
  79. CString str = g_HotKeys.ElementAt(x)->GetName();
  80. str += " and ";
  81. str += g_HotKeys.ElementAt(y)->GetName();
  82. str += " cannot be the same.";
  83. MessageBox(str);
  84. g_HotKeys.SetKeys(keys); // restore the original values
  85. return FALSE;
  86. }
  87. g_HotKeys.SaveAllKeys();
  88. g_HotKeys.RegisterAll(true);
  89. return CPropertyPage::OnApply();
  90. }