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.

169 lines
4.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 -99 **/
  4. /**********************************************************************/
  5. /*
  6. statndpp.cpp
  7. Comment goes here
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "winssnap.h"
  12. #include "StatNdpp.h"
  13. #include "status.h"
  14. #include "root.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. #define MILLISEC_PER_MINUTE (60 * 1000)
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CStatusNodePropGen property page
  23. IMPLEMENT_DYNCREATE(CStatusNodePropGen, CPropertyPageBase)
  24. CStatusNodePropGen::CStatusNodePropGen() : CPropertyPageBase(CStatusNodePropGen::IDD)
  25. {
  26. //{{AFX_DATA_INIT(CStatusNodePropGen)
  27. m_nUpdateInterval = 0;
  28. //}}AFX_DATA_INIT
  29. }
  30. CStatusNodePropGen::~CStatusNodePropGen()
  31. {
  32. }
  33. void CStatusNodePropGen::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CPropertyPageBase::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(CStatusNodePropGen)
  37. DDX_Text(pDX, IDC_EDIT_UPDATE, m_nUpdateInterval);
  38. DDV_MinMaxInt(pDX, m_nUpdateInterval, 1, 59);
  39. //}}AFX_DATA_MAP
  40. }
  41. BEGIN_MESSAGE_MAP(CStatusNodePropGen, CPropertyPageBase)
  42. //{{AFX_MSG_MAP(CStatusNodePropGen)
  43. ON_EN_CHANGE(IDC_EDIT_UPDATE, OnChangeEditUpdate)
  44. //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CStatusNodePropGen message handlers
  48. void CStatusNodePropGen::OnChangeEditUpdate()
  49. {
  50. // mark the root node as dirty so that the user is prompted to save the
  51. // file, refresh interval is part of the .msc file
  52. SPITFSNode spNode, spParent;
  53. spNode = GetHolder()->GetNode();
  54. // set the upadte interval from the root node
  55. spNode->GetParent(&spParent);
  56. // mark the data as dirty so that we'll ask the user to save.
  57. spParent->SetData(TFS_DATA_DIRTY, TRUE);
  58. SetDirty(TRUE);
  59. }
  60. BOOL CStatusNodePropGen::OnInitDialog()
  61. {
  62. CPropertyPageBase::OnInitDialog();
  63. SPITFSNode spNode, spParent;
  64. spNode = GetHolder()->GetNode();
  65. // set the upadte interval from the root node
  66. spNode->GetParent(&spParent);
  67. CWinsRootHandler *pRoot
  68. = GETHANDLER(CWinsRootHandler, spParent);
  69. m_nUpdateInterval = pRoot->GetUpdateInterval()/(MILLISEC_PER_MINUTE);
  70. UpdateData(FALSE);
  71. m_uImage = (UINT) spNode->GetData(TFS_DATA_IMAGEINDEX);
  72. // load the correct icon
  73. for (int i = 0; i < ICON_IDX_MAX; i++)
  74. {
  75. if (g_uIconMap[i][1] == m_uImage)
  76. {
  77. HICON hIcon = LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(g_uIconMap[i][0]));
  78. if (hIcon)
  79. ((CStatic *) GetDlgItem(IDC_STATIC_ICON))->SetIcon(hIcon);
  80. break;
  81. }
  82. }
  83. SetDirty(FALSE);
  84. return TRUE;
  85. }
  86. BOOL
  87. CStatusNodePropGen::OnApply()
  88. {
  89. UpdateData();
  90. // update the m_dwInterval for the status node
  91. SPITFSNode spNode, spParent;
  92. CWinsRootHandler *pRoot= NULL;
  93. CWinsStatusHandler *pStat = NULL;
  94. spNode = GetHolder()->GetNode();
  95. spNode->GetParent(&spParent);
  96. pRoot = GETHANDLER(CWinsRootHandler, spParent);
  97. pStat = GETHANDLER(CWinsStatusHandler, spNode);
  98. DWORD dwValue = m_nUpdateInterval * MILLISEC_PER_MINUTE;
  99. pStat->SetUpdateInterval(dwValue);
  100. pRoot->SetUpdateInterval(dwValue);
  101. return CPropertyPageBase::OnApply();
  102. }
  103. /////////////////////////////////////////////////////////////////////////////
  104. // CRepNodeProperties Handlers
  105. /////////////////////////////////////////////////////////////////////////////
  106. CStatusNodeProperties::CStatusNodeProperties
  107. (
  108. ITFSNode * pNode,
  109. IComponentData * pComponentData,
  110. ITFSComponentData * pTFSCompData,
  111. LPCTSTR pszSheetName
  112. ) : CPropertyPageHolderBase(pNode, pComponentData, pszSheetName)
  113. {
  114. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  115. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  116. Assert(pTFSCompData != NULL);
  117. m_spTFSCompData.Set(pTFSCompData);
  118. }
  119. CStatusNodeProperties::~CStatusNodeProperties()
  120. {
  121. RemovePageFromList((CPropertyPageBase*) &m_pageGeneral, FALSE);
  122. }