Implement the GUI setup wizard.

svn path=/trunk/; revision=9163
This commit is contained in:
Eric Kohl 2004-04-16 13:37:18 +00:00
parent 956eca91cf
commit dc45d5f3f3
7 changed files with 502 additions and 16 deletions

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.6 2004/03/21 14:37:18 navaraf Exp $
# $Id: Makefile,v 1.7 2004/04/16 13:37:18 ekohl Exp $
PATH_TO_TOP = ../..
@ -17,7 +17,7 @@ TARGET_RCFLAGS += -D__USE_W32API -D_WIN32_IE=0x0500
TARGET_LFLAGS = -nostartfiles -nostdlib
TARGET_OBJECTS = dllmain.o install.o logfile.o
TARGET_OBJECTS = dllmain.o install.o logfile.o wizard.o
# wizard.o
include $(PATH_TO_TOP)/rules.mak

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: dllmain.c,v 1.2 2004/03/21 14:37:19 navaraf Exp $
/* $Id: dllmain.c,v 1.3 2004/04/16 13:37:18 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -30,8 +30,14 @@
#include <windows.h>
#include <commctrl.h>
#include "globals.h"
/* GLOBALS *******************************************************************/
HINSTANCE hDllInstance;
/* FUNCTIONS *****************************************************************/
BOOL STDCALL
@ -39,8 +45,11 @@ DllMain (HINSTANCE hInstance,
DWORD dwReason,
LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
InitCommonControls();
if (dwReason == DLL_PROCESS_ATTACH)
{
InitCommonControls();
hDllInstance = hInstance;
}
return TRUE;
}

View file

@ -0,0 +1,34 @@
/*
* Copyright (C) 2004 Eric Kohl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
typedef struct _SETUPDATA
{
TCHAR OwnerName[51];
TCHAR OwnerOrganization[51];
TCHAR ComputerName[MAX_COMPUTERNAME_LENGTH + 1]; /* max. 63 characters */
TCHAR AdminPassword[15]; /* max. 14 characters */
} SETUPDATA, *PSETUPDATA;
extern HINSTANCE hDllInstance;
/* wizard.c */
VOID InstallWizard (VOID);
/* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: install.c,v 1.10 2004/04/09 18:27:10 weiden Exp $
/* $Id: install.c,v 1.11 2004/04/16 13:37:18 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -35,14 +35,12 @@
#include <samlib.h>
#include <syssetup.h>
#include "globals.h"
#include "resource.h"
// #define NO_GUI
#define VMWINST
#if 0
VOID Wizard (VOID);
#endif
/* userenv.dll */
BOOL WINAPI InitializeProfiles (VOID);
@ -289,15 +287,16 @@ InstallReactOS (HINSTANCE hInstance)
RtlFreeSid (AdminSid);
RtlFreeSid (DomainSid);
#if 0
Wizard ();
#if 1
InstallWizard ();
#endif
#ifdef VMWINST
RunVMWInstall();
#endif
DialogBox(
GetModuleHandle(TEXT("syssetup.dll")),
// GetModuleHandle(TEXT("syssetup.dll")),
hDllInstance,
MAKEINTRESOURCE(IDD_RESTART),
NULL,
RestartDlgProc);

View file

@ -19,7 +19,24 @@
#ifndef RESOURCE_H
#define RESOURCE_H
#define IDD_RESTART 1001
#define IDC_RESTART_PROGRESS 1002
#define IDC_STATIC -1
#define IDD_WELCOMEPAGE 1000
#define IDD_OWNERPAGE 1001
#define IDC_OWNERNAME 1002
#define IDC_OWNERORGANIZATION 1003
#define IDD_COMPUTERPAGE 1004
#define IDC_COMPUTERNAME 1005
#define IDC_ADMINPASSWORD1 1006
#define IDC_ADMINPASSWORD2 1007
#define IDD_FINISHPAGE 1050
#define IDD_RESTART 2000
#define IDC_RESTART_PROGRESS 2001
#endif /* RESOURCE_H */

View file

