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.

230 lines
6.4 KiB

  1. /*++
  2. Copyright (C) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. enabldlg.cpp
  5. Abstract:
  6. Implementation of the provider status dialog box.
  7. --*/
  8. #include "stdafx.h"
  9. #include "provprop.h"
  10. #include "smcfgmsg.h"
  11. #include "smlogcfg.h"
  12. #include "enabldlg.h"
  13. #include "smcfghlp.h"
  14. #include "smtprov.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. static ULONG
  21. s_aulHelpIds[] =
  22. {
  23. IDC_PACT_CHECK_SHOW_ENABLED, IDH_PACT_CHECK_SHOW_ENABLED,
  24. IDC_PACT_PROVIDERS_LIST, IDH_PACT_PROVIDERS_LIST,
  25. 0,0
  26. };
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CActiveProviderDlg dialog
  29. CActiveProviderDlg::CActiveProviderDlg(CWnd* pParent /*=NULL*/)
  30. : CDialog(CActiveProviderDlg::IDD, pParent),
  31. m_pProvidersPage( NULL ),
  32. m_iListViewWidth(0)
  33. {
  34. //{{AFX_DATA_INIT(CActiveProviderDlg)
  35. //}}AFX_DATA_INIT
  36. }
  37. void CActiveProviderDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CActiveProviderDlg)
  41. DDX_Control(pDX, IDC_PACT_PROVIDERS_LIST, m_Providers);
  42. DDX_Check(pDX, IDC_PACT_CHECK_SHOW_ENABLED, m_bShowEnabledOnly);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(CActiveProviderDlg, CDialog)
  46. //{{AFX_MSG_MAP(CActiveProviderDlg)
  47. ON_BN_CLICKED(IDC_PACT_CHECK_SHOW_ENABLED, OnCheckShowEnabled)
  48. ON_WM_HELPINFO()
  49. ON_WM_CONTEXTMENU()
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CActiveProviderDlg message handlers
  54. BOOL
  55. CActiveProviderDlg::OnInitDialog()
  56. {
  57. RECT rect;
  58. m_bShowEnabledOnly = FALSE;
  59. CDialog::OnInitDialog(); // Calls UpdateDate ( FALSE ) to init the checkbox value.
  60. // Get the width of the list view control, then delete the default column.
  61. m_Providers.GetClientRect(&rect);
  62. m_iListViewWidth = rect.right;
  63. UpdateList();
  64. return TRUE; // return TRUE unless you set the focus to a control
  65. // EXCEPTION: OCX Property Pages should return FALSE
  66. }
  67. void
  68. CActiveProviderDlg::OnCheckShowEnabled()
  69. {
  70. // ::SendMessage(m_Providers.m_hWnd, WM_SETREDRAW, TRUE, 0);
  71. UpdateData(TRUE);
  72. UpdateList();
  73. }
  74. BOOL
  75. CActiveProviderDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  76. {
  77. ASSERT( NULL != m_pProvidersPage );
  78. if ( pHelpInfo->iCtrlId >= IDC_PACT_FIRST_HELP_CTRL_ID ) {
  79. InvokeWinHelp(WM_HELP, NULL, (LPARAM)pHelpInfo, m_pProvidersPage->GetContextHelpFilePath(), s_aulHelpIds);
  80. }
  81. return TRUE;
  82. }
  83. void
  84. CActiveProviderDlg::OnContextMenu(CWnd* pWnd, CPoint /* point */)
  85. {
  86. ASSERT( NULL != m_pProvidersPage );
  87. InvokeWinHelp(WM_CONTEXTMENU, (WPARAM)( pWnd->m_hWnd), NULL, m_pProvidersPage->GetContextHelpFilePath(), s_aulHelpIds);
  88. return;
  89. }
  90. // Helper functions
  91. void CActiveProviderDlg::UpdateList()
  92. {
  93. LVCOLUMN lvCol;
  94. LVITEM lvItem;
  95. INT iGenIndex;
  96. INT iAllIndex;
  97. INT iEnabledIndex;
  98. INT iCount;
  99. CString arrstrHeader[2];
  100. CString strEnabled;
  101. INT iColWidth[2];
  102. CString strItemText;
  103. ResourceStateManager rsm;
  104. (arrstrHeader[0]).LoadString( IDS_PROV_NAME );
  105. (arrstrHeader[1]).LoadString( IDS_PROV_STATUS );
  106. strEnabled.LoadString(IDS_PROV_ENABLED);
  107. m_Providers.DeleteAllItems();
  108. m_Providers.DeleteColumn(1); // Note - Column 1 might not exist.
  109. m_Providers.DeleteColumn(0);
  110. lvCol.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH | LVCF_FMT;
  111. lvCol.fmt = LVCFMT_LEFT;
  112. if ( m_bShowEnabledOnly ) {
  113. iColWidth[0] = m_iListViewWidth;
  114. iColWidth[1] = 0;
  115. } else {
  116. iColWidth[0] = (m_iListViewWidth * 75) / 100;
  117. iColWidth[1] = (m_iListViewWidth * 25) / 100;
  118. }
  119. if ( m_bShowEnabledOnly ) {
  120. lvCol.iSubItem = 0;
  121. lvCol.pszText = arrstrHeader[0].GetBufferSetLength( arrstrHeader[0].GetLength());
  122. lvCol.cx = iColWidth[0];
  123. m_Providers.InsertColumn(0,&lvCol);
  124. } else {
  125. INT iColIndex;
  126. for (iColIndex = 0 ; iColIndex < 2 ;iColIndex++ ){
  127. lvCol.iSubItem = 0;
  128. lvCol.pszText = arrstrHeader[iColIndex].GetBufferSetLength( arrstrHeader[iColIndex].GetLength());
  129. lvCol.cx = iColWidth[iColIndex];
  130. m_Providers.InsertColumn(iColIndex,&lvCol);
  131. }
  132. }
  133. iEnabledIndex = 0;
  134. iAllIndex = 0;
  135. // Add Kernel provider separately.
  136. if(m_bShowEnabledOnly) {
  137. if ( m_pProvidersPage->GetKernelProviderEnabled() ) {
  138. m_Providers.InsertItem(iEnabledIndex,(LPCTSTR)(m_pProvidersPage->GetKernelProviderDescription()));
  139. }
  140. } else {
  141. lvItem.mask = LVIF_TEXT;
  142. lvItem.iItem = 0;
  143. lvItem.iSubItem = 0;
  144. m_Providers.InsertItem(iAllIndex++,(LPCTSTR)(m_pProvidersPage->GetKernelProviderDescription()));
  145. // Show status
  146. if ( m_pProvidersPage->GetKernelProviderEnabled() ) {
  147. lvItem.pszText = strEnabled.GetBufferSetLength( strEnabled.GetLength() );
  148. lvItem.iSubItem = 1;
  149. m_Providers.SetItem(&lvItem);
  150. }
  151. }
  152. // Add general providers
  153. m_pProvidersPage->GetGenProviderCount( iCount );
  154. for ( iGenIndex = 0; iGenIndex < iCount ; iGenIndex++ ){
  155. lvItem.mask = LVIF_TEXT;
  156. lvItem.iItem = iAllIndex;
  157. lvItem.iSubItem = 0;
  158. if ( m_pProvidersPage->IsActiveProvider(iGenIndex) ) {
  159. CString strProviderName;
  160. if(m_bShowEnabledOnly){
  161. if ( m_pProvidersPage->IsEnabledProvider(iGenIndex) ){
  162. m_pProvidersPage->GetProviderDescription ( iGenIndex, strProviderName );
  163. m_Providers.InsertItem (iEnabledIndex++,strProviderName );
  164. }
  165. } else {
  166. m_pProvidersPage->GetProviderDescription ( iGenIndex, strProviderName );
  167. m_Providers.InsertItem (iAllIndex,strProviderName );
  168. // Show status
  169. if ( m_pProvidersPage->IsEnabledProvider(iGenIndex) ){
  170. lvItem.pszText = strEnabled.GetBufferSetLength( strEnabled.GetLength() );
  171. lvItem.iSubItem = 1;
  172. m_Providers.SetItem(&lvItem);
  173. }
  174. }
  175. }
  176. }
  177. }
  178. void
  179. CActiveProviderDlg::SetProvidersPage( CProvidersProperty* pPage )
  180. {
  181. // The providers page is not always the parent, so store a separate pointer
  182. m_pProvidersPage = pPage;
  183. }