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.

2066 lines
70 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. UNREFERENCED_PARAMETER(lParam);
  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 ( SUCCEEDED(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 = (DWORD)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. #if 0
  568. #ifndef ANYARCHITECTUREIMAGES
  569. if (g_Options.ProcessorArchitecture != PROCESSOR_ARCHITECTURE_INTEL) {
  570. MessageBoxFromStrings( hDlg, IDS_NOT_SUPPORTED_ARCHITECTURE_TITLE, IDS_NOT_SUPPORTED_ARCHITECTURE_TEXT, MB_OK );
  571. Edit_SetText( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ), g_Options.szSourcePath );
  572. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  573. break;
  574. }
  575. #endif
  576. #endif
  577. hr = CheckImageSource( hDlg );
  578. if ( hr != S_OK )
  579. {
  580. Edit_SetText( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ), g_Options.szSourcePath );
  581. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  582. break;
  583. }
  584. Edit_SetText( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ), g_Options.szSourcePath );
  585. hr = CheckInstallation( );
  586. }
  587. break;
  588. case PSN_QUERYCANCEL:
  589. return VerifyCancel( hDlg );
  590. case PSN_SETACTIVE:
  591. if ( g_Options.fError
  592. || g_Options.fAbort
  593. || !g_Options.fNewOS ) {
  594. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  595. break;
  596. }
  597. else
  598. {
  599. DWORD dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_IMAGESOURCE) );
  600. PropSheet_SetWizButtons( GetParent( hDlg ),
  601. (dwLen ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK) );
  602. ClearMessageQueue( );
  603. }
  604. break;
  605. }
  606. break;
  607. case WM_COMMAND:
  608. DWORD dwLen;
  609. switch( LOWORD( wParam))
  610. {
  611. case IDC_E_IMAGESOURCE:
  612. if ( HIWORD(wParam) != EN_CHANGE )
  613. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  614. // fall thru...
  615. #ifdef SHOW_ARCHITECTURERADIOBUTTON
  616. case IDC_C_X86:
  617. case IDC_C_IA64:
  618. {
  619. if( ( 0x0003 & Button_GetState( GetDlgItem( hDlg, IDC_C_X86 ) ) ) == BST_CHECKED ) {
  620. g_Options.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
  621. wcscpy( g_Options.ProcessorArchitectureString, L"i386" );
  622. }
  623. if( ( 0x0003 & Button_GetState( GetDlgItem( hDlg, IDC_C_IA64 ) ) ) == BST_CHECKED ) {
  624. g_Options.ProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64;
  625. wcscpy( g_Options.ProcessorArchitectureString, L"ia64" );
  626. }
  627. dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ) );
  628. PropSheet_SetWizButtons( GetParent( hDlg ),
  629. ( dwLen) ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK );
  630. }
  631. break;
  632. #else
  633. dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ) );
  634. PropSheet_SetWizButtons(
  635. GetParent( hDlg ),
  636. ( dwLen) ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK );
  637. break;
  638. #endif
  639. case IDC_B_BROWSE:
  640. {
  641. WCHAR szPath[ MAX_PATH ];
  642. WCHAR szTitle[ SMALL_BUFFER_SIZE ];
  643. BROWSEINFO bs;
  644. DWORD dw;
  645. ZeroMemory( &bs, sizeof(bs) );
  646. bs.hwndOwner = hDlg;
  647. dw = LoadString( g_hinstance, IDS_BROWSECAPTION_SOURCEDIR, szTitle, ARRAYSIZE( szTitle ));
  648. Assert( dw );
  649. bs.lpszTitle = (LPWSTR) szTitle;
  650. bs.ulFlags = BIF_RETURNONLYFSDIRS | BIF_RETURNFSANCESTORS;
  651. LPITEMIDLIST pidl = SHBrowseForFolder( &bs );
  652. if ( pidl && SHGetPathFromIDList( pidl, szPath) ) {
  653. if ( wcslen( szPath ) > ARRAYSIZE(g_Options.szSourcePath) - 2 ) {
  654. MessageBoxFromStrings( hDlg, IDS_PATH_TOO_LONG_TITLE, IDS_PATH_TOO_LONG_TEXT, MB_OK );
  655. //
  656. // SHGetPathFromIDList() returns the path with a
  657. // trailing backslash, which we want to drop
  658. // The directory that the user selected will be
  659. // validated when the user clicks next
  660. szPath[ ARRAYSIZE(g_Options.szSourcePath) - 1 ] = L'\0';
  661. }
  662. Edit_SetText( GetDlgItem( hDlg, IDC_E_IMAGESOURCE ), szPath );
  663. }
  664. }
  665. break;
  666. default:
  667. break;
  668. }
  669. break;
  670. default:
  671. //
  672. // try to cancel CD autoplay
  673. //
  674. if (!g_uQueryCancelAutoPlay) {
  675. g_uQueryCancelAutoPlay = RegisterWindowMessage(TEXT("QueryCancelAutoPlay"));
  676. DebugMsg( "generate autoplay message %d\n", g_uQueryCancelAutoPlay );
  677. }
  678. if (uMsg == g_uQueryCancelAutoPlay) {
  679. DebugMsg( "received autoplay message\n" );
  680. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, 1 );
  681. return 1; // cancel auto-play
  682. }
  683. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  684. }
  685. return TRUE;
  686. }
  687. //
  688. // VerifyDirectoryName( )
  689. //
  690. BOOL
  691. VerifyDirectoryName( )
  692. {
  693. TraceFunc( "VerifyDirectoryName()\n" );
  694. BOOL fReturn = FALSE;
  695. LPWSTR psz = g_Options.szInstallationName;
  696. //
  697. // Make sure there's no control codes in the
  698. // name.
  699. //
  700. while ( *psz > 32 && *psz < 127 )
  701. psz++;
  702. if ( *psz == L'\0' )
  703. {
  704. fReturn = TRUE;
  705. }
  706. //
  707. // Make sure the directory's name isn't
  708. // '.' or that it doesn't contain ".."
  709. //
  710. fReturn = fReturn &&
  711. (wcsstr(g_Options.szInstallationName, L"..") == NULL) &&
  712. (wcscmp(g_Options.szInstallationName, L".") != 0);
  713. RETURN(fReturn);
  714. }
  715. //
  716. // OSDirectoryDlgProc( )
  717. //
  718. INT_PTR CALLBACK
  719. OSDirectoryDlgProc(
  720. HWND hDlg,
  721. UINT uMsg,
  722. WPARAM wParam,
  723. LPARAM lParam )
  724. {
  725. NMHDR FAR *lpnmhdr;
  726. switch ( uMsg )
  727. {
  728. case WM_INITDIALOG:
  729. {
  730. HWND hwndEdit = GetDlgItem( hDlg, IDC_E_OSDIRECTORY );
  731. Edit_LimitText( hwndEdit, ARRAYSIZE(g_Options.szInstallationName) - 1 );
  732. Edit_SetText( hwndEdit, g_Options.szInstallationName );
  733. }
  734. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  735. case WM_NOTIFY:
  736. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  737. lpnmhdr = (NMHDR FAR *) lParam;
  738. switch ( lpnmhdr->code )
  739. {
  740. case PSN_WIZNEXT:
  741. Edit_GetText( GetDlgItem( hDlg, IDC_E_OSDIRECTORY ),
  742. g_Options.szInstallationName,
  743. ARRAYSIZE( g_Options.szInstallationName ) );
  744. if ( !VerifyDirectoryName( ) )
  745. {
  746. MessageBoxFromStrings( hDlg, IDS_OSCHOOSER_DIRECTORY_RESTRICTION_TITLE, IDS_OSCHOOSER_DIRECTORY_RESTRICTION_TEXT, MB_OK );
  747. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  748. break;
  749. }
  750. BuildDirectories( );
  751. CheckDirectory( hDlg, g_Options.szInstallationPath );
  752. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK | PSWIZB_NEXT );
  753. break;
  754. case PSN_QUERYCANCEL:
  755. return VerifyCancel( hDlg );
  756. case PSN_SETACTIVE:
  757. if ( g_Options.fError
  758. || g_Options.fAbort
  759. || !g_Options.fNewOS ) {
  760. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  761. break;
  762. }
  763. else
  764. {
  765. DWORD dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_OSDIRECTORY) );
  766. PropSheet_SetWizButtons( GetParent( hDlg ),
  767. (dwLen ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK) );
  768. ClearMessageQueue( );
  769. }
  770. break;
  771. }
  772. break;
  773. case WM_COMMAND:
  774. {
  775. if ( HIWORD( wParam ) == EN_CHANGE ) {
  776. DWORD dwLen = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_OSDIRECTORY ) );
  777. PropSheet_SetWizButtons( GetParent( hDlg ), ( dwLen ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK ) );
  778. }
  779. }
  780. break;
  781. default:
  782. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  783. }
  784. return TRUE;
  785. }
  786. //
  787. // HelpTextEditWndProc( )
  788. //
  789. INT_PTR CALLBACK
  790. HelpTextEditWndProc(
  791. HWND hWnd,
  792. UINT uMsg,
  793. WPARAM wParam,
  794. LPARAM lParam )
  795. {
  796. switch ( uMsg )
  797. {
  798. case WM_KEYDOWN:
  799. // ignore CONTROL characters
  800. if ( 0 <= GetKeyState( VK_CONTROL ) )
  801. {
  802. // fake button presses
  803. if ( LOWORD( wParam ) == VK_RETURN ) {
  804. PropSheet_PressButton( GetParent( GetParent( hWnd ) ), PSBTN_NEXT );
  805. return FALSE;
  806. } else if ( LOWORD( wParam ) == VK_ESCAPE ) {
  807. PropSheet_PressButton( GetParent( GetParent( hWnd ) ), PSBTN_CANCEL );
  808. return FALSE;
  809. }
  810. }
  811. break;
  812. }
  813. return CallWindowProc(g_pOldEditWndProc, hWnd, uMsg, wParam, lParam);
  814. }
  815. //
  816. // VerifySIFText( )
  817. //
  818. BOOL
  819. VerifySIFText(
  820. LPWSTR pszText )
  821. {
  822. TraceFunc( "VerifySIFText()\n" );
  823. BOOL fReturn = FALSE;
  824. if ( !pszText )
  825. RETURN(fReturn);
  826. //
  827. // make sure the string consists of valid characters that can be displayed
  828. // by the OS Chooser. Note that the OS Chooser is not localized, so this
  829. // check is really for ASCII chars >= 32 (space) and < 127 (DEL)
  830. //
  831. while ( *pszText >= 32 && *pszText < 127 )
  832. pszText++;
  833. if ( *pszText == L'\0' )
  834. {
  835. fReturn = TRUE;
  836. }
  837. RETURN(fReturn);
  838. }
  839. //
  840. // DefaultSIFDlgProc( )
  841. //
  842. // Generates the default SIF.
  843. //
  844. INT_PTR CALLBACK
  845. DefaultSIFDlgProc(
  846. HWND hDlg,
  847. UINT uMsg,
  848. WPARAM wParam,
  849. LPARAM lParam )
  850. {
  851. NMHDR FAR *lpnmhdr;
  852. WCHAR szHelpTextFromInf[200];
  853. WCHAR szDescriptionFromInf[200];
  854. WCHAR szHelpTextFormat [200];
  855. DWORD dw;
  856. switch ( uMsg )
  857. {
  858. case WM_INITDIALOG:
  859. Edit_LimitText( GetDlgItem( hDlg, IDC_E_DESCRIPTION ), ARRAYSIZE(g_Options.szDescription) - 1 );
  860. Edit_LimitText( GetDlgItem( hDlg, IDC_E_HELPTEXT ), ARRAYSIZE(g_Options.szHelpText) - 1 );
  861. // subclass the edit boxes
  862. g_pOldEditWndProc = (WNDPROC) SetWindowLongPtr( GetDlgItem( hDlg, IDC_E_HELPTEXT), GWLP_WNDPROC, (LONG_PTR)&HelpTextEditWndProc);
  863. SetWindowLongPtr( GetDlgItem( hDlg, IDC_E_HELPTEXT), GWLP_WNDPROC, (LONG_PTR)&HelpTextEditWndProc);
  864. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  865. case WM_NOTIFY:
  866. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  867. lpnmhdr = (NMHDR FAR *) lParam;
  868. switch ( lpnmhdr->code )
  869. {
  870. case PSN_WIZBACK: //fall through
  871. case PSN_WIZNEXT:
  872. Edit_GetText( GetDlgItem( hDlg, IDC_E_DESCRIPTION ),
  873. szDescriptionFromInf,
  874. ARRAYSIZE(szDescriptionFromInf) );
  875. Edit_GetText( GetDlgItem( hDlg, IDC_E_HELPTEXT ),
  876. szHelpTextFromInf,
  877. ARRAYSIZE(szHelpTextFromInf) );
  878. if ( !VerifySIFText( szDescriptionFromInf ) )
  879. {
  880. MessageBoxFromStrings( hDlg,
  881. IDS_OSCHOOSER_RESTRICTION_FIELDS_TITLE,
  882. IDS_OSCHOOSER_RESTRICTION_FIELDS_TEXT,
  883. MB_OK );
  884. SetFocus( GetDlgItem( hDlg, IDC_E_DESCRIPTION ) );
  885. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't go to next dialog
  886. break;
  887. }
  888. lstrcpyn( g_Options.szDescription, szDescriptionFromInf, ARRAYSIZE(g_Options.szDescription) );
  889. if ( !VerifySIFText( szHelpTextFromInf ) )
  890. {
  891. MessageBoxFromStrings( hDlg,
  892. IDS_OSCHOOSER_RESTRICTION_FIELDS_TITLE,
  893. IDS_OSCHOOSER_RESTRICTION_FIELDS_TEXT,
  894. MB_OK );
  895. SetFocus( GetDlgItem( hDlg, IDC_E_HELPTEXT ) );
  896. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't go to next dialog
  897. break;
  898. }
  899. lstrcpyn( g_Options.szHelpText, szHelpTextFromInf, ARRAYSIZE(g_Options.szHelpText) );
  900. g_Options.fRetrievedWorkstationString = TRUE;
  901. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  902. break;
  903. case PSN_QUERYCANCEL:
  904. return VerifyCancel( hDlg );
  905. case PSN_SETACTIVE:
  906. if ( g_Options.fError
  907. || g_Options.fAbort
  908. || !g_Options.fNewOS ) {
  909. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  910. break;
  911. }
  912. if (g_Options.szDescription[0] == L'\0') {
  913. //
  914. // we did not find a description from txtsetup.sif
  915. //
  916. if (SUCCEEDED(GetHelpAndDescriptionTextFromSif(
  917. szHelpTextFromInf,
  918. ARRAYSIZE(szHelpTextFromInf),
  919. szDescriptionFromInf,
  920. ARRAYSIZE(szDescriptionFromInf)))) {
  921. lstrcpyn(g_Options.szDescription,szDescriptionFromInf, ARRAYSIZE(g_Options.szDescription));
  922. lstrcpyn(g_Options.szHelpText,szHelpTextFromInf, ARRAYSIZE(g_Options.szHelpText));
  923. }
  924. } else {
  925. //
  926. // We got a description and need to build the Help text
  927. //
  928. if (g_Options.szHelpText[0] == L'\0') {
  929. dw = LoadString( g_hinstance, IDS_DEFAULT_HELPTEXT,
  930. szHelpTextFormat, ARRAYSIZE(szHelpTextFormat) );
  931. Assert( dw );
  932. _snwprintf(g_Options.szHelpText, ARRAYSIZE(g_Options.szHelpText), szHelpTextFormat, g_Options.szDescription);
  933. TERMINATE_BUFFER(g_Options.szHelpText);
  934. }
  935. }
  936. SetDlgItemText( hDlg, IDC_E_DESCRIPTION, g_Options.szDescription );
  937. SetDlgItemText( hDlg, IDC_E_HELPTEXT, g_Options.szHelpText );
  938. DWORD dwLen1 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_DESCRIPTION) );
  939. DWORD dwLen2 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_HELPTEXT) );
  940. PropSheet_SetWizButtons( GetParent( hDlg ),
  941. (dwLen1 && dwLen2 ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK) );
  942. ClearMessageQueue( );
  943. break;
  944. }
  945. break;
  946. case WM_COMMAND:
  947. switch( LOWORD( wParam ) )
  948. {
  949. case IDC_E_DESCRIPTION:
  950. if ( HIWORD( wParam ) == EN_CHANGE ) {
  951. DWORD dwLen1 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_DESCRIPTION) );
  952. DWORD dwLen2 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_HELPTEXT) );
  953. PropSheet_SetWizButtons( GetParent( hDlg ),
  954. (dwLen1 && dwLen2 ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK) );
  955. }
  956. break;
  957. case IDC_E_HELPTEXT:
  958. if ( HIWORD( wParam ) == EN_CHANGE ) {
  959. DWORD dwLen1 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_DESCRIPTION) );
  960. DWORD dwLen2 = Edit_GetTextLength( GetDlgItem( hDlg, IDC_E_HELPTEXT) );
  961. PropSheet_SetWizButtons( GetParent( hDlg ),
  962. (dwLen1 && dwLen2 ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK) );
  963. }
  964. break;
  965. }
  966. break;
  967. default:
  968. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  969. }
  970. return TRUE;
  971. }
  972. //
  973. // ScreensDlgProc( )
  974. //
  975. INT_PTR CALLBACK
  976. ScreensDlgProc(
  977. HWND hDlg,
  978. UINT uMsg,
  979. WPARAM wParam,
  980. LPARAM lParam )
  981. {
  982. NMHDR FAR *lpnmhdr;
  983. switch ( uMsg )
  984. {
  985. case WM_INITDIALOG:
  986. SetFocus( GetDlgItem( hDlg, IDC_R_SAVEOLDFILES ) );
  987. BaseDlgProc( hDlg, uMsg, wParam, lParam );
  988. return FALSE;
  989. case WM_NOTIFY:
  990. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  991. lpnmhdr = (NMHDR FAR *) lParam;
  992. switch ( lpnmhdr->code )
  993. {
  994. case PSN_QUERYCANCEL:
  995. return VerifyCancel( hDlg );
  996. case PSN_SETACTIVE:
  997. if ( g_Options.fError
  998. || g_Options.fAbort
  999. || !g_Options.fNewOS
  1000. || !g_Options.fOSChooserScreensDirectory
  1001. || g_Options.fFirstTime ) {
  1002. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // don't show
  1003. break;
  1004. }
  1005. LONG lResult;
  1006. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_LEAVEALONE ) );
  1007. g_Options.fScreenLeaveAlone = !!(lResult == BST_CHECKED);
  1008. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_OVERWRITE ) );
  1009. g_Options.fScreenOverwrite = !!(lResult == BST_CHECKED);
  1010. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_SAVEOLDFILES ) );
  1011. g_Options.fScreenSaveOld = !!(lResult == BST_CHECKED);
  1012. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK |
  1013. ( g_Options.fScreenLeaveAlone
  1014. | g_Options.fScreenOverwrite
  1015. | g_Options.fScreenSaveOld ? PSWIZB_NEXT : 0 ) );
  1016. ClearMessageQueue( );
  1017. break;
  1018. }
  1019. break;
  1020. case WM_COMMAND:
  1021. if ( HIWORD( wParam ) == BN_CLICKED ) {
  1022. LONG lResult;
  1023. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_LEAVEALONE ) );
  1024. g_Options.fScreenLeaveAlone = !!(lResult == BST_CHECKED);
  1025. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_OVERWRITE ) );
  1026. g_Options.fScreenOverwrite = !!(lResult == BST_CHECKED);
  1027. lResult = Button_GetCheck( GetDlgItem( hDlg, IDC_R_SAVEOLDFILES ) );
  1028. g_Options.fScreenSaveOld = !!(lResult == BST_CHECKED);
  1029. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK |
  1030. ( g_Options.fScreenLeaveAlone
  1031. | g_Options.fScreenOverwrite
  1032. | g_Options.fScreenSaveOld ? PSWIZB_NEXT : 0 ) );
  1033. }
  1034. break;
  1035. default:
  1036. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1037. }
  1038. return TRUE;
  1039. }
  1040. //
  1041. // LanguageDlgProc( )
  1042. //
  1043. INT_PTR CALLBACK
  1044. LanguageDlgProc(
  1045. HWND hDlg,
  1046. UINT uMsg,
  1047. WPARAM wParam,
  1048. LPARAM lParam )
  1049. {
  1050. NMHDR FAR *lpnmhdr;
  1051. switch ( uMsg )
  1052. {
  1053. case WM_NOTIFY:
  1054. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1055. lpnmhdr = (NMHDR FAR *) lParam;
  1056. switch ( lpnmhdr->code )
  1057. {
  1058. case PSN_QUERYCANCEL:
  1059. return VerifyCancel( hDlg );
  1060. case PSN_SETACTIVE:
  1061. if ( !g_Options.fNewOS
  1062. || g_Options.fError
  1063. || g_Options.fAbort ) {
  1064. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // do not show this page
  1065. return TRUE;
  1066. } else {
  1067. DWORD dwCodePage;
  1068. if (g_Options.fAutomated) {
  1069. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1070. }
  1071. // we should have the workstation language by now
  1072. Assert( g_Options.fLanguageSet );
  1073. dwCodePage = GetSystemDefaultLCID();
  1074. if (dwCodePage) {
  1075. DebugMsg( "Server's Installation Code Page: 0x%04x\n", dwCodePage );
  1076. if ( PRIMARYLANGID( LANGIDFROMLCID(dwCodePage) ) != PRIMARYLANGID( g_Options.dwWksCodePage ) ) {
  1077. // Check to see if the OSChooser\<Language> exists. If it does,
  1078. // we don't show the warning page.
  1079. WCHAR szPath[ MAX_PATH ];
  1080. wsprintf(
  1081. szPath,
  1082. L"%s\\OSChooser\\%s",
  1083. g_Options.szIntelliMirrorPath,
  1084. g_Options.szLanguage );
  1085. DebugMsg( "Checking for %s directory....", szPath );
  1086. if ( 0xFFFFffff == GetFileAttributes( szPath ) ) // doesn't exist
  1087. { // show the page
  1088. DebugMsg( "doesn't exist.\n" );
  1089. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT | PSWIZB_BACK );
  1090. ClearMessageQueue( );
  1091. return TRUE;
  1092. }
  1093. DebugMsg( "does. Skip warning.\n" );
  1094. // don't show the page, must have already been prompted
  1095. // before.
  1096. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1097. return TRUE;
  1098. } else {
  1099. // don't show the page, the locales match
  1100. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1101. return TRUE;
  1102. }
  1103. }
  1104. }
  1105. break;
  1106. }
  1107. break;
  1108. default:
  1109. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1110. }
  1111. return TRUE;
  1112. }
  1113. //
  1114. // SummaryDlgProc( )
  1115. //
  1116. INT_PTR CALLBACK
  1117. SummaryDlgProc(
  1118. HWND hDlg,
  1119. UINT uMsg,
  1120. WPARAM wParam,
  1121. LPARAM lParam )
  1122. {
  1123. NMHDR FAR *lpnmhdr;
  1124. switch ( uMsg )
  1125. {
  1126. case WM_INITDIALOG:
  1127. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1128. case WM_NOTIFY:
  1129. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1130. lpnmhdr = (NMHDR FAR *) lParam;
  1131. switch ( lpnmhdr->code )
  1132. {
  1133. case PSN_QUERYCANCEL:
  1134. return VerifyCancel( hDlg );
  1135. case PSN_SETACTIVE:
  1136. if ( !g_Options.fNewOS
  1137. || g_Options.fError
  1138. || g_Options.fAbort ) {
  1139. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 ); // do not show this page
  1140. break;
  1141. } else {
  1142. WCHAR szText[ SMALL_BUFFER_SIZE ] = { L'\0' };
  1143. WCHAR szFilepath[ MAX_PATH ];
  1144. DWORD dwLen = 0;
  1145. RECT rect;
  1146. if( g_Options.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL ) {
  1147. DWORD dw;
  1148. dw = LoadString( g_hinstance, IDS_X86, szText, ARRAYSIZE( szText ));
  1149. Assert( dw );
  1150. } else if ( g_Options.ProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64 ) {
  1151. DWORD dw;
  1152. dw = LoadString( g_hinstance, IDS_IA64, &szText[ dwLen ], ARRAYSIZE( szText ) - dwLen );
  1153. Assert( dw );
  1154. }
  1155. // attempt to ellipsis path
  1156. lstrcpy( szFilepath, g_Options.szSourcePath );
  1157. GetWindowRect( GetDlgItem( hDlg, IDC_S_SOURCEPATH ), &rect );
  1158. PathCompactPath( NULL, szFilepath, rect.right - rect.left );
  1159. SetDlgItemText( hDlg, IDC_S_SOURCEPATH, szFilepath );
  1160. SetDlgItemText( hDlg, IDC_S_OSDIRECTORY, g_Options.szInstallationName );
  1161. SetDlgItemText( hDlg, IDC_S_PLATFORM, szText );
  1162. SetDlgItemText( hDlg, IDC_S_INTELLIMIRRORROOT, g_Options.szIntelliMirrorPath );
  1163. SetDlgItemText( hDlg, IDC_S_LANGUAGE, g_Options.szLanguage );
  1164. wsprintf( szFilepath, L"%s.%s", g_Options.szMajorVersion, g_Options.szMinorVersion );
  1165. SetDlgItemText( hDlg, IDC_S_NTVERSION, szFilepath );
  1166. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_FINISH | PSWIZB_BACK );
  1167. ClearMessageQueue( );
  1168. }
  1169. break;
  1170. }
  1171. break;
  1172. default:
  1173. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1174. }
  1175. return TRUE;
  1176. }
  1177. //
  1178. // ServerOKDlgProc( )
  1179. //
  1180. INT_PTR CALLBACK
  1181. ServerOKDlgProc(
  1182. HWND hDlg,
  1183. UINT uMsg,
  1184. WPARAM wParam,
  1185. LPARAM lParam )
  1186. {
  1187. NMHDR FAR *lpnmhdr;
  1188. switch ( uMsg )
  1189. {
  1190. case WM_INITDIALOG:
  1191. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1192. case WM_NOTIFY:
  1193. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1194. lpnmhdr = (NMHDR FAR *) lParam;
  1195. switch ( lpnmhdr->code )
  1196. {
  1197. case PSN_QUERYCANCEL:
  1198. return VerifyCancel( hDlg );
  1199. case PSN_SETACTIVE:
  1200. if ( g_Options.fNewOS
  1201. || g_Options.fError
  1202. || g_Options.fAbort ) {
  1203. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1204. break;
  1205. }
  1206. HRESULT hr = CheckInstallation( );
  1207. if ( hr != S_OK ) {
  1208. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1209. PropSheet_PressButton( GetParent( hDlg ), PSBTN_FINISH );
  1210. break;
  1211. }
  1212. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_BACK | PSWIZB_FINISH );
  1213. ClearMessageQueue( );
  1214. break;
  1215. }
  1216. break;
  1217. default:
  1218. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1219. }
  1220. return TRUE;
  1221. }
  1222. //
  1223. // CheckWelcomeDlgProc( )
  1224. //
  1225. // "Check's Welcome" dialog proc.
  1226. //
  1227. INT_PTR CALLBACK
  1228. CheckWelcomeDlgProc(
  1229. HWND hDlg,
  1230. UINT uMsg,
  1231. WPARAM wParam,
  1232. LPARAM lParam )
  1233. {
  1234. NMHDR FAR *lpnmhdr;
  1235. switch ( uMsg )
  1236. {
  1237. case WM_INITDIALOG:
  1238. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1239. case WM_NOTIFY:
  1240. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1241. lpnmhdr = (NMHDR FAR *) lParam;
  1242. switch ( lpnmhdr->code )
  1243. {
  1244. case PSN_QUERYCANCEL:
  1245. return VerifyCancel( hDlg );
  1246. case PSN_SETACTIVE:
  1247. if ( !g_Options.fCheckServer ) {
  1248. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1249. break;
  1250. }
  1251. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT );
  1252. ClearMessageQueue( );
  1253. break;
  1254. case PSN_WIZNEXT:
  1255. // CheckInstallation( );
  1256. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  1257. break;
  1258. }
  1259. break;
  1260. default:
  1261. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1262. }
  1263. return TRUE;
  1264. }
  1265. //
  1266. // AddWelcomeDlgProc( )
  1267. //
  1268. // "Add's Welcome" dialog proc.
  1269. //
  1270. INT_PTR CALLBACK
  1271. AddWelcomeDlgProc(
  1272. HWND hDlg,
  1273. UINT uMsg,
  1274. WPARAM wParam,
  1275. LPARAM lParam )
  1276. {
  1277. NMHDR FAR *lpnmhdr;
  1278. switch ( uMsg )
  1279. {
  1280. case WM_INITDIALOG:
  1281. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1282. case WM_NOTIFY:
  1283. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1284. lpnmhdr = (NMHDR FAR *) lParam;
  1285. switch ( lpnmhdr->code )
  1286. {
  1287. case PSN_QUERYCANCEL:
  1288. return VerifyCancel( hDlg );
  1289. case PSN_SETACTIVE:
  1290. if ( !g_Options.fAddOption ) {
  1291. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1292. break;
  1293. }
  1294. PropSheet_SetWizButtons( GetParent( hDlg ), PSWIZB_NEXT );
  1295. ClearMessageQueue( );
  1296. break;
  1297. case PSN_WIZNEXT:
  1298. // CheckInstallation( );
  1299. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  1300. break;
  1301. }
  1302. break;
  1303. default:
  1304. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1305. }
  1306. return TRUE;
  1307. }
  1308. //
  1309. // ExamineServerDlgProc( )
  1310. //
  1311. // This is the screen that is shown wait CheckInstallation() runs for
  1312. // the first time. I had to move it from the InitializeOptions() because
  1313. // "-upgrade" shouldn't go through the exhaustive search and possibly
  1314. // show UI.
  1315. //
  1316. INT_PTR CALLBACK
  1317. ExamineServerDlgProc(
  1318. HWND hDlg,
  1319. UINT uMsg,
  1320. WPARAM wParam,
  1321. LPARAM lParam )
  1322. {
  1323. NMHDR FAR *lpnmhdr;
  1324. switch ( uMsg )
  1325. {
  1326. case WM_INITDIALOG:
  1327. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1328. case WM_NOTIFY:
  1329. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, FALSE );
  1330. lpnmhdr = (NMHDR FAR *) lParam;
  1331. switch ( lpnmhdr->code )
  1332. {
  1333. case PSN_QUERYCANCEL:
  1334. return VerifyCancel( hDlg );
  1335. case PSN_SETACTIVE:
  1336. if ( g_Options.fAlreadyChecked
  1337. || g_Options.fError
  1338. || g_Options.fAbort )
  1339. {
  1340. SetWindowLongPtr( hDlg, DWLP_MSGRESULT, -1 );
  1341. break;
  1342. }
  1343. PropSheet_SetWizButtons( GetParent( hDlg ), 0 );
  1344. ClearMessageQueue( );
  1345. PostMessage( hDlg, WM_USER, 0, 0 );
  1346. break;
  1347. }
  1348. break;
  1349. case WM_USER:
  1350. {
  1351. DWORD hr;
  1352. HANDLE hThread;
  1353. hThread = CreateThread( NULL, NULL, (LPTHREAD_START_ROUTINE) &CheckInstallation, NULL, NULL, NULL );
  1354. while ( WAIT_TIMEOUT == WaitForSingleObject( hThread, 0) )
  1355. {
  1356. MSG Msg;
  1357. if ( PeekMessage( &Msg, NULL, 0, 0, PM_REMOVE ) )
  1358. {
  1359. DispatchMessage( &Msg );
  1360. }
  1361. }
  1362. if ( GetExitCodeThread( hThread, &hr ) )
  1363. {
  1364. DebugMsg( "Thread Exit Code was 0x%08x\n", hr );
  1365. // If check installation failed, bail!
  1366. if ( FAILED( hr ) ) {
  1367. // Bail on the whole thing. Fake the finish button so
  1368. // we can exit without the "Are you sure?" dialog popping up.
  1369. g_Options.fError = TRUE;
  1370. PropSheet_SetWizButtons( GetParent( hDlg ), PSBTN_FINISH );
  1371. PropSheet_PressButton( GetParent( hDlg ), PSBTN_FINISH );
  1372. break;
  1373. }
  1374. }
  1375. CloseHandle( hThread );
  1376. g_Options.fAlreadyChecked = TRUE;
  1377. // Push the next button
  1378. PropSheet_PressButton( GetParent( hDlg ), PSBTN_NEXT );
  1379. }
  1380. break;
  1381. default:
  1382. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1383. }
  1384. return TRUE;
  1385. }
  1386. LBITEMDATA items[] = {
  1387. { STATE_NOTSTARTED, IDS_CREATINGDIRECTORYTREE, CreateDirectories, TEXT("") }, // 0
  1388. { STATE_NOTSTARTED, IDS_COPYSERVERFILES, CopyServerFiles, TEXT("") }, // 1
  1389. { STATE_NOTSTARTED, IDS_COPYINGFILES, CopyClientFiles, TEXT("") }, // 2
  1390. { STATE_NOTSTARTED, IDS_UPDATINGSCREENS, CopyScreenFiles, TEXT("") }, // 3
  1391. { STATE_NOTSTARTED, IDS_COPYTEMPLATEFILES, CopyTemplateFiles, TEXT("") }, // 4
  1392. { STATE_NOTSTARTED, IDS_CREATING_SERVICES, CreateRemoteBootServices, TEXT("") }, // 5
  1393. { STATE_NOTSTARTED, IDS_UPDATINGREGISTRY, ModifyRegistry, TEXT("") }, // 6
  1394. { STATE_NOTSTARTED, IDS_CREATING_SIS_VOLUME, CreateSISVolume, TEXT("") }, // 7
  1395. { STATE_NOTSTARTED, IDS_CORRECTING_SIS_ACLS, CreateSISVolume, TEXT("") }, // 8
  1396. { STATE_NOTSTARTED, IDS_STARTING_SERVICES, StartRemoteBootServices, TEXT("") }, // 9
  1397. { STATE_NOTSTARTED, IDS_AUTHORIZING_DHCP, AuthorizeDhcp, TEXT("") } // 10
  1398. };
  1399. //
  1400. // SetupDlgProc( )
  1401. //
  1402. INT_PTR CALLBACK
  1403. SetupDlgProc(
  1404. HWND hDlg,
  1405. UINT uMsg,
  1406. WPARAM wParam,
  1407. LPARAM lParam )
  1408. {
  1409. static BOOL bDoneFirstPass;
  1410. static UINT nItems;
  1411. static HBRUSH hBrush = NULL;
  1412. LPSETUPDLGDATA psdd = (LPSETUPDLGDATA) GetWindowLongPtr( hDlg, GWLP_USERDATA );
  1413. switch ( uMsg )
  1414. {
  1415. case WM_INITDIALOG:
  1416. {
  1417. BITMAP bm;
  1418. // grab the bitmaps
  1419. psdd = (LPSETUPDLGDATA) TraceAlloc( GMEM_FIXED, sizeof(SETUPDLGDATA) );
  1420. if (psdd == NULL) {
  1421. return FALSE;
  1422. }
  1423. psdd->hChecked = LoadImage( g_hinstance,
  1424. MAKEINTRESOURCE( IDB_CHECK ),
  1425. IMAGE_BITMAP,
  1426. 0, 0,
  1427. LR_DEFAULTSIZE | LR_LOADTRANSPARENT );
  1428. DebugMemoryAddHandle( psdd->hChecked );
  1429. GetObject( psdd->hChecked, sizeof(bm), &bm );
  1430. psdd->dwWidth = bm.bmWidth;
  1431. psdd->hError = LoadImage( g_hinstance,
  1432. MAKEINTRESOURCE( IDB_X ),
  1433. IMAGE_BITMAP,
  1434. 0, 0,
  1435. LR_DEFAULTSIZE | LR_LOADTRANSPARENT );
  1436. DebugMemoryAddHandle( psdd->hError );
  1437. GetObject( psdd->hError, sizeof(bm), &bm );
  1438. psdd->dwWidth = ( psdd->dwWidth > bm.bmWidth ? psdd->dwWidth : bm.bmWidth );
  1439. psdd->hArrow = LoadImage( g_hinstance,
  1440. MAKEINTRESOURCE( IDB_ARROW ),
  1441. IMAGE_BITMAP,
  1442. 0, 0,
  1443. LR_DEFAULTSIZE | LR_LOADTRANSPARENT );
  1444. DebugMemoryAddHandle( psdd->hArrow );
  1445. GetObject( psdd->hArrow, sizeof(bm), &bm );
  1446. psdd->dwWidth = ( psdd->dwWidth > bm.bmWidth ?
  1447. psdd->dwWidth :
  1448. bm.bmWidth );
  1449. HWND hwnd = GetDlgItem( hDlg, IDC_L_SETUP );
  1450. HFONT hFontOld = (HFONT) SendMessage( hwnd, WM_GETFONT, 0, 0);
  1451. if(hFontOld != NULL)
  1452. {
  1453. LOGFONT lf;
  1454. if ( GetObject( hFontOld, sizeof(LOGFONT), (LPSTR) &lf ) )
  1455. {
  1456. psdd->hFontNormal = CreateFontIndirect(&lf);
  1457. DebugMemoryAddHandle( psdd->hFontNormal );
  1458. lf.lfWeight = FW_BOLD;
  1459. psdd->hFontBold = CreateFontIndirect(&lf);
  1460. DebugMemoryAddHandle( psdd->hFontBold );
  1461. }
  1462. }
  1463. HDC hDC = GetDC( NULL );
  1464. HANDLE hOldFont = SelectObject( hDC, psdd->hFontBold );
  1465. TEXTMETRIC tm;
  1466. GetTextMetrics( hDC, &tm );
  1467. psdd->dwHeight = tm.tmHeight + 2;
  1468. SelectObject( hDC, hOldFont );
  1469. ReleaseDC( NULL, hDC );
  1470. ListBox_SetItemHeight( hwnd, -1, psdd->dwHeight );
  1471. SetWindowLongPtr( hDlg, GWLP_USERDATA, (LONG_PTR) psdd );
  1472. //
  1473. // Eliminate things that have already been done
  1474. //
  1475. if ( g_Options.fDirectoryTreeExists
  1476. && g_Options.fIMirrorShareFound ) {
  1477. items[ 0 ].uState = STATE_WONTSTART;
  1478. }
  1479. if ( !g_Options.fFirstTime
  1480. && g_Options.fTFTPDFilesFound
  1481. && g_Options.fSISFilesFound
  1482. && g_Options.fSISGrovelerFilesFound
  1483. && g_Options.fOSChooserInstalled
  1484. && g_Options.fBINLFilesFound
  1485. && g_Options.fRegSrvDllsFilesFound ) {
  1486. items[ 1 ].uState = STATE_WONTSTART;
  1487. }
  1488. if ( !g_Options.fNewOS ) {
  1489. items[ 2 ].uState = STATE_WONTSTART;
  1490. items[ 3 ].uState = STATE_WONTSTART;
  1491. }
  1492. if ( !g_Options.fNewOS
  1493. || ( g_Options.fScreenLeaveAlone
  1494. && !g_Options.fFirstTime ) ) {
  1495. items[ 3 ].uState = STATE_WONTSTART;
  1496. }
  1497. if ( !g_Options.fNewOS ) {
  1498. items[ 4 ].uState = STATE_WONTSTART;
  1499. }
  1500. if ( g_Options.fBINLServiceInstalled
  1501. && g_Options.fTFTPDServiceInstalled
  1502. && g_Options.fSISServiceInstalled
  1503. && g_Options.fSISGrovelerServiceInstalled
  1504. && g_Options.fBINLSCPFound ) {
  1505. items[ 5 ].uState = STATE_WONTSTART;
  1506. }
  1507. if ( g_Options.fRegistryIntact
  1508. && g_Options.fRegSrvDllsRegistered
  1509. && g_Options.fTFTPDDirectoryFound ) {
  1510. items[ 6 ].uState = STATE_WONTSTART;
  1511. }
  1512. if ( g_Options.fSISVolumeCreated ) {
  1513. items[ 7 ].uState = STATE_WONTSTART;
  1514. }
  1515. if ( !g_Options.fSISVolumeCreated
  1516. || g_Options.fSISSecurityCorrect ) {
  1517. items[ 8 ].uState = STATE_WONTSTART;
  1518. }
  1519. if( g_Options.fDontAuthorizeDhcp ) {
  1520. items[ 10 ].uState = STATE_WONTSTART;
  1521. }
  1522. nItems = 0;
  1523. for( int i = 0; i < ARRAYSIZE(items); i++ )
  1524. {
  1525. if ( items[i].uState != STATE_WONTSTART ) {
  1526. DWORD dw;
  1527. dw = LoadString( g_hinstance,
  1528. items[ i ].rsrcId,
  1529. items[ i ].szText,
  1530. ARRAYSIZE( items[ i ].szText ) );
  1531. Assert( dw );
  1532. ListBox_AddString( hwnd, &items[ i ] );
  1533. nItems++;
  1534. }
  1535. }
  1536. bDoneFirstPass = FALSE;
  1537. //
  1538. // Set a timer to fire in a few seconds so that we can force
  1539. // the setup to proceed even if we don't get the WM_DRAWITEM
  1540. // messages
  1541. //
  1542. SetTimer(hDlg,1,3 * 1000,NULL);
  1543. }
  1544. CenterDialog( hDlg );
  1545. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1546. case WM_DESTROY:
  1547. {
  1548. Assert( psdd );
  1549. if ( hBrush != NULL )
  1550. {
  1551. DeleteObject(hBrush);
  1552. hBrush = NULL;
  1553. }
  1554. DeleteObject( psdd->hChecked );
  1555. DebugMemoryDelete( psdd->hChecked );
  1556. DeleteObject( psdd->hError );
  1557. DebugMemoryDelete( psdd->hError );
  1558. DeleteObject( psdd->hArrow );
  1559. DebugMemoryDelete( psdd->hArrow );
  1560. DeleteObject( psdd->hFontNormal );
  1561. DebugMemoryDelete( psdd->hFontNormal );
  1562. DeleteObject( psdd->hFontBold );
  1563. DebugMemoryDelete( psdd->hFontBold );
  1564. TraceFree( psdd );
  1565. SetWindowLongPtr( hDlg, GWLP_USERDATA, NULL );
  1566. }
  1567. break;
  1568. case WM_STARTSETUP:
  1569. {
  1570. HWND hwnd = GetDlgItem( hDlg, IDC_L_SETUP );
  1571. RECT rc;
  1572. INT nProgressBoxHeight = 0;
  1573. HRESULT hr;
  1574. SetDlgItemText( hDlg, IDC_S_OPERATION, TEXT("") );
  1575. SendMessage( GetDlgItem( hDlg, IDC_P_METER) , PBM_SETPOS, 0, 0 );
  1576. GetClientRect( hwnd, &rc );
  1577. //
  1578. // Create the directories paths...
  1579. //
  1580. BuildDirectories( );
  1581. INT i = 0;
  1582. if (g_Options.fError) {
  1583. // Already tanked, set the first item with an error.
  1584. for(i=0;i< ARRAYSIZE(items);i++){
  1585. if(items[i].uState != STATE_WONTSTART){
  1586. items[i].uState = STATE_ERROR;
  1587. break;
  1588. }
  1589. }
  1590. }
  1591. while ( i < ARRAYSIZE( items )
  1592. && !g_Options.fError
  1593. && !g_Options.fAbort )
  1594. {
  1595. if ( items[ i ].uState != STATE_WONTSTART )
  1596. {
  1597. hr = CheckInstallation( );
  1598. if ( FAILED(hr) ) {
  1599. g_Options.fError = TRUE;
  1600. items[i].uState = STATE_ERROR;
  1601. break;
  1602. }
  1603. items[ i ].uState = STATE_STARTED;
  1604. InvalidateRect( hwnd, &rc, TRUE );
  1605. // process some messages
  1606. MSG Msg;
  1607. while ( PeekMessage( &Msg, NULL, 0, 0, PM_REMOVE ) )
  1608. {
  1609. TranslateMessage( &Msg );
  1610. DispatchMessage( &Msg );
  1611. }
  1612. hr = THR( items[ i ].pfn( hDlg ) );
  1613. if ( FAILED(hr) ) {
  1614. // fatal error - halt installation
  1615. items[ i ].uState = STATE_ERROR;
  1616. g_Options.fError = TRUE;
  1617. } else if ( hr == S_FALSE ) {
  1618. // non-fatal error - but something went wrong
  1619. items[ i ].uState = STATE_ERROR;
  1620. } else {
  1621. items[ i ].uState = STATE_DONE;
  1622. }
  1623. InvalidateRect( hwnd, &rc, TRUE );
  1624. }
  1625. i++;
  1626. }
  1627. hr = THR( CheckInstallation( ) );
  1628. if (g_Options.fFirstTime) {
  1629. // We believe this is the first time risetup has been run
  1630. if ( i > 0 ) {
  1631. // There were items in the list to start with
  1632. if ( items[ i - 1].rsrcId == IDS_AUTHORIZING_DHCP) {
  1633. //
  1634. // We reached the dhcp task, which implies we
  1635. // finished
  1636. GetSetRanFlag( FALSE, FALSE );
  1637. } else {
  1638. //
  1639. // We never reached dhcp authorization (or we
  1640. // skipped it)
  1641. //
  1642. GetSetRanFlag( FALSE, g_Options.fError );
  1643. }
  1644. }
  1645. }
  1646. // If no errors, exit.
  1647. if ( g_Options.fAutomated && !g_Options.fError )
  1648. {
  1649. EndDialog( hDlg, 1 );
  1650. }
  1651. else
  1652. { // we are not bailing, resize, etc.
  1653. // disable & hide "Cancel" button
  1654. HWND hwndCancel = GetDlgItem( hDlg, IDCANCEL );
  1655. ShowWindow( hwndCancel, SW_HIDE );
  1656. EnableWindow( hwndCancel, FALSE );
  1657. // hide progress bar stuff
  1658. HWND hwndGroupBox = GetDlgItem( hDlg, IDC_G_OPERATION );
  1659. ShowWindow( GetDlgItem( hDlg, IDC_S_OPERATION), SW_HIDE );
  1660. ShowWindow( GetDlgItem( hDlg, IDC_P_METER), SW_HIDE );
  1661. ShowWindow( hwndGroupBox, SW_HIDE );
  1662. GetWindowRect( hwndGroupBox, &rc );
  1663. nProgressBoxHeight = rc.bottom - rc.top;
  1664. // make "Done" button move it up and make it visible
  1665. HWND hwndOK = GetDlgItem( hDlg, IDOK );
  1666. GetWindowRect( hwndOK, &rc );
  1667. MapWindowPoints( NULL, hDlg, (LPPOINT) &rc, 2 );
  1668. SetWindowPos( hwndOK,
  1669. NULL,
  1670. rc.left, rc.top - nProgressBoxHeight,
  1671. 0, 0,
  1672. SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW );
  1673. // make "Done" the default button
  1674. LONG lStyle = GetWindowLong( hwndOK, GWL_STYLE );
  1675. lStyle |= BS_DEFPUSHBUTTON;
  1676. SetWindowLong( hwndOK, GWL_STYLE, lStyle );
  1677. EnableWindow( hwndOK, TRUE );
  1678. // Shrink dialog
  1679. GetWindowRect( hDlg, &rc );
  1680. MoveWindow( hDlg,
  1681. rc.left, rc.top,
  1682. rc.right - rc.left, rc.bottom - rc.top - nProgressBoxHeight,
  1683. TRUE );
  1684. }
  1685. }
  1686. break;
  1687. case WM_MEASUREITEM:
  1688. {
  1689. LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
  1690. RECT rc;
  1691. HWND hwnd = GetDlgItem( hDlg, IDC_L_SETUP );
  1692. GetClientRect( hwnd, &rc );
  1693. lpmis->itemWidth = rc.right - rc.left;
  1694. lpmis->itemHeight = 15;
  1695. }
  1696. break;
  1697. case WM_DRAWITEM:
  1698. {
  1699. Assert( psdd );
  1700. LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT) lParam;
  1701. LPLBITEMDATA plbid = (LPLBITEMDATA) lpdis->itemData;
  1702. RECT rc = lpdis->rcItem;
  1703. HANDLE hOldFont = INVALID_HANDLE_VALUE;
  1704. rc.right = rc.bottom = psdd->dwWidth;
  1705. switch ( plbid->uState )
  1706. {
  1707. case STATE_NOTSTARTED:
  1708. hOldFont = SelectObject( lpdis->hDC, psdd->hFontNormal );
  1709. break;
  1710. case STATE_STARTED:
  1711. DrawBitmap( psdd->hArrow, lpdis, &rc );
  1712. hOldFont = SelectObject( lpdis->hDC, psdd->hFontBold );
  1713. break;
  1714. case STATE_DONE:
  1715. DrawBitmap( psdd->hChecked, lpdis, &rc );
  1716. hOldFont = SelectObject( lpdis->hDC, psdd->hFontNormal );
  1717. break;
  1718. case STATE_ERROR:
  1719. DrawBitmap( psdd->hError, lpdis, &rc );
  1720. hOldFont = SelectObject( lpdis->hDC, psdd->hFontNormal );
  1721. break;
  1722. }
  1723. rc = lpdis->rcItem;
  1724. rc.left += psdd->dwHeight;
  1725. DrawText( lpdis->hDC, plbid->szText, -1, &rc, DT_LEFT | DT_VCENTER );
  1726. if ( hOldFont != INVALID_HANDLE_VALUE )
  1727. {
  1728. SelectObject( lpdis->hDC, hOldFont );
  1729. }
  1730. if ( !bDoneFirstPass && lpdis->itemID == nItems - 1 )
  1731. {
  1732. // delay the message until we have painted at least once.
  1733. bDoneFirstPass = TRUE;
  1734. PostMessage( hDlg, WM_STARTSETUP, 0, 0 );
  1735. }
  1736. }
  1737. break;
  1738. case WM_CTLCOLORLISTBOX:
  1739. {
  1740. if ( hBrush == NULL )
  1741. {
  1742. LOGBRUSH brush;
  1743. brush.lbColor = GetSysColor( COLOR_3DFACE );
  1744. brush.lbStyle = BS_SOLID;
  1745. hBrush = (HBRUSH) CreateBrushIndirect( &brush );
  1746. }
  1747. SetBkMode( (HDC) wParam, OPAQUE );
  1748. SetBkColor( (HDC) wParam, GetSysColor( COLOR_3DFACE ) );
  1749. return (INT_PTR)hBrush;
  1750. }
  1751. break;
  1752. case WM_SETTINGCHANGE:
  1753. if ( hBrush ) {
  1754. DeleteObject( hBrush );
  1755. hBrush = NULL;
  1756. }
  1757. break;
  1758. case WM_COMMAND:
  1759. {
  1760. switch( LOWORD( wParam ) )
  1761. {
  1762. case IDCANCEL:
  1763. if ( HIWORD(wParam) == BN_CLICKED )
  1764. {
  1765. if ( !VerifyCancel( hDlg ) ) {
  1766. EndDialog( hDlg, 0 );
  1767. }
  1768. }
  1769. break;
  1770. case IDOK:
  1771. if ( HIWORD(wParam) == BN_CLICKED )
  1772. {
  1773. EndDialog( hDlg, 1 );
  1774. }
  1775. break;
  1776. }
  1777. }
  1778. case WM_TIMER:
  1779. if ( !bDoneFirstPass && g_Options.fAutomated ) {
  1780. //
  1781. // we're in an unattended setup. We haven't gotten the
  1782. // WM_STARTSETUP signal yet, so we'll do that right here.
  1783. //
  1784. bDoneFirstPass = TRUE;
  1785. PostMessage( hDlg, WM_STARTSETUP, 0, 0 );
  1786. }
  1787. KillTimer(hDlg, 1);
  1788. //
  1789. // fall through
  1790. //
  1791. default:
  1792. return BaseDlgProc( hDlg, uMsg, wParam, lParam );
  1793. }
  1794. return FALSE;
  1795. }