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.

957 lines
23 KiB

  1. //
  2. // Driver Verifier UI
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. //
  7. // module: DCntPage.cpp
  8. // author: DMihai
  9. // created: 11/1/00
  10. //
  11. // Description:
  12. //
  13. #include "stdafx.h"
  14. #include "verifier.h"
  15. #include "DCntPage.h"
  16. #include "VrfUtil.h"
  17. #include "VGlobal.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. //
  24. // Timer ID
  25. //
  26. #define REFRESH_TIMER_ID 0x1234
  27. //
  28. // Help IDs
  29. //
  30. static DWORD MyHelpIds[] =
  31. {
  32. IDC_PERDRVC_DRIVER_COMBO, IDH_DV_Counters_DriverList,
  33. IDC_PERDRVC_LIST, IDH_DV_DriverCounters,
  34. 0, 0
  35. };
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CDriverCountersPage property page
  38. IMPLEMENT_DYNCREATE(CDriverCountersPage, CVerifierPropertyPage)
  39. CDriverCountersPage::CDriverCountersPage() : CVerifierPropertyPage(CDriverCountersPage::IDD)
  40. {
  41. //{{AFX_DATA_INIT(CDriverCountersPage)
  42. //}}AFX_DATA_INIT
  43. m_nSortColumnIndex = 0;
  44. m_bAscendSortName = FALSE;
  45. m_bAscendSortValue = FALSE;
  46. m_uTimerHandler = 0;
  47. m_pParentSheet = NULL;
  48. }
  49. CDriverCountersPage::~CDriverCountersPage()
  50. {
  51. }
  52. void CDriverCountersPage::DoDataExchange(CDataExchange* pDX)
  53. {
  54. if( ! pDX->m_bSaveAndValidate )
  55. {
  56. //
  57. // Query the kernel
  58. //
  59. VrfGetRuntimeVerifierData( &m_RuntimeVerifierData );
  60. }
  61. CVerifierPropertyPage::DoDataExchange(pDX);
  62. //{{AFX_DATA_MAP(CDriverCountersPage)
  63. DDX_Control(pDX, IDC_PERDRVC_DRIVER_COMBO, m_DriversCombo);
  64. DDX_Control(pDX, IDC_PERDRVC_NEXT_DESCR_STATIC, m_NextDescription);
  65. DDX_Control(pDX, IDC_PERDRVC_LIST, m_CountersList);
  66. //}}AFX_DATA_MAP
  67. }
  68. BEGIN_MESSAGE_MAP(CDriverCountersPage, CVerifierPropertyPage)
  69. //{{AFX_MSG_MAP(CDriverCountersPage)
  70. ON_WM_TIMER()
  71. ON_CBN_SELENDOK(IDC_PERDRVC_DRIVER_COMBO, OnSelendokDriverCombo)
  72. ON_NOTIFY(LVN_COLUMNCLICK, IDC_PERDRVC_LIST, OnColumnclickPerdrvcList)
  73. ON_WM_CONTEXTMENU()
  74. ON_MESSAGE( WM_HELP, OnHelp )
  75. //}}AFX_MSG_MAP
  76. END_MESSAGE_MAP()
  77. /////////////////////////////////////////////////////////////
  78. VOID CDriverCountersPage::SetupListHeader()
  79. {
  80. LVCOLUMN lvColumn;
  81. CRect rectWnd;
  82. CString strCounter, strValue;
  83. VERIFY( strCounter.LoadString( IDS_COUNTER ) );
  84. VERIFY( strValue.LoadString( IDS_VALUE ) );
  85. //
  86. // List's regtangle
  87. //
  88. m_CountersList.GetClientRect( &rectWnd );
  89. //
  90. // Column 0 - counter
  91. //
  92. ZeroMemory( &lvColumn, sizeof( lvColumn ) );
  93. lvColumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
  94. lvColumn.fmt = LVCFMT_LEFT;
  95. lvColumn.iSubItem = 0;
  96. lvColumn.pszText = strCounter.GetBuffer( strCounter.GetLength() + 1 );
  97. lvColumn.cx = (int)( rectWnd.Width() * 0.50 );
  98. VERIFY( m_CountersList.InsertColumn( 0, &lvColumn ) != -1 );
  99. strCounter.ReleaseBuffer();
  100. //
  101. // Column 1
  102. //
  103. lvColumn.iSubItem = 1;
  104. lvColumn.pszText = strValue.GetBuffer( strValue.GetLength() + 1 );
  105. lvColumn.cx = (int)( rectWnd.Width() * 0.47 );
  106. VERIFY( m_CountersList.InsertColumn( 1, &lvColumn ) != -1 );
  107. strValue.ReleaseBuffer();
  108. }
  109. /////////////////////////////////////////////////////////////
  110. VOID CDriverCountersPage::FillTheList()
  111. {
  112. CRuntimeDriverData *pRuntimeDriverData;
  113. pRuntimeDriverData = GetCurrentDrvRuntimeData();
  114. AddAllListItems( pRuntimeDriverData );
  115. }
  116. /////////////////////////////////////////////////////////////
  117. VOID CDriverCountersPage::AddAllListItems( CRuntimeDriverData *pRuntimeDriverData )
  118. {
  119. if( NULL != pRuntimeDriverData )
  120. {
  121. ASSERT_VALID( pRuntimeDriverData );
  122. //
  123. // N.B.
  124. //
  125. // If you change this order then you need to change GetCounterValue as well
  126. //
  127. AddCounterInList( 0, IDS_CURRENTPAGEDPOOLALLOCATIONS_LIST, pRuntimeDriverData->CurrentPagedPoolAllocations );
  128. AddCounterInList( 1, IDS_PEAKPAGEDPOOLALLOCATIONS_LIST, pRuntimeDriverData->PeakPagedPoolAllocations );
  129. AddCounterInList( 2, IDS_PAGEDPOOLUSAGEINBYTES_LIST, pRuntimeDriverData->PagedPoolUsageInBytes );
  130. AddCounterInList( 3, IDS_PEAKPAGEDPOOLUSAGEINBYTES_LIST, pRuntimeDriverData->PeakPagedPoolUsageInBytes );
  131. AddCounterInList( 4, IDS_CURRENTNONPAGEDPOOLALLOCATIONS_LIST, pRuntimeDriverData->CurrentNonPagedPoolAllocations );
  132. AddCounterInList( 5, IDS_PEAKNONPAGEDPOOLALLOCATIONS_LIST, pRuntimeDriverData->PeakNonPagedPoolAllocations );
  133. AddCounterInList( 6, IDS_NONPAGEDPOOLUSAGEINBYTES_LIST, pRuntimeDriverData->NonPagedPoolUsageInBytes );
  134. AddCounterInList( 7, IDS_PEAKNONPAGEDPOOLUSAGEINBYTES_LIST, pRuntimeDriverData->PeakNonPagedPoolUsageInBytes );
  135. }
  136. else
  137. {
  138. //
  139. // N.B.
  140. //
  141. // If you change this order then you need to change GetCounterValue as well
  142. //
  143. AddCounterInList( 0, IDS_CURRENTPAGEDPOOLALLOCATIONS_LIST );
  144. AddCounterInList( 1, IDS_PEAKPAGEDPOOLALLOCATIONS_LIST );
  145. AddCounterInList( 2, IDS_PAGEDPOOLUSAGEINBYTES_LIST );
  146. AddCounterInList( 3, IDS_PEAKPAGEDPOOLUSAGEINBYTES_LIST );
  147. AddCounterInList( 4, IDS_CURRENTNONPAGEDPOOLALLOCATIONS_LIST );
  148. AddCounterInList( 5, IDS_PEAKNONPAGEDPOOLALLOCATIONS_LIST );
  149. AddCounterInList( 6, IDS_NONPAGEDPOOLUSAGEINBYTES_LIST );
  150. AddCounterInList( 7, IDS_PEAKNONPAGEDPOOLUSAGEINBYTES_LIST );
  151. }
  152. }
  153. /////////////////////////////////////////////////////////////
  154. VOID CDriverCountersPage::RefreshTheList()
  155. {
  156. INT nListItems;
  157. INT nCrtListItem;
  158. INT_PTR nCrtCounterIndex;
  159. SIZE_T sizeValue;
  160. CRuntimeDriverData *pRuntimeDriverData;
  161. pRuntimeDriverData = GetCurrentDrvRuntimeData();
  162. nListItems = m_CountersList.GetItemCount();
  163. if( NULL != pRuntimeDriverData )
  164. {
  165. for( nCrtListItem = 0; nCrtListItem < nListItems; nCrtListItem += 1 )
  166. {
  167. nCrtCounterIndex = m_CountersList.GetItemData( nCrtListItem );
  168. sizeValue = GetCounterValue( nCrtCounterIndex, pRuntimeDriverData );
  169. UpdateCounterValueInList( nCrtListItem, sizeValue );
  170. }
  171. }
  172. else
  173. {
  174. //
  175. // N.B.
  176. //
  177. // If you change this order then you need to
  178. // change AddAllListItems as well
  179. //
  180. for( nCrtListItem = 0; nCrtListItem < nListItems; nCrtListItem += 1 )
  181. {
  182. UpdateCounterValueInList( nCrtListItem, g_szVoidText );
  183. }
  184. }
  185. SortTheList();
  186. }
  187. /////////////////////////////////////////////////////////////
  188. INT CDriverCountersPage::AddCounterInList( INT nItemData,
  189. ULONG uIdResourceString )
  190. {
  191. INT nActualIndex;
  192. LVITEM lvItem;
  193. CString strName;
  194. nActualIndex = -1;
  195. VERIFY( strName.LoadString( uIdResourceString ) );
  196. ZeroMemory( &lvItem, sizeof( lvItem ) );
  197. //
  198. // LVITEM's member pszText is not a const pointer
  199. // so we need to GetBuffer here :-(
  200. //
  201. //
  202. // Sub-item 0 - counter's name
  203. //
  204. lvItem.pszText = strName.GetBuffer( strName.GetLength() + 1 );
  205. if( NULL == lvItem.pszText )
  206. {
  207. goto Done;
  208. }
  209. lvItem.mask = LVIF_TEXT | LVIF_PARAM;
  210. lvItem.lParam = nItemData;
  211. lvItem.iItem = m_CountersList.GetItemCount();
  212. nActualIndex = m_CountersList.InsertItem( &lvItem );
  213. if( nActualIndex < 0 )
  214. {
  215. //
  216. // Could not add an item in the list - give up
  217. //
  218. goto Done;
  219. }
  220. Done:
  221. //
  222. // All done
  223. //
  224. return nActualIndex;
  225. }
  226. /////////////////////////////////////////////////////////////
  227. VOID CDriverCountersPage::AddCounterInList( INT nItemData,
  228. ULONG uIdResourceString,
  229. SIZE_T sizeValue )
  230. {
  231. INT nActualIndex;
  232. nActualIndex = AddCounterInList( nItemData, uIdResourceString );
  233. if( nActualIndex < 0 )
  234. {
  235. //
  236. // Could not add an item in the list - give up
  237. //
  238. goto Done;
  239. }
  240. //
  241. // Sub-item 1 - counter's value
  242. //
  243. UpdateCounterValueInList( nActualIndex,
  244. sizeValue );
  245. Done:
  246. //
  247. // All done
  248. //
  249. NOTHING;
  250. }
  251. /////////////////////////////////////////////////////////////
  252. SIZE_T CDriverCountersPage::GetCounterValue( INT_PTR nCounterIndex, CRuntimeDriverData *pRuntimeDriverData /*= NULL*/ )
  253. {
  254. SIZE_T sizeValue;
  255. if( NULL == pRuntimeDriverData )
  256. {
  257. pRuntimeDriverData = GetCurrentDrvRuntimeData();
  258. }
  259. if( NULL == pRuntimeDriverData )
  260. {
  261. //
  262. // No driver is curently selected in the combo
  263. //
  264. return 0;
  265. }
  266. //
  267. // N.B.
  268. //
  269. // If you change this switch statement you need to change AddAllListItems as well
  270. //
  271. switch( nCounterIndex )
  272. {
  273. case 0:
  274. sizeValue = pRuntimeDriverData->CurrentPagedPoolAllocations;
  275. break;
  276. case 1:
  277. sizeValue = pRuntimeDriverData->PeakPagedPoolAllocations;
  278. break;
  279. case 2:
  280. sizeValue = pRuntimeDriverData->PagedPoolUsageInBytes;
  281. break;
  282. case 3:
  283. sizeValue = pRuntimeDriverData->PeakPagedPoolUsageInBytes;
  284. break;
  285. case 4:
  286. sizeValue = pRuntimeDriverData->CurrentNonPagedPoolAllocations;
  287. break;
  288. case 5:
  289. sizeValue = pRuntimeDriverData->PeakNonPagedPoolAllocations;
  290. break;
  291. case 6:
  292. sizeValue = pRuntimeDriverData->NonPagedPoolUsageInBytes;
  293. break;
  294. case 7:
  295. sizeValue = pRuntimeDriverData->PeakNonPagedPoolUsageInBytes;
  296. break;
  297. default:
  298. //
  299. // Oops, how did we get here ?!?
  300. //
  301. ASSERT( FALSE );
  302. sizeValue = 0;
  303. break;
  304. }
  305. return sizeValue;
  306. }
  307. /////////////////////////////////////////////////////////////
  308. BOOL CDriverCountersPage::GetCounterName( LPARAM lItemData,
  309. TCHAR *szCounterName,
  310. ULONG uCounterNameBufferLen )
  311. {
  312. INT nItemIndex;
  313. BOOL bResult;
  314. LVFINDINFO FindInfo;
  315. LVITEM lvItem;
  316. bResult = FALSE;
  317. ZeroMemory( &FindInfo, sizeof( FindInfo ) );
  318. FindInfo.flags = LVFI_PARAM;
  319. FindInfo.lParam = lItemData;
  320. nItemIndex = m_CountersList.FindItem( &FindInfo );
  321. if( nItemIndex < 0 || nItemIndex > 7 )
  322. {
  323. ASSERT( FALSE );
  324. }
  325. else
  326. {
  327. //
  328. // Found our item - get the name
  329. //
  330. ZeroMemory( &lvItem, sizeof( lvItem ) );
  331. lvItem.mask = LVIF_TEXT;
  332. lvItem.iItem = nItemIndex;
  333. lvItem.iSubItem = 0;
  334. lvItem.pszText = szCounterName;
  335. lvItem.cchTextMax = uCounterNameBufferLen;
  336. bResult = m_CountersList.GetItem( &lvItem );
  337. if( bResult == FALSE )
  338. {
  339. //
  340. // Could not get the current item's attributes?!?
  341. //
  342. ASSERT( FALSE );
  343. }
  344. }
  345. return bResult;
  346. }
  347. /////////////////////////////////////////////////////////////
  348. VOID CDriverCountersPage::UpdateCounterValueInList( INT nItemIndex,
  349. LPTSTR szValue )
  350. {
  351. LVITEM lvItem;
  352. //
  353. // Update the list item
  354. //
  355. ZeroMemory( &lvItem, sizeof( lvItem ) );
  356. lvItem.mask = LVIF_TEXT;
  357. lvItem.iItem = nItemIndex;
  358. lvItem.iSubItem = 1;
  359. lvItem.pszText = szValue;
  360. VERIFY( m_CountersList.SetItem( &lvItem ) );
  361. }
  362. /////////////////////////////////////////////////////////////
  363. VOID CDriverCountersPage::UpdateCounterValueInList( INT nItemIndex,
  364. SIZE_T sizeValue )
  365. {
  366. TCHAR szValue[ 32 ];
  367. #ifndef _WIN64
  368. //
  369. // 32 bit SIZE_T
  370. //
  371. _sntprintf( szValue,
  372. ARRAY_LENGTH( szValue ),
  373. _T( "%u" ),
  374. sizeValue );
  375. #else
  376. //
  377. // 64 bit SIZE_T
  378. //
  379. _sntprintf( szValue,
  380. ARRAY_LENGTH( szValue ),
  381. _T( "%I64u" ),
  382. sizeValue );
  383. #endif
  384. szValue[ ARRAY_LENGTH( szValue ) - 1 ] = 0;
  385. UpdateCounterValueInList( nItemIndex,
  386. szValue );
  387. }
  388. /////////////////////////////////////////////////////////////
  389. VOID CDriverCountersPage::RefreshCombo()
  390. {
  391. BOOL *pbAlreadyInCombo;
  392. CRuntimeDriverData *pRuntimeDriverData;
  393. INT_PTR nDrivers;
  394. INT_PTR nCrtDriver;
  395. INT nCrtSelectedItem;
  396. INT nCrtItemIndex;
  397. INT nComboItemCount;
  398. INT nActualIndex;
  399. CString strCurrentDriverName;
  400. CString strDriverName;
  401. nDrivers = m_RuntimeVerifierData.m_RuntimeDriverDataArray.GetSize();
  402. if( 0 >= nDrivers )
  403. {
  404. //
  405. // No drivers are currently verified - delete the combo-box content
  406. //
  407. m_DriversCombo.ResetContent();
  408. m_DriversCombo.SetCurSel( CB_ERR );
  409. m_DriversCombo.EnableWindow( FALSE );
  410. OnSelendokDriverCombo();
  411. }
  412. else
  413. {
  414. nCrtSelectedItem = 0;
  415. nComboItemCount = m_DriversCombo.GetCount();
  416. //
  417. // Note the currently selected driver name
  418. //
  419. GetCurrentSelDriverName( strCurrentDriverName );
  420. //
  421. // Allocate an array of BOOL values, one for each driver in
  422. // our runtime data array
  423. //
  424. pbAlreadyInCombo = new BOOL[ nDrivers ];
  425. if( NULL == pbAlreadyInCombo )
  426. {
  427. goto Done;
  428. }
  429. for( nCrtDriver = 0; nCrtDriver < nDrivers; nCrtDriver++ )
  430. {
  431. pbAlreadyInCombo[ nCrtDriver ] = FALSE;
  432. }
  433. //
  434. // Parse all the items currently in the combo-box
  435. //
  436. for( nCrtItemIndex = 0; nCrtItemIndex < nComboItemCount; nCrtItemIndex++ )
  437. {
  438. m_DriversCombo.GetLBText( nCrtItemIndex, strDriverName );
  439. //
  440. // Parse all the currently verified drivers
  441. //
  442. for( nCrtDriver = 0; nCrtDriver < nDrivers; nCrtDriver++ )
  443. {
  444. pRuntimeDriverData = m_RuntimeVerifierData.m_RuntimeDriverDataArray.GetAt( nCrtDriver );
  445. ASSERT_VALID( pRuntimeDriverData );
  446. if( strDriverName.CompareNoCase( pRuntimeDriverData->m_strName ) == 0 )
  447. {
  448. pbAlreadyInCombo[ nCrtDriver ] = TRUE;
  449. break;
  450. }
  451. }
  452. if( nCrtDriver >= nDrivers )
  453. {
  454. //
  455. // We need to delete the current combo item because
  456. // the corresponfing driver is no longer verified
  457. //
  458. m_DriversCombo.DeleteString( nCrtItemIndex );
  459. nCrtItemIndex--;
  460. nComboItemCount--;
  461. }
  462. }
  463. //
  464. // Add the new items in the combo
  465. //
  466. for( nCrtDriver = 0; nCrtDriver < nDrivers; nCrtDriver++ )
  467. {
  468. if( FALSE == pbAlreadyInCombo[ nCrtDriver ] )
  469. {
  470. pRuntimeDriverData = m_RuntimeVerifierData.m_RuntimeDriverDataArray.GetAt( nCrtDriver );
  471. ASSERT_VALID( pRuntimeDriverData );
  472. nActualIndex = m_DriversCombo.AddString( pRuntimeDriverData->m_strName );
  473. if( nActualIndex != CB_ERR )
  474. {
  475. m_DriversCombo.SetItemData( nActualIndex, nCrtDriver );
  476. }
  477. }
  478. }
  479. delete [] pbAlreadyInCombo;
  480. //
  481. // Restore the old current selection in the combo
  482. //
  483. nComboItemCount = m_DriversCombo.GetCount();
  484. for( nCrtItemIndex = 0; nCrtItemIndex < nComboItemCount; nCrtItemIndex++ )
  485. {
  486. m_DriversCombo.GetLBText( nCrtItemIndex, strDriverName );
  487. if( strDriverName.CompareNoCase( strCurrentDriverName ) == 0 )
  488. {
  489. nCrtSelectedItem = nCrtItemIndex;
  490. break;
  491. }
  492. }
  493. m_DriversCombo.SetCurSel( nCrtSelectedItem );
  494. OnSelendokDriverCombo();
  495. }
  496. Done:
  497. NOTHING;
  498. }
  499. /////////////////////////////////////////////////////////////
  500. VOID CDriverCountersPage::RefreshInfo()
  501. {
  502. if( UpdateData( FALSE ) )
  503. {
  504. //
  505. // Refresh the combo content - this will also
  506. // refresh the counters list
  507. //
  508. RefreshCombo();
  509. }
  510. }
  511. /////////////////////////////////////////////////////////////
  512. VOID CDriverCountersPage::GetCurrentSelDriverName( CString &strName )
  513. {
  514. INT nCrtSel;
  515. nCrtSel = m_DriversCombo.GetCurSel();
  516. if( CB_ERR != nCrtSel )
  517. {
  518. m_DriversCombo.GetLBText( nCrtSel, strName );
  519. }
  520. else
  521. {
  522. strName.Empty();
  523. }
  524. }
  525. /////////////////////////////////////////////////////////////
  526. CRuntimeDriverData *CDriverCountersPage::GetCurrentDrvRuntimeData()
  527. {
  528. INT nCrtComboSelection;
  529. INT_PTR nCrtDriverIndex;
  530. CRuntimeDriverData *pRuntimeDriverData;
  531. pRuntimeDriverData = NULL;
  532. nCrtDriverIndex = -1;
  533. nCrtComboSelection = m_DriversCombo.GetCurSel();
  534. if( nCrtComboSelection != CB_ERR )
  535. {
  536. nCrtDriverIndex = m_DriversCombo.GetItemData( nCrtComboSelection );
  537. if( nCrtDriverIndex >= 0 && nCrtDriverIndex < m_RuntimeVerifierData.m_RuntimeDriverDataArray.GetSize() )
  538. {
  539. pRuntimeDriverData = m_RuntimeVerifierData.m_RuntimeDriverDataArray.GetAt( nCrtDriverIndex );
  540. ASSERT_VALID( pRuntimeDriverData );
  541. }
  542. }
  543. return pRuntimeDriverData;
  544. }
  545. /////////////////////////////////////////////////////////////
  546. VOID CDriverCountersPage::SortTheList()
  547. {
  548. if( 0 != m_nSortColumnIndex )
  549. {
  550. //
  551. // Sort by counter value - this is probably not very useful
  552. // but we are providing it to be consistent with all
  553. // the lists being sortable by any column
  554. //
  555. m_CountersList.SortItems( CounterValueCmpFunc, (LPARAM)this );
  556. }
  557. else
  558. {
  559. //
  560. // Sort by driver name
  561. //
  562. m_CountersList.SortItems( CounterNameCmpFunc, (LPARAM)this );
  563. }
  564. }
  565. /////////////////////////////////////////////////////////////
  566. int CALLBACK CDriverCountersPage::CounterValueCmpFunc( LPARAM lParam1,
  567. LPARAM lParam2,
  568. LPARAM lParamSort)
  569. {
  570. SIZE_T size1;
  571. SIZE_T size2;
  572. int nCmpRez = 0;
  573. CDriverCountersPage *pThis = (CDriverCountersPage *)lParamSort;
  574. ASSERT_VALID( pThis );
  575. size1 = pThis->GetCounterValue( (INT) lParam1 );
  576. size2 = pThis->GetCounterValue( (INT) lParam2 );
  577. if( size1 > size2 )
  578. {
  579. nCmpRez = 1;
  580. }
  581. else
  582. {
  583. if( size1 < size2 )
  584. {
  585. nCmpRez = -1;
  586. }
  587. }
  588. if( FALSE != pThis->m_bAscendSortValue )
  589. {
  590. nCmpRez *= -1;
  591. }
  592. return nCmpRez;
  593. }
  594. /////////////////////////////////////////////////////////////
  595. int CALLBACK CDriverCountersPage::CounterNameCmpFunc( LPARAM lParam1,
  596. LPARAM lParam2,
  597. LPARAM lParamSort)
  598. {
  599. int nCmpRez = 0;
  600. BOOL bSuccess;
  601. TCHAR szCounterName1[ _MAX_PATH ];
  602. TCHAR szCounterName2[ _MAX_PATH ];
  603. CDriverCountersPage *pThis = (CDriverCountersPage *)lParamSort;
  604. ASSERT_VALID( pThis );
  605. //
  606. // Get the first counter name
  607. //
  608. bSuccess = pThis->GetCounterName( lParam1,
  609. szCounterName1,
  610. ARRAY_LENGTH( szCounterName1 ) );
  611. if( FALSE == bSuccess )
  612. {
  613. goto Done;
  614. }
  615. //
  616. // Get the second counter name
  617. //
  618. bSuccess = pThis->GetCounterName( lParam2,
  619. szCounterName2,
  620. ARRAY_LENGTH( szCounterName2 ) );
  621. if( FALSE == bSuccess )
  622. {
  623. goto Done;
  624. }
  625. //
  626. // Compare the names
  627. //
  628. nCmpRez = _tcsicmp( szCounterName1, szCounterName2 );
  629. if( FALSE != pThis->m_bAscendSortName )
  630. {
  631. nCmpRez *= -1;
  632. }
  633. Done:
  634. return nCmpRez;
  635. }
  636. /////////////////////////////////////////////////////////////
  637. // CDriverCountersPage message handlers
  638. BOOL CDriverCountersPage::OnInitDialog()
  639. {
  640. CPropertyPage::OnInitDialog();
  641. //
  642. // Setup the settings bits list
  643. //
  644. m_CountersList.SetExtendedStyle(
  645. LVS_EX_FULLROWSELECT | m_CountersList.GetExtendedStyle() );
  646. m_CountersList.SetBkColor( ::GetSysColor( COLOR_3DFACE ) );
  647. m_CountersList.SetTextBkColor( ::GetSysColor( COLOR_3DFACE ) );
  648. SetupListHeader();
  649. FillTheList();
  650. SortTheList();
  651. RefreshCombo();
  652. VrfSetWindowText( m_NextDescription, IDS_DCNT_PAGE_NEXT_DESCR );
  653. VERIFY( m_uTimerHandler = SetTimer( REFRESH_TIMER_ID,
  654. 5000,
  655. NULL ) );
  656. return TRUE; // return TRUE unless you set the focus to a control
  657. // EXCEPTION: OCX Property Pages should return FALSE
  658. }
  659. /////////////////////////////////////////////////////////////
  660. VOID CDriverCountersPage::OnTimer(UINT nIDEvent)
  661. {
  662. if( nIDEvent == REFRESH_TIMER_ID )
  663. {
  664. ASSERT_VALID( m_pParentSheet );
  665. if( m_pParentSheet->GetActivePage() == this )
  666. {
  667. //
  668. // Refresh the displayed data
  669. //
  670. RefreshInfo();
  671. }
  672. }
  673. CPropertyPage::OnTimer(nIDEvent);
  674. }
  675. /////////////////////////////////////////////////////////////////////////////
  676. BOOL CDriverCountersPage::OnSetActive()
  677. {
  678. ASSERT_VALID( m_pParentSheet );
  679. m_pParentSheet->SetWizardButtons( PSWIZB_BACK |
  680. PSWIZB_FINISH );
  681. return CVerifierPropertyPage::OnSetActive();
  682. }
  683. /////////////////////////////////////////////////////////////
  684. void CDriverCountersPage::OnSelendokDriverCombo()
  685. {
  686. RefreshTheList();
  687. }
  688. /////////////////////////////////////////////////////////////
  689. void CDriverCountersPage::OnColumnclickPerdrvcList(NMHDR* pNMHDR, LRESULT* pResult)
  690. {
  691. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  692. if( 0 != pNMListView->iSubItem )
  693. {
  694. //
  695. // Clicked on the counter value column
  696. //
  697. if( m_nSortColumnIndex == pNMListView->iSubItem )
  698. {
  699. //
  700. // Change the current ascend/descend order for this column
  701. //
  702. m_bAscendSortValue = !m_bAscendSortValue;
  703. }
  704. }
  705. else
  706. {
  707. //
  708. // Clicked on the counter name column
  709. //
  710. if( m_nSortColumnIndex == pNMListView->iSubItem )
  711. {
  712. //
  713. // Change the current ascend/descend order for this column
  714. //
  715. m_bAscendSortName = !m_bAscendSortName;
  716. }
  717. }
  718. m_nSortColumnIndex = pNMListView->iSubItem;
  719. SortTheList();
  720. *pResult = 0;
  721. }
  722. /////////////////////////////////////////////////////////////
  723. LONG CDriverCountersPage::OnHelp( WPARAM wParam, LPARAM lParam )
  724. {
  725. LONG lResult = 0;
  726. LPHELPINFO lpHelpInfo = (LPHELPINFO)lParam;
  727. ::WinHelp(
  728. (HWND) lpHelpInfo->hItemHandle,
  729. g_szVerifierHelpFile,
  730. HELP_WM_HELP,
  731. (DWORD_PTR) MyHelpIds );
  732. return lResult;
  733. }
  734. /////////////////////////////////////////////////////////////////////////////
  735. void CDriverCountersPage::OnContextMenu(CWnd* pWnd, CPoint point)
  736. {
  737. ::WinHelp(
  738. pWnd->m_hWnd,
  739. g_szVerifierHelpFile,
  740. HELP_CONTEXTMENU,
  741. (DWORD_PTR) MyHelpIds );
  742. }