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
4.3 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. // Copyright (c) 2002 Microsoft Corporation. All rights reserved.
  3. // Copyright (c) 2002 OSR Open Systems Resources, Inc.
  4. //
  5. // ProviderFormatSelectionDlg.cpp : implementation file
  6. //////////////////////////////////////////////////////////////////////////////
  7. #include "stdafx.h"
  8. #include <tchar.h>
  9. #include <wmistr.h>
  10. #include <initguid.h>
  11. extern "C" {
  12. #include <evntrace.h>
  13. }
  14. #include <traceprt.h>
  15. #include "TraceView.h"
  16. #include "LogSession.h"
  17. #include "ProviderFormatInfo.h"
  18. #include "FormatSourceSelectDlg.h"
  19. #include "ProviderFormatSelectionDlg.h"
  20. // CProviderFormatSelectionDlg dialog
  21. IMPLEMENT_DYNAMIC(CProviderFormatSelectionDlg, CDialog)
  22. CProviderFormatSelectionDlg::CProviderFormatSelectionDlg(CWnd* pParent, CTraceSession *pTraceSession)
  23. : CDialog(CProviderFormatSelectionDlg::IDD, pParent)
  24. {
  25. m_pTraceSession = pTraceSession;
  26. }
  27. CProviderFormatSelectionDlg::~CProviderFormatSelectionDlg()
  28. {
  29. }
  30. BOOL CProviderFormatSelectionDlg::OnInitDialog()
  31. {
  32. BOOL retVal;
  33. retVal = CDialog::OnInitDialog();
  34. ((CButton *)GetDlgItem(IDC_PDB_SELECT_RADIO))->SetCheck(BST_CHECKED);
  35. GetDlgItem(IDC_PDB_FILE_EDIT)->EnableWindow(TRUE);
  36. GetDlgItem(IDC_PDB_BROWSE_BUTTON)->EnableWindow(TRUE);
  37. ((CButton *)GetDlgItem(IDC_TMF_SELECT_RADIO))->SetCheck(BST_UNCHECKED);
  38. return retVal;
  39. }
  40. void CProviderFormatSelectionDlg::DoDataExchange(CDataExchange* pDX)
  41. {
  42. CDialog::DoDataExchange(pDX);
  43. DDX_Control(pDX, IDC_PDB_FILE_EDIT, m_pdbFileName);
  44. }
  45. BEGIN_MESSAGE_MAP(CProviderFormatSelectionDlg, CDialog)
  46. ON_BN_CLICKED(IDOK, OnBnClickedOk)
  47. ON_BN_CLICKED(IDC_PDB_SELECT_RADIO, OnBnClickedPdbSelectRadio)
  48. ON_BN_CLICKED(IDC_TMF_SELECT_RADIO, OnBnClickedTmfSelectRadio)
  49. ON_BN_CLICKED(IDC_PDB_BROWSE_BUTTON, OnBnClickedPdbBrowseButton)
  50. END_MESSAGE_MAP()
  51. // CProviderFormatSelectionDlg message handlers
  52. void CProviderFormatSelectionDlg::OnBnClickedOk()
  53. {
  54. if(BST_CHECKED == IsDlgButtonChecked(IDC_PDB_SELECT_RADIO)) {
  55. m_pdbFileName.GetWindowText(m_pTraceSession->m_pdbFile);
  56. //
  57. // Have the trace session process the PDB
  58. //
  59. if(!m_pTraceSession->ProcessPdb()) {
  60. EndDialog(2);
  61. return;
  62. }
  63. OnOK();
  64. return;
  65. }
  66. if(((CButton *)GetDlgItem(IDC_TMF_SELECT_RADIO))->GetCheck()) {
  67. //
  68. // Now get the TMF file(s) or path as necessary
  69. //
  70. CFormatSourceSelectDlg *pDialog = new CFormatSourceSelectDlg(this, m_pTraceSession);
  71. if(NULL == pDialog) {
  72. EndDialog(2);
  73. return;
  74. }
  75. if(IDOK != pDialog->DoModal()) {
  76. delete pDialog;
  77. EndDialog(2);
  78. return;
  79. }
  80. delete pDialog;
  81. EndDialog(1);
  82. return;
  83. }
  84. }
  85. void CProviderFormatSelectionDlg::OnBnClickedPdbSelectRadio()
  86. {
  87. ((CButton *)GetDlgItem(IDC_PDB_SELECT_RADIO))->SetCheck(BST_CHECKED);
  88. GetDlgItem(IDC_PDB_FILE_EDIT)->EnableWindow(TRUE);
  89. GetDlgItem(IDC_PDB_BROWSE_BUTTON)->EnableWindow(TRUE);
  90. ((CButton *)GetDlgItem(IDC_TMF_SELECT_RADIO))->SetCheck(BST_UNCHECKED);
  91. }
  92. void CProviderFormatSelectionDlg::OnBnClickedTmfSelectRadio()
  93. {
  94. ((CButton *)GetDlgItem(IDC_PDB_SELECT_RADIO))->SetCheck(BST_UNCHECKED);
  95. GetDlgItem(IDC_PDB_FILE_EDIT)->EnableWindow(FALSE);
  96. GetDlgItem(IDC_PDB_BROWSE_BUTTON)->EnableWindow(FALSE);
  97. ((CButton *)GetDlgItem(IDC_TMF_SELECT_RADIO))->SetCheck(BST_CHECKED);
  98. }
  99. void CProviderFormatSelectionDlg::OnBnClickedPdbBrowseButton()
  100. {
  101. //
  102. // Use the common controls file open dialog
  103. //
  104. CFileDialog fileDlg(TRUE,
  105. _T("pdb"),_T("*.pdb"),
  106. OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_READONLY |
  107. OFN_HIDEREADONLY | OFN_EXPLORER | OFN_NOCHANGEDIR,
  108. _T("Program Database Files (*.pdb)|*.pdb||"),
  109. this);
  110. //
  111. // Pop the dialog... Any error, just return
  112. //
  113. if( fileDlg.DoModal()!=IDOK ) {
  114. return;
  115. }
  116. //
  117. // Get the file name and display it
  118. //
  119. if(!fileDlg.GetPathName().IsEmpty()) {
  120. m_pdbFileName.SetWindowText(fileDlg.GetPathName());
  121. m_pdbFileName.SetFocus();
  122. }
  123. }