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.

127 lines
3.1 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. // Copyright (c) 2002 Microsoft Corporation. All rights reserved.
  3. // Copyright (c) 2002 OSR Open Systems Resources, Inc.
  4. //
  5. // ProviderFormatInfo.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 "utils.h"
  18. #include "PathDlg.h"
  19. #include "ProviderFormatInfo.h"
  20. // CProviderFormatInfo dialog
  21. IMPLEMENT_DYNAMIC(CProviderFormatInfo, CDialog)
  22. CProviderFormatInfo::CProviderFormatInfo(CWnd* pParent, CTraceSession *pTraceSession)
  23. : CDialog(CProviderFormatInfo::IDD, pParent)
  24. {
  25. m_pTraceSession = pTraceSession;
  26. }
  27. CProviderFormatInfo::~CProviderFormatInfo()
  28. {
  29. }
  30. void CProviderFormatInfo::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialog::DoDataExchange(pDX);
  33. }
  34. BEGIN_MESSAGE_MAP(CProviderFormatInfo, CDialog)
  35. ON_BN_CLICKED(IDC_TMF_BROWSE_BUTTON, OnBnClickedTmfBrowseButton)
  36. ON_BN_CLICKED(IDOK, OnBnClickedOk)
  37. END_MESSAGE_MAP()
  38. // CProviderFormatInfo message handlers
  39. void CProviderFormatInfo::OnBnClickedTmfBrowseButton()
  40. {
  41. CString str;
  42. CListBox *pListBox;
  43. LONG index;
  44. CString fileName;
  45. POSITION pos;
  46. CString pathAndFile;
  47. int length = 32768;
  48. //
  49. // Use the common controls file open dialog; Allow multiple files
  50. // to be selected
  51. //
  52. CFileDialog fileDlg(TRUE,_T("tmf"),_T("*.tmf"),
  53. OFN_NOCHANGEDIR | OFN_HIDEREADONLY |
  54. OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST |
  55. OFN_ALLOWMULTISELECT | OFN_READONLY | OFN_EXPLORER,
  56. _T("Trace Format Files (*.tmf)|*.tmf|All Files (*.*)|*.*||"),
  57. this);
  58. fileDlg.m_ofn.lpstrFile = fileName.GetBuffer(length);
  59. fileDlg.m_ofn.nMaxFile = length;
  60. //
  61. // Pop the dialog...Any error just return
  62. //
  63. if(IDOK != fileDlg.DoModal()) {
  64. return;
  65. }
  66. //
  67. // Iterate over multiple selections
  68. //
  69. pos = fileDlg.GetStartPosition();
  70. while(pos) {
  71. //
  72. // Get the file path specification of a file
  73. //
  74. pathAndFile = fileDlg.GetNextPathName(pos);
  75. //
  76. // Add it to the trace session
  77. //
  78. m_pTraceSession->m_tmfFile.Add(pathAndFile);
  79. //
  80. // Clip off the path, and add just the file and extension
  81. // to the list of format files opened
  82. //
  83. str = (LPCTSTR)pathAndFile;
  84. index = str.ReverseFind('\\');
  85. str = str.Mid(index+1);
  86. pListBox = (CListBox *)GetDlgItem(IDC_TMF_FILE_LIST);
  87. pListBox->InsertString(pListBox->GetCount(), str);
  88. //
  89. // Now remove the path and add the GUID to the trace
  90. // session GUID list
  91. //
  92. index = str.ReverseFind('.');
  93. str = str.Left(index);
  94. m_pTraceSession->m_formatGuid.Add(str);
  95. }
  96. }
  97. void CProviderFormatInfo::OnBnClickedOk()
  98. {
  99. if(0 == m_pTraceSession->m_tmfFile.GetSize()) {
  100. EndDialog(2);
  101. return;
  102. }
  103. EndDialog(1);
  104. }