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.

151 lines
3.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997-2001.
  5. //
  6. // File: SelAcct.cpp
  7. //
  8. // Contents: Implementation of property page to allow account selection for
  9. // cert management
  10. //
  11. //----------------------------------------------------------------------------
  12. #include "stdafx.h"
  13. #include "SelAcct.h"
  14. #ifdef _DEBUG
  15. #ifndef ALPHA
  16. #define new DEBUG_NEW
  17. #endif
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. extern HINSTANCE g_hInstance;
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CSelectAccountPropPage property page
  24. //IMPLEMENT_DYNCREATE(CSelectAccountPropPage, CAutoDeletePropPage)
  25. CSelectAccountPropPage::CSelectAccountPropPage (const bool bIsWindowsNT)
  26. : CAutoDeletePropPage(CSelectAccountPropPage::IDD),
  27. m_pdwLocation (0),
  28. m_bIsWindowsNT (bIsWindowsNT)
  29. {
  30. //{{AFX_DATA_INIT(CSelectAccountPropPage)
  31. // NOTE: the ClassWizard will add member initialization here
  32. //}}AFX_DATA_INIT
  33. }
  34. CSelectAccountPropPage::~CSelectAccountPropPage()
  35. {
  36. }
  37. void CSelectAccountPropPage::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CAutoDeletePropPage::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CSelectAccountPropPage)
  41. // NOTE: the ClassWizard will add DDX and DDV calls here
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(CSelectAccountPropPage, CAutoDeletePropPage)
  45. //{{AFX_MSG_MAP(CSelectAccountPropPage)
  46. ON_BN_CLICKED(IDC_PERSONAL_ACCT, OnPersonalAcct)
  47. ON_BN_CLICKED(IDC_SERVICE_ACCT, OnServiceAcct)
  48. ON_BN_CLICKED(IDC_MACHINE_ACCT, OnMachineAcct)
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CSelectAccountPropPage message handlers
  53. BOOL CSelectAccountPropPage::OnInitDialog()
  54. {
  55. AfxSetResourceHandle (g_hInstance);
  56. ASSERT (m_pdwLocation);
  57. if ( m_pdwLocation )
  58. *m_pdwLocation = CERT_SYSTEM_STORE_CURRENT_USER;
  59. CAutoDeletePropPage::OnInitDialog();
  60. GetDlgItem (IDC_PERSONAL_ACCT)->SendMessage (BM_SETCHECK, BST_CHECKED, 0);
  61. if ( !m_bIsWindowsNT )
  62. {
  63. GetDlgItem (IDC_SERVICE_ACCT)->EnableWindow (FALSE);
  64. }
  65. return TRUE; // return TRUE unless you set the focus to a control
  66. // EXCEPTION: OCX Property Pages should return FALSE
  67. }
  68. void CSelectAccountPropPage::AssignLocationPtr(DWORD * pdwLocation)
  69. {
  70. m_pdwLocation = pdwLocation;
  71. }
  72. /////////////////////////////////////////////////////////////////////////////
  73. // MyPropertyPage message handlers
  74. void CSelectAccountPropPage::OnPersonalAcct()
  75. {
  76. ASSERT (m_pdwLocation);
  77. if ( m_pdwLocation )
  78. {
  79. *m_pdwLocation = CERT_SYSTEM_STORE_CURRENT_USER;
  80. GetParent ()->SendMessage (PSM_SETWIZBUTTONS, 0, PSWIZB_FINISH);
  81. }
  82. }
  83. void CSelectAccountPropPage::OnServiceAcct()
  84. {
  85. ASSERT (m_pdwLocation);
  86. if ( m_pdwLocation )
  87. {
  88. *m_pdwLocation = CERT_SYSTEM_STORE_SERVICES;
  89. GetParent ()->SendMessage (PSM_SETWIZBUTTONS, 0, PSWIZB_NEXT);
  90. }
  91. }
  92. void CSelectAccountPropPage::OnMachineAcct()
  93. {
  94. ASSERT (m_pdwLocation);
  95. if ( m_pdwLocation )
  96. {
  97. *m_pdwLocation = CERT_SYSTEM_STORE_LOCAL_MACHINE;
  98. GetParent ()->SendMessage (PSM_SETWIZBUTTONS, 0, PSWIZB_NEXT);
  99. }
  100. }
  101. BOOL CSelectAccountPropPage::OnSetActive()
  102. {
  103. BOOL bResult = CAutoDeletePropPage::OnSetActive();
  104. ASSERT (bResult);
  105. if ( bResult )
  106. {
  107. if ( m_bIsWindowsNT )
  108. {
  109. if ( GetDlgItem (IDC_PERSONAL_ACCT)->SendMessage (BM_GETCHECK, BST_CHECKED, 0)
  110. == BST_CHECKED )
  111. {
  112. GetParent ()->PostMessage (PSM_SETWIZBUTTONS, 0, PSWIZB_FINISH);
  113. }
  114. else
  115. {
  116. GetParent ()->PostMessage (PSM_SETWIZBUTTONS, 0, PSWIZB_NEXT);
  117. }
  118. }
  119. else
  120. {
  121. // If Windows 95 or Windows 98, we only allow local machine
  122. GetParent ()->PostMessage (PSM_SETWIZBUTTONS, 0, PSWIZB_FINISH);
  123. }
  124. }
  125. return bResult;
  126. }