@ -1,5 +1,6 @@
/*
* Copyright (C) 2004 Filip Navara
* Copyright (C) 2004 Eric Kohl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,14 +19,81 @@
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
IDD_WELCOMEPAGE DIALOG DISCARDABLE 0, 0, 317, 193
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "ReactOS Setup"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Welcome to the ReactOS Setup Wizard.", IDC_STATIC, 115, 9, 189, 31
LTEXT "This wizard installs ReactOS on your computer. The wizard "\
"needs to gather some information about you and your computer "\
"to set up ReactOS properly.", IDC_STATIC, 115, 50, 189, 100
LTEXT "Click Next to continue with Setup.", IDC_STATIC, 115, 160, 189, 31
END
IDD_OWNERPAGE DIALOG DISCARDABLE 0, 0, 317, 143
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "ReactOS Setup"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Type your full name and the name of your company or organization.",
IDC_STATIC, 54, 7, 242, 21
LTEXT "Na&me:", IDC_STATIC, 54, 37, 44, 8
EDITTEXT IDC_OWNERNAME, 132, 35, 163, 14, WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL
LTEXT "&Organization:", IDC_STATIC, 54, 57, 44, 8
EDITTEXT IDC_OWNERORGANIZATION, 132, 55, 163, 14, WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL
END
IDD_COMPUTERPAGE DIALOG DISCARDABLE 0, 0, 317, 143
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "ReactOS Setup"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Type a name for your computer that is 63 characters or less. "\
"If you are on a network, your computer name must be unique.",
IDC_STATIC, 54, 7, 250, 24
LTEXT "&Computer Name:", IDC_STATIC, 54, 38, 75, 8
EDITTEXT IDC_COMPUTERNAME, 132, 35, 163, 14, WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL | ES_UPPERCASE
LTEXT "Setup will create a user account on your computer called Administrator. "\
"You can use this account if you need full access to your computer.",
IDC_STATIC, 54, 57, 250, 25
LTEXT "Type an Administrator Password that is 14 characters or less.",
IDC_STATIC, 54, 87, 250, 8
LTEXT "&Administrator Password:", IDC_STATIC, 54, 104, 75, 8
EDITTEXT IDC_ADMINPASSWORD1, 132, 101, 172, 14, WS_VISIBLE | WS_TABSTOP | ES_PASSWORD
LTEXT "C&onfirm Password:", IDC_STATIC, 54, 123, 75, 8
EDITTEXT IDC_ADMINPASSWORD2, 132, 120, 172, 14, WS_VISIBLE | WS_TABSTOP | ES_PASSWORD
END
IDD_FINISHPAGE DIALOG DISCARDABLE 0, 0, 317, 193
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Completing ReactOS Setup"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Completing the ReactOS Setup Wizard",IDC_STATIC,115,9,195,37
LTEXT "You have successfully completed ReactOS Setup.\n\n" \
"When you click Finish, your computer will restart.", IDC_STATIC, 115, 58, 195, 100
LTEXT "If there is a CD in a drive, remove it. Then, to restart "\
"your computer, click Finish.", IDC_STATIC, 115, 160, 195, 31
END
IDD_RESTART DIALOG 6, 18, 245, 116
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "ReactOS Installation"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Installation of ReactOS was successfully completed.", -1, 13, 12, 212, 16
LTEXT "In order to continue, the installation program needs to restart your computer. The computer will be automatically restarted in 15 seconds or if you press the Restart button.", -1, 13, 33, 212, 32
LTEXT "Installation of ReactOS was successfully completed.", IDC_STATIC, 13, 12, 212, 16
LTEXT "In order to continue, the installation program needs to restart your computer. "\
"The computer will be automatically restarted in 15 seconds or if you press the "\
"Restart button.", IDC_STATIC, 13, 33, 212, 32
/* GROUPBOX "", -1, 7, 3, 231, 106 */
CONTROL "", IDC_RESTART_PROGRESS, "msctls_progress32", PBS_SMOOTH | WS_CHILD | WS_VISIBLE | WS_BORDER, 13, 70, 212, 8
PUSHBUTTON "&Restart", IDOK, 98, 87, 50, 14
END
/* EOF */

View file

