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.

747 lines
22 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: intro.c
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "newdevp.h"
  11. #include <dbt.h>
  12. INT_PTR
  13. InitIntroDlgProc(
  14. HWND hDlg,
  15. PNEWDEVWIZ NewDevWiz
  16. )
  17. {
  18. HFONT hfont;
  19. HDC hDC;
  20. int FontSize, PtsPixels;
  21. HWND hwndParentDlg;
  22. HWND hwndList;
  23. LOGFONT LogFont;
  24. TCHAR Buffer[64];
  25. //
  26. // Create the big bold font
  27. //
  28. hDC = GetDC(hDlg);
  29. if (hDC) {
  30. hfont = (HFONT)SendMessage(GetDlgItem(hDlg, IDC_INTRO_MSG1), WM_GETFONT, 0, 0);
  31. GetObject(hfont, sizeof(LogFont), &LogFont);
  32. LogFont.lfWeight = FW_BOLD;
  33. PtsPixels = GetDeviceCaps(hDC, LOGPIXELSY);
  34. FontSize = 12;
  35. LogFont.lfHeight = 0 - (PtsPixels * FontSize / 72);
  36. NewDevWiz->hfontTextBigBold = CreateFontIndirect(&LogFont);
  37. if (NewDevWiz->hfontTextBigBold ) {
  38. SetWindowFont(GetDlgItem(hDlg, IDC_INTRO_MSG1), NewDevWiz->hfontTextBigBold, TRUE);
  39. }
  40. }
  41. //
  42. // Create the bold font
  43. //
  44. hfont = (HFONT)SendMessage(GetDlgItem(hDlg, IDC_INTRO_MSG3), WM_GETFONT, 0, 0);
  45. GetObject(hfont, sizeof(LogFont), &LogFont);
  46. LogFont.lfWeight = FW_BOLD;
  47. NewDevWiz->hfontTextBold = CreateFontIndirect(&LogFont);
  48. if (NewDevWiz->hfontTextBold ) {
  49. SetWindowFont(GetDlgItem(hDlg, IDC_INTRO_MSG3), NewDevWiz->hfontTextBold, TRUE);
  50. }
  51. if (NDWTYPE_UPDATE == NewDevWiz->InstallType) {
  52. SetDlgText(hDlg, IDC_INTRO_MSG1, IDS_INTRO_MSG1_UPGRADE, IDS_INTRO_MSG1_UPGRADE);
  53. } else {
  54. //
  55. // The default text on the Wizard is for the Found New Hardware case, so we only
  56. // need to set the title text.
  57. //
  58. SetDlgText(hDlg, IDC_INTRO_MSG1, IDS_INTRO_MSG1_NEW, IDS_INTRO_MSG1_NEW);
  59. }
  60. //
  61. // Set the Initial radio button state to do auto-search.
  62. //
  63. CheckRadioButton(hDlg,
  64. IDC_INTRO_SEARCH,
  65. IDC_INTRO_ADVANCED,
  66. IDC_INTRO_SEARCH
  67. );
  68. return TRUE;
  69. }
  70. INT_PTR CALLBACK
  71. IntroDlgProc(
  72. HWND hDlg,
  73. UINT wMsg,
  74. WPARAM wParam,
  75. LPARAM lParam
  76. )
  77. {
  78. PNEWDEVWIZ NewDevWiz = (PNEWDEVWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  79. if (wMsg == WM_INITDIALOG) {
  80. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  81. NewDevWiz = (PNEWDEVWIZ)lppsp->lParam;
  82. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NewDevWiz);
  83. if (!InitIntroDlgProc(hDlg, NewDevWiz)) {
  84. return FALSE;
  85. }
  86. return TRUE;
  87. }
  88. switch (wMsg) {
  89. case WM_DESTROY: {
  90. if (NewDevWiz->hfontTextBigBold ) {
  91. DeleteObject(NewDevWiz->hfontTextBigBold);
  92. NewDevWiz->hfontTextBigBold = NULL;
  93. }
  94. if (NewDevWiz->hfontTextBold ) {
  95. DeleteObject(NewDevWiz->hfontTextBold);
  96. NewDevWiz->hfontTextBold = NULL;
  97. }
  98. break;
  99. }
  100. case WM_NOTIFY:
  101. switch (((NMHDR FAR *)lParam)->code) {
  102. case PSN_SETACTIVE:
  103. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT);
  104. NewDevWiz->PrevPage = IDD_NEWDEVWIZ_INTRO;
  105. SetDriverDescription(hDlg, IDC_INTRO_DRVDESC, NewDevWiz);
  106. if (NewDevWiz->InstallType == NDWTYPE_FOUNDNEW) {
  107. SetTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID, INSTALL_COMPLETE_CHECK_TIMEOUT, NULL);
  108. }
  109. break;
  110. case PSN_RESET:
  111. KillTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID);
  112. break;
  113. case PSN_WIZNEXT:
  114. NewDevWiz->EnterFrom = IDD_NEWDEVWIZ_INTRO;
  115. if (IsDlgButtonChecked(hDlg, IDC_INTRO_SEARCH)) {
  116. //
  117. // Set the search flags to search the following places automatically:
  118. // - default INF search path
  119. // - Windows Update, if we are connected to the Internet
  120. // - CD-ROM drives
  121. // - Floppy drives
  122. //
  123. NewDevWiz->SearchOptions = (SEARCH_DEFAULT |
  124. SEARCH_FLOPPY |
  125. SEARCH_CDROM |
  126. SEARCH_INET_IF_CONNECTED
  127. );
  128. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_SEARCHING);
  129. } else {
  130. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_ADVANCEDSEARCH);
  131. }
  132. KillTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID);
  133. break;
  134. }
  135. break;
  136. case WM_DEVICECHANGE:
  137. if ((wParam == DBT_DEVICEARRIVAL) &&
  138. (((PDEV_BROADCAST_VOLUME)lParam)->dbcv_devicetype == DBT_DEVTYP_VOLUME) &&
  139. (((PDEV_BROADCAST_VOLUME)lParam)->dbcv_flags & DBTF_MEDIA) &&
  140. (IsDlgButtonChecked(hDlg, IDC_INTRO_SEARCH))) {
  141. PropSheet_PressButton(GetParent(hDlg), PSBTN_NEXT);
  142. }
  143. break;
  144. case WM_TIMER:
  145. if (INSTALL_COMPLETE_CHECK_TIMERID == wParam) {
  146. if (IsInstallComplete(NewDevWiz->hDeviceInfo, &NewDevWiz->DeviceInfoData)) {
  147. PropSheet_PressButton(GetParent(hDlg), PSBTN_CANCEL);
  148. }
  149. }
  150. break;
  151. default:
  152. return(FALSE);
  153. }
  154. return(TRUE);
  155. }
  156. INT_PTR
  157. FinishInstallInitIntroDlgProc(
  158. HWND hDlg,
  159. PNEWDEVWIZ NewDevWiz
  160. )
  161. {
  162. HFONT hfont;
  163. HDC hDC;
  164. int FontSize, PtsPixels;
  165. HWND hwndParentDlg;
  166. HWND hwndList;
  167. LOGFONT LogFont;
  168. TCHAR Buffer[64];
  169. //
  170. // Create the big bold font
  171. //
  172. hDC = GetDC(hDlg);
  173. if (hDC) {
  174. hfont = (HFONT)SendMessage(GetDlgItem(hDlg, IDC_INTRO_MSG1), WM_GETFONT, 0, 0);
  175. GetObject(hfont, sizeof(LogFont), &LogFont);
  176. LogFont.lfWeight = FW_BOLD;
  177. PtsPixels = GetDeviceCaps(hDC, LOGPIXELSY);
  178. FontSize = 12;
  179. LogFont.lfHeight = 0 - (PtsPixels * FontSize / 72);
  180. NewDevWiz->hfontTextBigBold = CreateFontIndirect(&LogFont);
  181. if (NewDevWiz->hfontTextBigBold ) {
  182. SetWindowFont(GetDlgItem(hDlg, IDC_INTRO_MSG1), NewDevWiz->hfontTextBigBold, TRUE);
  183. }
  184. }
  185. //
  186. // Create the bold font
  187. //
  188. hfont = (HFONT)SendMessage(GetDlgItem(hDlg, IDC_INTRO_MSG3), WM_GETFONT, 0, 0);
  189. GetObject(hfont, sizeof(LogFont), &LogFont);
  190. LogFont.lfWeight = FW_BOLD;
  191. NewDevWiz->hfontTextBold = CreateFontIndirect(&LogFont);
  192. if (NewDevWiz->hfontTextBold ) {
  193. SetWindowFont(GetDlgItem(hDlg, IDC_INTRO_MSG3), NewDevWiz->hfontTextBold, TRUE);
  194. }
  195. if (NDWTYPE_UPDATE == NewDevWiz->InstallType) {
  196. SetDlgText(hDlg, IDC_INTRO_MSG1, IDS_INTRO_MSG1_UPGRADE, IDS_INTRO_MSG1_UPGRADE);
  197. } else {
  198. //
  199. // The default text on the Wizard is for the Found New Hardware case, so we only
  200. // need to set the title text.
  201. //
  202. SetDlgText(hDlg, IDC_INTRO_MSG1, IDS_INTRO_MSG1_NEW, IDS_INTRO_MSG1_NEW);
  203. }
  204. return TRUE;
  205. }
  206. INT_PTR CALLBACK
  207. FinishInstallIntroDlgProc(
  208. HWND hDlg,
  209. UINT wMsg,
  210. WPARAM wParam,
  211. LPARAM lParam
  212. )
  213. {
  214. PNEWDEVWIZ NewDevWiz = (PNEWDEVWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  215. HICON hicon;
  216. if (wMsg == WM_INITDIALOG) {
  217. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  218. NewDevWiz = (PNEWDEVWIZ)lppsp->lParam;
  219. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NewDevWiz);
  220. if (!InitIntroDlgProc(hDlg, NewDevWiz)) {
  221. return FALSE;
  222. }
  223. return TRUE;
  224. }
  225. switch (wMsg) {
  226. case WM_DESTROY: {
  227. if (NewDevWiz->hfontTextBigBold ) {
  228. DeleteObject(NewDevWiz->hfontTextBigBold);
  229. NewDevWiz->hfontTextBigBold = NULL;
  230. }
  231. if (NewDevWiz->hfontTextBold ) {
  232. DeleteObject(NewDevWiz->hfontTextBold);
  233. NewDevWiz->hfontTextBold = NULL;
  234. }
  235. hicon = (HICON)LOWORD(SendDlgItemMessage(hDlg, IDC_CLASSICON, STM_GETICON, 0, 0));
  236. if (hicon) {
  237. DestroyIcon(hicon);
  238. }
  239. break;
  240. }
  241. case WM_NOTIFY:
  242. switch (((NMHDR FAR *)lParam)->code) {
  243. case PSN_SETACTIVE:
  244. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT);
  245. NewDevWiz->PrevPage = IDD_NEWDEVWIZ_INTRO;
  246. SetDriverDescription(hDlg, IDC_INTRO_DRVDESC, NewDevWiz);
  247. if (SetupDiLoadClassIcon(NewDevWiz->ClassGuidSelected, &hicon, NULL)) {
  248. hicon = (HICON)SendDlgItemMessage(hDlg, IDC_CLASSICON, STM_SETICON, (WPARAM)hicon, 0L);
  249. if (hicon) {
  250. DestroyIcon(hicon);
  251. }
  252. }
  253. //
  254. // We also need to set the title for the wizard since we are the first wizard
  255. // page.
  256. //
  257. PropSheet_SetTitle(GetParent(hDlg),
  258. 0,
  259. (NewDevWiz->InstallType == NDWTYPE_FOUNDNEW) ?
  260. MAKEINTRESOURCE(IDS_FOUNDDEVICE) :
  261. MAKEINTRESOURCE(IDS_UPDATEDEVICE)
  262. );
  263. break;
  264. case PSN_RESET:
  265. break;
  266. case PSN_WIZNEXT:
  267. break;
  268. }
  269. break;
  270. default:
  271. return(FALSE);
  272. }
  273. return(TRUE);
  274. }
  275. int CALLBACK
  276. BrowseCallbackProc(
  277. HWND hwnd,
  278. UINT uMsg,
  279. LPARAM lParam,
  280. LPARAM lpData
  281. )
  282. {
  283. switch (uMsg) {
  284. case BFFM_INITIALIZED:
  285. SendMessage(hwnd, BFFM_SETSELECTION, (WPARAM)TRUE, lpData);
  286. break;
  287. case BFFM_SELCHANGED: {
  288. TCHAR CurrentPath[MAX_PATH];
  289. if (lParam && SHGetPathFromIDList((LPITEMIDLIST)lParam, CurrentPath)) {
  290. ConcatenatePaths(CurrentPath, TEXT("*.INF"), MAX_PATH, NULL);
  291. SendMessage(hwnd, BFFM_ENABLEOK, 0, (LPARAM)FileExists(CurrentPath, NULL));
  292. }
  293. break;
  294. }
  295. default:
  296. break;
  297. }
  298. return 0;
  299. }
  300. VOID
  301. DoBrowse(
  302. HWND hDlg
  303. )
  304. {
  305. BROWSEINFO bi;
  306. TCHAR CurrentLocation[MAX_PATH];
  307. TCHAR Title[MAX_PATH];
  308. LPITEMIDLIST pidl;
  309. ZeroMemory(&bi, sizeof(BROWSEINFO));
  310. GetDlgItemText(hDlg,
  311. IDC_ADVANCED_LOCATION_COMBO,
  312. CurrentLocation,
  313. SIZECHARS(CurrentLocation)
  314. );
  315. if (!LoadString(hNewDev, IDS_BROWSE_TITLE, Title, SIZECHARS(Title))) {
  316. Title[0] = TEXT('0');
  317. }
  318. bi.hwndOwner = hDlg;
  319. bi.pidlRoot = NULL;
  320. bi.pszDisplayName = NULL;
  321. bi.lpszTitle = Title;
  322. bi.ulFlags = BIF_NEWDIALOGSTYLE |
  323. BIF_RETURNONLYFSDIRS |
  324. BIF_RETURNFSANCESTORS |
  325. BIF_STATUSTEXT |
  326. BIF_NONEWFOLDERBUTTON |
  327. BIF_UAHINT;
  328. bi.lpfn = BrowseCallbackProc;
  329. bi.lParam = (LPARAM)CurrentLocation;
  330. pidl = SHBrowseForFolder(&bi);
  331. if (pidl && SHGetPathFromIDList(pidl, CurrentLocation)) {
  332. SetDlgItemText(hDlg,
  333. IDC_ADVANCED_LOCATION_COMBO,
  334. CurrentLocation
  335. );
  336. }
  337. }
  338. INT_PTR
  339. InitAdvancedSearchDlgProc(
  340. HWND hDlg,
  341. PNEWDEVWIZ NewDevWiz
  342. )
  343. {
  344. PTSTR *PathList;
  345. UINT PathCount;
  346. INT i;
  347. DWORD SearchOptions;
  348. //
  349. // Set the Initial radio button state to do auto-search.
  350. //
  351. CheckRadioButton(hDlg,
  352. IDC_ADVANCED_SEARCH,
  353. IDC_ADVANCED_LIST,
  354. IDC_ADVANCED_SEARCH
  355. );
  356. SearchOptions = GetSearchOptions();
  357. if ((SearchOptions & SEARCH_FLOPPY) ||
  358. (SearchOptions & SEARCH_CDROM)) {
  359. CheckDlgButton(hDlg, IDC_ADVANCED_REMOVABLEMEDIA, BST_CHECKED);
  360. }
  361. if (SearchOptions & SEARCH_DIRECTORY) {
  362. CheckDlgButton(hDlg, IDC_ADVANCED_LOCATION, BST_CHECKED);
  363. }
  364. //
  365. // Fill in the paths in the combo box
  366. //
  367. if (SetupQuerySourceList(0, &PathList, &PathCount)) {
  368. for (i=0; i<(int)PathCount; i++) {
  369. SendMessage(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO),
  370. CB_ADDSTRING,
  371. 0,
  372. (LPARAM)PathList[i]
  373. );
  374. }
  375. SetupFreeSourceList(&PathList, PathCount);
  376. }
  377. //
  378. // Disable the search combo box and browse button by default.
  379. //
  380. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO), (SearchOptions & SEARCH_DIRECTORY));
  381. EnableWindow(GetDlgItem(hDlg, IDC_BROWSE), (SearchOptions & SEARCH_DIRECTORY));
  382. //
  383. // Limit the text in the edit control to MAX_PATH characters, select
  384. // the first item and set up the autocomplet for directories.
  385. //
  386. SendMessage(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO), CB_LIMITTEXT, MAX_PATH, 0);
  387. SendMessage(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO), CB_SETCURSEL, 0, 0);
  388. SHAutoComplete(GetWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO), GW_CHILD), SHACF_FILESYS_DIRS);
  389. return TRUE;
  390. }
  391. INT_PTR CALLBACK
  392. AdvancedSearchDlgProc(
  393. HWND hDlg,
  394. UINT wMsg,
  395. WPARAM wParam,
  396. LPARAM lParam
  397. )
  398. {
  399. PNEWDEVWIZ NewDevWiz = (PNEWDEVWIZ)GetWindowLongPtr(hDlg, DWLP_USER);
  400. if (wMsg == WM_INITDIALOG) {
  401. LPPROPSHEETPAGE lppsp = (LPPROPSHEETPAGE)lParam;
  402. NewDevWiz = (PNEWDEVWIZ)lppsp->lParam;
  403. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)NewDevWiz);
  404. if (!InitAdvancedSearchDlgProc(hDlg, NewDevWiz)) {
  405. return FALSE;
  406. }
  407. return TRUE;
  408. }
  409. switch (wMsg) {
  410. case WM_COMMAND:
  411. switch (LOWORD(wParam)) {
  412. case IDC_ADVANCED_SEARCH:
  413. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_REMOVABLEMEDIA), TRUE);
  414. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION), TRUE);
  415. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO),
  416. IsDlgButtonChecked(hDlg, IDC_ADVANCED_LOCATION));
  417. EnableWindow(GetDlgItem(hDlg, IDC_BROWSE),
  418. IsDlgButtonChecked(hDlg, IDC_ADVANCED_LOCATION));
  419. break;
  420. case IDC_ADVANCED_LIST:
  421. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_REMOVABLEMEDIA), FALSE);
  422. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION), FALSE);
  423. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO), FALSE);
  424. EnableWindow(GetDlgItem(hDlg, IDC_BROWSE), FALSE);
  425. break;
  426. case IDC_ADVANCED_LOCATION:
  427. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_LOCATION_COMBO),
  428. IsDlgButtonChecked(hDlg, IDC_ADVANCED_LOCATION));
  429. EnableWindow(GetDlgItem(hDlg, IDC_BROWSE),
  430. IsDlgButtonChecked(hDlg, IDC_ADVANCED_LOCATION));
  431. break;
  432. case IDC_BROWSE:
  433. if (HIWORD(wParam) == BN_CLICKED) {
  434. DoBrowse(hDlg);
  435. }
  436. }
  437. break;
  438. case WM_NOTIFY:
  439. switch (((NMHDR FAR *)lParam)->code) {
  440. case PSN_SETACTIVE:
  441. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  442. NewDevWiz->PrevPage = IDD_NEWDEVWIZ_ADVANCEDSEARCH;
  443. if (NewDevWiz->InstallType == NDWTYPE_FOUNDNEW) {
  444. SetTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID, INSTALL_COMPLETE_CHECK_TIMEOUT, NULL);
  445. }
  446. break;
  447. case PSN_RESET:
  448. KillTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID);
  449. break;
  450. case PSN_WIZNEXT:
  451. NewDevWiz->EnterFrom = IDD_NEWDEVWIZ_ADVANCEDSEARCH;
  452. KillTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID);
  453. if (IsDlgButtonChecked(hDlg, IDC_ADVANCED_SEARCH)) {
  454. NewDevWiz->SearchOptions = SEARCH_DEFAULT | SEARCH_INET_IF_CONNECTED;
  455. if (IsDlgButtonChecked(hDlg, IDC_ADVANCED_REMOVABLEMEDIA)) {
  456. NewDevWiz->SearchOptions |= (SEARCH_FLOPPY | SEARCH_CDROM);
  457. }
  458. if (IsDlgButtonChecked(hDlg, IDC_ADVANCED_LOCATION)) {
  459. TCHAR TempPath[MAX_PATH];
  460. TCHAR MessageTitle[MAX_PATH];
  461. TCHAR MessageText[MAX_PATH*2];
  462. BOOL bPathIsGood = TRUE;
  463. if (GetDlgItemText(hDlg,
  464. IDC_ADVANCED_LOCATION_COMBO,
  465. NewDevWiz->BrowsePath,
  466. SIZECHARS(NewDevWiz->BrowsePath)
  467. )) {
  468. //
  469. // We have a path, now lets verify it. We will verify
  470. // both the path, and verify that there is at least
  471. // one INF file in that location. If either of these
  472. // aren't true then we will display an warning to the
  473. // user and remain on this page.
  474. //
  475. MessageTitle[0] = TEXT('\0');
  476. MessageText[0] = TEXT('\0');
  477. lstrcpy(TempPath, NewDevWiz->BrowsePath);
  478. ConcatenatePaths(TempPath, TEXT("*.INF"), MAX_PATH, NULL);
  479. //
  480. // We will first check if the path exists at all. To do
  481. // this we need to verify that FindFirstFile fails on
  482. // the directory, and the directory with *.INF
  483. // concatonated on the end. The reason for this is that
  484. // FindFirstFile does not handle root directory paths
  485. // correctly for some reason so they need to be special
  486. // cased.
  487. //
  488. if (!FileExists(NewDevWiz->BrowsePath, NULL) &&
  489. !FileExists(TempPath, NULL)) {
  490. LoadString(hNewDev,
  491. IDS_LOCATION_BAD_DIR,
  492. MessageText,
  493. SIZECHARS(MessageText));
  494. bPathIsGood = FALSE;
  495. } else if (!FileExists(TempPath, NULL)) {
  496. LoadString(hNewDev,
  497. IDS_LOCATION_NO_INFS,
  498. MessageText,
  499. SIZECHARS(MessageText));
  500. bPathIsGood = FALSE;
  501. }
  502. if (bPathIsGood) {
  503. SetupAddToSourceList(SRCLIST_SYSIFADMIN, NewDevWiz->BrowsePath);
  504. NewDevWiz->SearchOptions |= SEARCH_DIRECTORY;
  505. } else {
  506. if (GetWindowText(GetParent(hDlg),
  507. MessageTitle,
  508. SIZECHARS(MessageTitle)) &&
  509. (MessageText[0] != TEXT('\0'))) {
  510. MessageBox(hDlg, MessageText, MessageTitle, MB_OK | MB_ICONWARNING);
  511. SetDlgMsgResult(hDlg, wMsg, -1);
  512. break;
  513. }
  514. }
  515. }
  516. }
  517. SetSearchOptions(NewDevWiz->SearchOptions);
  518. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_SEARCHING);
  519. } else {
  520. ULONG DevNodeStatus;
  521. ULONG Problem=0;
  522. HDEVINFO hDeviceInfo;
  523. SP_DRVINFO_DATA DriverInfoData;
  524. HWND hwndParentDlg = GetParent(hDlg);
  525. //
  526. // If we have a selected driver,
  527. // or we know the class and there wasn't a problem installing
  528. // go into select device
  529. //
  530. //
  531. DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA);
  532. if (SetupDiEnumDriverInfo(NewDevWiz->hDeviceInfo,
  533. &NewDevWiz->DeviceInfoData,
  534. SPDIT_COMPATDRIVER,
  535. 0,
  536. &DriverInfoData
  537. )
  538. ||
  539. (!IsEqualGUID(&NewDevWiz->DeviceInfoData.ClassGuid,
  540. &GUID_NULL
  541. )
  542. &&
  543. CM_Get_DevNode_Status(&DevNodeStatus,
  544. &Problem,
  545. NewDevWiz->DeviceInfoData.DevInst,
  546. 0
  547. ) == CR_SUCCESS
  548. &&
  549. Problem != CM_PROB_FAILED_INSTALL
  550. )) {
  551. NewDevWiz->ClassGuidSelected = &NewDevWiz->DeviceInfoData.ClassGuid;
  552. NewDevWiz->EnterInto = IDD_NEWDEVWIZ_SELECTDEVICE;
  553. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_SELECTDEVICE);
  554. break;
  555. }
  556. NewDevWiz->ClassGuidSelected = NULL;
  557. NewDevWiz->EnterInto = IDD_NEWDEVWIZ_SELECTCLASS;
  558. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_SELECTCLASS);
  559. }
  560. break;
  561. case PSN_WIZBACK:
  562. KillTimer(hDlg, INSTALL_COMPLETE_CHECK_TIMERID);
  563. SetDlgMsgResult(hDlg, wMsg, IDD_NEWDEVWIZ_INTRO);
  564. break;
  565. }
  566. break;
  567. case WM_TIMER:
  568. if (INSTALL_COMPLETE_CHECK_TIMERID == wParam) {
  569. if (IsInstallComplete(NewDevWiz->hDeviceInfo, &NewDevWiz->DeviceInfoData)) {
  570. PropSheet_PressButton(GetParent(hDlg), PSBTN_CANCEL);
  571. }
  572. }
  573. break;
  574. default:
  575. return(FALSE);
  576. }
  577. return(TRUE);
  578. }