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.

592 lines
16 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: analyze.c
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "newdevp.h"
  11. #include <infstr.h>
  12. INT_PTR CALLBACK
  13. NDW_AnalyzeDlgProc(
  14. HWND hDlg,
  15. UINT wMsg,
  16. WPARAM wParam,
  17. LPARAM lParam
  18. )
  19. {
  20. HICON hicon;
  21. HWND hwndParentDlg = GetParent(hDlg);
  22. PNEWDEVWIZ NewDevWiz;
  23. PSP_INSTALLWIZARD_DATA InstallWizard;
  24. if (wMsg == WM_INITDIALOG) {
  25. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  26. NewDevWiz = (PNEWDEVWIZ)lppsp->lParam;
  27. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NewDevWiz);
  28. NewDevWiz->AnalyzeResult = 0;
  29. return TRUE;
  30. }
  31. NewDevWiz = (PNEWDEVWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  32. InstallWizard = &NewDevWiz->InstallDynaWiz;
  33. switch (wMsg) {
  34. case WM_DESTROY:
  35. hicon = (HICON)LOWORD(SendDlgItemMessage(hDlg,IDC_CLASSICON,STM_GETICON,0,0));
  36. if (hicon) {
  37. DestroyIcon(hicon);
  38. }
  39. break;
  40. case WM_NOTIFY:
  41. switch (((NMHDR FAR *)lParam)->code) {
  42. case PSN_SETACTIVE: {
  43. int PrevPage;
  44. DWORD RegisterError = ERROR_SUCCESS;
  45. SP_DRVINFO_DATA DriverInfoData;
  46. PrevPage = NewDevWiz->PrevPage;
  47. NewDevWiz->PrevPage = IDD_NEWDEVWIZ_ANALYZEDEV;
  48. if (PrevPage == IDD_WIZARDEXT_POSTANALYZE) {
  49. //
  50. // We decided not to show the Analyze page so just jump Back
  51. //
  52. PropSheet_PressButton(GetParent(hDlg), PSBTN_BACK);
  53. break;
  54. }
  55. //
  56. // Get info on currently selected device, since this could change
  57. // as the user move back and forth between wizard pages
  58. // we do this on each activate.
  59. //
  60. if (!SetupDiGetSelectedDevice(NewDevWiz->hDeviceInfo,
  61. &NewDevWiz->DeviceInfoData
  62. ))
  63. {
  64. RegisterError = GetLastError();
  65. #if DBG
  66. DbgPrint("Add Hardware: AnalyzeDlgProc no selected device %x\n",
  67. RegisterError
  68. );
  69. #endif
  70. }
  71. //
  72. // Set the class Icon
  73. //
  74. if (SetupDiLoadClassIcon(&NewDevWiz->DeviceInfoData.ClassGuid, &hicon, NULL)) {
  75. hicon = (HICON)SendDlgItemMessage(hDlg, IDC_CLASSICON, STM_SETICON, (WPARAM)hicon, 0L);
  76. if (hicon) {
  77. DestroyIcon(hicon);
  78. }
  79. }
  80. SetDriverDescription(hDlg, IDC_NDW_DESCRIPTION, NewDevWiz);
  81. PropSheet_SetWizButtons(hwndParentDlg, PSWIZB_BACK | PSWIZB_NEXT);
  82. //
  83. // need to determine conflict warning.
  84. //
  85. if (RegisterError != ERROR_SUCCESS) {
  86. SetDlgText(hDlg, IDC_NDW_TEXT, IDS_NDW_ANALYZEERR1, IDS_NDW_ANALYZEERR3);
  87. }
  88. else {
  89. SetDlgText(hDlg, IDC_NDW_TEXT, IDS_NDW_STDCFG1, IDS_NDW_STDCFG2);
  90. }
  91. if (InstallWizard->DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED) {
  92. if (RegisterError == ERROR_SUCCESS ||
  93. !(InstallWizard->DynamicPageFlags & DYNAWIZ_FLAG_ANALYZE_HANDLECONFLICT))
  94. {
  95. SetDlgMsgResult(hDlg, wMsg, IDD_DYNAWIZ_ANALYZE_NEXTPAGE);
  96. }
  97. }
  98. //
  99. // Only show the Analyze page if there was an error registering this device.
  100. //
  101. if (RegisterError == ERROR_SUCCESS) {
  102. PropSheet_PressButton(GetParent(hDlg), PSBTN_NEXT);
  103. }
  104. break;
  105. }
  106. case PSN_WIZBACK:
  107. if (NewDevWiz->WizExtPostAnalyze.hPropSheet) {
  108. PropSheet_RemovePage(hwndParentDlg,
  109. (WPARAM)-1,
  110. NewDevWiz->WizExtPostAnalyze.hPropSheet
  111. );
  112. NewDevWiz->WizExtPostAnalyze.hPropSheet = NULL;
  113. }
  114. SetDlgMsgResult(hDlg, wMsg, IDD_WIZARDEXT_PREANALYZE);
  115. break;
  116. case PSN_WIZNEXT:
  117. //
  118. // Add the PostAnalyze Page and jump to it
  119. //
  120. NewDevWiz->WizExtPostAnalyze.hPropSheet = CreateWizExtPage(IDD_WIZARDEXT_POSTANALYZE,
  121. WizExtPostAnalyzeDlgProc,
  122. NewDevWiz
  123. );
  124. if (NewDevWiz->WizExtPostAnalyze.hPropSheet) {
  125. PropSheet_AddPage(hwndParentDlg, NewDevWiz->WizExtPostAnalyze.hPropSheet);
  126. }
  127. SetDlgMsgResult(hDlg, wMsg, IDD_WIZARDEXT_POSTANALYZE);
  128. break;
  129. }
  130. break;
  131. default:
  132. return(FALSE);
  133. }
  134. return(TRUE);
  135. }
  136. INT_PTR CALLBACK
  137. WizExtPreAnalyzeDlgProc(
  138. HWND hDlg,
  139. UINT wMsg,
  140. WPARAM wParam,
  141. LPARAM lParam
  142. )
  143. {
  144. HWND hwndParentDlg = GetParent(hDlg);
  145. PNEWDEVWIZ NewDevWiz = (PNEWDEVWIZ )GetWindowLongPtr(hDlg, DWLP_USER);
  146. int PrevPageId;
  147. switch (wMsg) {
  148. case WM_INITDIALOG: {
  149. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  150. NewDevWiz = (PNEWDEVWIZ )lppsp->lParam;
  151. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NewDevWiz);
  152. break;
  153. }
  154. case WM_DESTROY:
  155. break;
  156. case WM_NOTIFY:
  157. switch (((NMHDR FAR *)lParam)->code) {
  158. case PSN_SETACTIVE:
  159. PrevPageId = NewDevWiz->PrevPage;
  160. NewDevWiz->PrevPage = IDD_WIZARDEXT_PREANALYZE;
  161. if (PrevPageId == IDD_WIZARDEXT_SELECT) {
  162. //
  163. // Moving forward on first page
  164. //
  165. //
  166. // if we are not doing the old fashioned DYNAWIZ
  167. // Add ClassWizard Extension pages for preanalyze
  168. //
  169. if ((NewDevWiz->Flags & IDI_FLAG_MANUALINSTALL) &&
  170. !(NewDevWiz->InstallDynaWiz.DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED))
  171. {
  172. AddClassWizExtPages(hwndParentDlg,
  173. NewDevWiz,
  174. &NewDevWiz->WizExtPreAnalyze.DeviceWizardData,
  175. DIF_NEWDEVICEWIZARD_PREANALYZE,
  176. NULL
  177. );
  178. }
  179. //
  180. // Add the end page, which is PreAnalyze end
  181. //
  182. NewDevWiz->WizExtPreAnalyze.hPropSheetEnd = CreateWizExtPage(IDD_WIZARDEXT_PREANALYZE_END,
  183. WizExtPreAnalyzeEndDlgProc,
  184. NewDevWiz
  185. );
  186. if (NewDevWiz->WizExtPreAnalyze.hPropSheetEnd) {
  187. PropSheet_AddPage(hwndParentDlg, NewDevWiz->WizExtPreAnalyze.hPropSheetEnd);
  188. }
  189. PropSheet_PressButton(hwndParentDlg, PSBTN_NEXT);
  190. }
  191. else {
  192. //
  193. // Moving backwards from PreAnalyze end on PreAanalyze
  194. //
  195. //
  196. // Clean up proppages added.
  197. //
  198. if (NewDevWiz->WizExtPreAnalyze.hPropSheetEnd) {
  199. PropSheet_RemovePage(hwndParentDlg,
  200. (WPARAM)-1,
  201. NewDevWiz->WizExtPreAnalyze.hPropSheetEnd
  202. );
  203. NewDevWiz->WizExtPreAnalyze.hPropSheetEnd = NULL;
  204. }
  205. RemoveClassWizExtPages(hwndParentDlg,
  206. &NewDevWiz->WizExtPreAnalyze.DeviceWizardData
  207. );
  208. //
  209. // Jump back
  210. // Note: The target pages don't set PrevPage, so set it for them
  211. //
  212. NewDevWiz->PrevPage = IDD_WIZARDEXT_SELECT;
  213. if (NewDevWiz->InstallDynaWiz.DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED) {
  214. SetDlgMsgResult(hDlg, wMsg, IDD_DYNAWIZ_ANALYZE_PREVPAGE);
  215. }
  216. else {
  217. SetDlgMsgResult(hDlg, wMsg, IDD_DYNAWIZ_SELECTDEV_PAGE);
  218. }
  219. }
  220. break;
  221. case PSN_WIZNEXT:
  222. SetDlgMsgResult(hDlg, wMsg, 0);
  223. break;
  224. }
  225. break;
  226. default:
  227. return(FALSE);
  228. }
  229. return(TRUE);
  230. }
  231. INT_PTR CALLBACK
  232. WizExtPreAnalyzeEndDlgProc(
  233. HWND hDlg,
  234. UINT wMsg,
  235. WPARAM wParam,
  236. LPARAM lParam
  237. )
  238. {
  239. HWND hwndParentDlg = GetParent(hDlg);
  240. PNEWDEVWIZ NewDevWiz = (PNEWDEVWIZ )GetWindowLongPtr(hDlg, DWLP_USER);
  241. int PrevPageId;
  242. switch (wMsg) {
  243. case WM_INITDIALOG: {
  244. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  245. NewDevWiz = (PNEWDEVWIZ )lppsp->lParam;
  246. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NewDevWiz);
  247. break;
  248. }
  249. case WM_DESTROY:
  250. break;
  251. case WM_NOTIFY:
  252. switch (((NMHDR FAR *)lParam)->code) {
  253. case PSN_SETACTIVE:
  254. PrevPageId = NewDevWiz->PrevPage;
  255. NewDevWiz->PrevPage = IDD_WIZARDEXT_PREANALYZE_END;
  256. if (PrevPageId == IDD_NEWDEVWIZ_ANALYZEDEV) {
  257. //
  258. // Moving backwards from analyzepage
  259. //
  260. //
  261. // Jump back
  262. //
  263. PropSheet_PressButton(hwndParentDlg, PSBTN_BACK);
  264. }
  265. else {
  266. //
  267. // Moving forward on end page
  268. //
  269. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_ANALYZEDEV);
  270. }
  271. break;
  272. case PSN_WIZBACK:
  273. case PSN_WIZNEXT:
  274. SetDlgMsgResult(hDlg, wMsg, 0);
  275. break;
  276. }
  277. break;
  278. default:
  279. return(FALSE);
  280. }
  281. return(TRUE);
  282. }
  283. INT_PTR CALLBACK
  284. WizExtPostAnalyzeDlgProc(
  285. HWND hDlg,
  286. UINT wMsg,
  287. WPARAM wParam,
  288. LPARAM lParam
  289. )
  290. {
  291. HWND hwndParentDlg = GetParent(hDlg);
  292. PNEWDEVWIZ NewDevWiz = (PNEWDEVWIZ )GetWindowLongPtr(hDlg, DWLP_USER);
  293. int PrevPageId;
  294. switch (wMsg) {
  295. case WM_INITDIALOG: {
  296. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  297. NewDevWiz = (PNEWDEVWIZ )lppsp->lParam;
  298. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NewDevWiz);
  299. break;
  300. }
  301. case WM_DESTROY:
  302. break;
  303. case WM_NOTIFY:
  304. switch (((NMHDR FAR *)lParam)->code) {
  305. case PSN_SETACTIVE:
  306. PrevPageId = NewDevWiz->PrevPage;
  307. NewDevWiz->PrevPage = IDD_WIZARDEXT_POSTANALYZE;
  308. if (PrevPageId == IDD_NEWDEVWIZ_ANALYZEDEV) {
  309. //
  310. // Moving forward on first page
  311. //
  312. //
  313. // if we are not doing the old fashioned DYNAWIZ
  314. // Add ClassWizard Extension pages for postanalyze
  315. //
  316. if ((NewDevWiz->Flags & IDI_FLAG_MANUALINSTALL) &&
  317. !(NewDevWiz->InstallDynaWiz.DynamicPageFlags & DYNAWIZ_FLAG_PAGESADDED))
  318. {
  319. AddClassWizExtPages(hwndParentDlg,
  320. NewDevWiz,
  321. &NewDevWiz->WizExtPostAnalyze.DeviceWizardData,
  322. DIF_NEWDEVICEWIZARD_POSTANALYZE,
  323. NULL
  324. );
  325. }
  326. //
  327. // Add the end page, which is PostAnalyze end
  328. //
  329. NewDevWiz->WizExtPostAnalyze.hPropSheetEnd = CreateWizExtPage(IDD_WIZARDEXT_POSTANALYZE_END,
  330. WizExtPostAnalyzeEndDlgProc,
  331. NewDevWiz
  332. );
  333. if (NewDevWiz->WizExtPostAnalyze.hPropSheetEnd) {
  334. PropSheet_AddPage(hwndParentDlg, NewDevWiz->WizExtPostAnalyze.hPropSheetEnd);
  335. }
  336. PropSheet_PressButton(hwndParentDlg, PSBTN_NEXT);
  337. }
  338. else {
  339. //
  340. // Moving backwards from PostAnalyze end on PostAnalyze
  341. //
  342. //
  343. // Clean up proppages added.
  344. //
  345. if (NewDevWiz->WizExtPostAnalyze.hPropSheetEnd) {
  346. PropSheet_RemovePage(hwndParentDlg,
  347. (WPARAM)-1,
  348. NewDevWiz->WizExtPostAnalyze.hPropSheetEnd
  349. );
  350. NewDevWiz->WizExtPostAnalyze.hPropSheetEnd = NULL;
  351. }
  352. RemoveClassWizExtPages(hwndParentDlg,
  353. &NewDevWiz->WizExtPostAnalyze.DeviceWizardData
  354. );
  355. }
  356. break;
  357. case PSN_WIZBACK:
  358. case PSN_WIZNEXT:
  359. SetDlgMsgResult(hDlg, wMsg, 0);
  360. break;
  361. }
  362. break;
  363. default:
  364. return(FALSE);
  365. }
  366. return(TRUE);
  367. }
  368. INT_PTR CALLBACK
  369. WizExtPostAnalyzeEndDlgProc(
  370. HWND hDlg,
  371. UINT wMsg,
  372. WPARAM wParam,
  373. LPARAM lParam
  374. )
  375. {
  376. HWND hwndParentDlg = GetParent(hDlg);
  377. PNEWDEVWIZ NewDevWiz = (PNEWDEVWIZ )GetWindowLongPtr(hDlg, DWLP_USER);
  378. int PrevPageId;
  379. switch (wMsg) {
  380. case WM_INITDIALOG: {
  381. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  382. NewDevWiz = (PNEWDEVWIZ )lppsp->lParam;
  383. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NewDevWiz);
  384. break;
  385. }
  386. case WM_DESTROY:
  387. break;
  388. case WM_NOTIFY:
  389. switch (((NMHDR FAR *)lParam)->code) {
  390. case PSN_SETACTIVE:
  391. PrevPageId = NewDevWiz->PrevPage;
  392. NewDevWiz->PrevPage = IDD_WIZARDEXT_POSTANALYZE_END;
  393. if (PrevPageId == IDD_NEWDEVWIZ_INSTALLDEV) {
  394. //
  395. // Moving backwards from finishpage
  396. //
  397. //
  398. // Jump back
  399. //
  400. PropSheet_PressButton(hwndParentDlg, PSBTN_BACK);
  401. }
  402. else {
  403. //
  404. // Moving forward on End page
  405. //
  406. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_INSTALLDEV);
  407. }
  408. break;
  409. case PSN_WIZBACK:
  410. case PSN_WIZNEXT:
  411. SetDlgMsgResult(hDlg, wMsg, 0);
  412. break;
  413. }
  414. break;
  415. default:
  416. return(FALSE);
  417. }
  418. return(TRUE);
  419. }