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.

396 lines
9.9 KiB

  1. //
  2. // Driver Verifier UI
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. //
  7. // module: taspage.cpp
  8. // author: DMihai
  9. // created: 11/1/00
  10. //
  11. // Description:
  12. //
  13. #include "stdafx.h"
  14. #include "verifier.h"
  15. #include "taspage.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. // Change this if you add/remove/change order
  25. // of radio buttons on this page
  26. //
  27. #define FIRST_RADIO_BUTTON_ID IDC_TAS_TYPICAL_RADIO
  28. //
  29. // Help IDs
  30. //
  31. static DWORD MyHelpIds[] =
  32. {
  33. IDC_TAS_TYPICAL_RADIO, IDH_DV_Settings_standard,
  34. IDC_TAS_ADVANCED_RADIO, IDH_DV_Settings_custom,
  35. IDC_TAS_DELETE_RADIO, IDH_DV_Settings_deleteexisting,
  36. IDC_TAS_VIEWREGISTRY_RADIO, IDH_DV_Settings_displaycurrent,
  37. IDC_TAS_STATISTICS_RADIO, IDH_DV_Settings_displayexisting,
  38. 0, 0
  39. };
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CTypAdvStatPage
  42. IMPLEMENT_DYNCREATE(CTypAdvStatPage, CVerifierPropertyPage)
  43. CTypAdvStatPage::CTypAdvStatPage()
  44. : CVerifierPropertyPage( CTypAdvStatPage::IDD )
  45. {
  46. //{{AFX_DATA_INIT(CTypAdvStatPage)
  47. m_nCrtRadio = -1;
  48. //}}AFX_DATA_INIT
  49. }
  50. CTypAdvStatPage::~CTypAdvStatPage()
  51. {
  52. }
  53. /////////////////////////////////////////////////////////////////////////////
  54. //
  55. // DDX support
  56. //
  57. void CTypAdvStatPage::DoDataExchange(CDataExchange* pDX)
  58. {
  59. CVerifierPropertyPage::DoDataExchange(pDX);
  60. //{{AFX_DATA_MAP(CTypAdvStatPage)
  61. DDX_Control(pDX, IDC_TAS_NEXT_DESCR_STATIC, m_NextDescription);
  62. DDX_Radio(pDX, IDC_TAS_TYPICAL_RADIO, m_nCrtRadio);
  63. //}}AFX_DATA_MAP
  64. }
  65. /////////////////////////////////////////////////////////////////////////////
  66. //
  67. // Message map
  68. //
  69. BEGIN_MESSAGE_MAP(CTypAdvStatPage, CVerifierPropertyPage)
  70. //{{AFX_MSG_MAP(CTypAdvStatPage)
  71. ON_BN_CLICKED(IDC_TAS_DELETE_RADIO, OnDeleteRadio)
  72. ON_BN_CLICKED(IDC_TAS_ADVANCED_RADIO, OnAdvancedRadio)
  73. ON_BN_CLICKED(IDC_TAS_STATISTICS_RADIO, OnStatisticsRadio)
  74. ON_BN_CLICKED(IDC_TAS_TYPICAL_RADIO, OnTypicalRadio)
  75. ON_BN_CLICKED(IDC_TAS_VIEWREGISTRY_RADIO, OnViewregistryRadio)
  76. ON_WM_CONTEXTMENU()
  77. ON_MESSAGE( WM_HELP, OnHelp )
  78. //}}AFX_MSG_MAP
  79. END_MESSAGE_MAP()
  80. /////////////////////////////////////////////////////////////////////////////
  81. //
  82. // All the property pages derived from this class should
  83. // provide these methods.
  84. //
  85. ULONG CTypAdvStatPage::GetDialogId() const
  86. {
  87. return CTypAdvStatPage::IDD;
  88. }
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CTypAdvStatPage message handlers
  91. LRESULT CTypAdvStatPage::OnWizardNext()
  92. {
  93. LRESULT lNextPageId;
  94. //
  95. // Kill a possible active worker thread
  96. //
  97. g_SlowProgressDlg.KillWorkerThread();
  98. //
  99. // Let's assume we cannot continue
  100. //
  101. lNextPageId = -1;
  102. if( UpdateData() == TRUE )
  103. {
  104. switch( m_nCrtRadio )
  105. {
  106. case IDC_TAS_TYPICAL_RADIO - FIRST_RADIO_BUTTON_ID:
  107. //
  108. // Set typical settings and go to driver selection page
  109. //
  110. g_NewVerifierSettings.m_SettingsBits.m_SettingsType = CSettingsBits::SettingsTypeTypical;
  111. g_NewVerifierSettings.m_SettingsBits.SetTypicalOnly();
  112. lNextPageId = IDD_DRVSET_PAGE;
  113. break;
  114. case IDC_TAS_ADVANCED_RADIO - FIRST_RADIO_BUTTON_ID:
  115. //
  116. // Start building custom settings (advanced, for developers)
  117. //
  118. g_NewVerifierSettings.m_SettingsBits.m_SettingsType = CSettingsBits::SettingsTypeCustom;
  119. lNextPageId = IDD_CUSTSETT_PAGE;
  120. break;
  121. case IDC_TAS_VIEWREGISTRY_RADIO - FIRST_RADIO_BUTTON_ID:
  122. //
  123. // Display the current registry settings
  124. //
  125. //
  126. // Load the current verified drivers string and flags from the registry
  127. //
  128. if( TRUE != VrtLoadCurrentRegistrySettings( g_bAllDriversVerified,
  129. g_astrVerifyDriverNamesRegistry,
  130. g_dwVerifierFlagsRegistry ) )
  131. {
  132. goto Done;
  133. }
  134. //
  135. // Look if we already have loaded the list of drivers
  136. // with version information, etc. and if we need it
  137. //
  138. if( TRUE != g_NewVerifierSettings.m_DriversSet.m_bDriverDataInitialized )
  139. {
  140. if( NULL == g_SlowProgressDlg.m_hWnd )
  141. {
  142. //
  143. // This is the first time we are showing the
  144. // "slow progress" dialog so create it first
  145. //
  146. g_SlowProgressDlg.Create( CSlowProgressDlg::IDD, AfxGetMainWnd() );
  147. }
  148. //
  149. // Show the dialog
  150. //
  151. g_SlowProgressDlg.ShowWindow( SW_SHOW );
  152. //
  153. // Start the worker thread to do the work in background
  154. // while the initial thread updates the GUI. If the thread ends
  155. // successfully it will press our "Next" button at the end, after setting
  156. // g_NewVerifierSettings.m_DriversSet.m_bDriverDataInitialized to TRUE
  157. //
  158. g_SlowProgressDlg.StartWorkerThread( CSlowProgressDlg::LoadDriverDataWorkerThread,
  159. IDS_LOADING_DRIVER_INFORMATION );
  160. //
  161. // Wait for the "next" button again
  162. //
  163. goto Done;
  164. }
  165. //
  166. // We have already loaded information (name, version, etc.) about
  167. // the currently loaded drivers if have gotten to this point.
  168. //
  169. // Go to the next page.
  170. //
  171. lNextPageId = IDD_CRT_REGISTRY_SETTINGS_PAGE;
  172. break;
  173. case IDC_TAS_STATISTICS_RADIO - FIRST_RADIO_BUTTON_ID:
  174. //
  175. // The user wants just statistics - nothing to change
  176. //
  177. lNextPageId = IDD_DRVSTATUS_STAT_PAGE;
  178. break;
  179. default:
  180. //
  181. // Oops. how did we get here?
  182. //
  183. // We shouldn't have had a "Next" button for the
  184. // "delete settings" selection
  185. //
  186. ASSERT( FALSE );
  187. }
  188. }
  189. GoingToNextPageNotify( lNextPageId );
  190. Done:
  191. return lNextPageId;
  192. }
  193. /////////////////////////////////////////////////////////////////////////////
  194. void CTypAdvStatPage::OnDeleteRadio()
  195. {
  196. ASSERT_VALID( m_pParentSheet );
  197. m_pParentSheet->SetWizardButtons(
  198. PSWIZB_FINISH );
  199. VrfSetWindowText( m_NextDescription, IDS_TAS_PAGE_NEXT_DESCR_DELETE );
  200. }
  201. void CTypAdvStatPage::OnAdvancedRadio()
  202. {
  203. ASSERT_VALID( m_pParentSheet );
  204. m_pParentSheet->SetWizardButtons(
  205. PSWIZB_NEXT );
  206. VrfSetWindowText( m_NextDescription, IDS_TAS_PAGE_NEXT_DESCR_CUSTOM );
  207. }
  208. void CTypAdvStatPage::OnStatisticsRadio()
  209. {
  210. ASSERT_VALID( m_pParentSheet );
  211. m_pParentSheet->SetWizardButtons(
  212. PSWIZB_NEXT );
  213. VrfSetWindowText( m_NextDescription, IDS_TAS_PAGE_NEXT_DESCR_STATISTICS );
  214. }
  215. void CTypAdvStatPage::OnTypicalRadio()
  216. {
  217. ASSERT_VALID( m_pParentSheet );
  218. m_pParentSheet->SetWizardButtons(
  219. PSWIZB_NEXT );
  220. VrfSetWindowText( m_NextDescription, IDS_TAS_PAGE_NEXT_DESCR_STANDARD );
  221. }
  222. void CTypAdvStatPage::OnViewregistryRadio()
  223. {
  224. ASSERT_VALID( m_pParentSheet );
  225. m_pParentSheet->SetWizardButtons(
  226. PSWIZB_NEXT );
  227. VrfSetWindowText( m_NextDescription, IDS_TAS_PAGE_NEXT_DESCR_REGISTRY );
  228. }
  229. /////////////////////////////////////////////////////////////////////////////
  230. BOOL CTypAdvStatPage::OnSetActive()
  231. {
  232. ASSERT_VALID( m_pParentSheet );
  233. m_pParentSheet->SetWizardButtons(
  234. PSWIZB_NEXT );
  235. return CVerifierPropertyPage::OnSetActive();
  236. }
  237. /////////////////////////////////////////////////////////////////////////////
  238. BOOL CTypAdvStatPage::OnWizardFinish()
  239. {
  240. BOOL bFinish;
  241. INT nResponse;
  242. //
  243. // Kill a possible active worker thread
  244. //
  245. g_SlowProgressDlg.KillWorkerThread();
  246. bFinish = FALSE;
  247. if( TRUE == UpdateData( TRUE ) )
  248. {
  249. //
  250. // This must have been the "delete settings" selection
  251. // if we had a "Finish" button.
  252. //
  253. ASSERT( IDC_TAS_DELETE_RADIO - FIRST_RADIO_BUTTON_ID == m_nCrtRadio );
  254. nResponse = AfxMessageBox( IDS_DELETE_ALL_SETTINGS,
  255. MB_YESNO );
  256. if( IDYES == nResponse )
  257. {
  258. VrfDeleteAllVerifierSettings();
  259. bFinish = CVerifierPropertyPage::OnWizardFinish();
  260. }
  261. }
  262. return bFinish;
  263. }
  264. /////////////////////////////////////////////////////////////////////////////
  265. BOOL CTypAdvStatPage::OnInitDialog()
  266. {
  267. //
  268. // Don't try to reconstruct the current data from the registry
  269. // to the GUI because it's too hard. Always start with the typical settings
  270. //
  271. m_nCrtRadio = IDC_TAS_TYPICAL_RADIO - FIRST_RADIO_BUTTON_ID;
  272. CVerifierPropertyPage::OnInitDialog();
  273. VrfSetWindowText( m_NextDescription, IDS_TAS_PAGE_NEXT_DESCR_STANDARD );
  274. return TRUE; // return TRUE unless you set the focus to a control
  275. // EXCEPTION: OCX Property Pages should return FALSE
  276. }
  277. /////////////////////////////////////////////////////////////
  278. LONG CTypAdvStatPage::OnHelp( WPARAM wParam, LPARAM lParam )
  279. {
  280. LONG lResult = 0;
  281. LPHELPINFO lpHelpInfo = (LPHELPINFO)lParam;
  282. ::WinHelp(
  283. (HWND) lpHelpInfo->hItemHandle,
  284. g_szVerifierHelpFile,
  285. HELP_WM_HELP,
  286. (DWORD_PTR) MyHelpIds );
  287. return lResult;
  288. }
  289. /////////////////////////////////////////////////////////////////////////////
  290. void CTypAdvStatPage::OnContextMenu(CWnd* pWnd, CPoint point)
  291. {
  292. ::WinHelp(
  293. pWnd->m_hWnd,
  294. g_szVerifierHelpFile,
  295. HELP_CONTEXTMENU,
  296. (DWORD_PTR) MyHelpIds );
  297. }