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.4 2004/06/17 21:23:50 kuehng 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 (ekohl@rz-online.de)
28 /* INCLUDES *****************************************************************/
42 /* GLOBALS ******************************************************************/
44 static SETUPDATA SetupData
;
47 /* FUNCTIONS ****************************************************************/
50 CenterWindow(HWND hWnd
)
56 hWndParent
= GetParent(hWnd
);
57 if (hWndParent
== NULL
)
58 hWndParent
= GetDesktopWindow();
60 GetWindowRect(hWndParent
, &rcParent
);
61 GetWindowRect(hWnd
, &rcWindow
);
65 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
66 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
74 WelcomeDlgProc(HWND hwndDlg
,
86 hwndControl
= GetParent(hwndDlg
);
88 /* Center the wizard window */
89 CenterWindow (hwndControl
);
91 /* Hide the system menu */
92 dwStyle
= GetWindowLong(hwndControl
, GWL_STYLE
);
93 SetWindowLong(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
95 /* Hide and disable the 'Cancel' button */
96 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
97 ShowWindow (hwndControl
, SW_HIDE
);
98 EnableWindow (hwndControl
, FALSE
);
105 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
110 /* Enable the Next button */
111 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
129 OwnerPageDlgProc(HWND hwndDlg
,
134 PSETUPDATA SetupData
;
136 /* Retrieve pointer to the global setup data */
137 SetupData
= (PSETUPDATA
)GetWindowLong (hwndDlg
, GWL_USERDATA
);
143 /* Save pointer to the global setup data */
144 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
145 SetWindowLong(hwndDlg
, GWL_USERDATA
, (LONG
)SetupData
);
147 SendDlgItemMessage(hwndDlg
, IDC_OWNERNAME
, EM_LIMITTEXT
, 50, 0);
148 SendDlgItemMessage(hwndDlg
, IDC_OWNERORGANIZATION
, EM_LIMITTEXT
, 50, 0);
150 /* set focus to owner name */
151 SetFocus(GetDlgItem(hwndDlg
,IDC_OWNERNAME
));
158 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
163 /* Enable the Back and Next buttons */
164 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
168 if (GetDlgItemText(hwndDlg
, IDC_OWNERNAME
, SetupData
->OwnerName
, 50) == 0)
171 _T("Setup cannot continue until you enter your name."),
173 MB_ICONERROR
| MB_OK
);
174 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
177 GetDlgItemText(hwndDlg
, IDC_OWNERORGANIZATION
, SetupData
->OwnerOrganization
, 50);
195 ComputerPageDlgProc(HWND hwndDlg
,
200 PSETUPDATA SetupData
;
204 /* Retrieve pointer to the global setup data */
205 SetupData
= (PSETUPDATA
)GetWindowLong (hwndDlg
, GWL_USERDATA
);
213 /* Save pointer to the global setup data */
214 SetupData
= (PSETUPDATA
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
215 SetWindowLong(hwndDlg
, GWL_USERDATA
, (LONG
)SetupData
);
217 /* Retrieve current computer name */
218 Length
= MAX_COMPUTERNAME_LENGTH
+ 1;
219 GetComputerNameA(SetupData
->ComputerName
, &Length
);
221 /* Display current computer name */
222 SetDlgItemTextA(hwndDlg
, IDC_COMPUTERNAME
, SetupData
->ComputerName
);
224 /* Set text limits */
225 SendDlgItemMessage(hwndDlg
, IDC_COMPUTERNAME
, EM_LIMITTEXT
, 64, 0);
226 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD1
, EM_LIMITTEXT
, 14, 0);
227 SendDlgItemMessage(hwndDlg
, IDC_ADMINPASSWORD2
, EM_LIMITTEXT
, 14, 0);
234 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
239 /* Enable the Back and Next buttons */
240 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_NEXT
);
244 if (GetDlgItemText(hwndDlg
, IDC_COMPUTERNAME
, SetupData
->ComputerName
, 64) == 0)
247 _T("Setup cannot continue until you enter the name of your computer."),
249 MB_ICONERROR
| MB_OK
);
250 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
254 /* FIXME: check computer name for invalid characters */
256 /* Check admin passwords */
257 GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD1
, Password1
, 15);
258 GetDlgItemText(hwndDlg
, IDC_ADMINPASSWORD2
, Password2
, 15);
259 if (_tcscmp (Password1
, Password2
))
262 _T("The passwords you entered do not match. Please enter "\
263 "the desired password again."),
265 MB_ICONERROR
| MB_OK
);
266 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, -1);
270 /* FIXME: check password for invalid characters */
272 _tcscpy (SetupData
->AdminPassword
, Password1
);
290 FinishDlgProc(HWND hwndDlg
,
303 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
308 /* Enable the correct buttons on for the active page */
309 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_BACK
| PSWIZB_FINISH
);
313 /* Handle a Back button click, if necessary */
317 /* Handle a Finish button click, if necessary */
338 HPROPSHEETPAGE ahpsp
[4];
340 // SHAREDWIZDATA wizdata;
342 /* Clear setup data */
343 ZeroMemory (&SetupData
, sizeof(SETUPDATA
));
345 /* Create the Welcome page */
346 ZeroMemory (&psp
, sizeof(PROPSHEETPAGE
));
347 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
348 psp
.dwFlags
= PSP_DEFAULT
; // | PSP_HIDEHEADER;
349 psp
.hInstance
= hDllInstance
;
350 psp
.lParam
= (LPARAM
)&SetupData
;
351 psp
.pfnDlgProc
= WelcomeDlgProc
;
352 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_WELCOMEPAGE
);
353 ahpsp
[0] = CreatePropertySheetPage(&psp
);
355 /* Create the Owner page */
356 psp
.dwFlags
= PSP_DEFAULT
; // | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
357 // psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_TITLE2);
358 // psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_SUBTITLE2);
359 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_OWNERPAGE
);
360 psp
.pfnDlgProc
= OwnerPageDlgProc
;
361 ahpsp
[1] = CreatePropertySheetPage(&psp
);
363 /* Create the Computer page */
364 psp
.dwFlags
= PSP_DEFAULT
; // | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
365 // psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_TITLE1);
366 // psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_SUBTITLE1);
367 psp
.pfnDlgProc
= ComputerPageDlgProc
;
368 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_COMPUTERPAGE
);
369 ahpsp
[2] = CreatePropertySheetPage(&psp
);
373 /* Create the Finish page */
374 psp
.dwFlags
= PSP_DEFAULT
; // | PSP_HIDEHEADER;
375 psp
.pfnDlgProc
= FinishDlgProc
;
376 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_FINISHPAGE
);
377 ahpsp
[3] = CreatePropertySheetPage(&psp
);
379 /* Create the property sheet */
380 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
381 psh
.dwFlags
= PSH_WIZARD
; //PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER;
382 psh
.hInstance
= hDllInstance
;
383 psh
.hwndParent
= NULL
;
387 // psh.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK);
388 // psh.pszbmHeader = MAKEINTRESOURCE(IDB_BANNER);
390 /* Display the wizard */