Leaked source code of windows server 2003
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.

824 lines
22 KiB

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