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.

900 lines
25 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // TraceDlg.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the CTraceDialog class.
  10. //
  11. // Author:
  12. // David Potter (davidp) May 29, 1996
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "resource.h"
  21. #define _RESOURCE_H_
  22. #include "TraceDlg.h"
  23. #include "TraceTag.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CTraceDialog dialog
  30. /////////////////////////////////////////////////////////////////////////////
  31. /////////////////////////////////////////////////////////////////////////////
  32. // Message Maps
  33. BEGIN_MESSAGE_MAP(CTraceDialog, CDialog)
  34. //{{AFX_MSG_MAP(CTraceDialog)
  35. ON_BN_CLICKED(IDC_TS_SELECT_ALL, OnSelectAll)
  36. ON_NOTIFY(LVN_ITEMCHANGED, IDC_TS_LISTBOX, OnItemChangedListbox)
  37. ON_BN_CLICKED(IDC_TS_TRACE_TO_DEBUG, OnClickedTraceToDebug)
  38. ON_BN_CLICKED(IDC_TS_TRACE_DEBUG_BREAK, OnClickedTraceDebugBreak)
  39. ON_BN_CLICKED(IDC_TS_TRACE_TO_COM2, OnClickedTraceToCom2)
  40. ON_BN_CLICKED(IDC_TS_TRACE_TO_FILE, OnClickedTraceToFile)
  41. ON_CBN_SELCHANGE(IDC_TS_TAGS_TO_DISPLAY_CB, OnSelChangeTagsToDisplay)
  42. ON_NOTIFY(LVN_COLUMNCLICK, IDC_TS_LISTBOX, OnColumnClickListbox)
  43. ON_BN_CLICKED(IDC_TS_DEFAULT, OnDefault)
  44. //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46. /////////////////////////////////////////////////////////////////////////////
  47. //++
  48. //
  49. // CTraceDialog::CTraceDialog
  50. //
  51. // Routine Description:
  52. // Constructor. Initializes the dialog class.
  53. //
  54. // Arguments:
  55. // pParent [IN OUT] Parent window.
  56. //
  57. // Return Value:
  58. // None.
  59. //
  60. //--
  61. /////////////////////////////////////////////////////////////////////////////
  62. CTraceDialog::CTraceDialog(CWnd * pParent /*=NULL*/)
  63. : CDialog(CTraceDialog::IDD, pParent)
  64. {
  65. //{{AFX_DATA_INIT(CTraceDialog)
  66. m_strFile = _T("");
  67. //}}AFX_DATA_INIT
  68. } //*** CTraceDialog::CTraceDialog()
  69. /////////////////////////////////////////////////////////////////////////////
  70. //++
  71. //
  72. // CTraceDialog::DoDataExchange
  73. //
  74. // Routine Description:
  75. // Do data exchange between the dialog and the class.
  76. //
  77. // Arguments:
  78. // pDX [IN OUT] Data exchange object
  79. //
  80. // Return Value:
  81. // None.
  82. //
  83. //--
  84. /////////////////////////////////////////////////////////////////////////////
  85. void CTraceDialog::DoDataExchange(CDataExchange * pDX)
  86. {
  87. CDialog::DoDataExchange(pDX);
  88. //{{AFX_DATA_MAP(CTraceDialog)
  89. DDX_Control(pDX, IDC_TS_LISTBOX, m_lcTagList);
  90. DDX_Control(pDX, IDC_TS_TRACE_TO_DEBUG, m_chkboxTraceToDebugWin);
  91. DDX_Control(pDX, IDC_TS_TRACE_DEBUG_BREAK, m_chkboxDebugBreak);
  92. DDX_Control(pDX, IDC_TS_TRACE_TO_COM2, m_chkboxTraceToCom2);
  93. DDX_Control(pDX, IDC_TS_TRACE_TO_FILE, m_chkboxTraceToFile);
  94. DDX_Control(pDX, IDC_TS_FILE, m_editFile);
  95. DDX_Control(pDX, IDC_TS_TAGS_TO_DISPLAY_CB, m_cboxDisplayOptions);
  96. DDX_Text(pDX, IDC_TS_FILE, m_strFile);
  97. //}}AFX_DATA_MAP
  98. } //*** CTraceDialog::DoDataExchange()
  99. /////////////////////////////////////////////////////////////////////////////
  100. //++
  101. //
  102. // CTraceDialog::OnInitDialog
  103. //
  104. // Routine Description:
  105. // Handler for the WM_INITDIALOG message.
  106. //
  107. // Arguments:
  108. // None.
  109. //
  110. // Return Value:
  111. // TRUE We need the focus to be set for us.
  112. // FALSE We already set the focus to the proper control.
  113. //
  114. //--
  115. /////////////////////////////////////////////////////////////////////////////
  116. BOOL CTraceDialog::OnInitDialog(void)
  117. {
  118. CDialog::OnInitDialog();
  119. // Set the dialog flags.
  120. {
  121. CTraceTag * ptag;
  122. ptag = CTraceTag::s_ptagFirst;
  123. while (ptag != NULL)
  124. {
  125. ptag->m_uiFlagsDialog = ptag->m_uiFlags;
  126. ptag = ptag->m_ptagNext;
  127. } // while: more tags in the list
  128. } // Set the dialog flags
  129. // Change list view control extended styles.
  130. {
  131. DWORD dwExtendedStyle;
  132. dwExtendedStyle = m_lcTagList.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE);
  133. m_lcTagList.SendMessage(
  134. LVM_SETEXTENDEDLISTVIEWSTYLE,
  135. 0,
  136. dwExtendedStyle
  137. | LVS_EX_FULLROWSELECT
  138. | LVS_EX_HEADERDRAGDROP
  139. );
  140. } // Change list view control extended styles
  141. // Set the columns in the listbox.
  142. VERIFY(m_lcTagList.InsertColumn(0, TEXT("Section"), LVCFMT_LEFT, 75) != -1);
  143. VERIFY(m_lcTagList.InsertColumn(1, TEXT("Name"), LVCFMT_LEFT, 125) != -1);
  144. VERIFY(m_lcTagList.InsertColumn(2, TEXT("State"), LVCFMT_CENTER, 50) != -1);
  145. // Load the combobox.
  146. /*0*/ VERIFY(m_cboxDisplayOptions.AddString(TEXT("All Tags")) != CB_ERR);
  147. /*1*/ VERIFY(m_cboxDisplayOptions.AddString(TEXT("Debug Window Enabled")) != CB_ERR);
  148. /*2*/ VERIFY(m_cboxDisplayOptions.AddString(TEXT("Break Enabled")) != CB_ERR);
  149. /*3*/ VERIFY(m_cboxDisplayOptions.AddString(TEXT("COM2 Enabled")) != CB_ERR);
  150. /*4*/ VERIFY(m_cboxDisplayOptions.AddString(TEXT("File Enabled")) != CB_ERR);
  151. /*5*/ VERIFY(m_cboxDisplayOptions.AddString(TEXT("Anything Enabled")) != CB_ERR);
  152. VERIFY(m_cboxDisplayOptions.SetCurSel(0) != CB_ERR);
  153. m_nCurFilter = 0;
  154. // Set maximum length of the file edit control.
  155. m_editFile.LimitText(_MAX_PATH);
  156. // Load the listbox.
  157. LoadListbox();
  158. // Set sort info.
  159. m_nSortDirection = -1;
  160. m_nSortColumn = -1;
  161. m_strFile = CTraceTag::PszFile();
  162. m_nCurFilter = -1;
  163. UpdateData(FALSE);
  164. return TRUE; // return TRUE unless you set the focus to a control
  165. // EXCEPTION: OCX Property Pages should return FALSE
  166. } //*** CTraceDialog::OnInitDialog()
  167. /////////////////////////////////////////////////////////////////////////////
  168. //++
  169. //
  170. // CTraceDialog::ConstructStateString [static]
  171. //
  172. // Routine Description:
  173. // Construct a string to display from the state of the trace tag.
  174. //
  175. // Arguments:
  176. // ptag [IN] Tag from which to construct the state string.
  177. // rstr [OUT] String in which to return the state string.
  178. //
  179. // Return Value:
  180. // None.
  181. //
  182. //--
  183. /////////////////////////////////////////////////////////////////////////////
  184. void CTraceDialog::ConstructStateString(
  185. IN const CTraceTag * ptag,
  186. OUT CString & rstr
  187. )
  188. {
  189. rstr = "";
  190. if (ptag->BDebugDialog())
  191. rstr += "D";
  192. if (ptag->BBreakDialog())
  193. rstr += "B";
  194. if (ptag->BCom2Dialog())
  195. rstr += "C";
  196. if (ptag->BFileDialog())
  197. rstr += "F";
  198. } //*** CTraceDialog::ConstructStateString()
  199. /////////////////////////////////////////////////////////////////////////////
  200. //++
  201. //
  202. // CTraceDialog::OnOK
  203. //
  204. // Routine Description:
  205. // Handler for the BN_CLICKED message on the OK button.
  206. //
  207. // Arguments:
  208. // None.
  209. //
  210. // Return Value:
  211. // None.
  212. //
  213. //--
  214. /////////////////////////////////////////////////////////////////////////////
  215. void CTraceDialog::OnOK(void)
  216. {
  217. CTraceTag * ptag;
  218. CString strSection;
  219. CString strState;
  220. // Write tag states.
  221. ptag = CTraceTag::s_ptagFirst;
  222. while (ptag != NULL)
  223. {
  224. if (ptag->m_uiFlags != ptag->m_uiFlagsDialog)
  225. {
  226. ptag->m_uiFlags = ptag->m_uiFlagsDialog;
  227. strSection.Format(TRACE_TAG_REG_SECTION_FMT, ptag->PszSubsystem());
  228. ptag->ConstructRegState(strState);
  229. AfxGetApp()->WriteProfileString(strSection, ptag->PszName(), strState);
  230. } // if: tag state changed
  231. ptag = ptag->m_ptagNext;
  232. } // while: more tags int he list.
  233. // Write the file.
  234. if (m_strFile != CTraceTag::PszFile())
  235. {
  236. g_strTraceFile = m_strFile;
  237. AfxGetApp()->WriteProfileString(TRACE_TAG_REG_SECTION, TRACE_TAG_REG_FILE, m_strFile);
  238. } // if: file changed
  239. CDialog::OnOK();
  240. } //*** CTraceDialog::OnOK()
  241. /////////////////////////////////////////////////////////////////////////////
  242. //++
  243. //
  244. // CTraceDialog::OnSelectAll
  245. //
  246. // Routine Description:
  247. // Handler for the BN_CLICKED message on the Select All button.
  248. //
  249. // Arguments:
  250. // None.
  251. //
  252. // Return Value:
  253. // None.
  254. //
  255. //--
  256. /////////////////////////////////////////////////////////////////////////////
  257. void CTraceDialog::OnSelectAll(void)
  258. {
  259. int ili;
  260. // Select all the items in the list control.
  261. ili = m_lcTagList.GetNextItem(-1, LVNI_ALL);
  262. while (ili != -1)
  263. {
  264. m_lcTagList.SetItemState(ili, LVIS_SELECTED, LVIS_SELECTED);
  265. ili = m_lcTagList.GetNextItem(ili, LVNI_ALL);
  266. } // while: more items in the list
  267. } //*** CTraceDialog::OnSelectAll()
  268. /////////////////////////////////////////////////////////////////////////////
  269. //++
  270. //
  271. // CTraceDialog::OnDefault
  272. //
  273. // Routine Description:
  274. // Handler for the BN_CLICKED message on the Default button.
  275. // Resets the trace tags to their default settings.
  276. //
  277. // Arguments:
  278. // None.
  279. //
  280. // Return Value:
  281. // None.
  282. //
  283. //--
  284. /////////////////////////////////////////////////////////////////////////////
  285. void CTraceDialog::OnDefault(void)
  286. {
  287. CTraceTag * ptag;
  288. ptag = CTraceTag::s_ptagFirst;
  289. while (ptag != NULL)
  290. {
  291. ptag->m_uiFlagsDialog = ptag->m_uiFlagsDefault;
  292. ptag = ptag->m_ptagNext;
  293. } // while: more tags int he list.
  294. // Reload the listbox, keeping the same items
  295. LoadListbox();
  296. } //*** CTraceDialog::OnDefault()
  297. /////////////////////////////////////////////////////////////////////////////
  298. //++
  299. //
  300. // CTraceDialog::OnItemChangedListbox
  301. //
  302. // Routine Description:
  303. // Handler for the LVN_ITEMCHANGED message on the listbox.
  304. //
  305. // Arguments:
  306. // None.
  307. //
  308. // Return Value:
  309. // None.
  310. //
  311. //--
  312. /////////////////////////////////////////////////////////////////////////////
  313. void CTraceDialog::OnItemChangedListbox(NMHDR * pNMHDR, LRESULT * pResult)
  314. {
  315. NM_LISTVIEW * pNMListView = (NM_LISTVIEW *) pNMHDR;
  316. // If the item just became unselected or selected, change the checkboxes to match.
  317. if ((pNMListView->uChanged & LVIF_STATE)
  318. && ((pNMListView->uOldState & LVIS_SELECTED)
  319. || (pNMListView->uNewState & LVIS_SELECTED)))
  320. {
  321. // Handle a selection change.
  322. OnSelChangedListbox();
  323. } // if: item received the focus
  324. *pResult = 0;
  325. } //*** CTraceDialog::OnItemChangedListbox()
  326. /////////////////////////////////////////////////////////////////////////////
  327. //++
  328. //
  329. // CTraceDialog::OnSelChangedListbox
  330. //
  331. // Routine Description:
  332. // Handles all that needs to when the listbox selection changes. That
  333. // is adjust the checkbox to their new value and determine if they need
  334. // to be simple or TRI-state checkboxes.
  335. //
  336. // Arguments:
  337. // None.
  338. //
  339. // Return Value:
  340. // None.
  341. //
  342. //--
  343. /////////////////////////////////////////////////////////////////////////////
  344. void CTraceDialog::OnSelChangedListbox(void)
  345. {
  346. int ili;
  347. int nDebugWin = BST_UNCHECKED;
  348. int nDebugBreak = BST_UNCHECKED;
  349. int nCom2 = BST_UNCHECKED;
  350. int nFile = BST_UNCHECKED;
  351. BOOL bFirstItem = TRUE;
  352. CTraceTag * ptag;
  353. ili = m_lcTagList.GetNextItem(-1, LVNI_SELECTED);
  354. while (ili != -1)
  355. {
  356. // Get the tag for the selected item.
  357. ptag = (CTraceTag *) m_lcTagList.GetItemData(ili);
  358. ASSERT(ptag != NULL);
  359. ptag->m_uiFlagsDialogStart = ptag->m_uiFlagsDialog;
  360. if (bFirstItem)
  361. {
  362. nDebugWin = ptag->BDebugDialog();
  363. nDebugBreak = ptag->BBreakDialog();
  364. nCom2 = ptag->BCom2Dialog();
  365. nFile = ptag->BFileDialog();
  366. bFirstItem = FALSE;
  367. } // if: first selected item
  368. else
  369. {
  370. if (ptag->BDebugDialog() != nDebugWin)
  371. nDebugWin = BST_INDETERMINATE;
  372. if (ptag->BBreakDialog() != nDebugBreak)
  373. nDebugBreak = BST_INDETERMINATE;
  374. if (ptag->BCom2Dialog() != nCom2)
  375. nCom2 = BST_INDETERMINATE;
  376. if (ptag->BFileDialog() != nFile)
  377. nFile = BST_INDETERMINATE;
  378. } // else: not first selected item
  379. // Get the next selected item.
  380. ili = m_lcTagList.GetNextItem(ili, LVNI_SELECTED);
  381. } // while: more selected items
  382. AdjustButton(!bFirstItem, m_chkboxTraceToDebugWin, nDebugWin);
  383. AdjustButton(!bFirstItem, m_chkboxDebugBreak, nDebugBreak);
  384. AdjustButton(!bFirstItem, m_chkboxTraceToCom2, nCom2);
  385. AdjustButton(!bFirstItem, m_chkboxTraceToFile, nFile);
  386. } //*** CTraceDialog::OnSelChangedListbox()
  387. /////////////////////////////////////////////////////////////////////////////
  388. //++
  389. //
  390. // CTraceDialog::AdjustButton
  391. //
  392. // Routine Description:
  393. // Configures the checkboxes of the dialog. This includes setting the
  394. // style and the value of the buttons.
  395. //
  396. // Arguments:
  397. // bEnable [IN] Determines if the given checkbox is enabled or not
  398. // (not when the selection is NULL!).
  399. // rchkbox [IN OUT] Checkbox to adjust.
  400. // nState [IN] State of the button (BST_CHECKED, BST_UNCHECKED,
  401. // or BST_INDETERMINATE).
  402. //
  403. // Return Value:
  404. // None.
  405. //
  406. //--
  407. /////////////////////////////////////////////////////////////////////////////
  408. void CTraceDialog::AdjustButton(
  409. IN BOOL bEnable,
  410. IN OUT CButton & rchkbox,
  411. IN int nState
  412. )
  413. {
  414. rchkbox.EnableWindow(bEnable);
  415. if (nState == BST_INDETERMINATE)
  416. rchkbox.SetButtonStyle(BS_AUTO3STATE, FALSE);
  417. else
  418. rchkbox.SetButtonStyle(BS_AUTOCHECKBOX, FALSE);
  419. rchkbox.SetCheck(nState);
  420. } //*** CTraceDialog::AdjustButton()
  421. /////////////////////////////////////////////////////////////////////////////
  422. //++
  423. //
  424. // CTraceDialog::OnColumnClickListbox
  425. //
  426. // Routine Description:
  427. // Handler for the LVN_COLUMNCLICK message on the listbox.
  428. //
  429. // Arguments:
  430. // None.
  431. //
  432. // Return Value:
  433. // None.
  434. //
  435. //--
  436. /////////////////////////////////////////////////////////////////////////////
  437. void CTraceDialog::OnColumnClickListbox(NMHDR * pNMHDR, LRESULT * pResult)
  438. {
  439. NM_LISTVIEW * pNMListView = (NM_LISTVIEW *) pNMHDR;
  440. // Save the current sort column and direction.
  441. if (pNMListView->iSubItem == NSortColumn())
  442. m_nSortDirection ^= -1;
  443. else
  444. {
  445. m_nSortColumn = pNMListView->iSubItem;
  446. m_nSortDirection = 0;
  447. } // else: different column
  448. // Sort the list.
  449. VERIFY(m_lcTagList.SortItems(CompareItems, (LPARAM) this));
  450. *pResult = 0;
  451. } //*** CTraceDialog::OnColumnClickListbox()
  452. /////////////////////////////////////////////////////////////////////////////
  453. //++
  454. //
  455. // CTraceDialog::CompareItems [static]
  456. //
  457. // Routine Description:
  458. // Callback function for the CListCtrl::SortItems method.
  459. //
  460. // Arguments:
  461. // lparam1 First item to compare.
  462. // lparam2 Second item to compare.
  463. // lparamSort Sort parameter.
  464. //
  465. // Return Value:
  466. // -1 First parameter comes before second.
  467. // 0 First and second parameters are the same.
  468. // 1 First parameter comes after second.
  469. //
  470. //--
  471. /////////////////////////////////////////////////////////////////////////////
  472. int CALLBACK CTraceDialog::CompareItems(
  473. LPARAM lparam1,
  474. LPARAM lparam2,
  475. LPARAM lparamSort
  476. )
  477. {
  478. CTraceTag * ptag1 = (CTraceTag *) lparam1;
  479. CTraceTag * ptag2 = (CTraceTag *) lparam2;
  480. CTraceDialog * pdlg = (CTraceDialog *) lparamSort;
  481. int nResult;
  482. ASSERT(ptag1 != NULL);
  483. ASSERT(ptag2 != NULL);
  484. ASSERT_VALID(pdlg);
  485. ASSERT(pdlg->NSortColumn() >= 0);
  486. switch (pdlg->NSortColumn())
  487. {
  488. // Sorting by subsystem.
  489. case 0:
  490. nResult = lstrcmp(ptag1->PszSubsystem(), ptag2->PszSubsystem());
  491. break;
  492. // Sorting by name.
  493. case 1:
  494. nResult = lstrcmp(ptag1->PszName(), ptag2->PszName());
  495. break;
  496. // Sorting by state.
  497. case 2:
  498. {
  499. CString strState1;
  500. CString strState2;
  501. ConstructStateString(ptag1, strState1);
  502. ConstructStateString(ptag2, strState2);
  503. // Compare the two strings.
  504. // Use CompareString() so that it will sort properly on localized builds.
  505. nResult = CompareString(
  506. LOCALE_USER_DEFAULT,
  507. 0,
  508. strState1,
  509. strState1.GetLength(),
  510. strState2,
  511. strState2.GetLength()
  512. );
  513. if ( nResult == CSTR_LESS_THAN )
  514. {
  515. nResult = -1;
  516. }
  517. else if ( nResult == CSTR_EQUAL )
  518. {
  519. nResult = 0;
  520. }
  521. else if ( nResult == CSTR_GREATER_THAN )
  522. {
  523. nResult = 1;
  524. }
  525. else
  526. {
  527. // An error occurred. Ignore it.
  528. nResult = 0;
  529. }
  530. break;
  531. } // if: sorting by state
  532. default:
  533. nResult = 0;
  534. break;
  535. } // switch: pdlg->NSortColumn()
  536. // Return the result based on the direction we are sorting.
  537. if (pdlg->NSortDirection() != 0)
  538. nResult = -nResult;
  539. return nResult;
  540. } //*** CTraceDialog::CompareItems()
  541. /////////////////////////////////////////////////////////////////////////////
  542. //++
  543. //
  544. // CTraceDialog::OnClickedTraceToDebug
  545. //
  546. // Routine Description:
  547. // Handler for the BN_CLICKED message on the Trace to Debug Window checkbox.
  548. //
  549. // Arguments:
  550. // None.
  551. //
  552. // Return Value:
  553. // None.
  554. //
  555. //--
  556. /////////////////////////////////////////////////////////////////////////////
  557. void CTraceDialog::OnClickedTraceToDebug(void)
  558. {
  559. ChangeState(m_chkboxTraceToDebugWin, CTraceTag::tfDebug);
  560. } //*** CTraceDialog::OnClickedTraceToDebug()
  561. /////////////////////////////////////////////////////////////////////////////
  562. //++
  563. //
  564. // CTraceDialog::OnClickedTraceDebugBreak
  565. //
  566. // Routine Description:
  567. // Handler for the BN_CLICKED message on the Debug Break checkbox.
  568. //
  569. // Arguments:
  570. // None.
  571. //
  572. // Return Value:
  573. // None.
  574. //
  575. //--
  576. /////////////////////////////////////////////////////////////////////////////
  577. void CTraceDialog::OnClickedTraceDebugBreak(void)
  578. {
  579. ChangeState(m_chkboxDebugBreak, CTraceTag::tfBreak);
  580. } //*** CTraceDialog::OnClickedTraceDebugBreak()
  581. /////////////////////////////////////////////////////////////////////////////
  582. //++
  583. //
  584. // CTraceDialog::OnClickedTraceToCom2
  585. //
  586. // Routine Description:
  587. // Handler for the BN_CLICKED message on the Trace to COM2 checkbox.
  588. //
  589. // Arguments:
  590. // None.
  591. //
  592. // Return Value:
  593. // None.
  594. //
  595. //--
  596. /////////////////////////////////////////////////////////////////////////////
  597. void CTraceDialog::OnClickedTraceToCom2(void)
  598. {
  599. ChangeState(m_chkboxTraceToCom2, CTraceTag::tfCom2);
  600. } //*** CTraceDialog::OnClickedTraceToCom2()
  601. /////////////////////////////////////////////////////////////////////////////
  602. //++
  603. //
  604. // CTraceDialog::OnClickedTraceToFile
  605. //
  606. // Routine Description:
  607. // Handler for the BN_CLICKED message on the Trace to File checkbox.
  608. //
  609. // Arguments:
  610. // None.
  611. //
  612. // Return Value:
  613. // None.
  614. //
  615. //--
  616. /////////////////////////////////////////////////////////////////////////////
  617. void CTraceDialog::OnClickedTraceToFile(void)
  618. {
  619. ChangeState(m_chkboxTraceToFile, CTraceTag::tfFile);
  620. } //*** CTraceDialog::OnClickedTraceToFile()
  621. /////////////////////////////////////////////////////////////////////////////
  622. //++
  623. //
  624. // CTraceDialog::ChangeState
  625. //
  626. // Routine Description:
  627. // Change the state of selected items.
  628. //
  629. // Arguments:
  630. // rchkbox [IN OUT] Checkbox whose state is changing.
  631. // tfMask [IN] Mask of state flags to change.
  632. //
  633. // Return Value:
  634. // None.
  635. //
  636. //--
  637. /////////////////////////////////////////////////////////////////////////////
  638. void CTraceDialog::ChangeState(
  639. IN OUT CButton & rchkbox,
  640. IN CTraceTag::TraceFlags tfMask
  641. )
  642. {
  643. int ili;
  644. CTraceTag * ptag;
  645. CString strState;
  646. int nState;
  647. nState = rchkbox.GetCheck();
  648. // Set the proper flag on all selected items.
  649. ili = m_lcTagList.GetNextItem(-1, LVNI_SELECTED);
  650. while (ili != -1)
  651. {
  652. // Get the selected item.
  653. ptag = (CTraceTag *) m_lcTagList.GetItemData(ili);
  654. ASSERT(ptag != NULL);
  655. // Set the proper flag in the trace tag.
  656. if (nState == BST_INDETERMINATE)
  657. {
  658. ptag->m_uiFlagsDialog &= ~tfMask;
  659. ptag->m_uiFlagsDialog |= (tfMask & ptag->m_uiFlagsDialogStart);
  660. } // if: checkbox is in an indeterminate state
  661. else
  662. ptag->SetFlagsDialog(tfMask, nState);
  663. // Set the State column.
  664. ConstructStateString(ptag, strState);
  665. VERIFY(m_lcTagList.SetItem(ili, 2, LVIF_TEXT, strState, 0, 0, 0, 0) != 0);
  666. // Get the next item.
  667. ili = m_lcTagList.GetNextItem(ili, LVNI_SELECTED);
  668. } // while: more items in the list
  669. } //*** CTraceDialog::ChangeState()
  670. /////////////////////////////////////////////////////////////////////////////
  671. //++
  672. //
  673. // CTraceDialog::OnSelChangeTagsToDisplay
  674. //
  675. // Routine Description:
  676. // Handler for the CBN_SELCHANGE message on the Tags To Display combobox.
  677. //
  678. // Arguments:
  679. // None.
  680. //
  681. // Return Value:
  682. // None.
  683. //
  684. //--
  685. /////////////////////////////////////////////////////////////////////////////
  686. void CTraceDialog::OnSelChangeTagsToDisplay(void)
  687. {
  688. int nCurFilter;
  689. // If a change was actually made, reload the listbox.
  690. nCurFilter = m_cboxDisplayOptions.GetCurSel();
  691. if (nCurFilter != m_nCurFilter)
  692. {
  693. m_nCurFilter = nCurFilter;
  694. LoadListbox();
  695. } // if: filter changed
  696. } //*** CTraceDialog::OnSelChangeTagsToDisplay()
  697. /////////////////////////////////////////////////////////////////////////////
  698. //++
  699. //
  700. // CTraceDialog::LoadListbox
  701. //
  702. // Routine Description:
  703. // Load the listbox.
  704. //
  705. // Arguments:
  706. // None.
  707. //
  708. // Return Value:
  709. // None.
  710. //
  711. //--
  712. /////////////////////////////////////////////////////////////////////////////
  713. void CTraceDialog::LoadListbox(void)
  714. {
  715. int ili;
  716. int iliReturn;
  717. CTraceTag * ptag;
  718. CString strState;
  719. m_lcTagList.DeleteAllItems();
  720. ptag = CTraceTag::s_ptagFirst;
  721. for (ili = 0 ; ptag != NULL ; )
  722. {
  723. // Insert the item in the list if it should be displayed.
  724. if (BDisplayTag(ptag))
  725. {
  726. iliReturn = m_lcTagList.InsertItem(
  727. LVIF_TEXT | LVIF_PARAM,
  728. ili,
  729. ptag->PszSubsystem(),
  730. 0,
  731. 0,
  732. 0,
  733. (LPARAM) ptag
  734. );
  735. ASSERT(iliReturn != -1);
  736. VERIFY(m_lcTagList.SetItem(iliReturn, 1, LVIF_TEXT, ptag->PszName(), 0, 0, 0, 0) != 0);
  737. ConstructStateString(ptag, strState);
  738. VERIFY(m_lcTagList.SetItem(iliReturn, 2, LVIF_TEXT, strState, 0, 0, 0, 0) != 0);
  739. ili++;
  740. } // if: tag shold be displayed
  741. // Get the next tag.
  742. ptag = ptag->m_ptagNext;
  743. } // while: more tags in the list
  744. // If the list is not empty, select the first item.
  745. if (m_lcTagList.GetItemCount() > 0)
  746. VERIFY(m_lcTagList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED) != 0);
  747. } //*** CTraceDialog::LoadListbox()
  748. /////////////////////////////////////////////////////////////////////////////
  749. //++
  750. //
  751. // CTraceDialog::BDisplayTag
  752. //
  753. // Purpose:
  754. // Determines if a given tag should be displayed based on
  755. // the current filter selection.
  756. //
  757. // Arguments:
  758. // ptag [IN] Pointer to the tag to test
  759. //
  760. // Return Value:
  761. // TRUE Display the tag.
  762. // FALSE Don't display the tag.
  763. //
  764. //--
  765. /////////////////////////////////////////////////////////////////////////////
  766. BOOL CTraceDialog::BDisplayTag(IN const CTraceTag * ptag)
  767. {
  768. BOOL bDisplay = TRUE;
  769. switch (m_nCurFilter)
  770. {
  771. default:
  772. // AssertAlways(LITERAL("Unknown Filter, adjust CTraceDialog::FDisplayFilter"));
  773. break;
  774. case 0:
  775. break;
  776. case 1:
  777. if (!ptag->BDebugDialog())
  778. bDisplay = FALSE;
  779. break;
  780. case 2:
  781. if (!ptag->BBreakDialog())
  782. bDisplay = FALSE;
  783. break;
  784. case 3:
  785. if (!ptag->BCom2Dialog())
  786. bDisplay = FALSE;
  787. break;
  788. case 4:
  789. if (!ptag->BFileDialog())
  790. bDisplay = FALSE;
  791. break;
  792. case 5:
  793. if (!ptag->m_uiFlagsDialog)
  794. bDisplay = FALSE;
  795. break;
  796. }
  797. return bDisplay;
  798. } //*** CTraceDialog::BDisplayTag()
  799. #endif // _DEBUG