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.

975 lines
22 KiB

  1. //
  2. // Driver Verifier UI
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. //
  7. // module: SDrvPage.cpp
  8. // author: DMihai
  9. // created: 11/1/00
  10. //
  11. // Description:
  12. //
  13. #include "stdafx.h"
  14. #include <Cderr.h>
  15. #include "verifier.h"
  16. #include "SDrvPage.h"
  17. #include "VrfUtil.h"
  18. #include "VGlobal.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. //
  25. // Help IDs
  26. //
  27. static DWORD MyHelpIds[] =
  28. {
  29. IDC_SELDRV_LIST, IDH_DV_SelectDriversToVerify,
  30. IDC_SELDRV_ADD_BUTTON, IDH_DV_Addbut_UnloadedDrivers,
  31. 0, 0
  32. };
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CSelectDriversPage property page
  35. IMPLEMENT_DYNCREATE(CSelectDriversPage, CVerifierPropertyPage)
  36. CSelectDriversPage::CSelectDriversPage()
  37. : CVerifierPropertyPage(CSelectDriversPage::IDD)
  38. {
  39. //{{AFX_DATA_INIT(CSelectDriversPage)
  40. // NOTE: the ClassWizard will add member initialization here
  41. //}}AFX_DATA_INIT
  42. m_pParentSheet = NULL;
  43. m_nSortColumnIndex = 1;
  44. m_bAscendSortVerified = FALSE;
  45. m_bAscendSortDrvName = FALSE;
  46. m_bAscendSortProvName = FALSE;
  47. m_bAscendSortVersion = FALSE;
  48. }
  49. CSelectDriversPage::~CSelectDriversPage()
  50. {
  51. }
  52. void CSelectDriversPage::DoDataExchange(CDataExchange* pDX)
  53. {
  54. CVerifierPropertyPage::DoDataExchange(pDX);
  55. //{{AFX_DATA_MAP(CSelectDriversPage)
  56. DDX_Control(pDX, IDC_SELDRV_NEXT_DESCR_STATIC, m_NextDescription);
  57. DDX_Control(pDX, IDC_SELDRV_LIST, m_DriversList);
  58. //}}AFX_DATA_MAP
  59. }
  60. BEGIN_MESSAGE_MAP(CSelectDriversPage, CVerifierPropertyPage)
  61. //{{AFX_MSG_MAP(CSelectDriversPage)
  62. ON_BN_CLICKED(IDC_SELDRV_ADD_BUTTON, OnAddButton)
  63. ON_NOTIFY(LVN_COLUMNCLICK, IDC_SELDRV_LIST, OnColumnclickSeldrvList)
  64. ON_WM_CONTEXTMENU()
  65. ON_MESSAGE( WM_HELP, OnHelp )
  66. //}}AFX_MSG_MAP
  67. END_MESSAGE_MAP()
  68. /////////////////////////////////////////////////////////////////////////////
  69. VOID CSelectDriversPage::SetupListHeader()
  70. {
  71. CString strTitle;
  72. CRect rectWnd;
  73. LVCOLUMN lvColumn;
  74. //
  75. // The list's rectangle
  76. //
  77. m_DriversList.GetClientRect( &rectWnd );
  78. ZeroMemory( &lvColumn,
  79. sizeof( lvColumn ) );
  80. lvColumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
  81. lvColumn.fmt = LVCFMT_LEFT;
  82. //
  83. // Column 0
  84. //
  85. VERIFY( strTitle.LoadString( IDS_VERIFICATION_STATUS ) );
  86. lvColumn.iSubItem = 0;
  87. lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
  88. lvColumn.cx = (int)( rectWnd.Width() * 0.08 );
  89. VERIFY( m_DriversList.InsertColumn( 0, &lvColumn ) != -1 );
  90. strTitle.ReleaseBuffer();
  91. //
  92. // Column 1
  93. //
  94. VERIFY( strTitle.LoadString( IDS_DRIVERS ) );
  95. lvColumn.iSubItem = 1;
  96. lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
  97. lvColumn.cx = (int)( rectWnd.Width() * 0.20 );
  98. VERIFY( m_DriversList.InsertColumn( 1, &lvColumn ) != -1 );
  99. strTitle.ReleaseBuffer();
  100. //
  101. // Column 2
  102. //
  103. VERIFY( strTitle.LoadString( IDS_PROVIDER ) );
  104. lvColumn.iSubItem = 2;
  105. lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
  106. lvColumn.cx = (int)( rectWnd.Width() * 0.47 );
  107. VERIFY( m_DriversList.InsertColumn( 2, &lvColumn ) != -1 );
  108. strTitle.ReleaseBuffer();
  109. //
  110. // Column 3
  111. //
  112. VERIFY( strTitle.LoadString( IDS_VERSION ) );
  113. lvColumn.iSubItem = 3;
  114. lvColumn.pszText = strTitle.GetBuffer( strTitle.GetLength() + 1 );
  115. lvColumn.cx = (int)( rectWnd.Width() * 0.22 );
  116. VERIFY( m_DriversList.InsertColumn( 3, &lvColumn ) != -1 );
  117. strTitle.ReleaseBuffer();
  118. }
  119. /////////////////////////////////////////////////////////////////////////////
  120. VOID CSelectDriversPage::FillTheList()
  121. {
  122. INT_PTR nDriversNo;
  123. INT_PTR nCrtDriverIndex;
  124. CDriverData *pCrtDrvData;
  125. const CDriverDataArray &DrvDataArray = g_NewVerifierSettings.m_DriversSet.m_aDriverData;
  126. m_DriversList.DeleteAllItems();
  127. //
  128. // Parse the driver data array
  129. //
  130. nDriversNo = DrvDataArray.GetSize();
  131. for( nCrtDriverIndex = 0; nCrtDriverIndex < nDriversNo; nCrtDriverIndex += 1)
  132. {
  133. pCrtDrvData = DrvDataArray.GetAt( nCrtDriverIndex );
  134. ASSERT_VALID( pCrtDrvData );
  135. AddListItem( nCrtDriverIndex,
  136. pCrtDrvData );
  137. }
  138. }
  139. /////////////////////////////////////////////////////////////////////////////
  140. INT CSelectDriversPage::AddListItem( INT_PTR nIndexInArray, CDriverData *pCrtDrvData )
  141. {
  142. INT nActualIndex;
  143. LVITEM lvItem;
  144. ASSERT_VALID( pCrtDrvData );
  145. nActualIndex = -1;
  146. ZeroMemory( &lvItem, sizeof( lvItem ) );
  147. //
  148. // LVITEM's member pszText is not a const pointer
  149. // so we need to GetBuffer here :-(
  150. //
  151. //
  152. // Sub-item 0 - verification status - empty text and a checkbox
  153. //
  154. lvItem.pszText = g_szVoidText;
  155. lvItem.mask = LVIF_TEXT | LVIF_PARAM;
  156. lvItem.lParam = nIndexInArray;
  157. lvItem.iItem = m_DriversList.GetItemCount();
  158. nActualIndex = m_DriversList.InsertItem( &lvItem );
  159. if( nActualIndex < 0 )
  160. {
  161. //
  162. // Could not add an item in the list - give up
  163. //
  164. goto Done;
  165. }
  166. m_DriversList.SetCheck( nActualIndex, FALSE );
  167. //
  168. // Sub-item 1 - driver name
  169. //
  170. lvItem.pszText = pCrtDrvData->m_strName.GetBuffer( pCrtDrvData->m_strName.GetLength() + 1 );
  171. if( NULL == lvItem.pszText )
  172. {
  173. goto Done;
  174. }
  175. lvItem.mask = LVIF_TEXT;
  176. lvItem.iItem = nActualIndex;
  177. lvItem.iSubItem = 1;
  178. VERIFY( m_DriversList.SetItem( &lvItem ) );
  179. pCrtDrvData->m_strName.ReleaseBuffer();
  180. //
  181. // Sub-item 2 - provider
  182. //
  183. lvItem.pszText = pCrtDrvData->m_strCompanyName.GetBuffer(
  184. pCrtDrvData->m_strCompanyName.GetLength() + 1 );
  185. if( NULL == lvItem.pszText )
  186. {
  187. goto Done;
  188. }
  189. lvItem.mask = LVIF_TEXT;
  190. lvItem.iItem = nActualIndex;
  191. lvItem.iSubItem = 2;
  192. VERIFY( m_DriversList.SetItem( &lvItem ) );
  193. pCrtDrvData->m_strCompanyName.ReleaseBuffer();
  194. //
  195. // Sub-item 3 - version
  196. //
  197. lvItem.pszText = pCrtDrvData->m_strFileVersion.GetBuffer(
  198. pCrtDrvData->m_strFileVersion.GetLength() + 1 );
  199. if( NULL == lvItem.pszText )
  200. {
  201. goto Done;
  202. }
  203. lvItem.mask = LVIF_TEXT;
  204. lvItem.iItem = nActualIndex;
  205. lvItem.iSubItem = 3;
  206. VERIFY( m_DriversList.SetItem( &lvItem ) );
  207. pCrtDrvData->m_strFileVersion.ReleaseBuffer();
  208. Done:
  209. //
  210. // All done
  211. //
  212. return nActualIndex;
  213. }
  214. /////////////////////////////////////////////////////////////////////////////
  215. BOOL CSelectDriversPage::GetNewVerifiedDriversList()
  216. {
  217. INT nListItemCount;
  218. INT nCrtListItem;
  219. INT_PTR nCrtDriversArrayIndex;
  220. BOOL bVerified;
  221. CDriverData *pCrtDrvData;
  222. const CDriverDataArray &DrvDataArray = g_NewVerifierSettings.m_DriversSet.m_aDriverData;
  223. CDriverData::VerifyDriverTypeEnum VerifyStatus;
  224. nListItemCount = m_DriversList.GetItemCount();
  225. for( nCrtListItem = 0; nCrtListItem < nListItemCount; nCrtListItem += 1 )
  226. {
  227. //
  228. // Verification status for the current list item
  229. //
  230. bVerified = m_DriversList.GetCheck( nCrtListItem );
  231. if( bVerified )
  232. {
  233. VerifyStatus = CDriverData::VerifyDriverYes;
  234. }
  235. else
  236. {
  237. VerifyStatus = CDriverData::VerifyDriverNo;
  238. }
  239. //
  240. // Set the right verify state in our driver array
  241. //
  242. nCrtDriversArrayIndex = m_DriversList.GetItemData( nCrtListItem );
  243. pCrtDrvData = DrvDataArray.GetAt( nCrtDriversArrayIndex );
  244. ASSERT_VALID( pCrtDrvData );
  245. pCrtDrvData->m_VerifyDriverStatus = VerifyStatus;
  246. }
  247. return TRUE;
  248. }
  249. /////////////////////////////////////////////////////////////
  250. VOID CSelectDriversPage::SortTheList()
  251. {
  252. if( 0 != m_nSortColumnIndex )
  253. {
  254. //
  255. // Sort by driver name, provider or version
  256. //
  257. m_DriversList.SortItems( StringCmpFunc, (LPARAM)this );
  258. }
  259. else
  260. {
  261. //
  262. // Sort by verified status
  263. //
  264. m_DriversList.SortItems( CheckedStatusCmpFunc, (LPARAM)this );
  265. }
  266. }
  267. /////////////////////////////////////////////////////////////
  268. int CALLBACK CSelectDriversPage::StringCmpFunc( LPARAM lParam1,
  269. LPARAM lParam2,
  270. LPARAM lParamSort)
  271. {
  272. int nCmpRez = 0;
  273. BOOL bSuccess;
  274. CString strName1;
  275. CString strName2;
  276. CSelectDriversPage *pThis = (CSelectDriversPage *)lParamSort;
  277. ASSERT_VALID( pThis );
  278. ASSERT( 0 != pThis->m_nSortColumnIndex );
  279. //
  280. // Get the first name
  281. //
  282. bSuccess = pThis->GetColumnStrValue( lParam1,
  283. strName1 );
  284. if( FALSE == bSuccess )
  285. {
  286. goto Done;
  287. }
  288. //
  289. // Get the second name
  290. //
  291. bSuccess = pThis->GetColumnStrValue( lParam2,
  292. strName2 );
  293. if( FALSE == bSuccess )
  294. {
  295. goto Done;
  296. }
  297. //
  298. // Compare the names
  299. //
  300. nCmpRez = strName1.CompareNoCase( strName2 );
  301. switch( pThis->m_nSortColumnIndex )
  302. {
  303. case 1:
  304. //
  305. // Sort by driver name
  306. //
  307. if( FALSE != pThis->m_bAscendSortDrvName )
  308. {
  309. nCmpRez *= -1;
  310. }
  311. break;
  312. case 2:
  313. //
  314. // Sort by provider name
  315. //
  316. if( FALSE != pThis->m_bAscendSortProvName )
  317. {
  318. nCmpRez *= -1;
  319. }
  320. break;
  321. case 3:
  322. //
  323. // Sort by version
  324. //
  325. if( FALSE != pThis->m_bAscendSortVersion )
  326. {
  327. nCmpRez *= -1;
  328. }
  329. break;
  330. default:
  331. //
  332. // Oops - how did we get here ?!?
  333. //
  334. ASSERT( FALSE );
  335. break;
  336. }
  337. Done:
  338. return nCmpRez;
  339. }
  340. /////////////////////////////////////////////////////////////
  341. int CALLBACK CSelectDriversPage::CheckedStatusCmpFunc( LPARAM lParam1,
  342. LPARAM lParam2,
  343. LPARAM lParamSort)
  344. {
  345. int nCmpRez = 0;
  346. INT nItemIndex;
  347. BOOL bVerified1;
  348. BOOL bVerified2;
  349. LVFINDINFO FindInfo;
  350. CSelectDriversPage *pThis = (CSelectDriversPage *)lParamSort;
  351. ASSERT_VALID( pThis );
  352. ASSERT( 0 == pThis->m_nSortColumnIndex );
  353. //
  354. // Find the first item
  355. //
  356. ZeroMemory( &FindInfo, sizeof( FindInfo ) );
  357. FindInfo.flags = LVFI_PARAM;
  358. FindInfo.lParam = lParam1;
  359. nItemIndex = pThis->m_DriversList.FindItem( &FindInfo );
  360. if( nItemIndex < 0 )
  361. {
  362. ASSERT( FALSE );
  363. goto Done;
  364. }
  365. bVerified1 = pThis->m_DriversList.GetCheck( nItemIndex );
  366. //
  367. // Find the second item
  368. //
  369. FindInfo.flags = LVFI_PARAM;
  370. FindInfo.lParam = lParam2;
  371. nItemIndex = pThis->m_DriversList.FindItem( &FindInfo );
  372. if( nItemIndex < 0 )
  373. {
  374. ASSERT( FALSE );
  375. goto Done;
  376. }
  377. bVerified2 = pThis->m_DriversList.GetCheck( nItemIndex );
  378. //
  379. // Compare them
  380. //
  381. if( bVerified1 != bVerified2 )
  382. {
  383. if( FALSE != bVerified1 )
  384. {
  385. nCmpRez = 1;
  386. }
  387. else
  388. {
  389. nCmpRez = -1;
  390. }
  391. if( FALSE != pThis->m_bAscendSortVerified )
  392. {
  393. nCmpRez *= -1;
  394. }
  395. }
  396. Done:
  397. return nCmpRez;
  398. }
  399. /////////////////////////////////////////////////////////////
  400. BOOL CSelectDriversPage::GetColumnStrValue( LPARAM lItemData,
  401. CString &strName )
  402. {
  403. CDriverData *pCrtDrvData;
  404. pCrtDrvData = g_NewVerifierSettings.m_DriversSet.m_aDriverData.GetAt( (INT_PTR) lItemData );
  405. ASSERT_VALID( pCrtDrvData );
  406. switch( m_nSortColumnIndex )
  407. {
  408. case 1:
  409. //
  410. // Sort by driver name
  411. //
  412. strName = pCrtDrvData->m_strName;
  413. break;
  414. case 2:
  415. //
  416. // Sort by provider name
  417. //
  418. strName = pCrtDrvData->m_strCompanyName;
  419. break;
  420. case 3:
  421. //
  422. // Sort by version
  423. //
  424. strName = pCrtDrvData->m_strFileVersion;
  425. break;
  426. default:
  427. //
  428. // Oops - how did we get here ?!?
  429. //
  430. ASSERT( FALSE );
  431. break;
  432. }
  433. return TRUE;
  434. }
  435. /////////////////////////////////////////////////////////////////////////////
  436. BOOL CSelectDriversPage::OnSetActive()
  437. {
  438. //
  439. // The wizard has at least one more step (display the summarry)
  440. //
  441. m_pParentSheet->SetWizardButtons( PSWIZB_BACK |
  442. PSWIZB_FINISH );
  443. return CVerifierPropertyPage::OnSetActive();
  444. }
  445. /////////////////////////////////////////////////////////////////////////////
  446. // CSelectDriversPage message handlers
  447. BOOL CSelectDriversPage::OnInitDialog()
  448. {
  449. CVerifierPropertyPage::OnInitDialog();
  450. //
  451. // setup the list
  452. //
  453. m_DriversList.SetExtendedStyle(
  454. LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | m_DriversList.GetExtendedStyle() );
  455. SetupListHeader();
  456. FillTheList();
  457. SortTheList();
  458. //
  459. // Display the description of the next step
  460. //
  461. VrfSetWindowText( m_NextDescription, IDS_SELDRV_PAGE_NEXT_DESCR_FINISH );
  462. return TRUE; // return TRUE unless you set the focus to a control
  463. // EXCEPTION: OCX Property Pages should return FALSE
  464. }
  465. /////////////////////////////////////////////////////////////////////////////
  466. BOOL CSelectDriversPage::OnWizardFinish()
  467. {
  468. BOOL bExitTheApp;
  469. bExitTheApp = FALSE;
  470. if( GetNewVerifiedDriversList() )
  471. {
  472. if( FALSE == g_NewVerifierSettings.m_DriversSet.ShouldVerifySomeDrivers() )
  473. {
  474. VrfErrorResourceFormat( IDS_SELECT_AT_LEAST_ONE_DRIVER );
  475. goto Done;
  476. }
  477. g_NewVerifierSettings.SaveToRegistry();
  478. //
  479. // Exit the app
  480. //
  481. bExitTheApp = CVerifierPropertyPage::OnWizardFinish();
  482. }
  483. Done:
  484. return bExitTheApp;
  485. }
  486. /////////////////////////////////////////////////////////////////////////////
  487. #define VRF_MAX_CHARS_FOR_OPEN 4096
  488. void CSelectDriversPage::OnAddButton()
  489. {
  490. POSITION pos;
  491. DWORD dwRetValue;
  492. DWORD dwOldMaxFileName = 0;
  493. DWORD dwErrorCode;
  494. INT nFileNameStartIndex;
  495. INT nNewListItemIndex;
  496. INT_PTR nResult;
  497. INT_PTR nNewDriverDataIndex;
  498. CDriverData *pNewDrvData;
  499. TCHAR szDriversDir[ _MAX_PATH ];
  500. TCHAR szAppTitle[ _MAX_PATH ];
  501. TCHAR *szFilesBuffer = NULL;
  502. TCHAR *szOldFilesBuffer = NULL;
  503. CString strPathName;
  504. CString strFileName;
  505. CFileDialog fileDlg(
  506. TRUE, // open file
  507. _T( "sys" ), // default extension
  508. NULL, // no initial file name
  509. OFN_ALLOWMULTISELECT | // multiple selection
  510. OFN_HIDEREADONLY | // hide the "open read-only" checkbox
  511. OFN_NONETWORKBUTTON | // no network button
  512. OFN_NOTESTFILECREATE | // don't test for write protection, a full disk, etc.
  513. OFN_SHAREAWARE, // don't check the existance of file with OpenFile
  514. _T( "Drivers (*.sys)|*.sys||" ) ); // only one filter
  515. //
  516. // check the max length for the returned string
  517. //
  518. if( fileDlg.m_ofn.nMaxFile < VRF_MAX_CHARS_FOR_OPEN )
  519. {
  520. //
  521. // allocate a new buffer for the file names
  522. //
  523. szFilesBuffer = new TCHAR[ VRF_MAX_CHARS_FOR_OPEN ];
  524. szFilesBuffer[ 0 ] = (TCHAR)0;
  525. if( szFilesBuffer != NULL )
  526. {
  527. //
  528. // Save the old buffer address and length
  529. //
  530. dwOldMaxFileName = fileDlg.m_ofn.nMaxFile;
  531. szOldFilesBuffer = fileDlg.m_ofn.lpstrFile;
  532. //
  533. // Set the new buffer address and length
  534. //
  535. fileDlg.m_ofn.lpstrFile = szFilesBuffer;
  536. fileDlg.m_ofn.nMaxFile = VRF_MAX_CHARS_FOR_OPEN;
  537. }
  538. }
  539. //
  540. // Dialog title
  541. //
  542. if( VrfLoadString(
  543. IDS_APPTITLE,
  544. szAppTitle,
  545. ARRAY_LENGTH( szAppTitle ) ) )
  546. {
  547. fileDlg.m_ofn.lpstrTitle = szAppTitle;
  548. }
  549. //
  550. // We change directory first time we try this to %windir%\system32\drivers
  551. //
  552. dwRetValue = ExpandEnvironmentStrings(
  553. _T( "%windir%\\system32\\drivers" ),
  554. szDriversDir,
  555. ARRAY_LENGTH( szDriversDir ) );
  556. if( dwRetValue > 0 && dwRetValue <= ARRAY_LENGTH( szDriversDir ) )
  557. {
  558. fileDlg.m_ofn.lpstrInitialDir = szDriversDir;
  559. }
  560. //
  561. // Show the file selection dialog
  562. //
  563. nResult = fileDlg.DoModal();
  564. switch( nResult )
  565. {
  566. case IDOK:
  567. break;
  568. case IDCANCEL:
  569. goto cleanup;
  570. default:
  571. dwErrorCode = CommDlgExtendedError();
  572. if( dwErrorCode == FNERR_BUFFERTOOSMALL )
  573. {
  574. VrfErrorResourceFormat(
  575. IDS_TOO_MANY_FILES_SELECTED );
  576. }
  577. else
  578. {
  579. VrfErrorResourceFormat(
  580. IDS_CANNOT_OPEN_FILES,
  581. dwErrorCode );
  582. }
  583. goto cleanup;
  584. }
  585. //
  586. // Parse all the selected files and try to enable them for verification
  587. //
  588. pos = fileDlg.GetStartPosition();
  589. while( pos != NULL )
  590. {
  591. //
  592. // Get the full path for the next file
  593. //
  594. strPathName = fileDlg.GetNextPathName( pos );
  595. //
  596. // Split only the file name, without the directory
  597. //
  598. nFileNameStartIndex = strPathName.ReverseFind( _T( '\\' ) );
  599. if( nFileNameStartIndex < 0 )
  600. {
  601. //
  602. // This shoudn't happen but you never know :-)
  603. //
  604. nFileNameStartIndex = 0;
  605. }
  606. else
  607. {
  608. //
  609. // skip the backslash
  610. //
  611. nFileNameStartIndex += 1;
  612. }
  613. strFileName = strPathName.Right( strPathName.GetLength() - nFileNameStartIndex );
  614. //
  615. // Try to add this driver to our global driver list
  616. //
  617. if( g_NewVerifierSettings.m_DriversSet.IsDriverNameInList( strFileName ) )
  618. {
  619. VrfErrorResourceFormat( IDS_DRIVER_IS_ALREADY_IN_LIST,
  620. (LPCTSTR) strFileName );
  621. }
  622. else
  623. {
  624. nNewDriverDataIndex = g_NewVerifierSettings.m_DriversSet.AddNewDriverData( strFileName, TRUE );
  625. if( nNewDriverDataIndex >= 0 )
  626. {
  627. //
  628. // Force refreshing the unsigned driver data
  629. //
  630. g_NewVerifierSettings.m_DriversSet.m_bUnsignedDriverDataInitialized = FALSE;
  631. //
  632. // Add a new item to our list, for the new driver
  633. //
  634. pNewDrvData = g_NewVerifierSettings.m_DriversSet.m_aDriverData.GetAt( nNewDriverDataIndex );
  635. ASSERT_VALID( pNewDrvData );
  636. nNewListItemIndex = AddListItem( nNewDriverDataIndex,
  637. pNewDrvData );
  638. if( nNewListItemIndex >= 0 )
  639. {
  640. m_DriversList.EnsureVisible( nNewListItemIndex, TRUE );
  641. }
  642. }
  643. }
  644. }
  645. cleanup:
  646. if( szFilesBuffer != NULL )
  647. {
  648. fileDlg.m_ofn.nMaxFile = dwOldMaxFileName;
  649. fileDlg.m_ofn.lpstrFile = szOldFilesBuffer;
  650. delete szFilesBuffer;
  651. }
  652. }
  653. /////////////////////////////////////////////////////////////////////////////
  654. void CSelectDriversPage::OnColumnclickSeldrvList(NMHDR* pNMHDR, LRESULT* pResult)
  655. {
  656. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  657. switch( pNMListView->iSubItem )
  658. {
  659. case 0:
  660. //
  661. // Clicked on the "verified" column
  662. //
  663. if( m_nSortColumnIndex == pNMListView->iSubItem )
  664. {
  665. //
  666. // Change the current ascend/descend order for this column
  667. //
  668. m_bAscendSortVerified = !m_bAscendSortVerified;
  669. }
  670. break;
  671. case 1:
  672. //
  673. // Clicked on the driver name column
  674. //
  675. if( m_nSortColumnIndex == pNMListView->iSubItem )
  676. {
  677. //
  678. // Change the current ascend/descend order for this column
  679. //
  680. m_bAscendSortDrvName = !m_bAscendSortDrvName;
  681. }
  682. break;
  683. case 2:
  684. //
  685. // Clicked on the provider column
  686. //
  687. if( m_nSortColumnIndex == pNMListView->iSubItem )
  688. {
  689. //
  690. // Change the current ascend/descend order for this column
  691. //
  692. m_bAscendSortProvName = !m_bAscendSortProvName;
  693. }
  694. break;
  695. case 3:
  696. //
  697. // Clicked on the version column
  698. //
  699. if( m_nSortColumnIndex == pNMListView->iSubItem )
  700. {
  701. //
  702. // Change the current ascend/descend order for this column
  703. //
  704. m_bAscendSortVersion = !m_bAscendSortVersion;
  705. }
  706. break;
  707. default:
  708. //
  709. // Oops - how did we get here ?!?
  710. //
  711. ASSERT( FALSE );
  712. goto Done;
  713. }
  714. m_nSortColumnIndex = pNMListView->iSubItem;
  715. SortTheList();
  716. Done:
  717. *pResult = 0;
  718. }
  719. /////////////////////////////////////////////////////////////
  720. LONG CSelectDriversPage::OnHelp( WPARAM wParam, LPARAM lParam )
  721. {
  722. LONG lResult = 0;
  723. LPHELPINFO lpHelpInfo = (LPHELPINFO)lParam;
  724. ::WinHelp(
  725. (HWND) lpHelpInfo->hItemHandle,
  726. g_szVerifierHelpFile,
  727. HELP_WM_HELP,
  728. (DWORD_PTR) MyHelpIds );
  729. return lResult;
  730. }
  731. /////////////////////////////////////////////////////////////////////////////
  732. void CSelectDriversPage::OnContextMenu(CWnd* pWnd, CPoint point)
  733. {
  734. ::WinHelp(
  735. pWnd->m_hWnd,
  736. g_szVerifierHelpFile,
  737. HELP_CONTEXTMENU,
  738. (DWORD_PTR) MyHelpIds );
  739. }