f031a7d8fad872ee3a138357016c8499a62bfc72
3 * Copyright (C) 2004 ReactOS Team
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.
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.
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.
19 /* $Id: wizard.c,v 1.6 2004/08/28 11:08:50 ekohl Exp $
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS system libraries
23 * PURPOSE: System setup
24 * FILE: lib/syssetup/wizard.c
25 * PROGRAMER: Eric Kohl
28 /* INCLUDES *****************************************************************/
44 /* GLOBALS ******************************************************************/
46 static SETUPDATA SetupData
;
49 /* FUNCTIONS ****************************************************************/
52 CenterWindow(HWND hWnd
)
58 hWndParent
= GetParent(hWnd
);
59 if (hWndParent
== NULL
)
60 hWndParent
= GetDesktopWindow();
62 GetWindowRect(hWndParent
, &rcParent
);
63 GetWindowRect(hWnd
, &rcWindow
);
67 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
68 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
76 WelcomeDlgProc(HWND hwndDlg
,
88 hwndControl
= GetParent(hwndDlg
);
90 /* Center the wizard window */
91 CenterWindow (hwndControl
);
93 /* Hide the system menu */
94 dwStyle
= GetWindowLong(hwndControl
, GWL_STYLE
);
95 SetWindowLong(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
97 /* Hide and disable the 'Cancel' button */
98 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
99 ShowWindow (hwndControl
, SW_HIDE
);
100 EnableWindow (hwndControl
, FALSE
);
107 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
112 /* Enable the Next button */
113 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
131 OwnerPageDlgProc(HWND hwndDlg
,
137 TCHAR OwnerOrganization
[51];
145 SendDlgItemMessage(hwndDlg
, IDC_OWNERNAME
, EM_LIMITTEXT
, 50, 0);
146 SendDlgItemMessage(hwndDlg
, IDC_OWNERORGANIZATION
, EM_LIMITTEXT
, 50, 0);
148 /* Set focus to owner name */
149 SetFocus(GetDlgItem(hwndDlg
, IDC_OWNERNAME
));
156 lpnm
= (LPNMHDR
)lParam
;
161 /* Enable the Back and Next buttons */
162 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
167 if (GetDlgItemText(hwndDlg
, IDC_OWNERNAME
, OwnerName
, 50) == 0)
170 _T("Setup cannot continue until you enter your name."),
172 MB_ICONERROR
| MB_OK
);
173 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
177 OwnerOrganization
[0] = 0;
178 GetDlgItemText(hwndDlg
, IDC_OWNERORGANIZATION
, OwnerOrganization
, 50);
180 RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
181 _T("Software\\Microsoft\\Windows NT\\CurrentVersion"),
185 /* FIXME: check error code */
188 _T("RegisteredOwner"),
192 (_tcslen(OwnerName
) + 1) * sizeof(TCHAR
));
193 /* FIXME: check error code */
196 _T("RegisteredOrganization"),
200 (_tcslen(OwnerOrganization
) + 1) * sizeof(TCHAR
));
201 /* FIXME: check error code */
221 ComputerPageDlgProc(HWND hwndDlg
,
226 TCHAR ComputerName
[MAX_COMPUTERNAME_LENGTH
+ 1];
236 /* Retrieve current computer name */
237 Length
= MAX_COMPUTERNAME_LENGTH
+ 1;
238 GetComputerName(ComputerName
, &Length
);
240 /* Display current computer name */
241 SetDlgItemText(hwndDlg
, IDC_COMPUTERNAME
, ComputerName
);
243 /* Set text limits */
244 SendDlgItemMessage(hwndDlg
, IDC_COMPUTERNAME
, EM_LIMITTEXT
, 64, 0);
245 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD1
, EM_LIMITTEXT
, 14, 0);
246 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD2
, EM_LIMITTEXT
, 14, 0);
248 /* Set focus to computer name */
249 SetFocus(GetDlgItem(hwndDlg
, IDC_COMPUTERNAME
));
256 lpnm
= (LPNMHDR
)lParam
;
261 /* Enable the Back and Next buttons */
262 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
266 if (GetDlgItemText(hwndDlg
, IDC_COMPUTERNAME
, ComputerName
, 64) == 0)
269 _T("Setup cannot continue until you enter the name of your computer."),
271 MB_ICONERROR
| MB_OK
);
272 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
276 /* FIXME: check computer name for invalid characters */
278 if (!SetComputerName(ComputerName
))
281 _T("Setup failed to set the computer name."),
283 MB_ICONERROR
| MB_OK
);
284 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
288 /* Check admin passwords */
289 GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD1
, Password1
, 15);
290 GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD2
, Password2
, 15);
291 if (_tcscmp(Password1
, Password2
))
294 _T("The passwords you entered do not match. Please enter "\
295 "the desired password again."),
297 MB_ICONERROR
| MB_OK
);
298 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
302 /* FIXME: check password for invalid characters */
304 /* FIXME: Set admin password */
322 LocalePageDlgProc(HWND hwndDlg
,
327 PSETUPDATA SetupData
;
329 /* Retrieve pointer to the global setup data */
330 SetupData
= (PSETUPDATA
)GetWindowLong (hwndDlg
, GWL_USERDATA
);
336 /* Save pointer to the global setup data */
337 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
338 SetWindowLong(hwndDlg
, GWL_USERDATA
, (LONG
)SetupData
);
346 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
351 /* Enable the Back and Next buttons */
352 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
373 FinishDlgProc(HWND hwndDlg
,
386 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
391 /* Enable the correct buttons on for the active page */
392 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_FINISH
);
396 /* Handle a Back button click, if necessary */
400 /* Handle a Finish button click, if necessary */
421 HPROPSHEETPAGE ahpsp
[5];
423 // SHAREDWIZDATA wizdata;
425 /* Clear setup data */
426 ZeroMemory(&SetupData
, sizeof(SETUPDATA
));
428 /* Create the Welcome page */
429 ZeroMemory (&psp
, sizeof(PROPSHEETPAGE
));
430 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
431 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
432 psp
.hInstance
= hDllInstance
;
433 psp
.lParam
= (LPARAM
)&SetupData
;
434 psp
.pfnDlgProc
= WelcomeDlgProc
;
435 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_WELCOMEPAGE
);
436 ahpsp
[0] = CreatePropertySheetPage(&psp
);
438 /* Create the Owner page */
439 psp
.dwFlags
= PSP_DEFAULT
; // | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
440 // psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_OWNERTITLE);
441 // psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_OWNERSUBTITLE);
442 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_OWNERPAGE
);
443 psp
.pfnDlgProc
= OwnerPageDlgProc
;
444 ahpsp
[1] = CreatePropertySheetPage(&psp
);
446 /* Create the Computer page */
447 psp
.dwFlags
= PSP_DEFAULT
; // | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
448 // psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_COMPUTERTITLE);
449 // psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_COMPUTERSUBTITLE);
450 psp
.pfnDlgProc
= ComputerPageDlgProc
;
451 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_COMPUTERPAGE
);
452 ahpsp
[2] = CreatePropertySheetPage(&psp
);
455 /* Create the Locale page */
456 psp
.dwFlags
= PSP_DEFAULT
; // | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
457 // psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_LOCALETITLE);
458 // psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_LOCALESUBTITLE);
459 psp
.pfnDlgProc
= LocalePageDlgProc
;
460 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_LOCALEPAGE
);
461 ahpsp
[3] = CreatePropertySheetPage(&psp
);
464 /* Create the Finish page */
465 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
466 psp
.pfnDlgProc
= FinishDlgProc
;
467 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_FINISHPAGE
);
468 ahpsp
[4] = CreatePropertySheetPage(&psp
);
470 /* Create the property sheet */
471 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
472 psh
.dwFlags
= PSH_WIZARD
; //97 | PSH_WATERMARK | PSH_HEADER;
473 psh
.hInstance
= hDllInstance
;
474 psh
.hwndParent
= NULL
;
478 // psh.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK);
479 // psh.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER);
481 /* Display the wizard */