Leaked source code of windows server 2003
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.

139 lines
3.8 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1998.
  5. //
  6. // File: Tracking.cpp
  7. //
  8. // Contents: tracking property sheet
  9. //
  10. // Classes: CTracking
  11. //
  12. // History: 03-14-1998 stevebl Commented
  13. //
  14. //---------------------------------------------------------------------------
  15. #include "precomp.hxx"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CTracking property page
  23. IMPLEMENT_DYNCREATE(CTracking, CPropertyPage)
  24. CTracking::CTracking() : CPropertyPage(CTracking::IDD)
  25. {
  26. //{{AFX_DATA_INIT(CTracking)
  27. //}}AFX_DATA_INIT
  28. m_pIClassAdmin = NULL;
  29. }
  30. CTracking::~CTracking()
  31. {
  32. *m_ppThis = NULL;
  33. if (m_pIClassAdmin)
  34. {
  35. m_pIClassAdmin->Release();
  36. }
  37. }
  38. void CTracking::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CPropertyPage::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CTracking)
  42. DDX_Control(pDX, IDC_SPIN1, m_spin);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(CTracking, CPropertyPage)
  46. //{{AFX_MSG_MAP(CTracking)
  47. ON_BN_CLICKED(IDC_BUTTON1, OnCleanUpNow)
  48. ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)
  49. ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
  50. ON_EN_KILLFOCUS(IDC_EDIT1, OnKillfocusEdit1)
  51. ON_WM_CONTEXTMENU()
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CTracking message handlers
  56. void CTracking::OnCleanUpNow()
  57. {
  58. FILETIME ft;
  59. SYSTEMTIME st;
  60. // get current time
  61. GetSystemTime(&st);
  62. // convert it to a FILETIME value
  63. SystemTimeToFileTime(&st, &ft);
  64. // subtract the right number of days
  65. LARGE_INTEGER li;
  66. li.LowPart = ft.dwLowDateTime;
  67. li.HighPart = ft.dwHighDateTime;
  68. li.QuadPart -= ONE_FILETIME_DAY * (((LONGLONG)m_pToolDefaults->nUninstallTrackingMonths * 365) / 12);
  69. ft.dwLowDateTime = li.LowPart;
  70. ft.dwHighDateTime = li.HighPart;
  71. // tell the CS to clean up anything older
  72. m_pIClassAdmin->Cleanup(&ft);
  73. }
  74. BOOL CTracking::OnApply()
  75. {
  76. // TODO: Add your specialized code here and/or call the base class
  77. m_pToolDefaults->nUninstallTrackingMonths = (ULONG) m_spin.GetPos();
  78. MMCPropertyChangeNotify(m_hConsoleHandle, m_cookie);
  79. return CPropertyPage::OnApply();
  80. }
  81. BOOL CTracking::OnInitDialog()
  82. {
  83. CPropertyPage::OnInitDialog();
  84. m_spin.SetRange(1,60);
  85. m_spin.SetPos(m_pToolDefaults->nUninstallTrackingMonths);
  86. return TRUE; // return TRUE unless you set the focus to a control
  87. // EXCEPTION: OCX Property Pages should return FALSE
  88. }
  89. void CTracking::OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult)
  90. {
  91. NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  92. *pResult = 0;
  93. SetModified(m_spin.GetPos() != m_pToolDefaults->nUninstallTrackingMonths);
  94. }
  95. LRESULT CTracking::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  96. {
  97. switch (message)
  98. {
  99. case WM_USER_REFRESH:
  100. // UNDONE
  101. return 0;
  102. case WM_USER_CLOSE:
  103. return GetOwner()->SendMessage(WM_CLOSE);
  104. default:
  105. return CPropertyPage::WindowProc(message, wParam, lParam);
  106. }
  107. }
  108. void CTracking::OnChangeEdit1()
  109. {
  110. SetModified(m_spin.GetPos() != m_pToolDefaults->nUninstallTrackingMonths);
  111. }
  112. void CTracking::OnKillfocusEdit1()
  113. {
  114. // Reset the spin control to pull any values in the edit control back
  115. // into range if necessary.
  116. m_spin.SetPos(m_spin.GetPos());
  117. }
  118. void CTracking::OnContextMenu(CWnd* pWnd, CPoint point)
  119. {
  120. StandardContextMenu(pWnd->m_hWnd, IDD_UNINSTALLTRACKING);
  121. }