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.

307 lines
11 KiB

  1. // LogSessionOptionsDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "TraceView.h"
  5. #include "DisplayDlg.h"
  6. #include "LogSession.h"
  7. #include "LogSessionOptionsDlg.h"
  8. // CLogSessionOptionsDlg dialog
  9. IMPLEMENT_DYNAMIC(CLogSessionOptionsDlg, CDialog)
  10. CLogSessionOptionsDlg::CLogSessionOptionsDlg(CWnd* pParent, CLogSession *pLogSession)
  11. : CDialog(CLogSessionOptionsDlg::IDD, pParent)
  12. {
  13. m_pLogSession = pLogSession;
  14. }
  15. CLogSessionOptionsDlg::~CLogSessionOptionsDlg()
  16. {
  17. }
  18. int CLogSessionOptionsDlg::OnInitDialog()
  19. {
  20. LONG displayEnableFlags;
  21. CString str;
  22. int retVal = CDialog::OnInitDialog();
  23. // Hide all of the non-Tab1 items
  24. m_DisplayMaxBuf.ShowWindow(SW_HIDE);
  25. m_DisplayMinBuf.ShowWindow(SW_HIDE);
  26. m_DisplayBufferSize.ShowWindow(SW_HIDE);
  27. m_DisplayFlushTime.ShowWindow(SW_HIDE);
  28. m_DisplayTraceLevel.ShowWindow(SW_HIDE);
  29. m_DisplayDecayTime.ShowWindow(SW_HIDE);
  30. m_DisplayNewFile.ShowWindow(SW_HIDE);
  31. m_DisplayCir.ShowWindow(SW_HIDE);
  32. m_DisplaySeq.ShowWindow(SW_HIDE);
  33. m_DisplayFlags.ShowWindow(SW_HIDE);
  34. m_MaxBufValue.ShowWindow(SW_HIDE);
  35. m_MinBufValue.ShowWindow(SW_HIDE);
  36. m_BufferSizeValue.ShowWindow(SW_HIDE);
  37. m_FlushTimeValue.ShowWindow(SW_HIDE);
  38. m_TraceLevelValue.ShowWindow(SW_HIDE);
  39. m_DecayTimeValue.ShowWindow(SW_HIDE);
  40. m_NewFileValue.ShowWindow(SW_HIDE);
  41. m_CirValue.ShowWindow(SW_HIDE);
  42. m_SeqValue.ShowWindow(SW_HIDE);
  43. m_FlagsValue.ShowWindow(SW_HIDE);
  44. GetDlgItem(IDC_MAXBUF_STATIC)->ShowWindow(SW_HIDE);
  45. GetDlgItem(IDC_MINBUF_STATIC)->ShowWindow(SW_HIDE);
  46. GetDlgItem(IDC_BUFFERSIZE_STATIC)->ShowWindow(SW_HIDE);
  47. GetDlgItem(IDC_FLUSHTIME_STATIC)->ShowWindow(SW_HIDE);
  48. GetDlgItem(IDC_TRACELEVEL_STATIC)->ShowWindow(SW_HIDE);
  49. GetDlgItem(IDC_DECAYTIME_STATIC)->ShowWindow(SW_HIDE);
  50. GetDlgItem(IDC_NEWFILE_STATIC)->ShowWindow(SW_HIDE);
  51. GetDlgItem(IDC_CIR_STATIC)->ShowWindow(SW_HIDE);
  52. GetDlgItem(IDC_SEQ_STATIC)->ShowWindow(SW_HIDE);
  53. GetDlgItem(IDC_FLAGS_STATIC)->ShowWindow(SW_HIDE);
  54. GetDlgItem(IDC_DISPLAY1_STATIC)->ShowWindow(SW_HIDE);
  55. GetDlgItem(IDC_OPTION1_STATIC)->ShowWindow(SW_HIDE);
  56. GetDlgItem(IDC_VALUE1_STATIC)->ShowWindow(SW_HIDE);
  57. GetDlgItem(IDC_DISPLAY2_STATIC)->ShowWindow(SW_HIDE);
  58. GetDlgItem(IDC_OPTION2_STATIC)->ShowWindow(SW_HIDE);
  59. GetDlgItem(IDC_VALUE2_STATIC)->ShowWindow(SW_HIDE);
  60. // Setup the tab control
  61. ((CTabCtrl *)GetDlgItem(IDC_TAB1))->InsertItem(0, "Session Information");
  62. ((CTabCtrl *)GetDlgItem(IDC_TAB1))->InsertItem(1, "Display Options");
  63. // Handle the session name
  64. if(m_pLogSession->GetDisplayName() == "") {
  65. str.Format("Trace%d", m_pLogSession->GetLogSessionID());
  66. m_pLogSession->SetDisplayName(str);
  67. } else {
  68. m_LogSessionName.EnableWindow(FALSE);
  69. m_LogFileName.EnableWindow(FALSE);
  70. m_AppendToLogFile.EnableWindow(FALSE);
  71. GetDlgItem(IDC_LOGFILE_BROWSE_BUTTON)->EnableWindow(FALSE);
  72. }
  73. // Set the defaults
  74. displayEnableFlags = m_pLogSession->GetDisplayEnableFlags();
  75. m_DisplayMaxBuf.SetCheck(displayEnableFlags & LOGSESSION_DISPLAY_MAXBUF);
  76. m_DisplayMinBuf.SetCheck(displayEnableFlags & LOGSESSION_DISPLAY_MINBUF);
  77. m_DisplayBufferSize.SetCheck(displayEnableFlags & LOGSESSION_DISPLAY_BUFFERSIZE);
  78. m_DisplayTraceLevel.SetCheck(displayEnableFlags & LOGSESSION_DISPLAY_TRACELEVEL);
  79. m_DisplayFlushTime.SetCheck(displayEnableFlags & LOGSESSION_DISPLAY_FLUSHTIME);
  80. m_DisplayDecayTime.SetCheck(displayEnableFlags & LOGSESSION_DISPLAY_DECAYTIME);
  81. m_DisplayNewFile.SetCheck(displayEnableFlags & LOGSESSION_DISPLAY_NEWFILE);
  82. m_DisplayCir.SetCheck(displayEnableFlags & LOGSESSION_DISPLAY_CIR);
  83. m_DisplaySeq.SetCheck(displayEnableFlags & LOGSESSION_DISPLAY_SEQ);
  84. m_DisplayFlags.SetCheck(displayEnableFlags & LOGSESSION_DISPLAY_FLAGS);
  85. m_LogSessionName.SetWindowText(m_pLogSession->GetDisplayName());
  86. m_LogFileName.SetWindowText(m_pLogSession->m_OutputFileName);
  87. return retVal;
  88. }
  89. void CLogSessionOptionsDlg::DoDataExchange(CDataExchange* pDX)
  90. {
  91. CDialog::DoDataExchange(pDX);
  92. DDX_Control(pDX, IDC_DISPLAY_MAXBUF_CHECK, m_DisplayMaxBuf);
  93. DDX_Control(pDX, IDC_DISPLAY_MINBUF_CHECK, m_DisplayMinBuf);
  94. DDX_Control(pDX, IDC_DISPLAY_BUFSIZ_CHECK, m_DisplayBufferSize);
  95. DDX_Control(pDX, IDC_DISPLAY_FLUSHTIME_CHECK, m_DisplayFlushTime);
  96. DDX_Control(pDX, IDC_DISPLAY_TRCLVL_CHECK, m_DisplayTraceLevel);
  97. DDX_Control(pDX, IDC_DISPLAY_DECAYTIME_CHECK, m_DisplayDecayTime);
  98. DDX_Control(pDX, IDC_DISPLAY_NEWFILE_CHECK, m_DisplayNewFile);
  99. DDX_Control(pDX, IDC_DISPLAY_CIR_CHECK, m_DisplayCir);
  100. DDX_Control(pDX, IDC_DISPLAY_SEQ_CHECK, m_DisplaySeq);
  101. DDX_Control(pDX, IDC_DISPLAY_FLAGS_CHECK, m_DisplayFlags);
  102. DDX_Control(pDX, IDC_LOG_NAME_EDIT, m_LogSessionName);
  103. DDX_Control(pDX, IDC_MAXBUF_VAL_EDIT, m_MaxBufValue);
  104. DDX_Control(pDX, IDC_MINBUF_VAL_EDIT, m_MinBufValue);
  105. DDX_Control(pDX, IDC_BUFSIZ_VAL_EDIT, m_BufferSizeValue);
  106. DDX_Control(pDX, IDC_FLUSHTIME_VAL_EDIT, m_FlushTimeValue);
  107. DDX_Control(pDX, IDC_TRCLVL_VAL_EDIT, m_TraceLevelValue);
  108. DDX_Control(pDX, IDC_DECAYTIME_VAL_EDIT, m_DecayTimeValue);
  109. DDX_Control(pDX, IDC_NEWFILE_VAL_EDIT, m_NewFileValue);
  110. DDX_Control(pDX, IDC_CIR_VAL_EDIT, m_CirValue);
  111. DDX_Control(pDX, IDC_FLAGS_VAL_EDIT, m_FlagsValue);
  112. DDX_Control(pDX, IDC_LOGFILE_EDIT, m_LogFileName);
  113. DDX_Control(pDX, IDC_APPEND_CHECK, m_AppendToLogFile);
  114. DDX_Control(pDX, IDC_SEQ_VAL_EDIT3, m_SeqValue);
  115. }
  116. BEGIN_MESSAGE_MAP(CLogSessionOptionsDlg, CDialog)
  117. ON_BN_CLICKED(IDOK, OnBnClickedOk)
  118. ON_BN_CLICKED(IDC_LOGFILE_BROWSE_BUTTON, OnBnClickedLogfileBrowseButton)
  119. ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnTcnSelchangeTab1)
  120. END_MESSAGE_MAP()
  121. void CLogSessionOptionsDlg::OnBnClickedOk()
  122. {
  123. CString str;
  124. CString strBogus;
  125. LONG length;
  126. TCHAR logSessionName[500];
  127. m_LogFileName.GetWindowText(m_pLogSession->m_OutputFileName);
  128. // Warn the user that no logfile was specified
  129. if((m_LogFileName.IsWindowEnabled()) && (m_pLogSession->m_OutputFileName.IsEmpty())) {
  130. if(IDCANCEL == AfxMessageBox("No Log File Specified\n\nTrace Data Will Not Be Saved \n", MB_OKCANCEL)) {
  131. return;
  132. }
  133. }
  134. m_DisplayEnableFlags = 0;
  135. if(m_DisplayMaxBuf.GetCheck()) {
  136. m_DisplayEnableFlags |= LOGSESSION_DISPLAY_MAXBUF;
  137. };
  138. if(m_DisplayMinBuf.GetCheck()) {
  139. m_DisplayEnableFlags |= LOGSESSION_DISPLAY_MINBUF;
  140. };
  141. if(m_DisplayBufferSize.GetCheck()) {
  142. m_DisplayEnableFlags |= LOGSESSION_DISPLAY_BUFFERSIZE;
  143. };
  144. if(m_DisplayTraceLevel.GetCheck()) {
  145. m_DisplayEnableFlags |= LOGSESSION_DISPLAY_TRACELEVEL;
  146. };
  147. if(m_DisplayFlushTime.GetCheck()) {
  148. m_DisplayEnableFlags |= LOGSESSION_DISPLAY_FLUSHTIME;
  149. };
  150. if(m_DisplayDecayTime.GetCheck()) {
  151. m_DisplayEnableFlags |= LOGSESSION_DISPLAY_DECAYTIME;
  152. };
  153. if(m_DisplayNewFile.GetCheck()) {
  154. m_DisplayEnableFlags |= LOGSESSION_DISPLAY_NEWFILE;
  155. };
  156. if(m_DisplayCir.GetCheck()) {
  157. m_DisplayEnableFlags |= LOGSESSION_DISPLAY_CIR;
  158. };
  159. if(m_DisplaySeq.GetCheck()) {
  160. m_DisplayEnableFlags |= LOGSESSION_DISPLAY_SEQ;
  161. };
  162. if(m_DisplayFlags.GetCheck()) {
  163. m_DisplayEnableFlags |= LOGSESSION_DISPLAY_FLAGS;
  164. };
  165. m_pLogSession->SetDisplayEnableFlags(m_DisplayEnableFlags);
  166. // Update the log session name if changed
  167. length = m_LogSessionName.LineLength(0);
  168. memset((void *)logSessionName, 0, length + 2);
  169. m_LogSessionName.GetLine(0, logSessionName, length);
  170. str = logSessionName;
  171. m_pLogSession->SetDisplayName(str);
  172. OnOK();
  173. }
  174. void CLogSessionOptionsDlg::OnBnClickedLogfileBrowseButton()
  175. {
  176. char fileName[260] = ""; // buffer for file name
  177. OPENFILENAME openFile;
  178. ZeroMemory(&openFile, sizeof(OPENFILENAME));
  179. openFile.lStructSize = sizeof(OPENFILENAME);
  180. //openFile.hwndOwner = GetSafeHwnd();
  181. openFile.lpstrCustomFilter = NULL;
  182. openFile.nMaxCustFilter = 0;
  183. openFile.nFilterIndex = 1;
  184. openFile.lpstrFile = fileName;
  185. openFile.nMaxFile = 500;
  186. openFile.lpstrFileTitle = NULL;
  187. openFile.nMaxFileTitle = 0;
  188. openFile.lpstrInitialDir = NULL;
  189. openFile.lpstrTitle = "Open Log File";
  190. if(m_AppendToLogFile.GetCheck()) {
  191. openFile.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
  192. } else {
  193. openFile.Flags = OFN_CREATEPROMPT;
  194. }
  195. openFile.lpstrDefExt = "log";
  196. openFile.lpstrFilter = "log files (*.log)\0*.log\0all files (*.*)\0*.*\0";
  197. openFile.lCustData = NULL;
  198. openFile.lpfnHook = NULL;
  199. openFile.lpTemplateName = NULL;
  200. if(!GetOpenFileName(&openFile)) {
  201. AfxMessageBox("Failed To Open Logfile");
  202. } else {
  203. m_pLogSession->m_OutputFileName = fileName;
  204. m_LogFileName.SetWindowText(fileName);
  205. }
  206. }
  207. CTabCtrl
  208. void CLogSessionOptionsDlg::OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult)
  209. {
  210. // Hide all of the non-Tab1 items
  211. m_DisplayMaxBuf.ShowWindow(SW_HIDE);
  212. m_DisplayMinBuf.ShowWindow(SW_HIDE);
  213. m_DisplayBufferSize.ShowWindow(SW_HIDE);
  214. m_DisplayFlushTime.ShowWindow(SW_HIDE);
  215. m_DisplayTraceLevel.ShowWindow(SW_HIDE);
  216. m_DisplayDecayTime.ShowWindow(SW_HIDE);
  217. m_DisplayNewFile.ShowWindow(SW_HIDE);
  218. m_DisplayCir.ShowWindow(SW_HIDE);
  219. m_DisplaySeq.ShowWindow(SW_HIDE);
  220. m_DisplayFlags.ShowWindow(SW_HIDE);
  221. m_MaxBufValue.ShowWindow(SW_HIDE);
  222. m_MinBufValue.ShowWindow(SW_HIDE);
  223. m_BufferSizeValue.ShowWindow(SW_HIDE);
  224. m_FlushTimeValue.ShowWindow(SW_HIDE);
  225. m_TraceLevelValue.ShowWindow(SW_HIDE);
  226. m_DecayTimeValue.ShowWindow(SW_HIDE);
  227. m_NewFileValue.ShowWindow(SW_HIDE);
  228. m_CirValue.ShowWindow(SW_HIDE);
  229. m_SeqValue.ShowWindow(SW_HIDE);
  230. m_FlagsValue.ShowWindow(SW_HIDE);
  231. GetDlgItem(IDC_MAXBUF_STATIC)->ShowWindow(SW_HIDE);
  232. GetDlgItem(IDC_MINBUF_STATIC)->ShowWindow(SW_HIDE);
  233. GetDlgItem(IDC_BUFFERSIZE_STATIC)->ShowWindow(SW_HIDE);
  234. GetDlgItem(IDC_FLUSHTIME_STATIC)->ShowWindow(SW_HIDE);
  235. GetDlgItem(IDC_TRACELEVEL_STATIC)->ShowWindow(SW_HIDE);
  236. GetDlgItem(IDC_DECAYTIME_STATIC)->ShowWindow(SW_HIDE);
  237. GetDlgItem(IDC_NEWFILE_STATIC)->ShowWindow(SW_HIDE);
  238. GetDlgItem(IDC_CIR_STATIC)->ShowWindow(SW_HIDE);
  239. GetDlgItem(IDC_SEQ_STATIC)->ShowWindow(SW_HIDE);
  240. GetDlgItem(IDC_FLAGS_STATIC)->ShowWindow(SW_HIDE);
  241. GetDlgItem(IDC_DISPLAY1_STATIC)->ShowWindow(SW_HIDE);
  242. GetDlgItem(IDC_OPTION1_STATIC)->ShowWindow(SW_HIDE);
  243. GetDlgItem(IDC_VALUE1_STATIC)->ShowWindow(SW_HIDE);
  244. GetDlgItem(IDC_DISPLAY2_STATIC)->ShowWindow(SW_HIDE);
  245. GetDlgItem(IDC_OPTION2_STATIC)->ShowWindow(SW_HIDE);
  246. GetDlgItem(IDC_VALUE2_STATIC)->ShowWindow(SW_HIDE);
  247. *pResult = 0;
  248. }