OptionsCopyBuffers.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. }
  30. BEGIN_MESSAGE_MAP(COptionsCopyBuffers, CPropertyPage)
  31. END_MESSAGE_MAP()
  32. BOOL COptionsCopyBuffers::OnInitDialog()
  33. {
  34. CPropertyPage::OnInitDialog();
  35. CCopyBufferItem Item;
  36. g_Opt.GetCopyBufferItem(0, Item);
  37. theApp.m_pCopyBuffer1->CopyToCtrl(m_CopyBuffer1, m_hWnd, IDC_WIN_COPY_1);
  38. theApp.m_pPasteBuffer1->CopyToCtrl(m_PasteBuffer1, m_hWnd, IDC_WIN_PASTE_1);
  39. theApp.m_pCutBuffer1->CopyToCtrl(m_CutBuffer1, m_hWnd, IDC_WIN_CUT_1);
  40. CheckDlgButton(IDC_PLAY_SOUND_1, Item.m_bPlaySoundOnCopy);
  41. g_Opt.GetCopyBufferItem(1, Item);
  42. theApp.m_pCopyBuffer2->CopyToCtrl(m_CopyBuffer2, m_hWnd, IDC_WIN_COPY_2);
  43. theApp.m_pPasteBuffer2->CopyToCtrl(m_PasteBuffer2, m_hWnd, IDC_WIN_PASTE_2);
  44. theApp.m_pCutBuffer2->CopyToCtrl(m_CutBuffer2, m_hWnd, IDC_WIN_CUT_2);
  45. CheckDlgButton(IDC_PLAY_SOUND_2, Item.m_bPlaySoundOnCopy);
  46. g_Opt.GetCopyBufferItem(2, Item);
  47. theApp.m_pCopyBuffer3->CopyToCtrl(m_CopyBuffer3, m_hWnd, IDC_WIN_COPY_3);
  48. theApp.m_pPasteBuffer3->CopyToCtrl(m_PasteBuffer3, m_hWnd, IDC_WIN_PASTE_3);
  49. theApp.m_pCutBuffer3->CopyToCtrl(m_CutBuffer3, m_hWnd, IDC_WIN_CUT_3);
  50. CheckDlgButton(IDC_PLAY_SOUND_3, Item.m_bPlaySoundOnCopy);
  51. theApp.m_Language.UpdateOptionCopyBuffers(this);
  52. return TRUE;
  53. }
  54. BOOL COptionsCopyBuffers::OnApply()
  55. {
  56. ARRAY keys;
  57. g_HotKeys.GetKeys(keys); // save old keys just in case new ones are invalid
  58. theApp.m_pCopyBuffer1->CopyFromCtrl(m_CopyBuffer1, m_hWnd, IDC_WIN_COPY_1);
  59. theApp.m_pPasteBuffer1->CopyFromCtrl(m_PasteBuffer1, m_hWnd, IDC_WIN_PASTE_1);
  60. theApp.m_pCutBuffer1->CopyFromCtrl(m_CutBuffer1, m_hWnd, IDC_WIN_CUT_1);
  61. theApp.m_pCopyBuffer2->CopyFromCtrl(m_CopyBuffer2, m_hWnd, IDC_WIN_COPY_2);
  62. theApp.m_pPasteBuffer2->CopyFromCtrl(m_PasteBuffer2, m_hWnd, IDC_WIN_PASTE_2);
  63. theApp.m_pCutBuffer2->CopyFromCtrl(m_CutBuffer2, m_hWnd, IDC_WIN_CUT_2);
  64. theApp.m_pCopyBuffer3->CopyFromCtrl(m_CopyBuffer3, m_hWnd, IDC_WIN_COPY_3);
  65. theApp.m_pPasteBuffer3->CopyFromCtrl(m_PasteBuffer3, m_hWnd, IDC_WIN_PASTE_3);
  66. theApp.m_pCutBuffer3->CopyFromCtrl(m_CutBuffer3, m_hWnd, IDC_WIN_CUT_3);
  67. CCopyBufferItem Item;
  68. g_Opt.GetCopyBufferItem(0, Item);
  69. Item.m_bPlaySoundOnCopy = IsDlgButtonChecked(IDC_PLAY_SOUND_1);
  70. g_Opt.SetCopyBufferItem(0, Item);
  71. g_Opt.GetCopyBufferItem(1, Item);
  72. Item.m_bPlaySoundOnCopy = IsDlgButtonChecked(IDC_PLAY_SOUND_2);
  73. g_Opt.SetCopyBufferItem(1, Item);
  74. g_Opt.GetCopyBufferItem(2, Item);
  75. Item.m_bPlaySoundOnCopy = IsDlgButtonChecked(IDC_PLAY_SOUND_3);
  76. g_Opt.SetCopyBufferItem(2, Item);
  77. INT_PTR x;
  78. INT_PTR y;
  79. ARRAY NewKeys;
  80. g_HotKeys.GetKeys(NewKeys);
  81. if(g_HotKeys.FindFirstConflict(NewKeys, &x, &y))
  82. {
  83. CString str = g_HotKeys.ElementAt(x)->GetName();
  84. str += " and ";
  85. str += g_HotKeys.ElementAt(y)->GetName();
  86. str += " cannot be the same.";
  87. MessageBox(str);
  88. g_HotKeys.SetKeys(keys); // restore the original values
  89. return FALSE;
  90. }
  91. g_HotKeys.SaveAllKeys();
  92. g_HotKeys.RegisterAll(true);
  93. return CPropertyPage::OnApply();
  94. }