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.

207 lines
5.5 KiB

  1. /*++
  2. Copyright (C) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. provdlg.cpp
  5. Abstract:
  6. Implementation of the add providers dialog box.
  7. --*/
  8. #include "stdafx.h"
  9. #include "provprop.h"
  10. #include "smcfghlp.h"
  11. #include "provdlg.h"
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. static ULONG
  18. s_aulHelpIds[] =
  19. {
  20. IDC_PADD_PROVIDER_CAPTION, IDH_PADD_PROVIDER_LIST,
  21. IDC_PADD_PROVIDER_LIST, IDH_PADD_PROVIDER_LIST,
  22. 0,0
  23. };
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CProviderListDlg dialog
  26. CProviderListDlg::CProviderListDlg(CWnd* pParent)
  27. : CDialog(CProviderListDlg::IDD, pParent),
  28. m_pProvidersPage ( NULL ),
  29. m_dwMaxHorizListExtent ( 0 )
  30. {
  31. // EnableAutomation();
  32. //{{AFX_DATA_INIT(CProviderListDlg)
  33. //}}AFX_DATA_INIT
  34. }
  35. CProviderListDlg::~CProviderListDlg()
  36. {
  37. }
  38. void CProviderListDlg::OnFinalRelease()
  39. {
  40. // When the last reference for an automation object is released
  41. // OnFinalRelease is called. The base class will automatically
  42. // deletes the object. Add additional cleanup required for your
  43. // object before calling the base class.
  44. CDialog::OnFinalRelease();
  45. }
  46. void CProviderListDlg::DoDataExchange(CDataExchange* pDX)
  47. {
  48. CDialog::DoDataExchange(pDX);
  49. //{{AFX_DATA_MAP(CProviderListDlg)
  50. //}}AFX_DATA_MAP
  51. }
  52. BEGIN_MESSAGE_MAP(CProviderListDlg, CDialog)
  53. //{{AFX_MSG_MAP(CProviderListDlg)
  54. ON_WM_HELPINFO()
  55. ON_WM_CONTEXTMENU()
  56. //}}AFX_MSG_MAP
  57. END_MESSAGE_MAP()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CProviderListDlg message handlers
  60. BOOL CProviderListDlg::OnInitDialog()
  61. {
  62. DWORD dwStatus;
  63. ResourceStateManager rsm;
  64. dwStatus = InitProviderListBox();
  65. CDialog::OnInitDialog();
  66. // set focus to the provider list box
  67. GetDlgItem(IDC_PADD_PROVIDER_LIST)->SetFocus();
  68. return FALSE; // return TRUE unless you set the focus to a control
  69. // EXCEPTION: OCX Property Pages should return FALSE
  70. }
  71. void CProviderListDlg::OnOK()
  72. {
  73. CListBox * plbUnusedProviders = (CListBox *)GetDlgItem(IDC_PADD_PROVIDER_LIST);
  74. long lNumProviders;
  75. INT iSelCount;
  76. UpdateData (TRUE);
  77. // update the provider array based on list box contents.
  78. iSelCount = plbUnusedProviders->GetSelCount();
  79. if ( 0 != iSelCount && LB_ERR != iSelCount ) {
  80. lNumProviders = plbUnusedProviders->GetCount();
  81. if (lNumProviders != LB_ERR) {
  82. long lThisProvider;
  83. INT iProvIndex;
  84. DWORD dwStatus;
  85. // The Providers array has not changed since initialization, so no need to reload it here.
  86. lThisProvider = 0;
  87. while (lThisProvider < lNumProviders) {
  88. if ( 0 != plbUnusedProviders->GetSel( lThisProvider ) ) {
  89. // Selected, so set the state to InQuery.
  90. iProvIndex = (INT)plbUnusedProviders->GetItemData( lThisProvider );
  91. m_arrProviders[iProvIndex] = CSmTraceLogQuery::eInQuery;
  92. }
  93. lThisProvider++;
  94. }
  95. // Update the property page.
  96. ASSERT ( NULL != m_pProvidersPage );
  97. dwStatus = m_pProvidersPage->SetInQueryProviders ( m_arrProviders );
  98. }
  99. }
  100. CDialog::OnOK();
  101. }
  102. BOOL
  103. CProviderListDlg::OnHelpInfo(HELPINFO* pHelpInfo)
  104. {
  105. ASSERT( NULL != m_pProvidersPage );
  106. if ( pHelpInfo->iCtrlId >= IDC_PADD_FIRST_HELP_CTRL_ID ||
  107. pHelpInfo->iCtrlId == IDOK ||
  108. pHelpInfo->iCtrlId == IDCANCEL
  109. ) {
  110. InvokeWinHelp(WM_HELP, NULL, (LPARAM)pHelpInfo, m_pProvidersPage->GetContextHelpFilePath(), s_aulHelpIds);
  111. }
  112. return TRUE;
  113. }
  114. void
  115. CProviderListDlg::OnContextMenu(CWnd* pWnd, CPoint /* point */)
  116. {
  117. ASSERT( NULL != m_pProvidersPage );
  118. InvokeWinHelp(WM_CONTEXTMENU, (WPARAM)(pWnd->m_hWnd), NULL, m_pProvidersPage->GetContextHelpFilePath(), s_aulHelpIds);
  119. return;
  120. }
  121. //
  122. // Helper functions
  123. //
  124. DWORD
  125. CProviderListDlg::InitProviderListBox( void )
  126. {
  127. DWORD dwStatus = ERROR_SUCCESS;
  128. CString strProviderName;
  129. INT iProvIndex;
  130. DWORD dwItemExtent;
  131. CListBox * plbUnusedProviders = (CListBox *)GetDlgItem(IDC_PADD_PROVIDER_LIST);
  132. ASSERT( NULL != m_pProvidersPage );
  133. //load counter list box from string in counter list
  134. plbUnusedProviders->ResetContent();
  135. dwStatus = m_pProvidersPage->GetInQueryProviders ( m_arrProviders );
  136. // List unused providers
  137. for ( iProvIndex = 0; iProvIndex < m_arrProviders.GetSize(); iProvIndex++ ) {
  138. if ( ( CSmTraceLogQuery::eNotInQuery == m_arrProviders[iProvIndex] )
  139. && ( m_pProvidersPage->IsActiveProvider ( iProvIndex ) ) ) {
  140. INT iAddIndex;
  141. m_pProvidersPage->GetProviderDescription( iProvIndex, strProviderName );
  142. iAddIndex = plbUnusedProviders->AddString ( strProviderName );
  143. plbUnusedProviders->SetItemData ( iAddIndex, ( DWORD ) iProvIndex );
  144. // update list box extent
  145. dwItemExtent = (DWORD)((plbUnusedProviders->GetDC())->GetTextExtent (strProviderName)).cx;
  146. if (dwItemExtent > m_dwMaxHorizListExtent) {
  147. m_dwMaxHorizListExtent = dwItemExtent;
  148. plbUnusedProviders->SetHorizontalExtent(dwItemExtent);
  149. }
  150. }
  151. }
  152. return dwStatus;
  153. }
  154. void
  155. CProviderListDlg::SetProvidersPage( CProvidersProperty* pPage )
  156. {
  157. // The providers page is not always the parent, so store a separate pointer
  158. m_pProvidersPage = pPage;
  159. }