Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
4.9 KiB

  1. // HMHistoryPage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "snapin.h"
  5. #include "HMHistoryPage.h"
  6. #include "HMObject.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CHMHistoryPage property page
  14. IMPLEMENT_DYNCREATE(CHMHistoryPage, CHMPropertyPage)
  15. CHMHistoryPage::CHMHistoryPage() : CHMPropertyPage(CHMHistoryPage::IDD)
  16. {
  17. EnableAutomation();
  18. //{{AFX_DATA_INIT(CHMHistoryPage)
  19. m_iRefreshSelection = -1;
  20. m_iTimePeriod = 0;
  21. m_iNumberEvents = 0;
  22. //}}AFX_DATA_INIT
  23. m_sHelpTopic = _T("HMon21.chm::/dhmonhis.htm");
  24. }
  25. CHMHistoryPage::~CHMHistoryPage()
  26. {
  27. }
  28. void CHMHistoryPage::OnFinalRelease()
  29. {
  30. // When the last reference for an automation object is released
  31. // OnFinalRelease is called. The base class will automatically
  32. // deletes the object. Add additional cleanup required for your
  33. // object before calling the base class.
  34. CHMPropertyPage::OnFinalRelease();
  35. }
  36. void CHMHistoryPage::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CHMPropertyPage::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CHMHistoryPage)
  40. DDX_Control(pDX, IDC_SPIN7, m_TimeSpin);
  41. DDX_Control(pDX, IDC_SPIN1, m_EventSpin);
  42. DDX_Control(pDX, IDC_COMBO_TIME, m_TimeUnits);
  43. DDX_Radio(pDX, IDC_RADIO_NONE, m_iRefreshSelection);
  44. DDX_Text(pDX, IDC_EDIT_TIME_PERIOD, m_iTimePeriod);
  45. DDX_Text(pDX, IDC_EDIT_NUMBER_EVENTS, m_iNumberEvents);
  46. //}}AFX_DATA_MAP
  47. if( pDX->m_bSaveAndValidate )
  48. {
  49. m_Units = (TimeUnit)m_TimeUnits.GetCurSel();
  50. }
  51. else
  52. {
  53. m_TimeUnits.SetCurSel(m_Units);
  54. }
  55. switch( m_iRefreshSelection )
  56. {
  57. case 0: // None
  58. {
  59. GetDlgItem(IDC_EDIT_NUMBER_EVENTS)->EnableWindow(FALSE);
  60. GetDlgItem(IDC_SPIN7)->EnableWindow(FALSE);
  61. GetDlgItem(IDC_EDIT_TIME_PERIOD)->EnableWindow(FALSE);
  62. GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);
  63. GetDlgItem(IDC_COMBO_TIME)->EnableWindow(FALSE);
  64. }
  65. break;
  66. case 1: // Refresh by count of events
  67. {
  68. GetDlgItem(IDC_EDIT_NUMBER_EVENTS)->EnableWindow(TRUE);
  69. GetDlgItem(IDC_SPIN7)->EnableWindow(TRUE);
  70. GetDlgItem(IDC_EDIT_TIME_PERIOD)->EnableWindow(FALSE);
  71. GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);
  72. GetDlgItem(IDC_COMBO_TIME)->EnableWindow(FALSE);
  73. }
  74. break;
  75. case 2: // Refresh by time period
  76. {
  77. GetDlgItem(IDC_EDIT_NUMBER_EVENTS)->EnableWindow(FALSE);
  78. GetDlgItem(IDC_SPIN7)->EnableWindow(FALSE);
  79. GetDlgItem(IDC_EDIT_TIME_PERIOD)->EnableWindow(TRUE);
  80. GetDlgItem(IDC_SPIN1)->EnableWindow(TRUE);
  81. GetDlgItem(IDC_COMBO_TIME)->EnableWindow(TRUE);
  82. }
  83. break;
  84. }
  85. }
  86. BEGIN_MESSAGE_MAP(CHMHistoryPage, CHMPropertyPage)
  87. //{{AFX_MSG_MAP(CHMHistoryPage)
  88. ON_BN_CLICKED(IDC_RADIO_NONE, OnRadioNone)
  89. ON_BN_CLICKED(IDC_RADIO_NUMBER_EVENTS, OnRadioNumberEvents)
  90. ON_BN_CLICKED(IDC_RADIO_TIME_PERIOD, OnRadioTimePeriod)
  91. //}}AFX_MSG_MAP
  92. END_MESSAGE_MAP()
  93. BEGIN_DISPATCH_MAP(CHMHistoryPage, CHMPropertyPage)
  94. //{{AFX_DISPATCH_MAP(CHMHistoryPage)
  95. // NOTE - the ClassWizard will add and remove mapping macros here.
  96. //}}AFX_DISPATCH_MAP
  97. END_DISPATCH_MAP()
  98. // Note: we add support for IID_IHMHistoryPage to support typesafe binding
  99. // from VBA. This IID must match the GUID that is attached to the
  100. // dispinterface in the .ODL file.
  101. // {C3F44E6E-BA00-11D2-BD76-0000F87A3912}
  102. static const IID IID_IHMHistoryPage =
  103. { 0xc3f44e6e, 0xba00, 0x11d2, { 0xbd, 0x76, 0x0, 0x0, 0xf8, 0x7a, 0x39, 0x12 } };
  104. BEGIN_INTERFACE_MAP(CHMHistoryPage, CHMPropertyPage)
  105. INTERFACE_PART(CHMHistoryPage, IID_IHMHistoryPage, Dispatch)
  106. END_INTERFACE_MAP()
  107. /////////////////////////////////////////////////////////////////////////////
  108. // CHMHistoryPage message handlers
  109. BOOL CHMHistoryPage::OnInitDialog()
  110. {
  111. CHMPropertyPage::OnInitDialog();
  112. CHMObject* pObject = GetObjectPtr();
  113. if( ! pObject )
  114. {
  115. return FALSE;
  116. }
  117. m_iRefreshSelection = pObject->GetRefreshType();
  118. m_iNumberEvents = pObject->GetRefreshEventCount();
  119. pObject->GetRefreshTimePeriod(m_iTimePeriod,m_Units);
  120. UpdateData(FALSE);
  121. m_EventSpin.SetRange32(0,INT_MAX-1);
  122. m_TimeSpin.SetRange32(0,INT_MAX-1);
  123. return TRUE; // return TRUE unless you set the focus to a control
  124. // EXCEPTION: OCX Property Pages should return FALSE
  125. }
  126. void CHMHistoryPage::OnOK()
  127. {
  128. CHMPropertyPage::OnOK();
  129. }
  130. void CHMHistoryPage::OnRadioNone()
  131. {
  132. UpdateData();
  133. SetModified();
  134. }
  135. void CHMHistoryPage::OnRadioNumberEvents()
  136. {
  137. UpdateData();
  138. SetModified();
  139. }
  140. void CHMHistoryPage::OnRadioTimePeriod()
  141. {
  142. UpdateData();
  143. SetModified();
  144. }
  145. BOOL CHMHistoryPage::OnApply()
  146. {
  147. if( ! CHMPropertyPage::OnApply() )
  148. {
  149. return FALSE;
  150. }
  151. UpdateData();
  152. CHMObject* pObject = GetObjectPtr();
  153. if( ! pObject )
  154. {
  155. return FALSE;
  156. }
  157. pObject->SetRefreshType(m_iRefreshSelection);
  158. switch( m_iRefreshSelection )
  159. {
  160. case 0: // None
  161. {
  162. }
  163. break;
  164. case 1: // Refresh by count of events
  165. {
  166. pObject->SetRefreshEventCount(m_iNumberEvents);
  167. }
  168. break;
  169. case 2: // Refresh by time period
  170. {
  171. pObject->SetRefreshTimePeriod(m_iTimePeriod,m_Units);
  172. }
  173. break;
  174. }
  175. SetModified(FALSE);
  176. return TRUE;
  177. }