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.

156 lines
3.4 KiB

  1. // NewActionAssociationDlg.cpp : implementation file
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // 03/26/00 v-marfin 62211 : At least 1 state must be checked in order to close dlg
  6. #include "stdafx.h"
  7. #include "snapin.h"
  8. #include "NewActionAssociationDlg.h"
  9. #include <mmc.h>
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CNewActionAssociationDlg dialog
  17. CNewActionAssociationDlg::CNewActionAssociationDlg(CWnd* pParent /*=NULL*/)
  18. : CDialog(CNewActionAssociationDlg::IDD, pParent)
  19. {
  20. //{{AFX_DATA_INIT(CNewActionAssociationDlg)
  21. m_bCritical = FALSE;
  22. m_bDisabled = FALSE;
  23. m_bNoData = FALSE;
  24. m_bNormal = FALSE;
  25. m_bWarning = FALSE;
  26. m_iReminderTime = 0;
  27. m_iThrottleTime = 0;
  28. m_iThrottleUnits = 0;
  29. m_iReminderUnits = 0;
  30. //}}AFX_DATA_INIT
  31. m_iSelectedAction = 0;
  32. m_bEnableActionsComboBox = TRUE;
  33. }
  34. void CNewActionAssociationDlg::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CDialog::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(CNewActionAssociationDlg)
  38. DDX_Control(pDX, IDC_COMBO_ACTIONS, m_Actions);
  39. DDX_Check(pDX, IDC_CHECK_CRITICAL, m_bCritical);
  40. DDX_Check(pDX, IDC_CHECK_DISABLED, m_bDisabled);
  41. DDX_Check(pDX, IDC_CHECK_NO_DATA, m_bNoData);
  42. DDX_Check(pDX, IDC_CHECK_NORMAL, m_bNormal);
  43. DDX_Check(pDX, IDC_CHECK_WARNING, m_bWarning);
  44. DDX_Text(pDX, IDC_EDIT_REMINDER_TIME, m_iReminderTime);
  45. DDX_Text(pDX, IDC_EDIT_THROTTLE_TIME, m_iThrottleTime);
  46. DDX_CBIndex(pDX, IDC_COMBO_THROTTLE_UNITS, m_iThrottleUnits);
  47. DDX_CBIndex(pDX, IDC_COMBO_REMINDER_UNITS, m_iReminderUnits);
  48. //}}AFX_DATA_MAP
  49. }
  50. BEGIN_MESSAGE_MAP(CNewActionAssociationDlg, CDialog)
  51. //{{AFX_MSG_MAP(CNewActionAssociationDlg)
  52. ON_BN_CLICKED(IDC_BUTTON_HELP, OnButtonHelp)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CNewActionAssociationDlg message handlers
  57. BOOL CNewActionAssociationDlg::OnInitDialog()
  58. {
  59. CDialog::OnInitDialog();
  60. for( int i = 0; i < m_saActions.GetSize(); i++ )
  61. {
  62. m_Actions.AddString(m_saActions[i]);
  63. }
  64. m_Actions.SetCurSel(m_iSelectedAction);
  65. m_Actions.EnableWindow(m_bEnableActionsComboBox);
  66. SendDlgItemMessage(IDC_SPIN1,UDM_SETRANGE32,0,9999);
  67. SendDlgItemMessage(IDC_SPIN2,UDM_SETRANGE32,0,9999);
  68. return TRUE; // return TRUE unless you set the focus to a control
  69. // EXCEPTION: OCX Property Pages should return FALSE
  70. }
  71. void CNewActionAssociationDlg::OnOK()
  72. {
  73. // v-marfin 62211 : At least 1 state must be checked in order to close dlg
  74. UpdateData();
  75. if ((!m_bCritical) &&
  76. (!m_bDisabled) &&
  77. (!m_bNormal) &&
  78. (!m_bNoData) &&
  79. (!m_bWarning))
  80. {
  81. AfxMessageBox(IDS_ERR_SELECT_STATE);
  82. return;
  83. }
  84. CDialog::OnOK();
  85. switch( m_iThrottleUnits )
  86. {
  87. case 1: // minutes
  88. {
  89. m_iThrottleTime *= 60;
  90. }
  91. break;
  92. case 2: // hours
  93. {
  94. m_iThrottleTime *= 360;
  95. }
  96. break;
  97. }
  98. switch( m_iReminderUnits )
  99. {
  100. case 1: // minutes
  101. {
  102. m_iReminderTime *= 60;
  103. }
  104. break;
  105. case 2: // hours
  106. {
  107. m_iReminderTime *= 360;
  108. }
  109. break;
  110. }
  111. CString sSelectedAction;
  112. int iCurSel = m_Actions.GetCurSel();
  113. m_Actions.GetLBText(iCurSel,sSelectedAction);
  114. for( int i = 0; i < m_saActions.GetSize(); i++ )
  115. {
  116. if( m_saActions[i] == sSelectedAction )
  117. {
  118. m_iSelectedAction = i;
  119. return;
  120. }
  121. }
  122. }
  123. void CNewActionAssociationDlg::OnButtonHelp()
  124. {
  125. MMCPropertyHelp(_T("HMon21.chm::/dassoci8.htm")); // 62212
  126. }