DlgOptions.cpp
上传用户:lds876
上传日期:2013-05-25
资源大小:567k
文件大小:4k
源码类别:

P2P编程

开发平台:

Visual C++

  1. // DlgOptions.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "testbt.h"
  5. #include "DlgOptions.h"
  6. #include "MainFrm.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CDlgOptions dialog
  14. CDlgOptions::CDlgOptions(CWnd* pParent /*=NULL*/)
  15. : CPropertyPage(CDlgOptions::IDD)
  16. {
  17. m_dwHotKey = 0;
  18. //{{AFX_DATA_INIT(CDlgOptions)
  19. m_bHideTray = FALSE;
  20. //}}AFX_DATA_INIT
  21. }
  22. void CDlgOptions::DoDataExchange(CDataExchange* pDX)
  23. {
  24. CPropertyPage::DoDataExchange(pDX);
  25. //{{AFX_DATA_MAP(CDlgOptions)
  26. DDX_Control(pDX, IDC_GROUP_HOTKEY, m_gpHotkey);
  27. DDX_Control(pDX, IDC_GROUP_FILEMAN, m_gpFileMan);
  28. DDX_Control(pDX, IDC_HOTKEY_BOSS, m_hkBoss);
  29. DDX_Check(pDX, IDC_CHECK_HIDE_TRAY, m_bHideTray);
  30. DDX_Control(pDX, IDC_COMBO_WHEN_SAMENAME_EXIST, m_cbSavenameExist);
  31. DDX_Control(pDX, IDC_COMBO_MOVETO_CATE, m_cbMovetoCate);
  32. DDX_Control(pDX, IDC_COMBO_DBCLICK_ITEM, m_cbDbclickItem);
  33. //}}AFX_DATA_MAP
  34. }
  35. BEGIN_MESSAGE_MAP(CDlgOptions, CPropertyPage)
  36. //{{AFX_MSG_MAP(CDlgOptions)
  37. //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CDlgOptions message handlers
  41. BOOL CDlgOptions::OnInitDialog() 
  42. {
  43. CPropertyPage::OnInitDialog();
  44. m_hkBoss.SetRules(HKCOMB_NONE|// HKCOMB_A|
  45. HKCOMB_S|HKCOMB_CA|HKCOMB_SA|
  46. HKCOMB_SC|HKCOMB_SCA,HOTKEYF_CONTROL);
  47. m_hkBoss.SetFocus();
  48. for (int i=0; i<CSetupRegister::eSameNameCount; i++)
  49. m_cbSavenameExist.AddString(CSetupRegister::m_strOperSameName[i]);
  50. for (i=0; i<CSetupRegister::eMoveCateCount; i++)
  51. m_cbMovetoCate.AddString(CSetupRegister::m_strOperMovetoCate[i]);
  52. for (i=0; i<CSetupRegister::eDbclickCount; i++)
  53. m_cbDbclickItem.AddString(CSetupRegister::m_strOperDbclick[i]);
  54. return FALSE;
  55. }
  56. bool CDlgOptions::Apply()
  57. {
  58. UpdateData();
  59. UnregisterHotKey(AfxGetMainWnd()->GetSafeHwnd(), HOTKEY_ID);
  60. // must use Tray to restore mainframe.
  61. DWORD dwHotKey = m_hkBoss.GetHotKey();
  62. if (!dwHotKey)
  63. m_bHideTray = false;
  64. if (!::RegisterHotKey(AfxGetMainWnd()->GetSafeHwnd(), HOTKEY_ID, HIBYTE(dwHotKey), LOBYTE(dwHotKey)))
  65. {
  66. AfxMessageBox("注册热健失败");
  67. }
  68. m_dwHotKey = dwHotKey;
  69. return true;
  70. }
  71. void CDlgOptions::SetData(CSetupRegister *pSetupRegister)
  72. {
  73. m_bHideTray = pSetupRegister->m_bHideTray;
  74. m_dwHotKey = pSetupRegister->m_dwHotKey;
  75. m_hkBoss.SetHotKey(LOBYTE(m_dwHotKey), HIBYTE(m_dwHotKey));
  76. m_cbSavenameExist.SetCurSel(pSetupRegister->m_eOperSavenameExist);
  77. m_cbMovetoCate.SetCurSel(pSetupRegister->m_eOperMoveToCate);
  78. m_cbDbclickItem.SetCurSel(pSetupRegister->m_eOperDbclickItem);
  79. UpdateData(false);
  80. }
  81. void CDlgOptions::GetData(CSetupRegister *pSetupRegister)
  82. {
  83. UpdateData();
  84. pSetupRegister->m_bHideTray = m_bHideTray;
  85. pSetupRegister->m_dwHotKey = m_dwHotKey ;
  86. pSetupRegister->m_eOperSavenameExist = (CSetupRegister::eOperSameNameExist)m_cbSavenameExist.GetCurSel();
  87. pSetupRegister->m_eOperMoveToCate = (CSetupRegister::eOperMoveToCate)m_cbMovetoCate.GetCurSel();
  88. pSetupRegister->m_eOperDbclickItem = (CSetupRegister::eOperDbclickItem)m_cbDbclickItem.GetCurSel();
  89. }
  90. void CDlgOptions::OnOK() 
  91. {
  92. GetParent()->SendMessage(WM_COMMAND, IDOK, 0);
  93. CPropertyPage::OnOK();
  94. }
  95. void CDlgOptions::OnCancel() 
  96. {
  97. GetParent()->SendMessage(WM_COMMAND, IDCANCEL, 0);
  98. CPropertyPage::OnCancel();
  99. }
  100. /*******************************************************
  101. WORD VirtualKeyCode;
  102. WORD Modifiers;
  103. m_hkBoss.GetHotKey(VirtualKeyCode, Modifiers);
  104. if (VirtualKeyCode == 0)
  105. {
  106. // AfxMessageBox("请输入热健");
  107. // m_hkBoss.SetFocus();
  108. // return ;
  109. }
  110. ********************************************************/