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.

2029 lines
66 KiB

  1. /****************************************************************************
  2. Copyright (c) Microsoft Corporation 1997
  3. All rights reserved
  4. ***************************************************************************/
  5. #include "pch.h"
  6. #include "dialogs.h"
  7. #include "setup.h"
  8. #include "check.h"
  9. #include "dhcp.h"
  10. DEFINE_MODULE("Dialogs");
  11. #define BITMAP_WIDTH 16
  12. #define BITMAP_HEIGHT 16
  13. #define LG_BITMAP_WIDTH 32
  14. #define LG_BITMAP_HEIGHT 32
  15. static WNDPROC g_pOldEditWndProc;
  16. //
  17. // global window message for cancelling autoplay.
  18. //
  19. UINT g_uQueryCancelAutoPlay = 0;
  20. //
  21. // Check to see if the directory exists. If not, ask the user if we
  22. // should create it.
  23. //
  24. HRESULT
  25. CheckDirectory( HWND hDlg, LPWSTR pszPath )
  26. {
  27. TraceFunc( "CheckDirectory( ... )\n" );
  28. HRESULT hr = E_FAIL;
  29. DWORD dwAttrib = GetFileAttributes( pszPath );
  30. if ( dwAttrib != 0xFFFFffff
  31. && g_Options.fAutomated == FALSE )
  32. {
  33. INT iResult = MessageBoxFromStrings( hDlg,
  34. IDS_DIRECTORYEXISTS_CAPTION,
  35. IDS_DIRECTORYEXISTS_TEXT,
  36. MB_YESNO );
  37. if ( iResult == IDNO )
  38. goto Cleanup;
  39. }
  40. hr = S_OK;
  41. Cleanup:
  42. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, (hr == S_OK ? 0 : -1 ) );
  43. HRETURN(hr);
  44. }
  45. //
  46. // Base dialog proc - all unhandled calls are passed here. If they are not
  47. // handled here, then the default dialog proc will handle them.
  48. //
  49. INT_PTR CALLBACK
  50. BaseDlgProc(
  51. HWND hDlg,
  52. UINT uMsg,
  53. WPARAM wParam,
  54. LPARAM lParam )
  55. {
  56. NMHDR FAR *lpnmhdr;
  57. switch ( uMsg )
  58. {
  59. case WM_INITDIALOG:
  60. SetDialogFont( hDlg, IDC_S_TITLE1, DlgFontTitle );
  61. //SetDialogFont( hDlg, IDC_S_TITLE2, DlgFontTitle );
  62. //SetDialogFont( hDlg, IDC_S_TITLE3, DlgFontTitle );
  63. SetDialogFont( hDlg, IDC_S_BOLD1, DlgFontBold );
  64. SetDialogFont( hDlg, IDC_S_BOLD2, DlgFontBold );
  65. SetDialogFont( hDlg, IDC_S_BOLD3, DlgFontBold );
  66. break;
  67. case WM_PALETTECHANGED:
  68. if ((HWND)wParam != hDlg)
  69. {
  70. InvalidateRect(hDlg, NULL, NULL);
  71. UpdateWindow(hDlg);
  72. }
  73. break;
  74. default:
  75. return FALSE;
  76. }
  77. return TRUE;
  78. }
  79. //
  80. // WelcomeDlgProc( )
  81. //
  82. // "Welcome's" (the first page's) dialog proc.
  83. //
  84. INT_PTR CALLBACK
  85. WelcomeDlgProc(
  86. HWND hDlg,
  87. UINT uMsg,
  88. WPARAM wParam,
  89. LPARAM lParam )
  90. {
  91. NMHDR FAR *lpnmhdr;
  92. switch ( uMsg )
  93. {
  94. case WM_INITDIALOG:
  95. CenterDialog( GetParent( hDlg ) );
  96. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  97. case WM_NOTIFY:
  98. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  99. lpnmhdr = (NMHDR FAR *) lParam;
  100. switch ( lpnmhdr->code )
  101. {
  102. case PSN_QUERYCANCEL:
  103. return VerifyCancel( hDlg );
  104. case PSN_SETACTIVE:
  105. if ( g_Options.fAddOption
  106. || g_Options.fCheckServer )
  107. {
  108. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  109. break;
  110. }
  111. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT );
  112. ClearMessageQueue( );
  113. break;
  114. }
  115. break;
  116. default:
  117. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  118. }
  119. return TRUE;
  120. }
  121. //
  122. // VerifyRootDirectoryName( )
  123. //
  124. BOOL
  125. VerifyRootDirectoryName( )
  126. {
  127. TraceFunc( "VerifyRootDirectoryName()\n" );
  128. BOOL fReturn = FALSE;
  129. LPWSTR psz = g_Options.szIntelliMirrorPath;
  130. while ( *psz >= 32 && *psz < 127 )
  131. psz++;
  132. if ( *psz == L'\0' )
  133. {
  134. fReturn = TRUE;
  135. }
  136. RETURN(fReturn);
  137. }
  138. //
  139. // IntelliMirrorRootDlgProc( )
  140. //
  141. INT_PTR CALLBACK
  142. IntelliMirrorRootDlgProc(
  143. HWND hDlg,
  144. UINT uMsg,
  145. WPARAM wParam,
  146. LPARAM lParam )
  147. {
  148. NMHDR FAR *lpnmhdr;
  149. DWORD dwPathLength;
  150. switch ( uMsg )
  151. {
  152. case WM_INITDIALOG:
  153. {
  154. HWND hwndEdit = GetDlgItem( hDlg, IDC_E_INTELLIMIRRORROOT );
  155. Edit_LimitText( hwndEdit, ARRAYSIZE(g_Options.szIntelliMirrorPath) - 1 );
  156. Edit_SetText( hwndEdit, g_Options.szIntelliMirrorPath );
  157. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  158. }
  159. case WM_NOTIFY:
  160. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  161. lpnmhdr = (NMHDR FAR *) lParam;
  162. switch ( lpnmhdr->code )
  163. {
  164. case PSN_WIZNEXT:
  165. Edit_GetText( GetDlgItem( hDlg, IDC_E_INTELLIMIRRORROOT ),
  166. g_Options.szIntelliMirrorPath,
  167. ARRAYSIZE( g_Options.szIntelliMirrorPath ) );
  168. if ( !CheckIntelliMirrorDrive( hDlg ) )
  169. {
  170. g_Options.fIMirrorDirectory = TRUE;
  171. }
  172. //
  173. // Remove any trailing \ from the path, since NetShareAdd
  174. // can't handle those.
  175. //
  176. dwPathLength = lstrlen( g_Options.szIntelliMirrorPath );
  177. while ( ( dwPathLength > 0 ) &&
  178. ( g_Options.szIntelliMirrorPath[dwPathLength-1] == L'\\' ) ) {
  179. g_Options.szIntelliMirrorPath[dwPathLength-1] = L'\0';
  180. --dwPathLength;
  181. }
  182. if ( !VerifyRootDirectoryName( ) )
  183. {
  184. MessageBoxFromStrings( hDlg, IDS_OSCHOOSER_ROOT_DIRECTORY_RESTRICTION_TITLE, IDS_OSCHOOSER_ROOT_DIRECTORY_RESTRICTION_TEXT, MB_OK );
  185. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  186. break;
  187. }
  188. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK | PSWIZB_NEXT );
  189. break;
  190. case PSN_QUERYCANCEL:
  191. return VerifyCancel( hDlg );
  192. case PSN_SETACTIVE:
  193. if ( g_Options.fError
  194. || g_Options.fAbort
  195. || g_Options.fIMirrorShareFound
  196. || g_Options.fTFTPDDirectoryFound ) {
  197. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  198. }
  199. else
  200. {
  201. DWORD dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_INTELLIMIRRORROOT ) );
  202. PropSheet_SetWizButtons( GetParent( hDlg ),
  203. (dwLen ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK) );
  204. ClearMessageQueue( );
  205. }
  206. break;
  207. }
  208. break;
  209. case WM_COMMAND:
  210. switch( LOWORD( wParam))
  211. {
  212. case IDC_E_INTELLIMIRRORROOT:
  213. {
  214. if ( HIWORD(wParam) == EN_CHANGE )
  215. {
  216. DWORD dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_INTELLIMIRRORROOT) );
  217. PropSheet_SetWizButtons( GetParent( hDlg ), dwLen ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK );
  218. }
  219. }
  220. break;
  221. case IDC_B_BROWSE:
  222. {
  223. WCHAR szTitle[ SMALL_BUFFER_SIZE ];
  224. WCHAR szPath[ MAX_PATH ];
  225. BROWSEINFO bs;
  226. DWORD dw;
  227. ZeroMemory( &bs, sizeof(bs) );
  228. bs.hwndOwner = hDlg;
  229. dw = LoadString( g_hinstance, IDS_BROWSECAPTION_RBDIR, szTitle, ARRAYSIZE( szTitle ));
  230. Assert( dw );
  231. bs.lpszTitle = (LPWSTR) &szTitle;
  232. bs.ulFlags = BIF_RETURNONLYFSDIRS | BIF_RETURNFSANCESTORS;
  233. LPITEMIDLIST pidl = SHBrowseForFolder( &bs );
  234. if ( pidl && SHGetPathFromIDList( pidl, szPath ) ) {
  235. if ( wcslen( szPath ) > ARRAYSIZE(g_Options.szSourcePath) - 2 ) {
  236. MessageBoxFromStrings( hDlg, IDS_PATH_TOO_LONG_TITLE, IDS_PATH_TOO_LONG_TEXT, MB_OK );
  237. szPath[ ARRAYSIZE(g_Options.szSourcePath) - 1 ] = L'\0';
  238. }
  239. Edit_SetText( GetDlgItem( hDlg, IDC_E_INTELLIMIRRORROOT ), szPath );
  240. }
  241. }
  242. break;
  243. }
  244. break;
  245. default:
  246. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  247. }
  248. return TRUE;
  249. }
  250. //
  251. // SCPCheckWindows( )
  252. //
  253. void
  254. SCPCheckWindows( HWND hDlg )
  255. {
  256. // LONG lAllowNewClients = Button_GetCheck( GetDlgItem( hDlg, IDC_C_ACCEPTSNEWCLIENTS ) );
  257. // LONG lLimitClients = Button_GetCheck( GetDlgItem( hDlg, IDC_C_LIMITCLIENTS ) );
  258. LONG lAnswerRequests = Button_GetCheck( GetDlgItem( hDlg, IDC_C_RESPOND ) );
  259. // EnableWindow( GetDlgItem( hDlg, IDC_C_LIMITCLIENTS ), lAllowNewClients );
  260. // EnableWindow( GetDlgItem( hDlg, IDC_E_LIMIT ), lAllowNewClients && lLimitClients );
  261. // EnableWindow( GetDlgItem( hDlg, IDC_SPIN_LIMIT ), lAllowNewClients && lLimitClients );
  262. EnableWindow( GetDlgItem( hDlg, IDC_C_KNOWNCLIENTS ), lAnswerRequests );
  263. }
  264. //
  265. // SCPDlgProc( )
  266. //
  267. // SCP default setup settings
  268. //
  269. INT_PTR CALLBACK
  270. SCPDlgProc(
  271. HWND hDlg,
  272. UINT uMsg,
  273. WPARAM wParam,
  274. LPARAM lParam )
  275. {
  276. NMHDR FAR *lpnmhdr;
  277. static UINT uDlgState = 0;
  278. switch ( uMsg )
  279. {
  280. case WM_INITDIALOG:
  281. // Edit_LimitText( GetDlgItem( hDlg, IDC_E_LIMIT ), 3 );
  282. SCPCheckWindows( hDlg );
  283. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  284. case WM_NOTIFY:
  285. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  286. lpnmhdr = (NMHDR FAR *) lParam;
  287. switch ( lpnmhdr->code )
  288. {
  289. case PSN_WIZNEXT:
  290. {
  291. LONG lResult;
  292. //lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_C_ACCEPTSNEWCLIENTS ) );
  293. //scpdata[0].pszValue = ( lResult == BST_CHECKED ? L"TRUE" : L"FALSE" );
  294. //lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_C_LIMITCLIENTS ) );
  295. //scpdata[1].pszValue = ( lResult == BST_CHECKED ? L"TRUE" : L"FALSE" );
  296. //if ( lResult == BST_CHECKED ) {
  297. // GetDlgItemText( hDlg, IDC_E_LIMIT, scpdata[3].pszValue, 4 );
  298. //}
  299. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_C_RESPOND ) );
  300. scpdata[4].pszValue = ( lResult == BST_CHECKED ? L"TRUE" : L"FALSE" );
  301. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_C_KNOWNCLIENTS ) );
  302. scpdata[5].pszValue = ( lResult == BST_CHECKED ? L"TRUE" : L"FALSE" );
  303. }
  304. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  305. break;
  306. case PSN_QUERYCANCEL:
  307. return VerifyCancel( hDlg );
  308. case PSN_SETACTIVE:
  309. if ( g_Options.fError || g_Options.fAbort || g_Options.fBINLSCPFound ) {
  310. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  311. break;
  312. }
  313. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT | PSWIZB_BACK );
  314. ClearMessageQueue( );
  315. break;
  316. }
  317. break;
  318. case WM_COMMAND:
  319. {
  320. if ( HIWORD( wParam ) == BN_CLICKED ) {
  321. SCPCheckWindows( hDlg );
  322. }
  323. }
  324. break;
  325. default:
  326. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  327. }
  328. return TRUE;
  329. }
  330. //
  331. // WarningDlgProc( )
  332. //
  333. INT_PTR CALLBACK
  334. WarningDlgProc(
  335. HWND hDlg,
  336. UINT uMsg,
  337. WPARAM wParam,
  338. LPARAM lParam )
  339. {
  340. NMHDR FAR *lpnmhdr;
  341. switch ( uMsg )
  342. {
  343. case WM_INITDIALOG:
  344. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  345. case WM_NOTIFY:
  346. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  347. lpnmhdr = (NMHDR FAR *) lParam;
  348. switch ( lpnmhdr->code )
  349. {
  350. case PSN_QUERYCANCEL:
  351. return VerifyCancel( hDlg );
  352. case PSN_SETACTIVE:
  353. if ( g_Options.fError || g_Options.fAbort || g_Options.fNewOS) {
  354. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  355. }
  356. else
  357. {
  358. HRESULT hr = CheckInstallation( );
  359. if ( hr == S_OK || g_Options.fFirstTime ) {
  360. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // do not show this page
  361. break;
  362. }
  363. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK | PSWIZB_FINISH );
  364. ClearMessageQueue( );
  365. }
  366. break;
  367. }
  368. break;
  369. default:
  370. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  371. }
  372. return TRUE;
  373. }
  374. //
  375. // OptionsDlgProc( )
  376. //
  377. INT_PTR CALLBACK
  378. OptionsDlgProc(
  379. HWND hDlg,
  380. UINT uMsg,
  381. WPARAM wParam,
  382. LPARAM lParam )
  383. {
  384. NMHDR FAR *lpnmhdr;
  385. switch ( uMsg )
  386. {
  387. case WM_INITDIALOG:
  388. Button_SetCheck( GetDlgItem( hDlg, IDC_B_ADD ), BST_CHECKED );
  389. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  390. case WM_NOTIFY:
  391. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  392. lpnmhdr = (NMHDR FAR *) lParam;
  393. switch ( lpnmhdr->code )
  394. {
  395. case PSN_WIZNEXT:
  396. if ( BST_CHECKED == Button_GetCheck( GetDlgItem( hDlg, IDC_B_ADD ) ) ) {
  397. g_Options.fNewOS = TRUE;
  398. } else {
  399. g_Options.fNewOS = FALSE;
  400. }
  401. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  402. break;
  403. case PSN_QUERYCANCEL:
  404. return VerifyCancel( hDlg );
  405. case PSN_SETACTIVE:
  406. if ( g_Options.fFirstTime
  407. || g_Options.fAddOption ) {
  408. g_Options.fNewOS = TRUE;
  409. }
  410. if ( g_Options.fFirstTime
  411. || g_Options.fAddOption
  412. || g_Options.fError
  413. || g_Options.fAbort
  414. || g_Options.fCheckServer ) {
  415. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  416. break;
  417. }
  418. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK | PSWIZB_NEXT );
  419. ClearMessageQueue( );
  420. break;
  421. }
  422. break;
  423. default:
  424. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  425. }
  426. return TRUE;
  427. }
  428. //
  429. // ImageSourceDlgProc( )
  430. //
  431. INT_PTR CALLBACK
  432. ImageSourceDlgProc(
  433. HWND hDlg,
  434. UINT uMsg,
  435. WPARAM wParam,
  436. LPARAM lParam )
  437. {
  438. NMHDR FAR *lpnmhdr;
  439. switch ( uMsg )
  440. {
  441. case WM_INITDIALOG:
  442. {
  443. HWND hwndEdit = GetDlgItem( hDlg, IDC_E_IMAGESOURCE );
  444. SHAutoComplete(hwndEdit, SHACF_AUTOSUGGEST_FORCE_ON | SHACF_FILESYSTEM);
  445. Edit_LimitText( hwndEdit, ARRAYSIZE(g_Options.szSourcePath) - 1 );
  446. Edit_SetText( hwndEdit, g_Options.szSourcePath );
  447. #ifdef SHOW_ARCHITECTURERADIOBUTTON
  448. if( g_Options.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL ) {
  449. Button_SetCheck( GetDlgItem( hDlg, IDC_C_X86 ), BST_CHECKED );
  450. } else if( g_Options.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 ) {
  451. Button_SetCheck( GetDlgItem( hDlg, IDC_C_IA64 ), BST_CHECKED );
  452. }
  453. #endif
  454. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  455. }
  456. case WM_NOTIFY:
  457. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  458. lpnmhdr = (NMHDR FAR *) lParam;
  459. switch ( lpnmhdr->code )
  460. {
  461. case PSN_WIZNEXT:
  462. {
  463. CWaitCursor Wait;
  464. HRESULT hr;
  465. DWORD pathlen,archlen;
  466. WCHAR archscratch[10];
  467. BOOL FirstTime = TRUE;
  468. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  469. Edit_GetText( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ),
  470. g_Options.szSourcePath,
  471. ARRAYSIZE( g_Options.szSourcePath ) );
  472. #ifdef SHOW_ARCHITECTURERADIOBUTTON
  473. if( ( 0x0003 & Button_GetState( GetDlgItem( hDlg, IDC_C_X86 ) ) ) == BST_CHECKED ) {
  474. g_Options.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
  475. wcscpy( g_Options.ProcessorArchitectureString, L"i386" );
  476. wcscpy( archscracth, L"\\i386");
  477. archlen = 5;
  478. }
  479. if( ( 0x0003 & Button_GetState( GetDlgItem( hDlg, IDC_C_IA64 ) ) ) == BST_CHECKED ) {
  480. g_Options.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64;
  481. wcscpy(g_Options.ProcessorArchitectureString, L"ia64" );
  482. wcscpy( archscracth, L"\\ia64");
  483. archlen = 5;
  484. }
  485. pathlen = wcslen(g_Options.szSourcePath);
  486. // Remove any trailing slashes
  487. if ( g_Options.szSourcePath[ pathlen - 1 ] == L'\\' ) {
  488. g_Options.szSourcePath[ pathlen - 1 ] = L'\0';
  489. pathlen -= 1;
  490. }
  491. //
  492. // remove any processor specific subdir at the end of the path
  493. // if that's there as well, being careful not to underflow
  494. // the array
  495. //
  496. if ( (pathlen > archlen) &&
  497. (0 == _wcsicmp(
  498. &g_Options.szSourcePath[pathlen-archlen],
  499. archscracth))) {
  500. g_Options.szSourcePath[ pathlen - archlen ] = L'\0';
  501. }
  502. hr = FindImageSource( hDlg );
  503. if ( hr != S_OK ) {
  504. Edit_SetText( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ), g_Options.szSourcePath );
  505. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  506. break;
  507. }
  508. #else
  509. if (g_Options.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) {
  510. wcscpy(g_Options.ProcessorArchitectureString, L"i386" );
  511. wcscpy( archscratch, L"\\i386");
  512. archlen = 5;
  513. } else {
  514. wcscpy(g_Options.ProcessorArchitectureString, L"ia64" );
  515. wcscpy( archscratch, L"\\ia64");
  516. archlen = 5;
  517. }
  518. pathlen = wcslen(g_Options.szSourcePath);
  519. // Remove any trailing slashes
  520. if ( g_Options.szSourcePath[ pathlen - 1 ] == L'\\' ) {
  521. g_Options.szSourcePath[ pathlen - 1 ] = L'\0';
  522. pathlen -= 1;
  523. }
  524. tryfindimagesource:
  525. //
  526. // remove any processor specific subdir at the end of the path
  527. // if that's there as well, being careful not to underflow
  528. // the array
  529. //
  530. if ( (pathlen > archlen) &&
  531. (0 == _wcsicmp(
  532. &g_Options.szSourcePath[pathlen-archlen],
  533. archscratch))) {
  534. g_Options.szSourcePath[ pathlen - archlen ] = L'\0';
  535. }
  536. //
  537. // try the default architecture for the image.
  538. // If it doesn't work then try again with another architecture.
  539. //
  540. hr = FindImageSource( hDlg );
  541. if ( hr != S_OK ) {
  542. if (FirstTime) {
  543. FirstTime = FALSE;
  544. if (g_Options.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {
  545. g_Options.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
  546. wcscpy( g_Options.ProcessorArchitectureString, L"i386" );
  547. wcscpy( archscratch, L"\\i386");
  548. archlen = 5;
  549. } else {
  550. g_Options.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64;
  551. wcscpy(g_Options.ProcessorArchitectureString, L"ia64" );
  552. wcscpy( archscratch, L"\\ia64");
  553. archlen = 5;
  554. }
  555. goto tryfindimagesource;
  556. } else {
  557. //
  558. // We didn't find it. print a failure message.
  559. //
  560. MessageBoxFromStrings( hDlg, IDS_FILE_NOT_FOUND_TITLE, IDS_FILE_NOT_FOUND_TEXT, MB_OK );
  561. Edit_SetText( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ), g_Options.szSourcePath );
  562. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  563. break;
  564. }
  565. }
  566. #endif
  567. hr = CheckImageSource( hDlg );
  568. if ( hr != S_OK )
  569. {
  570. Edit_SetText( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ), g_Options.szSourcePath );
  571. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  572. break;
  573. }
  574. Edit_SetText( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ), g_Options.szSourcePath );
  575. hr = CheckInstallation( );
  576. }
  577. break;
  578. case PSN_QUERYCANCEL:
  579. return VerifyCancel( hDlg );
  580. case PSN_SETACTIVE:
  581. if ( g_Options.fError
  582. || g_Options.fAbort
  583. || !g_Options.fNewOS ) {
  584. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  585. break;
  586. }
  587. else
  588. {
  589. DWORD dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_IMAGESOURCE) );
  590. PropSheet_SetWizButtons( GetParent( hDlg ),
  591. (dwLen ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK) );
  592. ClearMessageQueue( );
  593. }
  594. break;
  595. }
  596. break;
  597. case WM_COMMAND:
  598. DWORD dwLen;
  599. switch( LOWORD( wParam))
  600. {
  601. case IDC_E_IMAGESOURCE:
  602. if ( HIWORD(wParam) != EN_CHANGE )
  603. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  604. // fall thru...
  605. #ifdef SHOW_ARCHITECTURERADIOBUTTON
  606. case IDC_C_X86:
  607. case IDC_C_IA64:
  608. {
  609. if( ( 0x0003 & Button_GetState( GetDlgItem( hDlg, IDC_C_X86 ) ) ) == BST_CHECKED ) {
  610. g_Options.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
  611. wcscpy( g_Options.ProcessorArchitectureString, L"i386" );
  612. }
  613. if( ( 0x0003 & Button_GetState( GetDlgItem( hDlg, IDC_C_IA64 ) ) ) == BST_CHECKED ) {
  614. g_Options.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64;
  615. wcscpy( g_Options.ProcessorArchitectureString, L"ia64" );
  616. }
  617. dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ) );
  618. PropSheet_SetWizButtons( GetParent( hDlg ),
  619. ( dwLen) ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK );
  620. }
  621. break;
  622. #else
  623. dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ) );
  624. PropSheet_SetWizButtons(
  625. GetParent( hDlg ),
  626. ( dwLen) ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK );
  627. break;
  628. #endif
  629. case IDC_B_BROWSE:
  630. {
  631. WCHAR szPath[ MAX_PATH ];
  632. WCHAR szTitle[ SMALL_BUFFER_SIZE ];
  633. BROWSEINFO bs;
  634. DWORD dw;
  635. ZeroMemory( &bs, sizeof(bs) );
  636. bs.hwndOwner = hDlg;
  637. dw = LoadString( g_hinstance, IDS_BROWSECAPTION_SOURCEDIR, szTitle, ARRAYSIZE( szTitle ));
  638. Assert( dw );
  639. bs.lpszTitle = (LPWSTR) &szTitle;
  640. bs.ulFlags = BIF_RETURNONLYFSDIRS | BIF_RETURNFSANCESTORS;
  641. LPITEMIDLIST pidl = SHBrowseForFolder( &bs );
  642. if ( pidl && SHGetPathFromIDList( pidl, szPath) ) {
  643. if ( wcslen( szPath ) > ARRAYSIZE(g_Options.szSourcePath) - 2 ) {
  644. MessageBoxFromStrings( hDlg, IDS_PATH_TOO_LONG_TITLE, IDS_PATH_TOO_LONG_TEXT, MB_OK );
  645. //
  646. // SHGetPathFromIDList() returns the path with a
  647. // trailing backslash, which we want to drop
  648. // The directory that the user selected will be
  649. // validated when the user clicks next
  650. szPath[ ARRAYSIZE(g_Options.szSourcePath) - 1 ] = L'\0';
  651. }
  652. Edit_SetText( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ), szPath );
  653. }
  654. }
  655. break;
  656. default:
  657. break;
  658. }
  659. break;
  660. default:
  661. //
  662. // try to cancel CD autoplay
  663. //
  664. if (!g_uQueryCancelAutoPlay) {
  665. g_uQueryCancelAutoPlay = RegisterWindowMessage(TEXT("QueryCancelAutoPlay"));
  666. DebugMsg( "generate autoplay message %d\n", g_uQueryCancelAutoPlay );
  667. }
  668. if (uMsg == g_uQueryCancelAutoPlay) {
  669. DebugMsg( "received autoplay message\n" );
  670. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, 1 );
  671. return 1; // cancel auto-play
  672. }
  673. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  674. }
  675. return TRUE;
  676. }
  677. //
  678. // VerifyDirectoryName( )
  679. //
  680. BOOL
  681. VerifyDirectoryName( )
  682. {
  683. TraceFunc( "VerifyDirectoryName()\n" );
  684. BOOL fReturn = FALSE;
  685. LPWSTR psz = g_Options.szInstallationName;
  686. while ( *psz > 32 && *psz < 127 )
  687. psz++;
  688. if ( *psz == L'\0' )
  689. {
  690. fReturn = TRUE;
  691. }
  692. RETURN(fReturn);
  693. }
  694. //
  695. // OSDirectoryDlgProc( )
  696. //
  697. INT_PTR CALLBACK
  698. OSDirectoryDlgProc(
  699. HWND hDlg,
  700. UINT uMsg,
  701. WPARAM wParam,
  702. LPARAM lParam )
  703. {
  704. NMHDR FAR *lpnmhdr;
  705. switch ( uMsg )
  706. {
  707. case WM_INITDIALOG:
  708. {
  709. HWND hwndEdit = GetDlgItem( hDlg, IDC_E_OSDIRECTORY );
  710. Edit_LimitText( hwndEdit, ARRAYSIZE(g_Options.szInstallationName) - 1 );
  711. Edit_SetText( hwndEdit, g_Options.szInstallationName );
  712. }
  713. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  714. case WM_NOTIFY:
  715. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  716. lpnmhdr = (NMHDR FAR *) lParam;
  717. switch ( lpnmhdr->code )
  718. {
  719. case PSN_WIZNEXT:
  720. Edit_GetText( GetDlgItem( hDlg, IDC_E_OSDIRECTORY ),
  721. g_Options.szInstallationName,
  722. ARRAYSIZE( g_Options.szInstallationName ) );
  723. if ( !VerifyDirectoryName( ) )
  724. {
  725. MessageBoxFromStrings( hDlg, IDS_OSCHOOSER_DIRECTORY_RESTRICTION_TITLE, IDS_OSCHOOSER_DIRECTORY_RESTRICTION_TEXT, MB_OK );
  726. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  727. break;
  728. }
  729. BuildDirectories( );
  730. CheckDirectory( hDlg, g_Options.szInstallationPath );
  731. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK | PSWIZB_NEXT );
  732. break;
  733. case PSN_QUERYCANCEL:
  734. return VerifyCancel( hDlg );
  735. case PSN_SETACTIVE:
  736. if ( g_Options.fError
  737. || g_Options.fAbort
  738. || !g_Options.fNewOS ) {
  739. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  740. break;
  741. }
  742. else
  743. {
  744. DWORD dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_OSDIRECTORY) );
  745. PropSheet_SetWizButtons( GetParent( hDlg ),
  746. (dwLen ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK) );
  747. ClearMessageQueue( );
  748. }
  749. break;
  750. }
  751. break;
  752. case WM_COMMAND:
  753. {
  754. if ( HIWORD( wParam ) == EN_CHANGE ) {
  755. DWORD dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_OSDIRECTORY ) );
  756. PropSheet_SetWizButtons( GetParent( hDlg ), ( dwLen ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK ) );
  757. }
  758. }
  759. break;
  760. default:
  761. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  762. }
  763. return TRUE;
  764. }
  765. //
  766. // HelpTextEditWndProc( )
  767. //
  768. INT_PTR CALLBACK
  769. HelpTextEditWndProc(
  770. HWND hWnd,
  771. UINT uMsg,
  772. WPARAM wParam,
  773. LPARAM lParam )
  774. {
  775. switch ( uMsg )
  776. {
  777. case WM_KEYDOWN:
  778. // ignore CONTROL characters
  779. if ( 0 <= GetKeyState( VK_CONTROL ) )
  780. {
  781. // fake button presses
  782. if ( LOWORD( wParam ) == VK_RETURN ) {
  783. PropSheet_PressButton( GetParent( GetParent( hWnd ) ), PSBTN_NEXT );
  784. return FALSE;
  785. } else if ( LOWORD( wParam ) == VK_ESCAPE ) {
  786. PropSheet_PressButton( GetParent( GetParent( hWnd ) ), PSBTN_CANCEL );
  787. return FALSE;
  788. }
  789. }
  790. break;
  791. }
  792. return CallWindowProc(g_pOldEditWndProc, hWnd, uMsg, wParam, lParam);
  793. }
  794. //
  795. // VerifySIFText( )
  796. //
  797. BOOL
  798. VerifySIFText(
  799. LPWSTR pszText )
  800. {
  801. TraceFunc( "VerifySIFText()\n" );
  802. BOOL fReturn = FALSE;
  803. if ( !pszText )
  804. RETURN(fReturn);
  805. //
  806. // make sure the string consists of valid characters that can be displayed
  807. // by the OS Chooser. Note that the OS Chooser is not localized, so this
  808. // check is really for ASCII chars >= 32 (space) and < 127 (DEL)
  809. //
  810. while ( *pszText >= 32 && *pszText < 127 )
  811. pszText++;
  812. if ( *pszText == L'\0' )
  813. {
  814. fReturn = TRUE;
  815. }
  816. RETURN(fReturn);
  817. }
  818. //
  819. // DefaultSIFDlgProc( )
  820. //
  821. // Generates the default SIF.
  822. //
  823. INT_PTR CALLBACK
  824. DefaultSIFDlgProc(
  825. HWND hDlg,
  826. UINT uMsg,
  827. WPARAM wParam,
  828. LPARAM lParam )
  829. {
  830. NMHDR FAR *lpnmhdr;
  831. WCHAR szHelpTextFromInf[200];
  832. WCHAR szDescriptionFromInf[200];
  833. WCHAR szHelpTextFormat [200];
  834. DWORD dw;
  835. switch ( uMsg )
  836. {
  837. case WM_INITDIALOG:
  838. Edit_LimitText( GetDlgItem( hDlg, IDC_E_DESCRIPTION ), ARRAYSIZE(g_Options.szDescription) - 1 );
  839. Edit_LimitText( GetDlgItem( hDlg, IDC_E_HELPTEXT ), ARRAYSIZE(g_Options.szHelpText) - 1 );
  840. // subclass the edit boxes
  841. g_pOldEditWndProc = (WNDPROC) SetWindowLongPtr( GetDlgItem( hDlg, IDC_E_HELPTEXT), GWLP_WNDPROC, (LONG_PTR)&HelpTextEditWndProc);
  842. SetWindowLongPtr( GetDlgItem( hDlg, IDC_E_HELPTEXT), GWLP_WNDPROC, (LONG_PTR)&HelpTextEditWndProc);
  843. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  844. case WM_NOTIFY:
  845. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  846. lpnmhdr = (NMHDR FAR *) lParam;
  847. switch ( lpnmhdr->code )
  848. {
  849. case PSN_WIZBACK: //fall through
  850. case PSN_WIZNEXT:
  851. Edit_GetText( GetDlgItem( hDlg, IDC_E_DESCRIPTION ),
  852. szDescriptionFromInf,
  853. ARRAYSIZE(szDescriptionFromInf) );
  854. Edit_GetText( GetDlgItem( hDlg, IDC_E_HELPTEXT ),
  855. szHelpTextFromInf,
  856. ARRAYSIZE(szHelpTextFromInf) );
  857. if ( !VerifySIFText( szDescriptionFromInf ) )
  858. {
  859. MessageBoxFromStrings( hDlg,
  860. IDS_OSCHOOSER_RESTRICTION_FIELDS_TITLE,
  861. IDS_OSCHOOSER_RESTRICTION_FIELDS_TEXT,
  862. MB_OK );
  863. SetFocus( GetDlgItem( hDlg, IDC_E_DESCRIPTION ) );
  864. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't go to next dialog
  865. break;
  866. }
  867. wcscpy( g_Options.szDescription, szDescriptionFromInf );
  868. if ( !VerifySIFText( szHelpTextFromInf ) )
  869. {
  870. MessageBoxFromStrings( hDlg,
  871. IDS_OSCHOOSER_RESTRICTION_FIELDS_TITLE,
  872. IDS_OSCHOOSER_RESTRICTION_FIELDS_TEXT,
  873. MB_OK );
  874. SetFocus( GetDlgItem( hDlg, IDC_E_HELPTEXT ) );
  875. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't go to next dialog
  876. break;
  877. }
  878. wcscpy( g_Options.szHelpText, szHelpTextFromInf );
  879. g_Options.fRetrievedWorkstationString = TRUE;
  880. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  881. break;
  882. case PSN_QUERYCANCEL:
  883. return VerifyCancel( hDlg );
  884. case PSN_SETACTIVE:
  885. if ( g_Options.fError
  886. || g_Options.fAbort
  887. || !g_Options.fNewOS ) {
  888. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  889. break;
  890. }
  891. if (g_Options.szDescription[0] == L'\0') {
  892. //
  893. // we did not find a description from txtsetup.sif
  894. //
  895. if (SUCCEEDED(GetHelpAndDescriptionTextFromSif(
  896. szHelpTextFromInf,
  897. ARRAYSIZE(szHelpTextFromInf),
  898. szDescriptionFromInf,
  899. ARRAYSIZE(szDescriptionFromInf)))) {
  900. wcscpy(g_Options.szDescription,szDescriptionFromInf);
  901. wcscpy(g_Options.szHelpText,szHelpTextFromInf);
  902. }
  903. } else {
  904. //
  905. // We got a description and need to build the Help text
  906. //
  907. if (g_Options.szHelpText[0] == L'\0') {
  908. dw = LoadString( g_hinstance, IDS_DEFAULT_HELPTEXT,
  909. szHelpTextFormat, ARRAYSIZE(szHelpTextFormat) );
  910. Assert( dw );
  911. wsprintf(g_Options.szHelpText, szHelpTextFormat, g_Options.szDescription);
  912. }
  913. }
  914. SetDlgItemText( hDlg, IDC_E_DESCRIPTION, g_Options.szDescription );
  915. SetDlgItemText( hDlg, IDC_E_HELPTEXT, g_Options.szHelpText );
  916. DWORD dwLen1 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_DESCRIPTION) );
  917. DWORD dwLen2 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_HELPTEXT) );
  918. PropSheet_SetWizButtons( GetParent( hDlg ),
  919. (dwLen1 && dwLen2 ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK) );
  920. ClearMessageQueue( );
  921. break;
  922. }
  923. break;
  924. case WM_COMMAND:
  925. switch( LOWORD( wParam ) )
  926. {
  927. case IDC_E_DESCRIPTION:
  928. if ( HIWORD( wParam ) == EN_CHANGE ) {
  929. DWORD dwLen1 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_DESCRIPTION) );
  930. DWORD dwLen2 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_HELPTEXT) );
  931. PropSheet_SetWizButtons( GetParent( hDlg ),
  932. (dwLen1 && dwLen2 ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK) );
  933. }
  934. break;
  935. case IDC_E_HELPTEXT:
  936. if ( HIWORD( wParam ) == EN_CHANGE ) {
  937. DWORD dwLen1 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_DESCRIPTION) );
  938. DWORD dwLen2 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_HELPTEXT) );
  939. PropSheet_SetWizButtons( GetParent( hDlg ),
  940. (dwLen1 && dwLen2 ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK) );
  941. }
  942. break;
  943. }
  944. break;
  945. default:
  946. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  947. }
  948. return TRUE;
  949. }
  950. //
  951. // ScreensDlgProc( )
  952. //
  953. INT_PTR CALLBACK
  954. ScreensDlgProc(
  955. HWND hDlg,
  956. UINT uMsg,
  957. WPARAM wParam,
  958. LPARAM lParam )
  959. {
  960. NMHDR FAR *lpnmhdr;
  961. switch ( uMsg )
  962. {
  963. case WM_INITDIALOG:
  964. SetFocus( GetDlgItem( hDlg, IDC_R_SAVEOLDFILES ) );
  965. BaseDlgProc( hDlg, uMsg, wParam, lParam );
  966. return FALSE;
  967. case WM_NOTIFY:
  968. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  969. lpnmhdr = (NMHDR FAR *) lParam;
  970. switch ( lpnmhdr->code )
  971. {
  972. case PSN_QUERYCANCEL:
  973. return VerifyCancel( hDlg );
  974. case PSN_SETACTIVE:
  975. if ( g_Options.fError
  976. || g_Options.fAbort
  977. || !g_Options.fNewOS
  978. || !g_Options.fOSChooserScreensDirectory
  979. || g_Options.fFirstTime ) {
  980. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  981. break;
  982. }
  983. LONG lResult;
  984. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_LEAVEALONE ) );
  985. g_Options.fScreenLeaveAlone = !!(lResult == BST_CHECKED);
  986. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_OVERWRITE ) );
  987. g_Options.fScreenOverwrite = !!(lResult == BST_CHECKED);
  988. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_SAVEOLDFILES ) );
  989. g_Options.fScreenSaveOld = !!(lResult == BST_CHECKED);
  990. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK |
  991. ( g_Options.fScreenLeaveAlone
  992. | g_Options.fScreenOverwrite
  993. | g_Options.fScreenSaveOld ? PSWIZB_NEXT : 0 ) );
  994. ClearMessageQueue( );
  995. break;
  996. }
  997. break;
  998. case WM_COMMAND:
  999. if ( HIWORD( wParam ) == BN_CLICKED ) {
  1000. LONG lResult;
  1001. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_LEAVEALONE ) );
  1002. g_Options.fScreenLeaveAlone = !!(lResult == BST_CHECKED);
  1003. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_OVERWRITE ) );
  1004. g_Options.fScreenOverwrite = !!(lResult == BST_CHECKED);
  1005. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_SAVEOLDFILES ) );
  1006. g_Options.fScreenSaveOld = !!(lResult == BST_CHECKED);
  1007. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK |
  1008. ( g_Options.fScreenLeaveAlone
  1009. | g_Options.fScreenOverwrite
  1010. | g_Options.fScreenSaveOld ? PSWIZB_NEXT : 0 ) );
  1011. }
  1012. break;
  1013. default:
  1014. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1015. }
  1016. return TRUE;
  1017. }
  1018. //
  1019. // LanguageDlgProc( )
  1020. //
  1021. INT_PTR CALLBACK
  1022. LanguageDlgProc(
  1023. HWND hDlg,
  1024. UINT uMsg,
  1025. WPARAM wParam,
  1026. LPARAM lParam )
  1027. {
  1028. NMHDR FAR *lpnmhdr;
  1029. switch ( uMsg )
  1030. {
  1031. case WM_NOTIFY:
  1032. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1033. lpnmhdr = (NMHDR FAR *) lParam;
  1034. switch ( lpnmhdr->code )
  1035. {
  1036. case PSN_QUERYCANCEL:
  1037. return VerifyCancel( hDlg );
  1038. case PSN_SETACTIVE:
  1039. if ( !g_Options.fNewOS
  1040. || g_Options.fError
  1041. || g_Options.fAbort ) {
  1042. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // do not show this page
  1043. return TRUE;
  1044. } else {
  1045. WCHAR szCodePage[ 32 ];
  1046. DWORD dwCodePage;
  1047. LPTSTR psz;
  1048. if (g_Options.fAutomated) {
  1049. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1050. }
  1051. // we should have the workstation language by now
  1052. Assert( g_Options.fLanguageSet );
  1053. if ((dwCodePage = GetSystemDefaultLCID())) {
  1054. DebugMsg( "Server's Installation Code Page: 0x%04x\n", dwCodePage );
  1055. if ( dwCodePage != g_Options.dwWksCodePage ) {
  1056. // Check to see if the OSChooser\<Language> exists. If it does,
  1057. // we don't show the warning page.
  1058. WCHAR szPath[ MAX_PATH ];
  1059. wsprintf(
  1060. szPath,
  1061. L"%s\\OSChooser\\%s",
  1062. g_Options.szIntelliMirrorPath,
  1063. g_Options.szLanguage );
  1064. DebugMsg( "Checking for %s directory....", szPath );
  1065. if ( 0xFFFFffff == GetFileAttributes( szPath ) ) // doesn't exist
  1066. { // show the page
  1067. DebugMsg( "doesn't exist.\n" );
  1068. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT | PSWIZB_BACK );
  1069. ClearMessageQueue( );
  1070. return TRUE;
  1071. }
  1072. DebugMsg( "does. Skip warning.\n" );
  1073. // don't show the page, must have already been prompted
  1074. // before.
  1075. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1076. return TRUE;
  1077. } else {
  1078. // don't show the page, the locales match
  1079. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1080. return TRUE;
  1081. }
  1082. }
  1083. }
  1084. break;
  1085. }
  1086. break;
  1087. default:
  1088. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1089. }
  1090. return TRUE;
  1091. }
  1092. //
  1093. // SummaryDlgProc( )
  1094. //
  1095. INT_PTR CALLBACK
  1096. SummaryDlgProc(
  1097. HWND hDlg,
  1098. UINT uMsg,
  1099. WPARAM wParam,
  1100. LPARAM lParam )
  1101. {
  1102. NMHDR FAR *lpnmhdr;
  1103. switch ( uMsg )
  1104. {
  1105. case WM_INITDIALOG:
  1106. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1107. case WM_NOTIFY:
  1108. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1109. lpnmhdr = (NMHDR FAR *) lParam;
  1110. switch ( lpnmhdr->code )
  1111. {
  1112. case PSN_QUERYCANCEL:
  1113. return VerifyCancel( hDlg );
  1114. case PSN_SETACTIVE:
  1115. if ( !g_Options.fNewOS
  1116. || g_Options.fError
  1117. || g_Options.fAbort ) {
  1118. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // do not show this page
  1119. break;
  1120. } else {
  1121. WCHAR szText[ SMALL_BUFFER_SIZE ] = { L'\0' };
  1122. WCHAR szFilepath[ MAX_PATH ];
  1123. DWORD dwLen = 0;
  1124. RECT rect;
  1125. if( g_Options.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL ) {
  1126. DWORD dw = LoadString( g_hinstance, IDS_X86, szText, ARRAYSIZE( szText ));
  1127. Assert( dw );
  1128. } else if ( g_Options.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 ) {
  1129. DWORD dw = LoadString( g_hinstance, IDS_IA64, &szText[ dwLen ], ARRAYSIZE( szText ) - dwLen );
  1130. Assert( dw );
  1131. }
  1132. // attempt to ellipsis path
  1133. lstrcpy( szFilepath, g_Options.szSourcePath );
  1134. GetWindowRect( GetDlgItem( hDlg, IDC_S_SOURCEPATH ), &rect );
  1135. PathCompactPath( NULL, szFilepath, rect.right - rect.left );
  1136. SetDlgItemText( hDlg, IDC_S_SOURCEPATH, szFilepath );
  1137. SetDlgItemText( hDlg, IDC_S_OSDIRECTORY, g_Options.szInstallationName );
  1138. SetDlgItemText( hDlg, IDC_S_PLATFORM, szText );
  1139. SetDlgItemText( hDlg, IDC_S_INTELLIMIRRORROOT, g_Options.szIntelliMirrorPath );
  1140. SetDlgItemText( hDlg, IDC_S_LANGUAGE, g_Options.szLanguage );
  1141. wsprintf( szFilepath, L"%s.%s", g_Options.szMajorVersion, g_Options.szMinorVersion );
  1142. SetDlgItemText( hDlg, IDC_S_NTVERSION, szFilepath );
  1143. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_FINISH | PSWIZB_BACK );
  1144. ClearMessageQueue( );
  1145. }
  1146. break;
  1147. }
  1148. break;
  1149. default:
  1150. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1151. }
  1152. return TRUE;
  1153. }
  1154. //
  1155. // ServerOKDlgProc( )
  1156. //
  1157. INT_PTR CALLBACK
  1158. ServerOKDlgProc(
  1159. HWND hDlg,
  1160. UINT uMsg,
  1161. WPARAM wParam,
  1162. LPARAM lParam )
  1163. {
  1164. NMHDR FAR *lpnmhdr;
  1165. switch ( uMsg )
  1166. {
  1167. case WM_INITDIALOG:
  1168. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1169. case WM_NOTIFY:
  1170. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1171. lpnmhdr = (NMHDR FAR *) lParam;
  1172. switch ( lpnmhdr->code )
  1173. {
  1174. case PSN_QUERYCANCEL:
  1175. return VerifyCancel( hDlg );
  1176. case PSN_SETACTIVE:
  1177. if ( g_Options.fNewOS
  1178. || g_Options.fError
  1179. || g_Options.fAbort ) {
  1180. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1181. break;
  1182. }
  1183. HRESULT hr = CheckInstallation( );
  1184. if ( hr != S_OK ) {
  1185. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1186. PropSheet_PressButton( GetParent( hDlg ), PSBTN_FINISH );
  1187. break;
  1188. }
  1189. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK | PSWIZB_FINISH );
  1190. ClearMessageQueue( );
  1191. break;
  1192. }
  1193. break;
  1194. default:
  1195. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1196. }
  1197. return TRUE;
  1198. }
  1199. //
  1200. // CheckWelcomeDlgProc( )
  1201. //
  1202. // "Check's Welcome" dialog proc.
  1203. //
  1204. INT_PTR CALLBACK
  1205. CheckWelcomeDlgProc(
  1206. HWND hDlg,
  1207. UINT uMsg,
  1208. WPARAM wParam,
  1209. LPARAM lParam )
  1210. {
  1211. NMHDR FAR *lpnmhdr;
  1212. switch ( uMsg )
  1213. {
  1214. case WM_INITDIALOG:
  1215. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1216. case WM_NOTIFY:
  1217. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1218. lpnmhdr = (NMHDR FAR *) lParam;
  1219. switch ( lpnmhdr->code )
  1220. {
  1221. case PSN_QUERYCANCEL:
  1222. return VerifyCancel( hDlg );
  1223. case PSN_SETACTIVE:
  1224. if ( !g_Options.fCheckServer ) {
  1225. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1226. break;
  1227. }
  1228. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT );
  1229. ClearMessageQueue( );
  1230. break;
  1231. case PSN_WIZNEXT:
  1232. // CheckInstallation( );
  1233. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  1234. break;
  1235. }
  1236. break;
  1237. default:
  1238. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1239. }
  1240. return TRUE;
  1241. }
  1242. //
  1243. // AddWelcomeDlgProc( )
  1244. //
  1245. // "Add's Welcome" dialog proc.
  1246. //
  1247. INT_PTR CALLBACK
  1248. AddWelcomeDlgProc(
  1249. HWND hDlg,
  1250. UINT uMsg,
  1251. WPARAM wParam,
  1252. LPARAM lParam )
  1253. {
  1254. NMHDR FAR *lpnmhdr;
  1255. switch ( uMsg )
  1256. {
  1257. case WM_INITDIALOG:
  1258. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1259. case WM_NOTIFY:
  1260. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1261. lpnmhdr = (NMHDR FAR *) lParam;
  1262. switch ( lpnmhdr->code )
  1263. {
  1264. case PSN_QUERYCANCEL:
  1265. return VerifyCancel( hDlg );
  1266. case PSN_SETACTIVE:
  1267. if ( !g_Options.fAddOption ) {
  1268. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1269. break;
  1270. }
  1271. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT );
  1272. ClearMessageQueue( );
  1273. break;
  1274. case PSN_WIZNEXT:
  1275. // CheckInstallation( );
  1276. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  1277. break;
  1278. }
  1279. break;
  1280. default:
  1281. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1282. }
  1283. return TRUE;
  1284. }
  1285. //
  1286. // ExamineServerDlgProc( )
  1287. //
  1288. // This is the screen that is shown wait CheckInstallation() runs for
  1289. // the first time. I had to move it from the InitializeOptions() because
  1290. // "-upgrade" shouldn't go through the exhaustive search and possibly
  1291. // show UI.
  1292. //
  1293. INT_PTR CALLBACK
  1294. ExamineServerDlgProc(
  1295. HWND hDlg,
  1296. UINT uMsg,
  1297. WPARAM wParam,
  1298. LPARAM lParam )
  1299. {
  1300. NMHDR FAR *lpnmhdr;
  1301. switch ( uMsg )
  1302. {
  1303. case WM_INITDIALOG:
  1304. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1305. case WM_NOTIFY:
  1306. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1307. lpnmhdr = (NMHDR FAR *) lParam;
  1308. switch ( lpnmhdr->code )
  1309. {
  1310. case PSN_QUERYCANCEL:
  1311. return VerifyCancel( hDlg );
  1312. case PSN_SETACTIVE:
  1313. if ( g_Options.fAlreadyChecked
  1314. || g_Options.fError
  1315. || g_Options.fAbort )
  1316. {
  1317. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1318. break;
  1319. }
  1320. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  1321. ClearMessageQueue( );
  1322. PostMessage( hDlg, WM_USER, 0, 0 );
  1323. break;
  1324. }
  1325. break;
  1326. case WM_USER:
  1327. {
  1328. DWORD hr;
  1329. HANDLE hThread;
  1330. hThread = CreateThread( NULL, NULL, (LPTHREAD_START_ROUTINE) &CheckInstallation, NULL, NULL, NULL );
  1331. while ( WAIT_TIMEOUT == WaitForSingleObject( hThread, 0) )
  1332. {
  1333. MSG Msg;
  1334. if ( PeekMessage( &Msg, NULL, 0, 0, PM_REMOVE ) )
  1335. {
  1336. DispatchMessage( &Msg );
  1337. }
  1338. }
  1339. if ( GetExitCodeThread( hThread, &hr ) )
  1340. {
  1341. DebugMsg( "Thread Exit Code was 0x%08x\n", hr );
  1342. // If check installation failed, bail!
  1343. if ( FAILED( hr ) ) {
  1344. // Bail on the whole thing. Fake the finish button so
  1345. // we can exit without the "Are you sure?" dialog popping up.
  1346. g_Options.fError = TRUE;
  1347. PropSheet_SetWizButtons( GetParent( hDlg ), PSBTN_FINISH );
  1348. PropSheet_PressButton( GetParent( hDlg ), PSBTN_FINISH );
  1349. break;
  1350. }
  1351. }
  1352. CloseHandle( hThread );
  1353. g_Options.fAlreadyChecked = TRUE;
  1354. // Push the next button
  1355. PropSheet_PressButton( GetParent( hDlg ), PSBTN_NEXT );
  1356. }
  1357. break;
  1358. default:
  1359. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1360. }
  1361. return TRUE;
  1362. }
  1363. LBITEMDATA items[] = {
  1364. { STATE_NOTSTARTED, IDS_CREATINGDIRECTORYTREE, CreateDirectories, TEXT("") }, // 0
  1365. { STATE_NOTSTARTED, IDS_COPYSERVERFILES, CopyServerFiles, TEXT("") }, // 1
  1366. { STATE_NOTSTARTED, IDS_COPYINGFILES, CopyClientFiles, TEXT("") }, // 2
  1367. { STATE_NOTSTARTED, IDS_UPDATINGSCREENS, CopyScreenFiles, TEXT("") }, // 3
  1368. { STATE_NOTSTARTED, IDS_COPYTEMPLATEFILES, CopyTemplateFiles, TEXT("") }, // 4
  1369. { STATE_NOTSTARTED, IDS_CREATING_SERVICES, CreateRemoteBootServices, TEXT("") }, // 5
  1370. { STATE_NOTSTARTED, IDS_UPDATINGREGISTRY, ModifyRegistry, TEXT("") }, // 6
  1371. { STATE_NOTSTARTED, IDS_CREATING_SIS_VOLUME, CreateSISVolume, TEXT("") }, // 7
  1372. { STATE_NOTSTARTED, IDS_STARTING_SERVICES, StartRemoteBootServices, TEXT("") }, // 8
  1373. { STATE_NOTSTARTED, IDS_AUTHORIZING_DHCP, AuthorizeDhcp, TEXT("") } // 9
  1374. };
  1375. //
  1376. // SetupDlgProc( )
  1377. //
  1378. INT_PTR CALLBACK
  1379. SetupDlgProc(
  1380. HWND hDlg,
  1381. UINT uMsg,
  1382. WPARAM wParam,
  1383. LPARAM lParam )
  1384. {
  1385. static BOOL bDoneFirstPass;
  1386. static UINT nItems;
  1387. static HBRUSH hBrush = NULL;
  1388. LPSETUPDLGDATA psdd = (LPSETUPDLGDATA) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  1389. switch ( uMsg )
  1390. {
  1391. case WM_INITDIALOG:
  1392. {
  1393. BITMAP bm;
  1394. // grab the bitmaps
  1395. psdd = (LPSETUPDLGDATA) TraceAlloc( GMEM_FIXED, sizeof(SETUPDLGDATA) );
  1396. if (psdd == NULL) {
  1397. return FALSE;
  1398. }
  1399. psdd->hChecked = LoadImage( g_hinstance,
  1400. MAKEINTRESOURCE( IDB_CHECK ),
  1401. IMAGE_BITMAP,
  1402. 0, 0,
  1403. LR_DEFAULTSIZE | LR_LOADTRANSPARENT );
  1404. DebugMemoryAddHandle( psdd->hChecked );
  1405. GetObject( psdd->hChecked, sizeof(bm), &bm );
  1406. psdd->dwWidth = bm.bmWidth;
  1407. psdd->hError = LoadImage( g_hinstance,
  1408. MAKEINTRESOURCE( IDB_X ),
  1409. IMAGE_BITMAP,
  1410. 0, 0,
  1411. LR_DEFAULTSIZE | LR_LOADTRANSPARENT );
  1412. DebugMemoryAddHandle( psdd->hError );
  1413. GetObject( psdd->hError, sizeof(bm), &bm );
  1414. psdd->dwWidth = ( psdd->dwWidth > bm.bmWidth ? psdd->dwWidth : bm.bmWidth );
  1415. psdd->hArrow = LoadImage( g_hinstance,
  1416. MAKEINTRESOURCE( IDB_ARROW ),
  1417. IMAGE_BITMAP,
  1418. 0, 0,
  1419. LR_DEFAULTSIZE | LR_LOADTRANSPARENT );
  1420. DebugMemoryAddHandle( psdd->hArrow );
  1421. GetObject( psdd->hArrow, sizeof(bm), &bm );
  1422. psdd->dwWidth = ( psdd->dwWidth > bm.bmWidth ?
  1423. psdd->dwWidth :
  1424. bm.bmWidth );
  1425. HWND hwnd = GetDlgItem( hDlg, IDC_L_SETUP );
  1426. HFONT hFontOld = (HFONT) SendMessage( hwnd, WM_GETFONT, 0, 0);
  1427. if(hFontOld != NULL)
  1428. {
  1429. LOGFONT lf;
  1430. if ( GetObject( hFontOld, sizeof(LOGFONT), (LPSTR) &lf ) )
  1431. {
  1432. psdd->hFontNormal = CreateFontIndirect(&lf);
  1433. DebugMemoryAddHandle( psdd->hFontNormal );
  1434. lf.lfWeight = FW_BOLD;
  1435. psdd->hFontBold = CreateFontIndirect(&lf);
  1436. DebugMemoryAddHandle( psdd->hFontBold );
  1437. }
  1438. }
  1439. HDC hDC = GetDC( NULL );
  1440. HANDLE hOldFont = SelectObject( hDC, psdd->hFontBold );
  1441. TEXTMETRIC tm;
  1442. GetTextMetrics( hDC, &tm );
  1443. psdd->dwHeight = tm.tmHeight + 2;
  1444. SelectObject( hDC, hOldFont );
  1445. ReleaseDC( NULL, hDC );
  1446. ListBox_SetItemHeight( hwnd, -1, psdd->dwHeight );
  1447. SetWindowLongPtr( hDlg, GWLP_USERDATA, (LONG_PTR) psdd );
  1448. //
  1449. // Eliminate things that have already been done
  1450. //
  1451. if ( g_Options.fDirectoryTreeExists
  1452. && g_Options.fIMirrorShareFound ) {
  1453. items[ 0 ].uState = STATE_WONTSTART;
  1454. }
  1455. if ( !g_Options.fFirstTime
  1456. && g_Options.fTFTPDFilesFound
  1457. && g_Options.fSISFilesFound
  1458. && g_Options.fSISGrovelerFilesFound
  1459. && g_Options.fOSChooserInstalled
  1460. && g_Options.fBINLFilesFound
  1461. && g_Options.fRegSrvDllsFilesFound ) {
  1462. items[ 1 ].uState = STATE_WONTSTART;
  1463. }
  1464. if ( !g_Options.fNewOS ) {
  1465. items[ 2 ].uState = STATE_WONTSTART;
  1466. items[ 3 ].uState = STATE_WONTSTART;
  1467. }
  1468. if ( !g_Options.fNewOS
  1469. || ( g_Options.fScreenLeaveAlone
  1470. && !g_Options.fFirstTime ) ) {
  1471. items[ 3 ].uState = STATE_WONTSTART;
  1472. }
  1473. if ( !g_Options.fNewOS ) {
  1474. items[ 4 ].uState = STATE_WONTSTART;
  1475. }
  1476. if ( g_Options.fBINLServiceInstalled
  1477. && g_Options.fTFTPDServiceInstalled
  1478. && g_Options.fSISServiceInstalled
  1479. && g_Options.fSISGrovelerServiceInstalled
  1480. && g_Options.fBINLSCPFound ) {
  1481. items[ 5 ].uState = STATE_WONTSTART;
  1482. }
  1483. if ( g_Options.fRegistryIntact
  1484. && g_Options.fRegSrvDllsRegistered
  1485. && g_Options.fTFTPDDirectoryFound ) {
  1486. items[ 6 ].uState = STATE_WONTSTART;
  1487. }
  1488. if ( g_Options.fSISVolumeCreated ) {
  1489. items[ 7 ].uState = STATE_WONTSTART;
  1490. }
  1491. if( g_Options.fDontAuthorizeDhcp ) {
  1492. items[ 9 ].uState = STATE_WONTSTART;
  1493. }
  1494. nItems = 0;
  1495. for( int i = 0; i < ARRAYSIZE(items); i++ )
  1496. {
  1497. if ( items[i].uState != STATE_WONTSTART ) {
  1498. DWORD dw = LoadString( g_hinstance,
  1499. items[ i ].rsrcId,
  1500. items[ i ].szText,
  1501. ARRAYSIZE( items[ i ].szText ) );
  1502. Assert( dw );
  1503. ListBox_AddString( hwnd, &items[ i ] );
  1504. nItems++;
  1505. }
  1506. }
  1507. bDoneFirstPass = FALSE;
  1508. //
  1509. // Set a timer to fire in a few seconds so that we can force
  1510. // the setup to proceed even if we don't get the WM_DRAWITEM
  1511. // messages
  1512. //
  1513. SetTimer(hDlg,1,3 * 1000,NULL);
  1514. }
  1515. CenterDialog( hDlg );
  1516. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1517. case WM_DESTROY:
  1518. {
  1519. Assert( psdd );
  1520. if ( hBrush != NULL )
  1521. {
  1522. DeleteObject(hBrush);
  1523. hBrush = NULL;
  1524. }
  1525. DeleteObject( psdd->hChecked );
  1526. DebugMemoryDelete( psdd->hChecked );
  1527. DeleteObject( psdd->hError );
  1528. DebugMemoryDelete( psdd->hError );
  1529. DeleteObject( psdd->hArrow );
  1530. DebugMemoryDelete( psdd->hArrow );
  1531. DeleteObject( psdd->hFontNormal );
  1532. DebugMemoryDelete( psdd->hFontNormal );
  1533. DeleteObject( psdd->hFontBold );
  1534. DebugMemoryDelete( psdd->hFontBold );
  1535. TraceFree( psdd );
  1536. SetWindowLongPtr( hDlg, GWLP_USERDATA, NULL );
  1537. }
  1538. break;
  1539. case WM_STARTSETUP:
  1540. {
  1541. HWND hwnd = GetDlgItem( hDlg, IDC_L_SETUP );
  1542. RECT rc;
  1543. INT nProgressBoxHeight = 0;
  1544. HRESULT hr;
  1545. SetDlgItemText( hDlg, IDC_S_OPERATION, TEXT("") );
  1546. SendMessage( GetDlgItem( hDlg, IDC_P_METER) , PBM_SETPOS, 0, 0 );
  1547. GetClientRect( hwnd, &rc );
  1548. //
  1549. // Create the directories paths...
  1550. //
  1551. BuildDirectories( );
  1552. INT i = 0;
  1553. if (g_Options.fError) {
  1554. // Already tanked, set the first item with an error.
  1555. for(i=0;i< ARRAYSIZE(items);i++){
  1556. if(items[i].uState != STATE_WONTSTART){
  1557. items[i].uState = STATE_ERROR;
  1558. break;
  1559. }
  1560. }
  1561. }
  1562. while ( i < ARRAYSIZE( items )
  1563. && !g_Options.fError
  1564. && !g_Options.fAbort )
  1565. {
  1566. if ( items[ i ].uState != STATE_WONTSTART )
  1567. {
  1568. hr = CheckInstallation( );
  1569. if ( FAILED(hr) ) {
  1570. g_Options.fError = TRUE;
  1571. items[i].uState = STATE_ERROR;
  1572. break;
  1573. }
  1574. items[ i ].uState = STATE_STARTED;
  1575. InvalidateRect( hwnd, &rc, TRUE );
  1576. // process some messages
  1577. MSG Msg;
  1578. while ( PeekMessage( &Msg, NULL, 0, 0, PM_REMOVE ) )
  1579. {
  1580. TranslateMessage( &Msg );
  1581. DispatchMessage( &Msg );
  1582. }
  1583. hr = THR( items[ i ].pfn( hDlg ) );
  1584. if ( FAILED(hr) ) {
  1585. // fatal error - halt installation
  1586. items[ i ].uState = STATE_ERROR;
  1587. g_Options.fError = TRUE;
  1588. } else if ( hr == S_FALSE ) {
  1589. // non-fatal error - but something went wrong
  1590. items[ i ].uState = STATE_ERROR;
  1591. } else {
  1592. items[ i ].uState = STATE_DONE;
  1593. }
  1594. InvalidateRect( hwnd, &rc, TRUE );
  1595. }
  1596. i++;
  1597. }
  1598. hr = THR( CheckInstallation( ) );
  1599. if (g_Options.fFirstTime) {
  1600. // We believe this is the first time risetup has been run
  1601. if ( i > 0 ) {
  1602. // There were items in the list to start with
  1603. if ( items[ i - 1].rsrcId == IDS_AUTHORIZING_DHCP) {
  1604. //
  1605. // We reached the dhcp task, which implies we
  1606. // finished
  1607. GetSetRanFlag( FALSE, FALSE );
  1608. } else {
  1609. //
  1610. // We never reached dhcp authorization (or we
  1611. // skipped it)
  1612. //
  1613. GetSetRanFlag( FALSE, g_Options.fError );
  1614. }
  1615. }
  1616. }
  1617. // If no errors, exit.
  1618. if ( g_Options.fAutomated && !g_Options.fError )
  1619. {
  1620. EndDialog( hDlg, 1 );
  1621. }
  1622. else
  1623. { // we are not bailing, resize, etc.
  1624. // disable & hide "Cancel" button
  1625. HWND hwndCancel = GetDlgItem( hDlg, IDCANCEL );
  1626. ShowWindow( hwndCancel, SW_HIDE );
  1627. EnableWindow( hwndCancel, FALSE );
  1628. // hide progress bar stuff
  1629. HWND hwndGroupBox = GetDlgItem( hDlg, IDC_G_OPERATION );
  1630. ShowWindow( GetDlgItem( hDlg, IDC_S_OPERATION), SW_HIDE );
  1631. ShowWindow( GetDlgItem( hDlg, IDC_P_METER), SW_HIDE );
  1632. ShowWindow( hwndGroupBox, SW_HIDE );
  1633. GetWindowRect( hwndGroupBox, &rc );
  1634. nProgressBoxHeight = rc.bottom - rc.top;
  1635. // make "Done" button move it up and make it visible
  1636. HWND hwndOK = GetDlgItem( hDlg, IDOK );
  1637. GetWindowRect( hwndOK, &rc );
  1638. MapWindowPoints( NULL, hDlg, (LPPOINT) &rc, 2 );
  1639. SetWindowPos( hwndOK,
  1640. NULL,
  1641. rc.left, rc.top - nProgressBoxHeight,
  1642. 0, 0,
  1643. SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW );
  1644. // make "Done" the default button
  1645. LONG lStyle = GetWindowLong( hwndOK, GWL_STYLE );
  1646. lStyle |= BS_DEFPUSHBUTTON;
  1647. SetWindowLong( hwndOK, GWL_STYLE, lStyle );
  1648. EnableWindow( hwndOK, TRUE );
  1649. // Shrink dialog
  1650. GetWindowRect( hDlg, &rc );
  1651. MoveWindow( hDlg,
  1652. rc.left, rc.top,
  1653. rc.right - rc.left, rc.bottom - rc.top - nProgressBoxHeight,
  1654. TRUE );
  1655. }
  1656. }
  1657. break;
  1658. case WM_MEASUREITEM:
  1659. {
  1660. LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
  1661. RECT rc;
  1662. HWND hwnd = GetDlgItem( hDlg, IDC_L_SETUP );
  1663. GetClientRect( hwnd, &rc );
  1664. lpmis->itemWidth = rc.right - rc.left;
  1665. lpmis->itemHeight = 15;
  1666. }
  1667. break;
  1668. case WM_DRAWITEM:
  1669. {
  1670. Assert( psdd );
  1671. LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT) lParam;
  1672. LPLBITEMDATA plbid = (LPLBITEMDATA) lpdis->itemData;
  1673. RECT rc = lpdis->rcItem;
  1674. HANDLE hOldFont = INVALID_HANDLE_VALUE;
  1675. rc.right = rc.bottom = psdd->dwWidth;
  1676. switch ( plbid->uState )
  1677. {
  1678. case STATE_NOTSTARTED:
  1679. hOldFont = SelectObject( lpdis->hDC, psdd->hFontNormal );
  1680. break;
  1681. case STATE_STARTED:
  1682. DrawBitmap( psdd->hArrow, lpdis, &rc );
  1683. hOldFont = SelectObject( lpdis->hDC, psdd->hFontBold );
  1684. break;
  1685. case STATE_DONE:
  1686. DrawBitmap( psdd->hChecked, lpdis, &rc );
  1687. hOldFont = SelectObject( lpdis->hDC, psdd->hFontNormal );
  1688. break;
  1689. case STATE_ERROR:
  1690. DrawBitmap( psdd->hError, lpdis, &rc );
  1691. hOldFont = SelectObject( lpdis->hDC, psdd->hFontNormal );
  1692. break;
  1693. }
  1694. rc = lpdis->rcItem;
  1695. rc.left += psdd->dwHeight;
  1696. DrawText( lpdis->hDC, plbid->szText, -1, &rc, DT_LEFT | DT_VCENTER );
  1697. if ( hOldFont != INVALID_HANDLE_VALUE )
  1698. {
  1699. SelectObject( lpdis->hDC, hOldFont );
  1700. }
  1701. if ( !bDoneFirstPass && lpdis->itemID == nItems - 1 )
  1702. {
  1703. // delay the message until we have painted at least once.
  1704. bDoneFirstPass = TRUE;
  1705. PostMessage( hDlg, WM_STARTSETUP, 0, 0 );
  1706. }
  1707. }
  1708. break;
  1709. case WM_CTLCOLORLISTBOX:
  1710. {
  1711. if ( hBrush == NULL )
  1712. {
  1713. LOGBRUSH brush;
  1714. brush.lbColor = GetSysColor( COLOR_3DFACE );
  1715. brush.lbStyle = BS_SOLID;
  1716. hBrush = (HBRUSH) CreateBrushIndirect( &brush );
  1717. }
  1718. SetBkMode( (HDC) wParam, OPAQUE );
  1719. SetBkColor( (HDC) wParam, GetSysColor( COLOR_3DFACE ) );
  1720. return (INT_PTR)hBrush;
  1721. }
  1722. break;
  1723. case WM_SETTINGCHANGE:
  1724. if ( hBrush ) {
  1725. DeleteObject( hBrush );
  1726. hBrush = NULL;
  1727. }
  1728. break;
  1729. case WM_COMMAND:
  1730. {
  1731. switch( LOWORD( wParam ) )
  1732. {
  1733. case IDCANCEL:
  1734. if ( HIWORD(wParam) == BN_CLICKED )
  1735. {
  1736. if ( !VerifyCancel( hDlg ) ) {
  1737. EndDialog( hDlg, 0 );
  1738. }
  1739. }
  1740. break;
  1741. case IDOK:
  1742. if ( HIWORD(wParam) == BN_CLICKED )
  1743. {
  1744. EndDialog( hDlg, 1 );
  1745. }
  1746. break;
  1747. }
  1748. }
  1749. case WM_TIMER:
  1750. if ( !bDoneFirstPass && g_Options.fAutomated ) {
  1751. //
  1752. // we're in an unattended setup. We haven't gotten the
  1753. // WM_STARTSETUP signal yet, so we'll do that right here.
  1754. //
  1755. bDoneFirstPass = TRUE;
  1756. PostMessage( hDlg, WM_STARTSETUP, 0, 0 );
  1757. }
  1758. KillTimer(hDlg, 1);
  1759. //
  1760. // fall through
  1761. //
  1762. default:
  1763. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1764. }
  1765. return FALSE;
  1766. }