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.

219 lines
5.9 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. if ( !::WinHelp (
  118. hWndControl,
  119. GetF1HelpFilename(),
  120. HELP_WM_HELP,
  121. (DWORD_PTR) help_map) )
  122. {
  123. _TRACE (0, L"WinHelp () failed: 0x%x\n", GetLastError ());
  124. }
  125. _TRACE (-1, L"Leaving CViewOptionsDlg::DoContextHelp\n");
  126. }
  127. void CViewOptionsDlg::OnContextMenu(CWnd* pWnd, CPoint point)
  128. {
  129. // point is in screen coordinates
  130. _TRACE (1, L"Entering CViewOptionsDlg::OnContextMenu\n");
  131. if ( pWnd->m_hWnd == GetDlgItem (IDC_VIEW_BY_PURPOSE)->m_hWnd ||
  132. pWnd->m_hWnd == GetDlgItem (IDC_VIEW_BY_STORE)->m_hWnd ||
  133. pWnd->m_hWnd == GetDlgItem (IDC_SHOW_PHYSICAL)->m_hWnd ||
  134. pWnd->m_hWnd == GetDlgItem (IDC_SHOW_ARCHIVED)->m_hWnd )
  135. {
  136. CMenu bar;
  137. if ( bar.LoadMenu(IDR_WHATS_THIS_CONTEXT_MENU1) )
  138. {
  139. CMenu& popup = *bar.GetSubMenu (0);
  140. ASSERT(popup.m_hMenu);
  141. if ( popup.TrackPopupMenu (TPM_RIGHTBUTTON | TPM_LEFTBUTTON,
  142. point.x, // in screen coordinates
  143. point.y, // in screen coordinates
  144. this) ) // route commands through main window
  145. {
  146. m_hWndWhatsThis = 0;
  147. CPoint clPoint (point);
  148. ScreenToClient (&clPoint);
  149. CWnd* pChild = ChildWindowFromPoint (
  150. clPoint, // in client coordinates
  151. CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT);
  152. if ( pChild )
  153. {
  154. // Check to see if the window returned is the group box.
  155. // If it is, we want to get the child windows that lie in
  156. // the group box, since we're
  157. // not interested in the group box itself.
  158. CWnd* pGroup = GetDlgItem (IDC_VIEW_MODE_GROUP);
  159. if ( pChild->m_hWnd == pGroup->m_hWnd )
  160. {
  161. CRect rc;
  162. // Try the "Certificate Purpose" control
  163. pChild = GetDlgItem (IDC_VIEW_BY_PURPOSE);
  164. if ( pChild )
  165. {
  166. pChild->GetWindowRect (&rc);
  167. if ( rc.PtInRect (point) )
  168. m_hWndWhatsThis = pChild->m_hWnd;
  169. else
  170. {
  171. // Try the "Logical Certificate Stores" control
  172. pChild = GetDlgItem (IDC_VIEW_BY_STORE);
  173. if ( pChild )
  174. {
  175. pChild->GetWindowRect (&rc);
  176. if ( rc.PtInRect (point) )
  177. m_hWndWhatsThis = pChild->m_hWnd;
  178. }
  179. }
  180. }
  181. }
  182. else
  183. m_hWndWhatsThis = pChild->m_hWnd;
  184. }
  185. }
  186. }
  187. }
  188. _TRACE (-1, L"Leaving CViewOptionsDlg::OnContextMenu\n");
  189. }