@ -0,0 +1,359 @@
/*
* ReactOS kernel
* Copyright (C) 2004 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: wizard.c,v 1.1 2004/04/16 13:37:18 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* PURPOSE: System setup
* FILE: lib/syssetup/wizard.c
* PROGRAMER: Eric Kohl (ekohl@rz-online.de)
*/
/* INCLUDES *****************************************************************/
#include <windows.h>
#include <commctrl.h>
#include <string.h>
#include <tchar.h>
#include <syssetup.h>
#include "globals.h"
#include "resource.h"
/* GLOBALS ******************************************************************/
static SETUPDATA SetupData;
/* FUNCTIONS ****************************************************************/
BOOL CALLBACK
WelcomeDlgProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
HWND hwndControl;
DWORD dwStyle;
/* Hide the system menu */
hwndControl = GetParent(hwndDlg);
dwStyle = GetWindowLong(hwndControl, GWL_STYLE);
SetWindowLong(hwndControl, GWL_STYLE, dwStyle & ~WS_SYSMENU);
/* Hide and disable the 'Cancel' button */
hwndControl = GetDlgItem(GetParent(hwndDlg), IDCANCEL);
ShowWindow (hwndControl, SW_HIDE);
EnableWindow (hwndControl, FALSE);
}
break;
case WM_NOTIFY:
{
LPNMHDR lpnm = (LPNMHDR)lParam;
switch (lpnm->code)
{
case PSN_SETACTIVE:
/* Enable the Next button */
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_NEXT);
break;
default:
break;
}
}
break;
default:
break;
}
return FALSE;
}
INT_PTR CALLBACK
OwnerPageDlgProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
PSETUPDATA SetupData;
/* Retrieve pointer to the global setup data */
SetupData = (PSETUPDATA)GetWindowLong (hwndDlg, GWL_USERDATA);
switch (uMsg)
{
case WM_INITDIALOG:
{
/* Save pointer to the global setup data */
SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
SetWindowLong(hwndDlg, GWL_USERDATA, (LONG)SetupData);
SendDlgItemMessage(hwndDlg, IDC_OWNERNAME, EM_LIMITTEXT, 50, 0);
SendDlgItemMessage(hwndDlg, IDC_OWNERORGANIZATION, EM_LIMITTEXT, 50, 0);
}
break;
case WM_NOTIFY:
{
LPNMHDR lpnm = (LPNMHDR)lParam;
switch (lpnm->code)
{
case PSN_SETACTIVE:
/* Enable the Back and Next buttons */
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
break;
case PSN_WIZNEXT:
if (GetDlgItemText(hwndDlg, IDC_OWNERNAME, SetupData->OwnerName, 50) == 0)
{
MessageBox (hwndDlg,
"Setup cannot continue until you enter your name.",
"ReactOS Setup",
MB_ICONERROR | MB_OK);
return -1;
}
GetDlgItemText(hwndDlg, IDC_OWNERORGANIZATION, SetupData->OwnerOrganization, 50);
break;
default:
break;
}
}
break;
default:
break;
}
return 0;
}
BOOL CALLBACK
ComputerPageDlgProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
PSETUPDATA SetupData;
TCHAR Password1[15];
TCHAR Password2[15];
/* Retrieve pointer to the global setup data */
SetupData = (PSETUPDATA)GetWindowLong (hwndDlg, GWL_USERDATA);
switch (uMsg)
{
case WM_INITDIALOG:
{
DWORD Length;
/* Save pointer to the global setup data */
SetupData = (PSETUPDATA)((LPPROPSHEETPAGE)lParam)->lParam;
SetWindowLong(hwndDlg, GWL_USERDATA, (LONG)SetupData);
/* Retrieve current computer name */
Length = MAX_COMPUTERNAME_LENGTH + 1;
GetComputerNameA(SetupData->ComputerName, &Length);
/* Display current computer name */
SetDlgItemTextA(hwndDlg, IDC_COMPUTERNAME, SetupData->ComputerName);
/* Set text limits */
SendDlgItemMessage(hwndDlg, IDC_COMPUTERNAME, EM_LIMITTEXT, 64, 0);
SendDlgItemMessage(hwndDlg, IDC_ADMINPASSWORD1, EM_LIMITTEXT, 14, 0);
SendDlgItemMessage(hwndDlg, IDC_ADMINPASSWORD2, EM_LIMITTEXT, 14, 0);
}
break;
case WM_NOTIFY:
{
LPNMHDR lpnm = (LPNMHDR)lParam;
switch (lpnm->code)
{
case PSN_SETACTIVE:
/* Enable the Back and Next buttons */
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_NEXT);
break;
case PSN_WIZNEXT:
if (GetDlgItemText(hwndDlg, IDC_COMPUTERNAME, SetupData->ComputerName, 64) == 0)
{
MessageBox (hwndDlg,
"Setup cannot continue until you enter the name of your computer.",
"ReactOS Setup",
MB_ICONERROR | MB_OK);
return -1;
}
/* FIXME: check computer name for invalid characters */
/* Check admin passwords */
GetDlgItemText(hwndDlg, IDC_ADMINPASSWORD1, Password1, 15);
GetDlgItemText(hwndDlg, IDC_ADMINPASSWORD2, Password2, 15);
if (_tcscmp (Password1, Password2))
{
MessageBox (hwndDlg,
"The passwords you entered do not match. Please enter "\
"the desired password again.",
"ReactOS Setup",
MB_ICONERROR | MB_OK);
return -1;
}
/* FIXME: check password for invalid characters */
_tcscpy (SetupData->AdminPassword, Password1);
break;
default:
break;
}
}
break;
default:
break;
}
return FALSE;
}
BOOL CALLBACK
FinishDlgProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
break;
case WM_NOTIFY:
{
LPNMHDR lpnm = (LPNMHDR)lParam;
switch (lpnm->code)
{
case PSN_SETACTIVE:
/* Enable the correct buttons on for the active page */
PropSheet_SetWizButtons(GetParent(hwndDlg), PSWIZB_BACK | PSWIZB_FINISH);
break;
case PSN_WIZBACK:
/* Handle a Back button click, if necessary */
break;
case PSN_WIZFINISH:
/* Handle a Finish button click, if necessary */
break;
default:
break;
}
}
break;
default:
break;
}
return 0;
}
VOID
InstallWizard (VOID)
{
PROPSHEETHEADER psh;
HPROPSHEETPAGE ahpsp[4];
PROPSHEETPAGE psp;
// SHAREDWIZDATA wizdata;
/* Clear setup data */
ZeroMemory (&SetupData, sizeof(SETUPDATA));
/* Create the Welcome page */
ZeroMemory (&psp, sizeof(PROPSHEETPAGE));
psp.dwSize = sizeof(PROPSHEETPAGE);
psp.dwFlags = PSP_DEFAULT; // | PSP_HIDEHEADER;
psp.hInstance = hDllInstance;
psp.lParam = (LPARAM)&SetupData;
psp.pfnDlgProc = WelcomeDlgProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_WELCOMEPAGE);
ahpsp[0] = CreatePropertySheetPage(&psp);
/* Create the Owner page */
psp.dwFlags = PSP_DEFAULT; // | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
// psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_TITLE2);
// psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_SUBTITLE2);
psp.pszTemplate = MAKEINTRESOURCE(IDD_OWNERPAGE);
psp.pfnDlgProc = OwnerPageDlgProc;
ahpsp[1] = CreatePropertySheetPage(&psp);
/* Create the Computer page */
psp.dwFlags = PSP_DEFAULT; // | PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
// psp.pszHeaderTitle = MAKEINTRESOURCE(IDS_TITLE1);
// psp.pszHeaderSubTitle = MAKEINTRESOURCE(IDS_SUBTITLE1);
psp.pfnDlgProc = ComputerPageDlgProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_COMPUTERPAGE);
ahpsp[2] = CreatePropertySheetPage(&psp);
/* Create the Finish page */
psp.dwFlags = PSP_DEFAULT; // | PSP_HIDEHEADER;
psp.pfnDlgProc = FinishDlgProc;
psp.pszTemplate = MAKEINTRESOURCE(IDD_FINISHPAGE);
ahpsp[3] = CreatePropertySheetPage(&psp);
/* Create the property sheet */
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_WIZARD; //PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER;
psh.hInstance = hDllInstance;
psh.hwndParent = NULL;
psh.nPages = 4;
psh.nStartPage = 0;
psh.phpage = ahpsp;
// psh.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK);
// psh.pszbmHeader = MAKEINTRESOURCE(IDB_BANNER);
/* Display the wizard */
PropertySheetA (&psh);
}
/* EOF */