Merging r37048, r37051, r37052, r37055 from the-real-msvc branch
[reactos.git] / reactos / base / setup / reactos / reactos.c
1 /*
2 * ReactOS applications
3 * Copyright (C) 2004-2008 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id$
20 *
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS GUI first stage setup application
23 * FILE: subsys/system/reactos/reactos.c
24 * PROGRAMMERS: Eric Kohl
25 * Matthias Kupfer
26 */
27
28 #include <windows.h>
29 #include <windowsx.h>
30 #include <commctrl.h>
31 #include <tchar.h>
32 #include <setupapi.h>
33 #include <wine/unicode.h>
34
35 #include "resource.h"
36
37 /* GLOBALS ******************************************************************/
38
39 HFONT hTitleFont;
40
41 typedef struct _LANG
42 {
43 TCHAR LangId[9];
44 TCHAR LangName[128];
45 LONG DefaultKBLayout;
46 } LANG, *PLANG;
47
48 typedef struct _KBLAYOUT
49 {
50 TCHAR LayoutId[9];
51 TCHAR LayoutName[128];
52 TCHAR DllName[128];
53 } KBLAYOUT, *PKBLAYOUT;
54
55 struct
56 {
57 // Settings
58 LONG DestDiskNumber; // physical disk
59 LONG DestPartNumber; // partition on disk
60 LONG DestPartSize; // if partition doesn't exist, size of partition
61 LONG FSType; // file system type on partition
62 LONG MBRInstallType; // install bootloader
63 LONG FormatPart; // type of format the partition
64 TCHAR SelectedLangId[9]; // selected language
65 TCHAR SelectedKBLayout[9]; // selected kayboard layout
66 WCHAR InstallationDirectory[MAX_PATH]; // installation directory on hdd
67 BOOLEAN RepairUpdateFlag; // flag for update/repair an installed reactos
68 // txtsetup.sif data
69 TCHAR DefaultLang[20]; // default language
70 TCHAR DefaultKBLayout[20]; // default keyboard layout
71 PLANG pLanguages;
72 LONG LangCount;
73 PKBLAYOUT pKbLayouts;
74 LONG KbLayoutCount;
75 } SetupData;
76
77 typedef struct _IMGINFO
78 {
79 HBITMAP hBitmap;
80 INT cxSource;
81 INT cySource;
82 } IMGINFO, *PIMGINFO;
83
84 TCHAR abort_msg[512],abort_title[64];
85 HINSTANCE hInstance;
86 BOOL isUnattend;
87
88 /* FUNCTIONS ****************************************************************/
89
90 static VOID
91 CenterWindow(HWND hWnd)
92 {
93 HWND hWndParent;
94 RECT rcParent;
95 RECT rcWindow;
96
97 hWndParent = GetParent(hWnd);
98 if (hWndParent == NULL)
99 hWndParent = GetDesktopWindow();
100
101 GetWindowRect(hWndParent, &rcParent);
102 GetWindowRect(hWnd, &rcWindow);
103
104 SetWindowPos(hWnd,
105 HWND_TOP,
106 ((rcParent.right - rcParent.left) - (rcWindow.right - rcWindow.left)) / 2,
107 ((rcParent.bottom - rcParent.top) - (rcWindow.bottom - rcWindow.top)) / 2,
108 0,
109 0,
110 SWP_NOSIZE);
111 }
112
113 static HFONT
114 CreateTitleFont(VOID)
115 {
116 NONCLIENTMETRICS ncm;
117 LOGFONT LogFont;
118 HDC hdc;
119 INT FontSize;
120 HFONT hFont;
121
122 ncm.cbSize = sizeof(NONCLIENTMETRICS);
123 SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
124
125 LogFont = ncm.lfMessageFont;
126 LogFont.lfWeight = FW_BOLD;
127 _tcscpy(LogFont.lfFaceName, _T("MS Shell Dlg"));
128
129 hdc = GetDC(NULL);
130 FontSize = 12;
131 LogFont.lfHeight = 0 - GetDeviceCaps (hdc, LOGPIXELSY) * FontSize / 72;
132 hFont = CreateFontIndirect(&LogFont);
133 ReleaseDC(NULL, hdc);
134
135 return hFont;
136 }
137
138 static VOID
139 InitImageInfo(PIMGINFO ImgInfo)
140 {
141 BITMAP bitmap;
142
143 ZeroMemory(ImgInfo, sizeof(*ImgInfo));
144
145 ImgInfo->hBitmap = LoadImage(hInstance,
146 MAKEINTRESOURCE(IDB_ROSLOGO),
147 IMAGE_BITMAP,
148 0,
149 0,
150 LR_DEFAULTCOLOR);
151
152 if (ImgInfo->hBitmap != NULL)
153 {
154 GetObject(ImgInfo->hBitmap, sizeof(BITMAP), &bitmap);
155
156 ImgInfo->cxSource = bitmap.bmWidth;
157 ImgInfo->cySource = bitmap.bmHeight;
158 }
159 }
160
161 static INT_PTR CALLBACK
162 StartDlgProc(HWND hwndDlg,
163 UINT uMsg,
164 WPARAM wParam,
165 LPARAM lParam)
166 {
167 switch (uMsg)
168 {
169 case WM_INITDIALOG:
170 {
171 HWND hwndControl;
172 DWORD dwStyle;
173
174 hwndControl = GetParent(hwndDlg);
175
176 /* Center the wizard window */
177 CenterWindow (hwndControl);
178
179 dwStyle = GetWindowLong(hwndControl, GWL_STYLE);
180 SetWindowLong(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU);
181
182 /* Hide and disable the 'Cancel' button at the moment,
183 * we use this button to cancel the setup process
184 * like F3 in usetup
185 */
186 hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL);
187 ShowWindow (hwndControl, SW_HIDE);
188 EnableWindow (hwndControl, FALSE);
189
190 /* Set title font */
191 SendDlgItemMessage(hwndDlg,
192 IDC_STARTTITLE,
193 WM_SETFONT,
194 (WPARAM)hTitleFont,
195 (LPARAM)TRUE);
196 }
197 break;
198 case WM_NOTIFY:
199 {
200 LPNMHDR lpnm = (LPNMHDR)lParam;
201
202 switch (lpnm->code)
203 {
204 case PSN_SETACTIVE: // Only "Finish" for closing the App
205 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_FINISH);
206 //PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
207 break;
208 default:
209 break;
210 }
211 break;
212 default:
213 break;
214 }
215
216 }
217 return FALSE;
218 }
219
220 static INT_PTR CALLBACK
221 LangSelDlgProc(HWND hwndDlg,
222 UINT uMsg,
223 WPARAM wParam,
224 LPARAM lParam)
225 {
226 PIMGINFO pImgInfo;
227 LONG i;
228 pImgInfo = (PIMGINFO)GetWindowLongPtr(hwndDlg, DWLP_USER);
229 switch (uMsg)
230 {
231 case WM_INITDIALOG:
232 {
233 HWND hwndControl;
234 DWORD dwStyle;
235
236 hwndControl = GetParent(hwndDlg);
237
238 dwStyle = GetWindowLong(hwndControl, GWL_STYLE);
239 SetWindowLong(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU);
240
241 hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL);
242 ShowWindow (hwndControl, SW_SHOW);
243 EnableWindow (hwndControl, TRUE);
244
245 pImgInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMGINFO));
246 if (pImgInfo == NULL)
247 {
248 EndDialog(hwndDlg, 0);
249 return FALSE;
250 }
251
252 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pImgInfo);
253
254 InitImageInfo(pImgInfo);
255
256 /* Set title font */
257 /*SendDlgItemMessage(hwndDlg,
258 IDC_STARTTITLE,
259 WM_SETFONT,
260 (WPARAM)hTitleFont,
261 (LPARAM)TRUE);*/
262 for (i=0; i< SetupData.LangCount;i++)
263 (void)ComboBox_AddString(GetDlgItem(hwndDlg,IDC_LANGUAGES),SetupData.pLanguages[i].LangName);
264 for (i=0; i< SetupData.KbLayoutCount;i++)
265 (void)ComboBox_AddString(GetDlgItem(hwndDlg,IDC_KEYLAYOUT),SetupData.pKbLayouts[i].LayoutName);
266 }
267 break;
268 case WM_DRAWITEM:
269 {
270 LPDRAWITEMSTRUCT lpDrawItem;
271 lpDrawItem = (LPDRAWITEMSTRUCT) lParam;
272 if (lpDrawItem->CtlID == IDB_ROSLOGO)
273 {
274 HDC hdcMem;
275 LONG left;
276
277 /* position image in centre of dialog */
278 left = (lpDrawItem->rcItem.right - pImgInfo->cxSource) / 2;
279
280 hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
281 if (hdcMem != NULL)
282 {
283 SelectObject(hdcMem, pImgInfo->hBitmap);
284 BitBlt(lpDrawItem->hDC,
285 left,
286 lpDrawItem->rcItem.top,
287 lpDrawItem->rcItem.right - lpDrawItem->rcItem.left,
288 lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top,
289 hdcMem,
290 0,
291 0,
292 SRCCOPY);
293 DeleteDC(hdcMem);
294 }
295 }
296 return TRUE;
297 }
298 case WM_NOTIFY:
299 {
300 LPNMHDR lpnm = (LPNMHDR)lParam;
301
302 switch (lpnm->code)
303 {
304 case PSN_SETACTIVE:
305 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT | PSWIZB_BACK);
306 break;
307 case PSN_QUERYCANCEL:
308 SetWindowLong(hwndDlg, DWL_MSGRESULT,MessageBox(GetParent(hwndDlg), abort_msg, abort_title, MB_YESNO | MB_ICONQUESTION) != IDYES);
309 return TRUE;
310 default:
311 break;
312 }
313 break;
314 default:
315 break;
316 }
317
318 }
319 return FALSE;
320 }
321
322 static INT_PTR CALLBACK
323 TypeDlgProc(HWND hwndDlg,
324 UINT uMsg,
325 WPARAM wParam,
326 LPARAM lParam)
327 {
328 switch (uMsg)
329 {
330 case WM_INITDIALOG:
331 {
332 HWND hwndControl;
333 DWORD dwStyle;
334
335 hwndControl = GetParent(hwndDlg);
336
337 dwStyle = GetWindowLong(hwndControl, GWL_STYLE);
338 SetWindowLong(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU);
339
340 CheckDlgButton(hwndDlg, IDC_INSTALL, BST_CHECKED);
341
342 /* Set title font */
343 /*SendDlgItemMessage(hwndDlg,
344 IDC_STARTTITLE,
345 WM_SETFONT,
346 (WPARAM)hTitleFont,
347 (LPARAM)TRUE);*/
348 }
349 break;
350 case WM_NOTIFY:
351 {
352 LPNMHDR lpnm = (LPNMHDR)lParam;
353
354 switch (lpnm->code)
355 {
356 case PSN_SETACTIVE:
357 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT | PSWIZB_BACK);
358 break;
359 case PSN_QUERYCANCEL:
360 SetWindowLong(hwndDlg, DWL_MSGRESULT,MessageBox(GetParent(hwndDlg), abort_msg, abort_title, MB_YESNO | MB_ICONQUESTION) != IDYES);
361 return TRUE;
362 default:
363 break;
364 }
365 break;
366 default:
367 break;
368 }
369
370 }
371 return FALSE;
372 }
373
374 static INT_PTR CALLBACK
375 DeviceDlgProc(HWND hwndDlg,
376 UINT uMsg,
377 WPARAM wParam,
378 LPARAM lParam)
379 {
380 switch (uMsg)
381 {
382 case WM_INITDIALOG:
383 {
384 HWND hwndControl;
385 DWORD dwStyle;
386
387 hwndControl = GetParent(hwndDlg);
388
389 dwStyle = GetWindowLong(hwndControl, GWL_STYLE);
390 SetWindowLong(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU);
391
392 /* Set title font */
393 /*SendDlgItemMessage(hwndDlg,
394 IDC_STARTTITLE,
395 WM_SETFONT,
396 (WPARAM)hTitleFont,
397 (LPARAM)TRUE);*/
398 }
399 break;
400 case WM_NOTIFY:
401 {
402 LPNMHDR lpnm = (LPNMHDR)lParam;
403
404 switch (lpnm->code)
405 {
406 case PSN_SETACTIVE:
407 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT | PSWIZB_BACK);
408 break;
409 case PSN_QUERYCANCEL:
410 SetWindowLong(hwndDlg, DWL_MSGRESULT,MessageBox(GetParent(hwndDlg), abort_msg, abort_title, MB_YESNO | MB_ICONQUESTION) != IDYES);
411 return TRUE;
412 default:
413 break;
414 }
415 break;
416 default:
417 break;
418 }
419
420 }
421 return FALSE;
422 }
423
424 static INT_PTR CALLBACK
425 DriveDlgProc(HWND hwndDlg,
426 UINT uMsg,
427 WPARAM wParam,
428 LPARAM lParam)
429 {
430 switch (uMsg)
431 {
432 case WM_INITDIALOG:
433 {
434 HWND hwndControl;
435 DWORD dwStyle;
436
437 hwndControl = GetParent(hwndDlg);
438
439 dwStyle = GetWindowLong(hwndControl, GWL_STYLE);
440 SetWindowLong(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU);
441
442 CheckDlgButton(hwndDlg, IDC_INSTFREELDR, BST_CHECKED);
443 /* Set title font */
444 /*SendDlgItemMessage(hwndDlg,
445 IDC_STARTTITLE,
446 WM_SETFONT,
447 (WPARAM)hTitleFont,
448 (LPARAM)TRUE);*/
449 }
450 break;
451 case WM_NOTIFY:
452 {
453 LPNMHDR lpnm = (LPNMHDR)lParam;
454
455 switch (lpnm->code)
456 {
457 case PSN_SETACTIVE:
458 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT | PSWIZB_BACK);
459 break;
460 case PSN_QUERYCANCEL:
461 SetWindowLong(hwndDlg, DWL_MSGRESULT,MessageBox(GetParent(hwndDlg), abort_msg, abort_title, MB_YESNO | MB_ICONQUESTION) != IDYES);
462 return TRUE;
463 default:
464 break;
465 }
466 break;
467 default:
468 break;
469 }
470
471 }
472 return FALSE;
473 }
474
475 static INT_PTR CALLBACK
476 ProcessDlgProc(HWND hwndDlg,
477 UINT uMsg,
478 WPARAM wParam,
479 LPARAM lParam)
480 {
481 switch (uMsg)
482 {
483 case WM_INITDIALOG:
484 {
485 HWND hwndControl;
486 DWORD dwStyle;
487
488 hwndControl = GetParent(hwndDlg);
489
490 dwStyle = GetWindowLong(hwndControl, GWL_STYLE);
491 SetWindowLong(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU);
492
493 hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL);
494 ShowWindow (hwndControl, SW_HIDE);
495 EnableWindow (hwndControl, FALSE);
496
497 /* Set title font */
498 /*SendDlgItemMessage(hwndDlg,
499 IDC_STARTTITLE,
500 WM_SETFONT,
501 (WPARAM)hTitleFont,
502 (LPARAM)TRUE);*/
503 }
504 break;
505 case WM_NOTIFY:
506 {
507 LPNMHDR lpnm = (LPNMHDR)lParam;
508
509 switch (lpnm->code)
510 {
511 case PSN_SETACTIVE:
512 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT );
513 break;
514 default:
515 break;
516 }
517 break;
518 default:
519 break;
520 }
521
522 }
523 return FALSE;
524 }
525
526 static INT_PTR CALLBACK
527 RestartDlgProc(HWND hwndDlg,
528 UINT uMsg,
529 WPARAM wParam,
530 LPARAM lParam)
531 {
532 switch (uMsg)
533 {
534 case WM_INITDIALOG:
535 {
536 HWND hwndControl;
537 DWORD dwStyle;
538
539 hwndControl = GetParent(hwndDlg);
540
541 dwStyle = GetWindowLong(hwndControl, GWL_STYLE);
542 SetWindowLong(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU);
543
544 /* Set title font */
545 /*SendDlgItemMessage(hwndDlg,
546 IDC_STARTTITLE,
547 WM_SETFONT,
548 (WPARAM)hTitleFont,
549 (LPARAM)TRUE);*/
550 }
551 break;
552 case WM_TIMER:
553 {
554 INT Position;
555 HWND hWndProgress;
556
557 hWndProgress = GetDlgItem(hwndDlg, IDC_RESTART_PROGRESS);
558 Position = SendMessage(hWndProgress, PBM_GETPOS, 0, 0);
559 if (Position == 300)
560 {
561 KillTimer(hwndDlg, 1);
562 PropSheet_PressButton(GetParent(hwndDlg), PSBTN_FINISH);
563 }
564 else
565 {
566 SendMessage(hWndProgress, PBM_SETPOS, Position + 1, 0);
567 }
568 return TRUE;
569 }
570 case WM_DESTROY:
571 return TRUE;
572 case WM_NOTIFY:
573 {
574 LPNMHDR lpnm = (LPNMHDR)lParam;
575
576 switch (lpnm->code)
577 {
578 case PSN_SETACTIVE: // Only "Finish" for closing the App
579 PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_FINISH);
580 SendDlgItemMessage(hwndDlg, IDC_RESTART_PROGRESS, PBM_SETRANGE, 0, MAKELPARAM(0, 300));
581 SendDlgItemMessage(hwndDlg, IDC_RESTART_PROGRESS, PBM_SETPOS, 0, 0);
582 SetTimer(hwndDlg, 1, 50, NULL);
583 break;
584 default:
585 break;
586 }
587 break;
588 default:
589 break;
590 }
591
592 }
593 return FALSE;
594 }
595
596 void LoadSetupData()
597 {
598 WCHAR szPath[MAX_PATH];
599 WCHAR *ch;
600 HINF hTxtsetupSif;
601 INFCONTEXT InfContext;
602 //TCHAR szValue[MAX_PATH];
603 DWORD LineLength;
604 LONG Count;
605 //HKEY hKey;
606
607 GetModuleFileNameW(NULL,szPath,MAX_PATH);
608 ch = strrchrW(szPath,L'\\');
609 if (ch != NULL)
610 *ch = L'\0';
611
612 wcscat(szPath, L"\\txtsetup.sif");
613 hTxtsetupSif = SetupOpenInfFileW(szPath, NULL, INF_STYLE_OLDNT, NULL);
614 if (hTxtsetupSif != INVALID_HANDLE_VALUE)
615 {
616 // get language list
617 Count = SetupGetLineCount(hTxtsetupSif, _T("Language"));
618 if (Count > 0)
619 {
620 // TODO: alloc memory for all entries and read entries
621 SetupData.pLanguages = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LANG) * Count);
622 if (SetupData.pLanguages != NULL)
623 {
624 SetupData.LangCount = Count;
625 Count = 0;
626 if (SetupFindFirstLine(hTxtsetupSif, _T("Language"),
627 NULL,&InfContext))
628 do
629 {
630 SetupGetStringField(&InfContext, 0, SetupData.pLanguages[Count].LangId, sizeof(SetupData.pLanguages[Count].LangId) / sizeof(TCHAR), &LineLength);
631 SetupGetStringField(&InfContext, 1, SetupData.pLanguages[Count].LangName, sizeof(SetupData.pLanguages[Count].LangName) / sizeof(TCHAR), &LineLength);
632 ++Count;
633 }
634 while (SetupFindNextLine(&InfContext, &InfContext) && Count < SetupData.LangCount);
635 }
636 }
637 // get keyboard layout list
638 Count = SetupGetLineCount(hTxtsetupSif, _T("KeyboardLayout"));
639 if (Count > 0)
640 {
641 // TODO: alloc memory for all entries and read entries
642 SetupData.pKbLayouts = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(KBLAYOUT) * Count);
643 if (SetupData.pKbLayouts != NULL)
644 {
645 SetupData.KbLayoutCount = Count;
646 Count = 0;
647 if (SetupFindFirstLine(hTxtsetupSif, _T("KeyboardLayout"),
648 NULL,&InfContext))
649 do
650 {
651 SetupGetStringField(&InfContext, 0, SetupData.pKbLayouts[Count].LayoutId, sizeof(SetupData.pKbLayouts[Count].LayoutId) / sizeof(TCHAR), &LineLength);
652 SetupGetStringField(&InfContext, 1, SetupData.pKbLayouts[Count].LayoutName, sizeof(SetupData.pKbLayouts[Count].LayoutName) / sizeof(TCHAR), &LineLength);
653 ++Count;
654 }
655 while (SetupFindNextLine(&InfContext, &InfContext) && Count < SetupData.LangCount);
656 }
657 }
658 SetupCloseInfFile(hTxtsetupSif);
659 }
660 }
661
662 BOOL isUnattendSetup()
663 {
664 WCHAR szPath[MAX_PATH];
665 WCHAR *ch;
666 HINF hUnattendedInf;
667 INFCONTEXT InfContext;
668 TCHAR szValue[MAX_PATH];
669 DWORD LineLength;
670 //HKEY hKey;
671 BOOL result = 0;
672
673 GetModuleFileNameW(NULL,szPath,MAX_PATH);
674 ch = strrchrW(szPath,L'\\');
675 if (ch != NULL)
676 *ch = L'\0';
677
678 wcscat(szPath, L"\\unattend.inf");
679 hUnattendedInf = SetupOpenInfFileW(szPath, NULL, INF_STYLE_OLDNT, NULL);
680 if (hUnattendedInf != INVALID_HANDLE_VALUE)
681 {
682 if (SetupFindFirstLine(hUnattendedInf, _T("Unattend"),
683 _T("UnattendSetupEnabled"),&InfContext))
684 {
685 if (SetupGetStringField(&InfContext, 1, szValue,
686 sizeof(szValue) / sizeof(TCHAR), &LineLength) &&
687 (_tcsicmp(szValue, _T("yes"))==0))
688 {
689 result = 1; // unattendSetup enabled
690 // read values and store in SetupData
691 }
692 }
693 SetupCloseInfFile(hUnattendedInf);
694 }
695 return result;
696 }
697
698 int WINAPI
699 WinMain(HINSTANCE hInst,
700 HINSTANCE hPrevInstance,
701 LPSTR lpszCmdLine,
702 int nCmdShow)
703 {
704 PROPSHEETHEADER psh;
705 HPROPSHEETPAGE ahpsp[7];
706 PROPSHEETPAGE psp = {0};
707 UINT nPages = 0;
708 hInstance = hInst;
709 isUnattend = isUnattendSetup();
710
711 if (!isUnattend)
712 {
713
714 LoadString(hInst,IDS_ABORTSETUP, abort_msg, sizeof(abort_msg)/sizeof(TCHAR));
715 LoadString(hInst,IDS_ABORTSETUP2, abort_title,sizeof(abort_title)/sizeof(TCHAR));
716
717 LoadSetupData();
718
719 /* Create the Start page, until setup is working */
720 psp.dwSize = sizeof(PROPSHEETPAGE);
721 psp.dwFlags = PSP_DEFAULT | PSP_HIDEHEADER;
722 psp.hInstance = hInst;
723 psp.lParam = 0;
724 psp.pfnDlgProc = StartDlgProc;
725 psp.pszTemplate = MAKEINTRESOURCE(IDD_STARTPAGE);
726 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
727
728 /* Create language selection page */
729 psp.dwSize = sizeof(PROPSHEETPAGE);
730 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
731 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_LANGTITLE);
732 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_LANGSUBTITLE);
733 psp.hInstance = hInst;
734 psp.lParam = 0;
735 psp.pfnDlgProc = LangSelDlgProc;
736 psp.pszTemplate = MAKEINTRESOURCE(IDD_LANGSELPAGE);
737 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
738 // Change language with "SetThreadLocale(langid)"
739
740 /* Create install type selection page */
741 psp.dwSize = sizeof(PROPSHEETPAGE);
742 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
743 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_TYPETITLE);
744 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_TYPESUBTITLE);
745 psp.hInstance = hInst;
746 psp.lParam = 0;
747 psp.pfnDlgProc = TypeDlgProc;
748 psp.pszTemplate = MAKEINTRESOURCE(IDD_TYPEPAGE);
749 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
750
751 /* Create device settings page */
752 psp.dwSize = sizeof(PROPSHEETPAGE);
753 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
754 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_DEVICETITLE);
755 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_DEVICESUBTITLE);
756 psp.hInstance = hInst;
757 psp.lParam = 0;
758 psp.pfnDlgProc = DeviceDlgProc;
759 psp.pszTemplate = MAKEINTRESOURCE(IDD_DEVICEPAGE);
760 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
761
762 /* Create install device settings page / boot method / install directory*/
763 psp.dwSize = sizeof(PROPSHEETPAGE);
764 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
765 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_DRIVETITLE);
766 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_DRIVESUBTITLE);
767 psp.hInstance = hInst;
768 psp.lParam = 0;
769 psp.pfnDlgProc = DriveDlgProc;
770 psp.pszTemplate = MAKEINTRESOURCE(IDD_DRIVEPAGE);
771 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
772
773 }
774
775 /* Create installation progress page */
776 psp.dwSize = sizeof(PROPSHEETPAGE);
777 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
778 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_PROCESSTITLE);
779 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_PROCESSSUBTITLE);
780 psp.hInstance = hInst;
781 psp.lParam = 0;
782 psp.pfnDlgProc = ProcessDlgProc;
783 psp.pszTemplate = MAKEINTRESOURCE(IDD_PROCESSPAGE);
784 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
785
786 if (!isUnattend)
787 {
788 /* Create finish to reboot page */
789 psp.dwSize = sizeof(PROPSHEETPAGE);
790 psp.dwFlags = PSP_DEFAULT | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
791 psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_RESTARTTITLE);
792 psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_RESTARTSUBTITLE);
793 psp.hInstance = hInst;
794 psp.lParam = 0;
795 psp.pfnDlgProc = RestartDlgProc;
796 psp.pszTemplate = MAKEINTRESOURCE(IDD_RESTARTPAGE);
797 ahpsp[nPages++] = CreatePropertySheetPage(&psp);
798 }
799
800 /* Create the property sheet */
801 psh.dwSize = sizeof(PROPSHEETHEADER);
802 psh.dwFlags = PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER;
803 psh.hInstance = hInst;
804 psh.hwndParent = NULL;
805 psh.nPages = nPages;
806 psh.nStartPage = 0;
807 psh.phpage = ahpsp;
808 psh.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK);
809 psh.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER);
810
811 /* Create title font */
812 hTitleFont = CreateTitleFont();
813
814 /* Display the wizard */
815 PropertySheet(&psh);
816
817 DeleteObject(hTitleFont);
818
819 return 0;
820
821 }
822
823 /* EOF */