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.

837 lines
22 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: pnpenum.c
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "hdwwiz.h"
  11. INT_PTR CALLBACK HdwAskDetectDlgProc(
  12. HWND hDlg,
  13. UINT wMsg,
  14. WPARAM wParam,
  15. LPARAM lParam
  16. )
  17. {
  18. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  19. switch (wMsg) {
  20. case WM_INITDIALOG: {
  21. HWND hwndParentDlg;
  22. HICON hIcon;
  23. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  24. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  25. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  26. break;
  27. }
  28. case WM_COMMAND:
  29. break;
  30. case WM_NOTIFY:
  31. switch (((NMHDR FAR *)lParam)->code) {
  32. case PSN_SETACTIVE:
  33. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  34. HardwareWiz->PrevPage = IDD_ADDDEVICE_ASKDETECT;
  35. //
  36. // Set the Initial radio button state.
  37. // default to do autodetection.
  38. //
  39. CheckRadioButton(hDlg,
  40. IDC_ADDDEVICE_ASKDETECT_AUTO,
  41. IDC_ADDDEVICE_ASKDETECT_SPECIFIC,
  42. IDC_ADDDEVICE_ASKDETECT_AUTO
  43. );
  44. break;
  45. case PSN_WIZBACK:
  46. //
  47. // If we are going back then this is effectively a Cancel
  48. //
  49. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_PROBLIST);
  50. break;
  51. case PSN_WIZNEXT:
  52. if (IsDlgButtonChecked(hDlg, IDC_ADDDEVICE_ASKDETECT_AUTO)) {
  53. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_DETECTION);
  54. } else {
  55. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_SELECTCLASS);
  56. }
  57. break;
  58. case PSN_RESET:
  59. HardwareWiz->Cancelled = TRUE;
  60. break;
  61. }
  62. break;
  63. default:
  64. return(FALSE);
  65. }
  66. return(TRUE);
  67. }
  68. DWORD
  69. PNPEnumerate(
  70. PHARDWAREWIZ HardwareWiz
  71. )
  72. {
  73. CONFIGRET ConfigRet;
  74. DEVINST RootDevInst, ChildDevInst;
  75. HDEVINFO hDeviceInfo;
  76. if (HardwareWiz->ExitDetect) {
  77. return 0;
  78. }
  79. //
  80. // reenumerate from the root of the devnode tree
  81. //
  82. ConfigRet = CM_Locate_DevNode_Ex(&RootDevInst,
  83. NULL,
  84. CM_LOCATE_DEVNODE_NORMAL,
  85. NULL
  86. );
  87. if (ConfigRet != CR_SUCCESS) {
  88. return 0;
  89. }
  90. //
  91. // Force install of ALL devices which still need installing.
  92. // save reboot flags to pass back to main thread.
  93. //
  94. ConfigRet = CM_Get_Child_Ex(&ChildDevInst,
  95. RootDevInst,
  96. 0,
  97. NULL
  98. );
  99. if (ConfigRet == CR_SUCCESS) {
  100. InstallSilentChildSiblings(NULL, HardwareWiz, ChildDevInst, TRUE);
  101. }
  102. if (HardwareWiz->Reboot) {
  103. return 0;
  104. }
  105. Sleep(100); // give a chance for new devices to be noticed by PNP
  106. //
  107. // Ask PNP to look for newly arrived devices.
  108. //
  109. CM_Reenumerate_DevNode_Ex(
  110. RootDevInst,
  111. CM_REENUMERATE_SYNCHRONOUS | CM_REENUMERATE_RETRY_INSTALLATION,
  112. NULL
  113. );
  114. Sleep(5000); // give a chance for new devices to be noticed by PNP
  115. do {
  116. if (HardwareWiz->ExitDetect) {
  117. return 0;
  118. }
  119. } while (CMP_WaitNoPendingInstallEvents(1000) == WAIT_TIMEOUT);
  120. return 0;
  121. }
  122. int
  123. InsertDeviceNodeListView(
  124. HWND hwndList,
  125. PHARDWAREWIZ HardwareWiz,
  126. HDEVINFO hDeviceInfo,
  127. PSP_DEVINFO_DATA DeviceInfoData
  128. )
  129. {
  130. INT lvIndex;
  131. LV_ITEM lviItem;
  132. PTCHAR DeviceName;
  133. TCHAR Buffer[MAX_PATH];
  134. ULONG Status = 0, Problem = 0;
  135. lviItem.mask = LVIF_TEXT | LVIF_PARAM;
  136. lviItem.iItem = -1;
  137. lviItem.iSubItem = 0;
  138. if (SetupDiGetClassImageIndex(&HardwareWiz->ClassImageList,
  139. &DeviceInfoData->ClassGuid,
  140. &lviItem.iImage
  141. )) {
  142. lviItem.mask |= LVIF_IMAGE;
  143. }
  144. DeviceName = BuildFriendlyName(DeviceInfoData->DevInst, NULL);
  145. if (DeviceName) {
  146. lviItem.pszText = DeviceName;
  147. } else {
  148. lviItem.pszText = szUnknown;
  149. }
  150. lviItem.mask |= LVIF_STATE;
  151. if (CM_Get_DevNode_Status(&Status, &Problem, DeviceInfoData->DevInst, 0) == CR_SUCCESS) {
  152. if (Problem) {
  153. //
  154. // Add the yellow ! or red X overlay to the devnode if it has a
  155. // problem.
  156. //
  157. lviItem.state = (Problem == CM_PROB_DISABLED) ?
  158. INDEXTOOVERLAYMASK(IDI_DISABLED_OVL - IDI_CLASSICON_OVERLAYFIRST + 1) :
  159. INDEXTOOVERLAYMASK(IDI_PROBLEM_OVL - IDI_CLASSICON_OVERLAYFIRST + 1);
  160. } else {
  161. lviItem.state = INDEXTOOVERLAYMASK(0);
  162. }
  163. lviItem.stateMask = LVIS_OVERLAYMASK;
  164. }
  165. lviItem.lParam = (LPARAM)DeviceInfoData->DevInst;
  166. lvIndex = ListView_InsertItem(hwndList, &lviItem);
  167. if (DeviceName) {
  168. LocalFree(DeviceName);
  169. }
  170. return lvIndex;
  171. }
  172. BOOL
  173. AnyNewPnPDevicesFound(
  174. HWND hDlg,
  175. PHARDWAREWIZ HardwareWiz
  176. )
  177. {
  178. HDEVINFO NewDeviceInfo, OldDeviceInfo;
  179. BOOL NewDevicesFound;
  180. BOOL NewDevice;
  181. INT iNew, iOld;
  182. SP_DEVINFO_DATA NewDeviceInfoData, OldDeviceInfoData;
  183. OldDeviceInfo = HardwareWiz->PNPEnumDeviceInfo;
  184. NewDeviceInfo = SetupDiGetClassDevs(NULL,
  185. NULL,
  186. GetParent(hDlg),
  187. DIGCF_ALLCLASSES
  188. );
  189. if (!OldDeviceInfo || NewDeviceInfo == INVALID_HANDLE_VALUE) {
  190. return FALSE;
  191. }
  192. NewDevicesFound = FALSE;
  193. iNew = 0;
  194. NewDeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
  195. while (SetupDiEnumDeviceInfo(NewDeviceInfo, iNew++, &NewDeviceInfoData)) {
  196. NewDevice = TRUE;
  197. iOld = 0;
  198. OldDeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
  199. while (SetupDiEnumDeviceInfo(OldDeviceInfo, iOld++, &OldDeviceInfoData)) {
  200. if (NewDeviceInfoData.DevInst == OldDeviceInfoData.DevInst) {
  201. //
  202. // If this DevInst exists in the Old DeviceInfo list then it is
  203. // not a new device.
  204. //
  205. NewDevice = FALSE;
  206. break;
  207. }
  208. }
  209. //
  210. // If we did not find this device in the original list then it is a new
  211. // PnP device. Set the NewDevicesFound BOOL and break out of the loop.
  212. //
  213. if (NewDevice) {
  214. NewDevicesFound = TRUE;
  215. break;
  216. }
  217. }
  218. SetupDiDestroyDeviceInfoList(NewDeviceInfo);
  219. return NewDevicesFound;
  220. }
  221. INT_PTR CALLBACK
  222. HdwPnpEnumDlgProc(
  223. HWND hDlg,
  224. UINT wMsg,
  225. WPARAM wParam,
  226. LPARAM lParam
  227. )
  228. {
  229. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  230. if (wMsg == WM_INITDIALOG) {
  231. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  232. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  233. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  234. return TRUE;
  235. }
  236. switch (wMsg) {
  237. case WM_COMMAND:
  238. break;
  239. case WM_DESTROY:
  240. if (HardwareWiz->PNPEnumDeviceInfo) {
  241. SetupDiDestroyDeviceInfoList(HardwareWiz->PNPEnumDeviceInfo);
  242. HardwareWiz->PNPEnumDeviceInfo = NULL;
  243. }
  244. break;
  245. case WUM_PNPENUMERATE:
  246. HardwareWiz->InstallPending = FALSE;
  247. HardwareWiz->CurrCursor = NULL;
  248. SetCursor(HardwareWiz->IdcArrow);
  249. Animate_Stop(GetDlgItem(hDlg, IDC_ANIMATE_SEARCH));
  250. if (HardwareWiz->ExitDetect) {
  251. break;
  252. }
  253. HardwareWiz->FoundPnPDevices = AnyNewPnPDevicesFound(hDlg, HardwareWiz);
  254. PropSheet_PressButton(GetParent(hDlg), PSBTN_NEXT);
  255. break;
  256. case WM_NOTIFY:
  257. switch (((NMHDR FAR *)lParam)->code) {
  258. case PSN_SETACTIVE: {
  259. int PrevPage;
  260. PrevPage = HardwareWiz->PrevPage;
  261. HardwareWiz->PrevPage = IDD_ADDDEVICE_PNPENUM;
  262. HardwareWiz->ExitDetect = FALSE;
  263. //
  264. // If moving forwards, kick off enumeration.
  265. //
  266. if (PrevPage != IDD_ADDDEVICE_ASKDETECT) {
  267. EnableWindow(GetDlgItem(GetParent(hDlg), IDCANCEL), FALSE);
  268. PropSheet_SetWizButtons(GetParent(hDlg), 0);
  269. SetDlgText(hDlg, IDC_HDW_TEXT, IDS_ADDDEVICE_PNPENUMERATE, IDS_ADDDEVICE_PNPENUMERATE);
  270. Animate_Open(GetDlgItem(hDlg, IDC_ANIMATE_SEARCH), MAKEINTRESOURCE(IDA_SEARCHING));
  271. Animate_Play(GetDlgItem(hDlg, IDC_ANIMATE_SEARCH), 0, -1, -1);
  272. //
  273. // Create a list of all of the installed devices, which
  274. // will be used after enumeration to build the list of
  275. // newly installed.
  276. //
  277. HardwareWiz->PNPEnumDeviceInfo = SetupDiGetClassDevs(
  278. NULL,
  279. NULL,
  280. GetParent(hDlg),
  281. DIGCF_ALLCLASSES
  282. );
  283. if (HardwareWiz->PNPEnumDeviceInfo == INVALID_HANDLE_VALUE) {
  284. HardwareWiz->PNPEnumDeviceInfo = NULL;
  285. }
  286. HardwareWiz->InstallPending = TRUE;
  287. HardwareWiz->CurrCursor = HardwareWiz->IdcAppStarting;
  288. SetCursor(HardwareWiz->CurrCursor);
  289. if (!SearchThreadRequest(HardwareWiz->SearchThread,
  290. hDlg,
  291. SEARCH_PNPENUM,
  292. 0
  293. )) {
  294. EnableWindow(GetDlgItem(GetParent(hDlg), IDCANCEL), TRUE);
  295. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK| PSWIZB_NEXT);
  296. SetDlgText(hDlg, IDC_HDW_TEXT, IDS_ADDDEVICE_PNPENUMERROR, IDS_ADDDEVICE_PNPENUMERROR);
  297. Animate_Stop(GetDlgItem(hDlg, IDC_ANIMATE_SEARCH));
  298. }
  299. }
  300. }
  301. break;
  302. case PSN_QUERYCANCEL:
  303. if (HardwareWiz->InstallPending) {
  304. if (HardwareWiz->ExitDetect) {
  305. SetDlgMsgResult(hDlg, wMsg, TRUE);
  306. break;
  307. }
  308. HardwareWiz->ExitDetect = TRUE;
  309. HardwareWiz->CurrCursor = HardwareWiz->IdcWait;
  310. SetCursor(HardwareWiz->CurrCursor);
  311. CancelSearchRequest(HardwareWiz);
  312. HardwareWiz->CurrCursor = NULL;
  313. }
  314. SetDlgMsgResult(hDlg, wMsg, FALSE);
  315. break;
  316. case PSN_RESET:
  317. HardwareWiz->Cancelled = TRUE;
  318. Animate_Stop(GetDlgItem(hDlg, IDC_ANIMATE_SEARCH));
  319. break;
  320. case PSN_WIZBACK:
  321. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_WELCOME);
  322. break;
  323. case PSN_WIZNEXT:
  324. if (HardwareWiz->FoundPnPDevices) {
  325. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_PNPFINISH);
  326. } else {
  327. EnableWindow(GetDlgItem(GetParent(hDlg), IDCANCEL), TRUE);
  328. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_CONNECTED);
  329. }
  330. break;
  331. }
  332. break;
  333. case WM_SETCURSOR:
  334. if (HardwareWiz->CurrCursor) {
  335. SetCursor(HardwareWiz->CurrCursor);
  336. break;
  337. }
  338. // fall thru to return(FALSE);
  339. default:
  340. return(FALSE);
  341. }
  342. return(TRUE);
  343. }
  344. BOOL
  345. FillInstalledDevicesList(
  346. HWND hDlg,
  347. PHARDWAREWIZ HardwareWiz
  348. )
  349. {
  350. HDEVINFO NewDeviceInfo, OldDeviceInfo;
  351. BOOL Installed;
  352. BOOL NewDevice;
  353. INT iNew, iOld;
  354. SP_DEVINFO_DATA NewDeviceInfoData, OldDeviceInfoData;
  355. HWND hwndList;
  356. hwndList = GetDlgItem(hDlg, IDC_FOUNDPNP_LIST);
  357. SendMessage(hwndList, WM_SETREDRAW, FALSE, 0L);
  358. ListView_DeleteAllItems(hwndList);
  359. OldDeviceInfo = HardwareWiz->PNPEnumDeviceInfo;
  360. NewDeviceInfo = SetupDiGetClassDevs(NULL,
  361. NULL,
  362. GetParent(hDlg),
  363. DIGCF_ALLCLASSES
  364. );
  365. if (!OldDeviceInfo || NewDeviceInfo == INVALID_HANDLE_VALUE) {
  366. SendMessage(hwndList, WM_SETREDRAW, TRUE, 0L);
  367. return FALSE;
  368. }
  369. //
  370. // For each element in the new list check to see if its in the old list.
  371. // If its not then it is a newly installed devnode so add it to the list box.
  372. //
  373. Installed = FALSE;
  374. iNew = 0;
  375. NewDeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
  376. while (SetupDiEnumDeviceInfo(NewDeviceInfo, iNew++, &NewDeviceInfoData)) {
  377. NewDevice = TRUE;
  378. iOld = 0;
  379. OldDeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
  380. while (SetupDiEnumDeviceInfo(OldDeviceInfo, iOld++, &OldDeviceInfoData)) {
  381. if (NewDeviceInfoData.DevInst == OldDeviceInfoData.DevInst) {
  382. //
  383. // If this DevInst exists in the Old DeviceInfo list then it is
  384. // not a new device.
  385. //
  386. NewDevice = FALSE;
  387. break;
  388. }
  389. }
  390. //
  391. // If this is a new device then add it to the list view and set
  392. // the Installed boolean to TRUE.
  393. //
  394. if (NewDevice) {
  395. InsertDeviceNodeListView(hwndList, HardwareWiz, NewDeviceInfo, &NewDeviceInfoData);
  396. Installed = TRUE;
  397. }
  398. }
  399. SetupDiDestroyDeviceInfoList(NewDeviceInfo);
  400. if (!Installed) {
  401. SendMessage(hwndList, WM_SETREDRAW, TRUE, 0L);
  402. SetupDiDestroyDeviceInfoList(HardwareWiz->PNPEnumDeviceInfo);
  403. HardwareWiz->PNPEnumDeviceInfo = NULL;
  404. return FALSE;
  405. }
  406. ListView_SetItemState(hwndList,
  407. 0,
  408. LVIS_SELECTED|LVIS_FOCUSED,
  409. LVIS_SELECTED|LVIS_FOCUSED
  410. );
  411. //
  412. // scroll the selected item into view.
  413. //
  414. ListView_EnsureVisible(hwndList, 0, FALSE);
  415. ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE_USEHEADER);
  416. SendMessage(hwndList, WM_SETREDRAW, TRUE, 0L);
  417. return Installed;
  418. }
  419. BOOL
  420. InitPnpFinishDlgProc(
  421. HWND hDlg,
  422. PHARDWAREWIZ HardwareWiz
  423. )
  424. {
  425. HFONT hfont;
  426. HICON hIcon;
  427. int FontSize, PtsPixels;
  428. HWND hwndParentDlg;
  429. HWND hwndList;
  430. LV_COLUMN lvcCol;
  431. LOGFONT LogFont;
  432. TCHAR Buffer[64];
  433. //
  434. // Insert columns for listview.
  435. // 0 == device name
  436. //
  437. hwndList = GetDlgItem(hDlg, IDC_FOUNDPNP_LIST);
  438. lvcCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  439. lvcCol.fmt = LVCFMT_LEFT;
  440. lvcCol.pszText = Buffer;
  441. lvcCol.iSubItem = 0;
  442. LoadString(hHdwWiz, IDS_DEVINSTALLED, Buffer, SIZECHARS(Buffer));
  443. ListView_InsertColumn(hwndList, 0, &lvcCol);
  444. SendMessage(hwndList,
  445. LVM_SETEXTENDEDLISTVIEWSTYLE,
  446. LVS_EX_FULLROWSELECT,
  447. LVS_EX_FULLROWSELECT
  448. );
  449. if (HardwareWiz->ClassImageList.cbSize) {
  450. ListView_SetImageList(hwndList,
  451. HardwareWiz->ClassImageList.ImageList,
  452. LVSIL_SMALL
  453. );
  454. }
  455. return TRUE;
  456. }
  457. INT_PTR CALLBACK
  458. HdwPnpFinishDlgProc(
  459. HWND hDlg,
  460. UINT wMsg,
  461. WPARAM wParam,
  462. LPARAM lParam
  463. )
  464. {
  465. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  466. HWND hwndParentDlg=GetParent(hDlg);
  467. switch (wMsg) {
  468. case WM_INITDIALOG: {
  469. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  470. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  471. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  472. SetWindowFont(GetDlgItem(hDlg, IDC_HDWNAME), HardwareWiz->hfontTextBigBold, TRUE);
  473. if (!InitPnpFinishDlgProc(hDlg, HardwareWiz)) {
  474. return FALSE;
  475. }
  476. break;
  477. }
  478. case WM_DESTROY:
  479. break;
  480. case WM_NOTIFY:
  481. switch (((LPNMHDR)lParam)->code) {
  482. case PSN_SETACTIVE:
  483. PropSheet_SetWizButtons(hwndParentDlg, PSWIZB_FINISH);
  484. EnableWindow(GetDlgItem(hwndParentDlg, IDCANCEL), FALSE);
  485. FillInstalledDevicesList(hDlg, HardwareWiz);
  486. break;
  487. case PSN_WIZFINISH:
  488. break;
  489. case NM_DBLCLK:
  490. if ((((LPNMHDR)lParam)->idFrom) == IDC_FOUNDPNP_LIST) {
  491. LVITEM lvItem;
  492. lvItem.mask = LVIF_PARAM;
  493. lvItem.iSubItem = 0;
  494. lvItem.iItem = ListView_GetNextItem(GetDlgItem(hDlg, IDC_FOUNDPNP_LIST),
  495. -1,
  496. LVNI_SELECTED);
  497. if ((lvItem.iItem != -1) &&
  498. ListView_GetItem(GetDlgItem(hDlg, IDC_FOUNDPNP_LIST), &lvItem) &&
  499. (lvItem.lParam)) {
  500. //
  501. // Launch the properties for this device.
  502. //
  503. DeviceProperties(hDlg,
  504. HardwareWiz->hMachine,
  505. (LPCSTR)(HardwareWiz->hMachine ? HardwareWiz->MachineName : NULL),
  506. (DEVNODE)lvItem.lParam,
  507. 0
  508. );
  509. }
  510. }
  511. }
  512. break;
  513. default:
  514. return(FALSE);
  515. }
  516. return(TRUE);
  517. }
  518. INT_PTR CALLBACK
  519. HdwConnectedDlgProc(
  520. HWND hDlg,
  521. UINT wMsg,
  522. WPARAM wParam,
  523. LPARAM lParam
  524. )
  525. {
  526. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  527. if (wMsg == WM_INITDIALOG) {
  528. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  529. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  530. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  531. return TRUE;
  532. }
  533. switch (wMsg) {
  534. case WM_COMMAND:
  535. switch (LOWORD(wParam)) {
  536. case IDC_ADDDEVICE_CONNECTED_YES:
  537. case IDC_ADDDEVICE_CONNECTED_NO:
  538. //
  539. // Only show the next button if one of the radio buttons are
  540. // selected.
  541. //
  542. if (IsDlgButtonChecked(hDlg, IDC_ADDDEVICE_CONNECTED_YES) ||
  543. IsDlgButtonChecked(hDlg, IDC_ADDDEVICE_CONNECTED_NO)) {
  544. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  545. } else {
  546. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  547. }
  548. break;
  549. }
  550. break;
  551. case WM_DESTROY:
  552. break;
  553. case WM_NOTIFY:
  554. switch (((NMHDR FAR *)lParam)->code) {
  555. case PSN_SETACTIVE:
  556. HardwareWiz->PrevPage = IDD_ADDDEVICE_CONNECTED;
  557. //
  558. // Only show the next button if one of the radio buttons are
  559. // selected.
  560. //
  561. if (IsDlgButtonChecked(hDlg, IDC_ADDDEVICE_CONNECTED_YES) ||
  562. IsDlgButtonChecked(hDlg, IDC_ADDDEVICE_CONNECTED_NO)) {
  563. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  564. } else {
  565. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK);
  566. }
  567. break;
  568. case PSN_WIZBACK:
  569. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_WELCOME);
  570. break;
  571. case PSN_WIZNEXT:
  572. if (IsDlgButtonChecked(hDlg, IDC_ADDDEVICE_CONNECTED_YES)) {
  573. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_PROBLIST);
  574. } else {
  575. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_CONNECTED_FINISH);
  576. }
  577. break;
  578. }
  579. break;
  580. default:
  581. return(FALSE);
  582. }
  583. return(TRUE);
  584. }
  585. INT_PTR CALLBACK
  586. HdwConnectedFinishDlgProc(
  587. HWND hDlg,
  588. UINT wMsg,
  589. WPARAM wParam,
  590. LPARAM lParam
  591. )
  592. {
  593. PHARDWAREWIZ HardwareWiz = (PHARDWAREWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  594. if (wMsg == WM_INITDIALOG) {
  595. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  596. HardwareWiz = (PHARDWAREWIZ)lppsp->lParam;
  597. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)HardwareWiz);
  598. SetWindowFont(GetDlgItem(hDlg, IDC_HDWNAME), HardwareWiz->hfontTextBigBold, TRUE);
  599. return TRUE;
  600. }
  601. switch (wMsg) {
  602. case WM_COMMAND:
  603. break;
  604. case WM_DESTROY:
  605. break;
  606. case WM_NOTIFY:
  607. switch (((NMHDR FAR *)lParam)->code) {
  608. case PSN_SETACTIVE:
  609. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_FINISH);
  610. break;
  611. case PSN_WIZBACK:
  612. SetDlgMsgResult(hDlg, wMsg, IDD_ADDDEVICE_CONNECTED);
  613. break;
  614. case PSN_WIZFINISH:
  615. if (IsDlgButtonChecked(hDlg, IDC_NEED_SHUTDOWN)) {
  616. //
  617. // Rember that we need to shutdown.
  618. //
  619. HardwareWiz->Shutdown = TRUE;
  620. }
  621. break;
  622. }
  623. break;
  624. default:
  625. return(FALSE);
  626. }
  627. return(TRUE);
  628. }