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.

178 lines
4.1 KiB

  1. //============================================================================
  2. // Copyright (C) Microsoft Corporation, 1996 - 1999
  3. //
  4. // File: rtrsheet.cpp
  5. //
  6. // History:
  7. // 06/19/96 Abolade Gbadegesin Created.
  8. //
  9. // Implementation of IP configuration dialogs.
  10. //============================================================================
  11. #include "stdafx.h"
  12. #include "mprapi.h"
  13. #include "rtrsheet.h"
  14. #include "rtrui.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. //----------------------------------------------------------------------------
  21. // Class: RtrPropertySheet
  22. //
  23. //----------------------------------------------------------------------------
  24. RtrPropertySheet::RtrPropertySheet(
  25. ITFSNode * pNode,
  26. IComponentData *pComponentData,
  27. ITFSComponentData *pTFSCompData,
  28. LPCTSTR pszSheetName,
  29. CWnd* pParent,
  30. UINT iPage,
  31. BOOL fScopePane)
  32. : CPropertyPageHolderBase(pNode, pComponentData, pszSheetName, fScopePane),
  33. m_fCancel(FALSE)
  34. {
  35. Assert(pTFSCompData);
  36. m_spTFSCompData.Set(pTFSCompData);
  37. }
  38. /*!--------------------------------------------------------------------------
  39. RtrPropertySheet::OnPropertyChange
  40. This operation occurs on the main thread. This function is called
  41. in response to an Apply operation on a property sheet.
  42. Author: KennT
  43. ---------------------------------------------------------------------------*/
  44. BOOL RtrPropertySheet::OnPropertyChange(BOOL bScopePane, LONG_PTR* pChangeMask)
  45. {
  46. BOOL bReturn = FALSE;
  47. // This means that all of the dirty pages have finished saving
  48. // their data, now we can go ahead and save the sheet data
  49. //
  50. // Because we have gotten here means that at least one page must
  51. // have been dirty, so go ahead and save the data (otherwise we would
  52. // never have gotten here).
  53. //
  54. if (m_cDirty == 1)
  55. {
  56. if (m_fCancel)
  57. {
  58. CancelSheetData();
  59. bReturn = TRUE;
  60. }
  61. else
  62. bReturn = SaveSheetData();
  63. }
  64. BOOL fPageReturn = CPropertyPageHolderBase::OnPropertyChange(
  65. bScopePane, pChangeMask);
  66. return bReturn && fPageReturn;
  67. }
  68. //----------------------------------------------------------------------------
  69. // Class: RtrPropertyPage
  70. //
  71. //----------------------------------------------------------------------------
  72. IMPLEMENT_DYNAMIC(RtrPropertyPage, CPropertyPageBase)
  73. RtrPropertyPage::~RtrPropertyPage()
  74. {
  75. if (m_hIcon)
  76. {
  77. DestroyIcon(m_hIcon);
  78. }
  79. }
  80. /*!--------------------------------------------------------------------------
  81. RtrPropertyPage::SetDirty
  82. -
  83. Author: KennT
  84. ---------------------------------------------------------------------------*/
  85. void RtrPropertyPage::SetDirty(BOOL bDirty)
  86. {
  87. // Set the property sheet to be dirty
  88. // But change the dirty count only if we are toggling the flag
  89. if (GetHolder() && (bDirty != IsDirty()))
  90. {
  91. GetHolder()->IncrementDirty(bDirty ? 1 : -1);
  92. }
  93. CPropertyPageBase::SetDirty(bDirty);
  94. }
  95. void RtrPropertyPage::OnCancel()
  96. {
  97. // We need to notify the property sheet of this
  98. ((RtrPropertySheet *)GetHolder())->SetCancelFlag(TRUE);
  99. // Give the property sheet a chance to do something
  100. OnApply();
  101. CPropertyPageBase::OnCancel();
  102. ((RtrPropertySheet *)GetHolder())->SetCancelFlag(FALSE);
  103. }
  104. void RtrPropertyPage::ValidateSpinRange(CSpinButtonCtrl *pSpin)
  105. {
  106. int iPos, iLow, iHigh;
  107. Assert(pSpin);
  108. iPos = pSpin->GetPos();
  109. if (HIWORD(iPos))
  110. {
  111. pSpin->GetRange(iLow, iHigh);
  112. iPos = iLow;
  113. pSpin->SetPos(iPos);
  114. }
  115. }
  116. BOOL RtrPropertyPage::OnApply()
  117. {
  118. BOOL fReturn = CPropertyPageBase::OnApply();
  119. SetDirty(FALSE);
  120. return fReturn;
  121. }
  122. void RtrPropertyPage::CancelApply()
  123. {
  124. CPropertyPageBase::CancelApply();
  125. SetDirty(FALSE);
  126. }
  127. void RtrPropertyPage::InitializeInterfaceIcon(UINT idcIcon, DWORD dwType)
  128. {
  129. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  130. UINT uIcon = IsWanInterface(dwType) ? IDI_RTRLIB_WAN : IDI_RTRLIB_LAN;
  131. if (m_hIcon)
  132. {
  133. DestroyIcon(m_hIcon);
  134. m_hIcon = NULL;
  135. }
  136. m_hIcon = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(uIcon));
  137. if (m_hIcon && GetDlgItem(idcIcon))
  138. ((CStatic *) GetDlgItem(idcIcon))->SetIcon(m_hIcon);
  139. }