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.

234 lines
6.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1998-2001.
  5. //
  6. // File: options.cpp
  7. //
  8. // Contents: CViewOptionsDlg - snapin-wide view options
  9. //
  10. //----------------------------------------------------------------------------
  11. // options.cpp : implementation file
  12. //
  13. #include "stdafx.h"
  14. #include <gpedit.h>
  15. #include "options.h"
  16. #include "compdata.h"
  17. #ifdef _DEBUG
  18. #ifndef ALPHA
  19. #define new DEBUG_NEW
  20. #endif
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CViewOptionsDlg dialog
  26. CViewOptionsDlg::CViewOptionsDlg(CWnd* pParent, CCertMgrComponentData* pCompData)
  27. : CHelpDialog(CViewOptionsDlg::IDD, pParent),
  28. m_pCompData (pCompData)
  29. {
  30. ASSERT (m_pCompData);
  31. //{{AFX_DATA_INIT(CViewOptionsDlg)
  32. m_bShowPhysicalStores = FALSE;
  33. m_bShowArchivedCerts = FALSE;
  34. //}}AFX_DATA_INIT
  35. }
  36. void CViewOptionsDlg::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CHelpDialog::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(CViewOptionsDlg)
  40. DDX_Control(pDX, IDC_SHOW_PHYSICAL, m_showPhysicalButton);
  41. DDX_Control(pDX, IDC_VIEW_BY_STORE, m_viewByStoreBtn);
  42. DDX_Control(pDX, IDC_VIEW_BY_PURPOSE, m_viewByPurposeBtn);
  43. DDX_Check(pDX, IDC_SHOW_PHYSICAL, m_bShowPhysicalStores);
  44. DDX_Check(pDX, IDC_SHOW_ARCHIVED, m_bShowArchivedCerts);
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(CViewOptionsDlg, CHelpDialog)
  48. //{{AFX_MSG_MAP(CViewOptionsDlg)
  49. ON_BN_CLICKED(IDC_VIEW_BY_PURPOSE, OnViewByPurpose)
  50. ON_BN_CLICKED(IDC_VIEW_BY_STORE, OnViewByStore)
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CViewOptionsDlg message handlers
  55. BOOL CViewOptionsDlg::OnInitDialog()
  56. {
  57. CHelpDialog::OnInitDialog();
  58. if ( m_pCompData )
  59. {
  60. BOOL bIsFileView = !m_pCompData->m_szFileName.IsEmpty ();
  61. if ( bIsFileView )
  62. m_showPhysicalButton.ShowWindow (SW_HIDE);
  63. m_bShowArchivedCerts = m_pCompData->m_bShowArchivedCertsPersist;
  64. m_bShowPhysicalStores = m_pCompData->m_bShowPhysicalStoresPersist;
  65. if ( IDM_STORE_VIEW == m_pCompData->m_activeViewPersist )
  66. m_viewByStoreBtn.SetCheck (1);
  67. else
  68. {
  69. m_viewByPurposeBtn.SetCheck (1);
  70. m_showPhysicalButton.EnableWindow (FALSE);
  71. }
  72. UpdateData (FALSE);
  73. }
  74. return TRUE; // return TRUE unless you set the focus to a control
  75. // EXCEPTION: OCX Property Pages should return FALSE
  76. }
  77. void CViewOptionsDlg::OnOK()
  78. {
  79. UpdateData (TRUE);
  80. if ( m_pCompData )
  81. {
  82. m_pCompData->m_bShowArchivedCertsPersist = m_bShowArchivedCerts;
  83. m_pCompData->m_bShowPhysicalStoresPersist = m_bShowPhysicalStores;
  84. if ( m_viewByStoreBtn.GetCheck () )
  85. m_pCompData->m_activeViewPersist = IDM_STORE_VIEW;
  86. else
  87. m_pCompData->m_activeViewPersist = IDM_USAGE_VIEW;
  88. }
  89. CHelpDialog::OnOK();
  90. }
  91. void CViewOptionsDlg::OnViewByPurpose()
  92. {
  93. if ( m_viewByPurposeBtn.GetCheck () )
  94. m_showPhysicalButton.EnableWindow (FALSE);
  95. else
  96. m_showPhysicalButton.EnableWindow (TRUE);
  97. }
  98. void CViewOptionsDlg::OnViewByStore()
  99. {
  100. if ( m_viewByStoreBtn.GetCheck () )
  101. m_showPhysicalButton.EnableWindow (TRUE);
  102. else
  103. m_showPhysicalButton.EnableWindow (FALSE);
  104. }
  105. void CViewOptionsDlg::DoContextHelp (HWND hWndControl)
  106. {
  107. _TRACE (1, L"Entering CViewOptionsDlg::DoContextHelp\n");
  108. static const DWORD help_map[] =
  109. {
  110. IDC_VIEW_BY_PURPOSE, IDH_OPTIONS_VIEW_BY_PURPOSE,
  111. IDC_VIEW_BY_STORE, IDH_OPTIONS_VIEW_BY_STORE,
  112. IDC_SHOW_PHYSICAL, IDH_OPTIONS_SHOW_PHYSICAL,
  113. IDC_SHOW_ARCHIVED, IDH_OPTIONS_SHOW_ARCHIVED,
  114. 0, 0
  115. };
  116. // Display context help for a control
  117. switch (::GetDlgCtrlID (hWndControl))
  118. {
  119. case IDC_VIEW_BY_PURPOSE:
  120. case IDC_VIEW_BY_STORE:
  121. case IDC_SHOW_PHYSICAL:
  122. case IDC_SHOW_ARCHIVED:
  123. case IDOK:
  124. case IDCANCEL:
  125. if ( !::WinHelp (
  126. hWndControl,
  127. GetF1HelpFilename(),
  128. HELP_WM_HELP,
  129. (DWORD_PTR) help_map) )
  130. {
  131. _TRACE (0, L"WinHelp () failed: 0x%x\n", GetLastError ());
  132. }
  133. break;
  134. default:
  135. break;
  136. }
  137. _TRACE (-1, L"Leaving CViewOptionsDlg::DoContextHelp\n");
  138. }
  139. void CViewOptionsDlg::OnContextMenu(CWnd* pWnd, CPoint point)
  140. {
  141. // point is in screen coordinates
  142. _TRACE (1, L"Entering CViewOptionsDlg::OnContextMenu\n");
  143. if ( pWnd->m_hWnd == GetDlgItem (IDC_VIEW_BY_PURPOSE)->m_hWnd ||
  144. pWnd->m_hWnd == GetDlgItem (IDC_VIEW_BY_STORE)->m_hWnd ||
  145. pWnd->m_hWnd == GetDlgItem (IDC_SHOW_PHYSICAL)->m_hWnd ||
  146. pWnd->m_hWnd == GetDlgItem (IDC_SHOW_ARCHIVED)->m_hWnd )
  147. {
  148. CMenu bar;
  149. if ( bar.LoadMenu(IDR_WHATS_THIS_CONTEXT_MENU1) )
  150. {
  151. CMenu& popup = *bar.GetSubMenu (0);
  152. ASSERT(popup.m_hMenu);
  153. if ( popup.TrackPopupMenu (TPM_RIGHTBUTTON | TPM_LEFTBUTTON,
  154. point.x, // in screen coordinates
  155. point.y, // in screen coordinates
  156. this) ) // route commands through main window
  157. {
  158. m_hWndWhatsThis = 0;
  159. CPoint clPoint (point);
  160. ScreenToClient (&clPoint);
  161. CWnd* pChild = ChildWindowFromPoint (
  162. clPoint, // in client coordinates
  163. CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT);
  164. if ( pChild )
  165. {
  166. // Check to see if the window returned is the group box.
  167. // If it is, we want to get the child windows that lie in
  168. // the group box, since we're
  169. // not interested in the group box itself.
  170. CWnd* pGroup = GetDlgItem (IDC_VIEW_MODE_GROUP);
  171. if ( pChild->m_hWnd == pGroup->m_hWnd )
  172. {
  173. CRect rc;
  174. // Try the "Certificate Purpose" control
  175. pChild = GetDlgItem (IDC_VIEW_BY_PURPOSE);
  176. if ( pChild )
  177. {
  178. pChild->GetWindowRect (&rc);
  179. if ( rc.PtInRect (point) )
  180. m_hWndWhatsThis = pChild->m_hWnd;
  181. else
  182. {
  183. // Try the "Logical Certificate Stores" control
  184. pChild = GetDlgItem (IDC_VIEW_BY_STORE);
  185. if ( pChild )
  186. {
  187. pChild->GetWindowRect (&rc);
  188. if ( rc.PtInRect (point) )
  189. m_hWndWhatsThis = pChild->m_hWnd;
  190. }
  191. }
  192. }
  193. }
  194. else
  195. m_hWndWhatsThis = pChild->m_hWnd;
  196. }
  197. }
  198. }
  199. }
  200. _TRACE (-1, L"Leaving CViewOptionsDlg::OnContextMenu\n");
  201. }