home *** CD-ROM | disk | FTP | other *** search
Wrap
// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // // SETUP.CPP // Main file for "MAIN.EXE" Setup Studio sample program // Use with CSETUP.DLL release 2.6. // // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // // This file requires Microsoft Visual C++ 1.5x Compiler and MFC 2.5x class Library. // Warning: You use this product at your own risk! You are responsible for making suitable backups in case it screws up. // You can use this file as a template and you can redistribute programs (without any royalties) but // you must not dsitribute this source code with your personnal passwords. // // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // // With the UNREGISTERED version you can' t install icons or runs programs at the end of the Set-up // because your files will be in the TEST directory (and not in the user' s directory). // // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // // There are 5 classes in this file: // // CSetupApp: The application management // CFirst: A splash dialog box with initialisation management // CMain: The main application window which calls dialog boxes and GoSetup function // CChoice1: To choose path and language // CChoice2: To choose files to install // // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Remark: // nPanelBold... specify italic mode ( not the bold mode ! ) // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------- // Private messages // ---------------------------------------------------------- #define PM_FIRST WM_USER + 0x049 // Message for CFirst Box to start the SetupInitialize #define PM_FIRST2 WM_USER + 0x050 // Message for CFirst Box to start the SetupInitialize #define IDCHANGEPATH 36 // EndDialog value when user want to change the path on Choice2 box // ---------------------------------------------------------- // Include files // ---------------------------------------------------------- #include <afx.h> #include <afxext.h> #include <stdlib.h> #include <direct.h> #include "setup.h" #pragma message ("SETUP.CPP(47): Please put CTL3D.H and CSETUP.H in your INCLUDE directory...") #pragma message ("SETUP.CPP(48): And put CTL3D.LIB and CSETUP.LIB in your LIB directory...") #include <csetup.h> #include <ctl3d.h> // ---------------------------------------------------------- // Local functions // ---------------------------------------------------------- #ifdef _DEBUG #undef THIS_FILE static char BASED_CODE THIS_FILE[] = __FILE__; #endif // ---------------------------------------------------------- // Local variables // ---------------------------------------------------------- BOOL bIsSetupOK, bWin4; // Result of SetupInitialize Function int iLanguage; // Language ( french or English ) CString UserPath; // Destination path int iType; // User configuration = TYPE_VB, TYPE_TCW, TYPE_MFC or TYPE_NONE long UserConfigSize; // The size of the user' s selection static char szOriginalPath[_MAX_PATH]; // First command line argument static char szTempSetupPath[_MAX_PATH]; // Second command line argument // ---------------------------------------------------------- // Local constants // ---------------------------------------------------------- #define TYPE_VB 0 // Indicate Best path for VB users #define TYPE_TCW 1 // Indicate Best path for TCW users #define TYPE_MFC 2 // Indicate Best path for MFC users #define TYPE_NONE 3 // Normal path must be used /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // I try to make a generic Setup Application... /// // This program can have up to 15 checkboxes and each checkbox is /// /// associated with a section. This program performs basic operations // // like section management, icons installation, winfile association // // and can run an EXE or an HLP file. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ----------------------- General settings ------------------------------------ const CString szYourName = "TEST"; // Put your <szYourName> password here, or TEST if you are not registered const CString szYourPassword = ""; // Put your <szPassword> here or nothing if you are not registered const int iBackgroundPaper = BROSSE_3DCIRCLE; // Choose the brush to use as the background paper, ( BROSSE_* ) const BOOL bBeepMode = TRUE; // True if you want the BEEP mode, FALSE if not const BOOL bVerifyMode = TRUE; // True if you want the VERIFY mode, FALSE if not const CString szProductName = "Setup Studio"; // Name of your works const CString szSetupBoxTitle = "Setup Studio 2.5 - Installation"; // Title of the Copy Dialog Box // ----------------------- General interface settings ------------------------------------ const CString Dialog1Title = "Setup Studio 2.6"; // Dialog box title for the path and other dialog boxes const CString Dialog3Title = "Setup Studio - Installation options"; // Dialog box title for the option dialog box const CString Dialog2Title = "Setup Studio 2.6"; // Dialog box title for the copy dialog box // ----------------------- Interface settings [PANEL1] ( first panel )------------------------------------ const int iPanel1Bitmap = 0; // Bitmap ID for Panel 1 or 0 to disable it const CString szPanel1Title = "Setup Studio 2.6"; // Panel 1 title or a blank string to disable it const CString szPanel1TitleFont = "Arial"; // Panel 1 title font to use const int iPanel1TitleSize = 56; // Panel 1 title font size to use const COLORREF lPanel1TitleColor = RGB(192,192,192); // Panel 1 title color to use const BOOL bPanel1Title3D = TRUE; // Panel 1 title 3D or not const BOOL bPanel1TitleBold = TRUE; // Panel 1 title bold or not const CString szPanel1Detail = "The ultimate setup toolkit to\nbuild setup programs for Win16/Win32!"; // Panel 1 detail or a blank string to disable it const CString szPanel1DetailFont = "Times New Roman"; // Panel 1 detail font to use const int iPanel1DetailSize = 28; // Panel 1 detail font size to use const COLORREF lPanel1DetailColor = RGB(0,0,138); // Panel 1 detail color to use const BOOL bPanel1Detail3D = TRUE; // Panel 1 detail 3D or not const BOOL bPanel1DetailBold = TRUE; // Panel 1 detail bold or not // ----------------------- Interface settings [PANEL2] ( user selects files to install )------------------------------------ const int iPanel2Bitmap = 0; // Bitmap ID for Panel 2 or 0 to disable it const CString szPanel2Title = "Setup Studio 2.6"; // Panel 2 title or a blank string to disable it const CString szPanel2TitleFont = "Arial"; // Panel 2 title font to use const int iPanel2TitleSize = 56; // Panel 2 title font size to use const COLORREF lPanel2TitleColor = RGB(192,192,192); // Panel 2 title color to use const BOOL bPanel2Title3D = TRUE; // Panel 2 title 3D or not const BOOL bPanel2TitleBold = TRUE; // Panel 2 title bold or not const CString szPanel2Detail = "The ultimate setup toolkit to\nbuild setup programs for Win16/Win32!"; // Panel 2 detail or a blank string to disable it const CString szPanel2DetailFont = "Times New Roman"; // Panel 2 detail font to use const int iPanel2DetailSize = 28; // Panel 2 detail font size to use const COLORREF lPanel2DetailColor = RGB( 0,0,138); // Panel 2 detail color to use const BOOL bPanel2Detail3D = TRUE; // Panel 2 detail 3D or not const BOOL bPanel2DetailBold = TRUE; // Panel 2 detail bold or not // ----------------------- Interface settings [PANEL3] ( files transfert )------------------------------------ const int iPanel3Bitmap = 0; // Bitmap ID for Panel 3 or 0 to disable it const CString szPanel3Title = "Setup Studio 2.6"; // Panel 3 title or a blank string to disable it const CString szPanel3TitleFont = "Arial"; // Panel 3 title font to use const int iPanel3TitleSize = 56; // Panel 3 title font size to use const COLORREF lPanel3TitleColor = RGB(192,192,192); // Panel 3 title color to use const BOOL bPanel3Title3D = TRUE; // Panel 3 title 3D or not const BOOL bPanel3TitleBold = TRUE; // Panel 3 title bold or not const CString szPanel3Detail = "[] Built-in Zip\\Unzip engine,\n[] No need to learn another language,\n[] No more than 4 functions required,\ \n[] Up to 1100 files, 30 disquettes...,\n[] Files dates checking, auto. backups...,\n[] Shared files support,\n[] 2 customizable languages,\n[] VB and VC templates,\ \n[] WRI manual and HLP help file,\n[] MS Setup Toolkit and Win95 compatible,\n[] And lots more..."; // Panel 3 detail or a blank string to disable it const CString szPanel3DetailFont = "Arial"; // Panel 3 detail font to use const int iPanel3DetailSize = 22; // Panel 3 detail font size to use const COLORREF lPanel3DetailColor = RGB(0,0,138); // Panel 3 detail color to use const BOOL bPanel3Detail3D = TRUE; // Panel 3 detail 3D or not const BOOL bPanel3DetailBold = FALSE; // Panel 3 detail bold or not // ----------------------- Shared files settings ------------------------------------ const BOOL bUseSharedBatch = FALSE; // Set this to TRUE if you wish to use the shared batch mode const CString szBatchFile = ""; // Dir and Name for the batch file, default = SYSSETUP.TMP\\SYSSETUP.BAT const CString szBatchDir = ""; // Temporary dir for shared files, default = SYSSETUP.TMP with final slash // ----------------------- LOG file settings ------------------------------------ const BOOL bUseLogFile = TRUE; // TRUE if you wish to use a LOG file, FALSE if not. const CString szLogFileName = "SETUP.LOG"; // Log file name ( without dir specification ) // ----------------------- SECTIONS management ------------------------------------ // 1 Section is associated to 1 checkbox typedef struct sSectionEntry{ unsigned bSelected : 1; // ---> TRUE if the user selects this section, FALSE if not long lSize; // ---> Section Size ( in bytes ) CString Name; // ---> Section name ( from SETUP.INF ) CString Directory; // ---> Destination relative directory for the section ( DIRX\\ for example ) CString ELabel; // ---> English label for the section ( will be associated with a CHECKBOX ) CString FLabel; // ---> French Label for the section ( will be associated with a CHECKBOX ) }SSECTIONENTRY; const int NumberOfSections = 4; // From 1 to 8 sections ( and checkboxes ) SSECTIONENTRY Section[ NumberOfSections]; // Now it' s depend of your INF File: You must create section entries for all checkboxes you want and // you must respect the diskettes order if your setup program contains more than 1 diskette: // See InitInstance for Implementation // ----------------------- Icons management ------------------------------------ const BOOL bInstallIcons = TRUE; // Install icons if section 0 is selected typedef struct sIconEntry { CString szIconRelativeName; // Program name for specified icon ( CTL3D\\SSTUDIO.EXE for example ) CString EGroupName; // Group Name ( english ) CString EIconName; // Icon title ( english ) CString EIconText; // Icon description ( english ) --> "" to add this icon without any dialog box CString FGroupName; // Group Name ( french ) CString FIconName; // Icon title ( french ) CString FIconText; // Icon description ( french ) }ICONENTRY; const int NumberOfIcons = 6; // How many icons ICONENTRY far IconEntry[NumberOfIcons]; // See InitInstance for Implementation // ----------------------- Association management ------------------------------------ const BOOL bMakeAssociation = TRUE; // TRUE if you wish to create or change WinFile associations typedef struct sWFAsso { CString szProgName; // EXE file name ( with the relative path if any ) CString szExt; // File extension to create ( TXT, DOC ... ) }SWFASSO; const int NumberOfAsso = 1; // Set the number of associations to create SWFASSO WFAsso[ NumberOfAsso]; // See InitInstance for Implementation // ----------------------- Last step: we launch something ------------------------------------ ////////////////////////////////////////////////////////////////////////////////////////////// // SPECIFIC for this setup: // We can' t run the Wizard, because this program uses CSETUP.DLL. // If you do it, you will get a share vialation error because the Wizard // will load CSETUP.DLL from the temporary setup directory when FINISH.EXE // is deleting this directory... // That' s why we run the HLP file instead! ////////////////////////////////////////////////////////////////////////////////////////////// const CString szLaunch = "SSTUDIO.HLP"; // Give a HLP or an EXE, COM, PIF, BAT file to launch when the setup is ok /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // End of generic declarations. // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Implementation - Specific ( so change the following values ) // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ---------------------------------------------------------- // Constructor // ---------------------------------------------------------- CSetupApp::CSetupApp() { // Now it' s depend of your INF File: You must create section entries for all checkboxes you want and // you must use the diskettes order if your setup program contains more than 1 diskette: // ----------------------------------------------------------------------- // We define the sections (as we do // with the Setup Studio Wizard) // ----------------------------------------------------------------------- Section[0].Name = "Files"; // no directory specification because we use the main destination directory Section[0].ELabel = "&Main files."; Section[0].FLabel = "&Fichiers principaux."; Section[1].Name = "MANUAL"; Section[1].ELabel = "&WRI manual."; Section[1].FLabel = "&Mode d' emploi (WRI)."; Section[2].Name = "VBTEMPLATE"; Section[2].ELabel = "Visual Basic &Template."; Section[2].FLabel = "ModΦle pour &Visual Basic."; Section[2].Directory = "TEMPLATE\\VB\\"; Section[3].Name = "VCTEMPLATE"; Section[3].ELabel = "Visual &C++ Template."; Section[3].FLabel = "ModΦle pour Visual &C++."; Section[3].Directory = "TEMPLATE\\VC\\"; // ----------------------------------------------------------------------- // Now, we add the icons (they will be installed // if the user installs the first main Section) // ----------------------------------------------------------------------- // Under Win32 ( NT >= 3.52 or Win4), the dialog // box won' t be displayed. // ----------------------------------------------------------------------- IconEntry[0].szIconRelativeName = "SSTUDIO.EXE"; // Icon name ( will be changed into UserPath + Name ) IconEntry[0].EGroupName = "Setup Studio 2.6"; IconEntry[0].EIconName = "Setup Wizard"; IconEntry[0].EIconText = "The Setup Studio Wizard is the useful assistant to layout files."; IconEntry[0].FGroupName = "Setup Studio 2.6"; IconEntry[0].FIconName = "Setup Wizard"; IconEntry[0].FIconText = "Le Setup Studio Wizard vous permet de crΘer les disquettes pour votre programme."; IconEntry[1].szIconRelativeName = "SSTUDIO.HLP"; // Icon name ( will be changed into UserPath + Name ) IconEntry[1].EGroupName = "Setup Studio 2.6"; IconEntry[1].EIconName = "Help File"; IconEntry[1].EIconText = "This HLP file lets you read the required informations to build your Setup program."; IconEntry[1].FGroupName = "Setup Studio 2.6"; IconEntry[1].FIconName ="Aide Online"; IconEntry[1].FIconText = "Ce fichier HLP donne toutes les informations nΘcessaires pour construire le programme d' installation."; IconEntry[2].szIconRelativeName = "MANUAL.WRI"; // Icon name ( will be changed into UserPath + Name ) IconEntry[2].EGroupName = "Setup Studio 2.6"; IconEntry[2].EIconName = "Manual"; IconEntry[2].EIconText = "Would you like to print this Setup Studio manual?"; IconEntry[2].FGroupName = "Setup Studio 2.6"; IconEntry[2].FIconName ="Mode d' emploi"; IconEntry[2].FIconText = "Pour Θtudier ce mode d' emploi (format WRI), nous vous conseillons de l' imprimer."; IconEntry[3].szIconRelativeName = "READ.ME"; // Icon name ( will be changed into UserPath + Name ) IconEntry[3].EGroupName = "Setup Studio 2.6"; IconEntry[3].EIconName = "READ.ME"; IconEntry[3].EIconText = "These are basic informations about the Setup Studio toolkit."; IconEntry[3].FGroupName = "Setup Studio 2.6"; IconEntry[3].FIconName ="READ.ME"; IconEntry[3].FIconText = "Les informations essentielles."; IconEntry[4].szIconRelativeName = "TEMPLATE\\VB\\MAIN.MAK"; // Icon name ( will be changed into UserPath + Name ) IconEntry[4].EGroupName = "Setup Studio 2.6"; IconEntry[4].EIconName = "VB Template"; IconEntry[4].EIconText = "Visual Basic users may use this VB template with their setup project."; IconEntry[4].FGroupName = "Setup Studio 2.6"; IconEntry[4].FIconName ="ModΦle VB"; IconEntry[4].FIconText = "Les utilisateurs de Visual Basic peuvent utiliser ce modΦle VB pour leurs projets de setup."; IconEntry[5].szIconRelativeName = "TEMPLATE\\VC\\MAIN.MAK"; // Icon name ( will be changed into UserPath + Name ) IconEntry[5].EGroupName = "Setup Studio 2.6"; IconEntry[5].EIconName = "VC Template"; IconEntry[5].EIconText = "Visual C++ (1.5x) users may use this VC template with their setup project."; IconEntry[5].FGroupName = "Setup Studio 2.6"; IconEntry[5].FIconName ="ModΦle VC"; IconEntry[5].FIconText = "Les utilisateurs de Visual C++ (1.5x) peuvent utiliser ce modΦle VC pour leurs projets de setup."; // ----------------------------------------------------------------------- // Now we add the WinFile associations // ----------------------------------------------------------------------- WFAsso[0].szProgName = "SSTUDIO.EXE"; // relative program name (using the chosen dest. dir) WFAsso[0].szExt = "CFG"; // extension to add } // ---------------------------------------------------------- // WM_INITDIALOG // Guess the best path for user // ---------------------------------------------------------- BOOL CChoice1::OnInitDialog() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// CDialog::OnInitDialog(); CString TempVBPath; register int i=0; SetWindowText( Dialog2Title ); // We change the font weight if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) { if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) { lFont.lfWeight = FW_NORMAL; if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) { SendDlgItemMessage( IDC_EDITSRCPATH, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_GROUPLANGUAGE, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_RADIOENGLISH, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_RADIOFRENCH, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_TEXTE, WM_SETFONT, (WPARAM) hfontDlg, 0); } } } SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) ); Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL ); CenterDialogBox( m_hWnd ); CString ProductName; ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire o∙ vous souhaitez installer ": "Please, give the directory in which you would like to install "; ProductName += szProductName; ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur 'OK':":" and click on 'OK'"; CheckRadioButton( IDC_RADIOENGLISH, IDC_RADIOFRENCH, ( iLanguage == LANGUAGE_FRENCH )?IDC_RADIOFRENCH: IDC_RADIOENGLISH ); SetDlgItemText( IDC_GROUPLANGUAGE, ( iLanguage == LANGUAGE_FRENCH )? "Votre langage... " : "Setup language... "); SetDlgItemText( IDC_TEXTE, ProductName ); SetDlgItemText( IDCANCEL, ( iLanguage == LANGUAGE_FRENCH )?"&Abandonner":"&Abort"); if ( UserPath.GetLength() > 0 ) SetDlgItemText( IDC_EDITSRCPATH, UserPath ); else { /////////////////////////////////////////////////////////// Specific ////////////////////////////////////////////////////////////////////// // We try to guess the best destination directory if ( DoesFileExist( "VB.INI", FALSE) ) { GetWinFileAssociation( "FRM", TempVBPath.GetBuffer(_MAX_PATH) ) ; TempVBPath.ReleaseBuffer(); if ( TempVBPath.GetLength() > 0 ) { TempVBPath = TempVBPath.Left( TempVBPath.GetLength() - 6 ); // kill VB.EXE TempVBPath += "SSETUP26"; // dir no slash FormatFileNameValid( TempVBPath, TRUE, UserPath.GetBuffer( _MAX_PATH ) ); UserPath.ReleaseBuffer(); UserPath.MakeUpper(); iType = TYPE_VB; } } if ( DoesFileExist( "TCW.INI", FALSE) ) { GetWinFileAssociation( "PRJ", TempVBPath.GetBuffer(_MAX_PATH) ) ; TempVBPath.ReleaseBuffer(); if ( TempVBPath.GetLength() > 0 ) { TempVBPath = TempVBPath.Left( TempVBPath.GetLength() - 10 ); // kill BIN\\TCW.EXE TempVBPath += "SSETUP26" ; // dir no slash FormatFileNameValid( TempVBPath, TRUE, UserPath.GetBuffer( _MAX_PATH ) ); UserPath.ReleaseBuffer(); UserPath.MakeUpper(); iType = TYPE_TCW; } } if ( DoesFileExist( "MSVC.INI", FALSE) ) { GetPrivateProfileString( "Microsoft Visual C++", "Path1", "", TempVBPath.GetBuffer(100), 98, "MSVC.INI"); TempVBPath.ReleaseBuffer(); if ( TempVBPath.GetLength() > 0 ) { TempVBPath = TempVBPath.Left( TempVBPath.GetLength() - 3 ); // kill BIN TempVBPath += "SSETUP26"; // dir no slash FormatFileNameValid( TempVBPath, TRUE, UserPath.GetBuffer( _MAX_PATH ) ); UserPath.ReleaseBuffer(); UserPath.MakeUpper(); iType = TYPE_MFC; } } // End of specific code ---- if ( UserPath.GetLength() < 1 ) { GetWindowsDirectory( UserPath.GetBuffer(_MAX_PATH), _MAX_PATH ); UserPath.ReleaseBuffer(); UserPath = UserPath.Left( 3 ); UserPath += "SSETUP26\\" ; // dir with slash iType = TYPE_NONE; } SetDlgItemText( IDC_EDITSRCPATH, UserPath ); /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// for ( i = 0 ; i < NumberOfSections ; i++ ) { if ( Section[i].Name.GetLength()> 0 ) Section[i].lSize = GetSectionSize( Section[i].Name ); } /////////////////////////////////////////////////////////// Specific ////////////////////////////////////////////////////////////////////// // We select the groups depending on the user development system: // VB users probably don' t wish to install the VC template... Section[0].bSelected = TRUE; // [Files] Section[1].bSelected = TRUE; // [MANUAL] Section[2].bSelected = TRUE; // [VBTEMPLATE] Section[3].bSelected = (iType != TYPE_VB)?TRUE:FALSE; // [VCTEMPLATE] } (CEdit*)(GetDlgItem( IDC_EDITSRCPATH))->SetFocus(); ((CEdit*)(GetDlgItem( IDC_EDITSRCPATH)))->SetSel( 0, -1L ); return FALSE; // return TRUE unless you set the focus to a control } // ---------------------------------------------------------- // CMain::PM_FIRST // Main function // ---------------------------------------------------------- afx_msg LRESULT CMain::OnFirstPrivate( WPARAM wParam, LPARAM lParam ) { CChoice1 box1( this ); // path selection CChoice2 box2( this ); // options selection int test2, iResult; register int i = 0; CString szLogFile; CString SrcHelpFile, DestHelpFile, Message,TempPath, IconPath, WinDir; char szTempBatch[_MAX_PATH], szShellTest[20]; /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// FIRSTBOX: if ( box1.DoModal() == IDCANCEL ) { if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Etes vous certain de vouloir\nabandonner l' installation?": "Are you sure you would like to abort\nthis installation program?", Dialog1Title, MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION ) == IDYES ) goto END; else goto FIRSTBOX; } SECONDBOX: // ----- Put Panel 2 if necessary ----- if ( iPanel2Bitmap == 0 ) { if ( szPanel2Title.GetLength() > 0 ) { SetTextLogo( szPanel2Title, szPanel2TitleFont, iPanel2TitleSize, lPanel2TitleColor, bPanel2Title3D, bPanel2TitleBold ); if ( szPanel2Detail.GetLength() > 0 ) SetTextDetail( szPanel2Detail, szPanel2DetailFont, iPanel2DetailSize, lPanel2DetailColor, bPanel2Detail3D, bPanel2DetailBold ); SetLogoType( TRUE ); SendMessage( WM_PAINT ); } } else { SetLogo( AfxGetInstanceHandle(), iPanel2Bitmap ); SetLogoType( FALSE ); SendMessage( WM_PAINT ); } test2 = box2.DoModal(); if ( test2 == IDCANCEL ) { if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Etes vous certain de vouloir\nabandonner l' installation?": "Are you sure you would like to abort\nthis installation program?", Dialog1Title, MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION ) == IDYES ) goto END; goto SECONDBOX; } else if ( test2 == IDCHANGEPATH ) goto FIRSTBOX; // ----- Put Panel 3 if necessary ----- if ( iPanel3Bitmap == 0 ) { if ( szPanel3Title.GetLength() > 0 ) { SetTextLogo( szPanel3Title, szPanel3TitleFont, iPanel3TitleSize, lPanel3TitleColor, bPanel3Title3D, bPanel3TitleBold ); if ( szPanel3Detail.GetLength() > 0 ) SetTextDetail( szPanel3Detail, szPanel3DetailFont, iPanel3DetailSize, lPanel3DetailColor, bPanel3Detail3D, bPanel3DetailBold ); SetLogoType( TRUE ); SendMessage( WM_PAINT ); } } else { SetLogo( AfxGetInstanceHandle(), iPanel3Bitmap ); SetLogoType( FALSE ); SendMessage( WM_PAINT ); } // log file ------ if ( bUseLogFile ) { szLogFile = UserPath + szLogFileName; SetLogFile( szLogFile ); } // Select sections for ( i = 0 ; i < NumberOfSections ; i++ ) { if ( Section[i].bSelected ) { if ( Section[i].Directory.GetLength() > 0 ) TempPath = UserPath + Section[i].Directory; else TempPath = UserPath; AddSectionToCopyList( Section[i].Name, TempPath ); } } // Now you can add specific section and display dialog box like this: /*if ( Section[0].bSelected ) { GetSystemDirectory( WinDir.GetBuffer( 255 ), 253 ); WinDir.ReleaseBuffer(); if ( WinDir.GetLength() > 3 ) WinDir += "\\"; if ( iLanguage == LANGUAGE_FRENCH ) { if ( MessageBox( "Installation des VBXs.\nComme vous avez choisi d' installer les VBXs,\n\ il convient de les copier dans le rΘpertoire WINDOWS\\SYSTEM.\nVoulez vous faire cette copie?", "VBXs Setup", MB_YESNO | MB_ICONQUESTION ) == IDYES ) AddSectionToCopyList( "SYSTEMVBX", WinDir ); } else { if ( MessageBox( "VBX Studio VBXs installation.\nAs you choose to install the VBXs, this setup program will also\n\ put a copy in the WINDOWS\\SYSTEM directory.\nDo you want to do this copy?", "VBXs Setup", MB_YESNO | MB_ICONQUESTION ) == IDYES ) AddSectionToCopyList( "SYSTEMVBX", WinDir ); } }*/ /////////////////////////////////////////////////////////// Specific ////////////////////////////////////////////////////////////////////// // We always add the [CTL3D] section: // This section contains CTL3DV2.DLL which must be installed in the SYSTEM directory if not found. /////////////////////////////////////////////////////////// Specific ////////////////////////////////////////////////////////////////////// GetSystemDirectory( TempPath.GetBuffer(255), 255 ); TempPath.ReleaseBuffer(); AddSectionToCopyList( "CTL3D", TempPath ); iResult = GoSetup( m_hWnd, TRUE ); // TRUE because we will use FINISH.EXE to clean up the temp dir when setup is complete if ( iResult == SETUP_SUCCESSFUL ) { /////////////////////////////////////////////////////////// Specific ////////////////////////////////////////////////////////////////////// // In this case we are using 2 MAIN.MAK files: One for the VB template and another // for the VC template: So we renamed the VB MAIN.MAK into VBMAIN.MAK to build this // setup. Now we have to rename this file if the user choose to install the VB template /////////////////////////////////////////////////////////// Specific ////////////////////////////////////////////////////////////////////// if ( Section[2].bSelected ) { SrcHelpFile = UserPath; SrcHelpFile += "TEMPLATE\\VB\\VBMAIN.MAK"; DestHelpFile = UserPath; DestHelpFile += "TEMPLATE\\VB\\MAIN.MAK"; if ( DoesFileExist( SrcHelpFile, TRUE ) ) { if ( DoesFileExist( DestHelpFile, TRUE ) ) DeleteFile( DestHelpFile ); RenameFile( SrcHelpFile, DestHelpFile ); } } /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// if ( Section[0].bSelected ) { if ( bInstallIcons ) { Message = ( iLanguage == LANGUAGE_FRENCH )?"Souhaitez vous installer les ic⌠nes de ":"Would you like to install the "; Message += szProductName; Message += ( iLanguage == LANGUAGE_FRENCH )?"?":" icons?"; if ( MessageBox( Message, Dialog1Title, MB_YESNO | MB_ICONQUESTION) == IDYES ) { // Maybe the icon installation will fail if ProgMan was replaced with a customized shell.... GetWindowsDirectory( szTempBatch, _MAX_PATH ); if ( szTempBatch[lstrlen( szTempBatch ) - 1 ] != '\\' ) lstrcat( szTempBatch, "\\" ); lstrcat( szTempBatch, "SYSTEM.INI" ); GetPrivateProfileString( "boot", "shell", "", szShellTest, 20, szTempBatch ); if ( !bWin4 ) if ( (lstrcmpi( szShellTest, "PROGMAN" ) != 0 ) && (lstrcmpi( szShellTest, "PROGMAN.EXE" ) != 0 ) ) { if ( iLanguage == LANGUAGE_FRENCH ) Message = "Le gestionnaire de programmes n' est pas prΘsent!\nL' installation des ic⌠nes peut Θchouer et une installation manuelle\ndes ic⌠nes sera peut Ωtre nΘcessaire."; else Message = "ProgMan not detected!\nIcons setup can fail, maybe a manual icons installation will be required."; MessageBox( Message, Dialog1Title, MB_OK | MB_ICONEXCLAMATION ); } for ( i = 0 ; i < NumberOfIcons ; i++ ) { IconPath = UserPath + IconEntry[i].szIconRelativeName; if ( DoesFileExist( IconPath, TRUE ) ) { if ( IconEntry[i].EIconText.GetLength() > 0 ) { AddItemToProgman( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName, IconPath, ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconName : IconEntry[i].EIconName, ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconText : IconEntry[i].EIconText ); ShowProgmanGroup( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName ); } else { AddProgmanGroup(( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName); ShowProgmanGroup( ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FGroupName : IconEntry[i].EGroupName ); AddProgmanItem( IconPath, ( iLanguage == LANGUAGE_FRENCH )? IconEntry[i].FIconName : IconEntry[i].EIconName ); } } } ShowWindow(SW_SHOWNORMAL ); } } } /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// if ( bMakeAssociation ) { for ( i = 0; i < NumberOfAsso; i++ ) { DestHelpFile = UserPath + WFAsso[i].szProgName; if ( DoesFileExist( DestHelpFile, TRUE )) CreateWinFileAssociation( WFAsso[i].szExt, DestHelpFile ); } } if ( szLaunch != "" ) { DestHelpFile = szLaunch; DestHelpFile = DestHelpFile.Right( 3 ); if ( DestHelpFile == "HLP" ) { DestHelpFile = UserPath + szLaunch; if ( DoesFileExist( DestHelpFile, TRUE )) { if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est terminΘe.\nVoulez vous parcourir le fichier\nd'aide maintenant?": "This installation is complete.\nWould you like to have a look at\nthe help file right now?", Dialog1Title ,MB_YESNO | MB_ICONQUESTION ) == IDYES ) ::WinHelp( NULL, DestHelpFile, HELP_CONTENTS, 0L ); } } else { DestHelpFile = UserPath + szLaunch; if ( DoesFileExist( DestHelpFile, TRUE )) { if ( MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est terminΘe.\nVoulez vous lancer le programme maintenant?": "This installation is complete.\nWould you like to have a look at the program right now?", Dialog1Title ,MB_YESNO | MB_ICONQUESTION ) == IDYES ) WinExec( DestHelpFile, SW_SHOW ); } } } }// Sucessful installation else { MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"L' installation est incomplΦte.\nPour utiliser ce produit, vous devrez l' installer α nouveau.": "Installation not complete.\nPlease to use this program, install it again.", Dialog1Title, MB_OK | MB_ICONEXCLAMATION ); } END: PostMessage( WM_CLOSE ); return TRUE; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Implementation - Generic // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CSetupApp // Application implementation // // ---------------------------------------------------------- // Message MAP // ---------------------------------------------------------- BEGIN_MESSAGE_MAP(CSetupApp, CWinApp) //{{AFX_MSG_MAP(CSetupApp) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG_MAP // Standard file based document commands END_MESSAGE_MAP() // ---------------------------------------------------------- // Application instanciation // ---------------------------------------------------------- CSetupApp NEAR theApp; // ---------------------------------------------------------- // Instance Initialization // ---------------------------------------------------------- BOOL CSetupApp::InitInstance() { bWin4 = SetupHasWin4Look(); if ( !bWin4 ) SetDialogBkColor(); // set dialog background color to gray // Always uses CTL3D with Win16 apps. Ctl3dRegister( AfxGetInstanceHandle() ); // See CTL3D API Ctl3dAutoSubclass( AfxGetInstanceHandle() ); // See CTL3D API EnableVBX(); // Initialize VBX support UserConfigSize = 0L; // We need to retrieve the COMMAND line arguments if (m_lpCmdLine[0] != '\0') { lstrcpy( (LPSTR)szOriginalPath, m_lpCmdLine ); // has replaced the old <ExtractParameter> function if ( GetWindowsDirectory( (LPSTR)szTempSetupPath, _MAX_PATH ) ) { if ( szTempSetupPath[ lstrlen( szTempSetupPath )-1] == '\\' ) lstrcat( (LPSTR)szTempSetupPath, "~SSETUP\\" ); else lstrcat( (LPSTR)szTempSetupPath, "\\~SSETUP\\" ); } else { ::MessageBox( NULL, "Internal error.\nCan' t find WINDOWS directory.", Dialog1Title, MB_OK | MB_ICONSTOP ); return FALSE; } } else { ::MessageBox( NULL, "This program cannot be launched directly.\nSETUP.EXE must be used to to this.\n", Dialog1Title, MB_OK | MB_ICONSTOP ); return FALSE; } CFirst boite1; boite1.DoModal(); if ( bIsSetupOK ) { CMain MainBox; MainBox.DoModal(); } return TRUE; } // ---------------------------------------------------------- // Intance Exit ( like WEP ) // ---------------------------------------------------------- int CSetupApp::ExitInstance() { Ctl3dUnregister( AfxGetInstanceHandle() ); DeleteSystemDir( ); return CWinApp::ExitInstance(); } // ---------------------------------------------------------- // VBX Event MAP (none) // ---------------------------------------------------------- //{{AFX_VBX_REGISTER_MAP() //}}AFX_VBX_REGISTER_MAP ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CFirst dialog - Splash style and initialization managment // // ---------------------------------------------------------- // Constructor // ---------------------------------------------------------- CFirst::CFirst(CWnd* pParent /*=NULL*/) : CDialog(CFirst::IDD, pParent) { //{{AFX_DATA_INIT(CFirst) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } // ---------------------------------------------------------- // Data Exchange // ---------------------------------------------------------- void CFirst::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CFirst) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } // ---------------------------------------------------------- // Message MAP // ---------------------------------------------------------- BEGIN_MESSAGE_MAP(CFirst, CDialog) //{{AFX_MSG_MAP(CFirst) ON_MESSAGE( PM_FIRST, OnFirstPrivate ) ON_WM_CLOSE() ON_WM_DESTROY() //}}AFX_MSG_MAP END_MESSAGE_MAP() // ---------------------------------------------------------- // WM_INITDIALOG // Interface managment and Call OnFirstPrivate // ---------------------------------------------------------- BOOL CFirst::OnInitDialog() { CDialog::OnInitDialog(); if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) { if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) { lFont.lfWeight = FW_NORMAL; if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) SendDlgItemMessage( IDC_STATIC1, WM_SETFONT, (WPARAM) hfontDlg, 0); } } SetWindowText( Dialog1Title ); SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) ); Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL ); CenterDialogBox( m_hWnd ); BringWindowToTop(); FirstCanClose = FALSE; //::PostMessage( m_hWnd, PM_FIRST, 0, 0L ); SendMessage( PM_FIRST ); return TRUE; // return TRUE unless you set the focus to a control } // ---------------------------------------------------------- // PM_FIRST private message function // Guess the user Language // Set interface // Call SetupInitialize // ---------------------------------------------------------- afx_msg LRESULT CFirst::OnFirstPrivate( WPARAM wParam, LPARAM lParam ) { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// static char far szTemp[6]; // Have a look in WIN.INI for Language detection ::GetProfileString( "intl", "sLanguage", "", (LPSTR)szTemp, 4 ); AnsiUpper( szTemp ); if (lstrcmp( szTemp, "FRA" )== 0 ) iLanguage = LANGUAGE_FRENCH; else iLanguage = LANGUAGE_ENGLISH; bIsSetupOK = SetupInitialize( szYourName, szYourPassword, iLanguage, (LPSTR)szOriginalPath, (LPSTR)szTempSetupPath ); SetupSetTitle( szSetupBoxTitle ); if ( bUseSharedBatch ) { CString szUserBatchFile, szUserBatchDir; GetWindowsDirectory( szUserBatchFile.GetBuffer(182), 180 ); szUserBatchFile.ReleaseBuffer(); szUserBatchFile = szUserBatchFile.Left( 3 ); szUserBatchDir = szUserBatchFile; szUserBatchFile += ( szBatchFile != "") ? szBatchFile : "SYSSETUP.TMP\\SYSSETUP.BAT" ; szUserBatchDir += ( szBatchDir != "")? szBatchDir : "SYSSETUP.TMP\\"; SetSharedBatchFile( szUserBatchFile, szUserBatchDir ); } SetPatternBrushStandard( iBackgroundPaper ); SetupSetBeepMode ( bBeepMode ); // Select or not the BEEP mode SetVerifyMode( bVerifyMode ); // Select or unselect the File Size Verification mode ( if size is bad, setup will abort ). // ---- panel 1 ---- if ( iPanel1Bitmap == 0 ) { if ( szPanel1Title.GetLength() > 0 ) { SetTextLogo( szPanel1Title, szPanel1TitleFont, iPanel1TitleSize, lPanel1TitleColor, bPanel1Title3D, bPanel1TitleBold ); if ( szPanel1Detail.GetLength() > 0 ) SetTextDetail( szPanel1Detail, szPanel1DetailFont, iPanel1DetailSize, lPanel1DetailColor, bPanel1Detail3D, bPanel1DetailBold ); SetLogoType( TRUE ); } } else { SetLogo( AfxGetInstanceHandle(), iPanel1Bitmap ); SetLogoType( FALSE ); } FirstCanClose = TRUE; PostMessage( WM_CLOSE ); return TRUE; } // ---------------------------------------------------------- // WM_CLOSE // Do not close during Initialization // ---------------------------------------------------------- void CFirst::OnClose() { if ( FirstCanClose ) CDialog::OnClose(); else MessageBeep( -1 ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CMain dialog - We use this dialog box as the main screen // // ---------------------------------------------------------- // Constructor // ---------------------------------------------------------- CMain::CMain(CWnd* pParent /*=NULL*/) : CDialog(CMain::IDD, pParent) { //{{AFX_DATA_INIT(CMain) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } // ---------------------------------------------------------- // Data Exchange // ---------------------------------------------------------- void CMain::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMain) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } // ---------------------------------------------------------- // Message MAP // ---------------------------------------------------------- BEGIN_MESSAGE_MAP(CMain, CDialog) //{{AFX_MSG_MAP(CMain) ON_MESSAGE( PM_FIRST2, OnFirstPrivate ) ON_MESSAGE( SN_NEWDISKREQUIRED, OnNewDisk ) ON_WM_PAINT() ON_WM_NCPAINT() //}}AFX_MSG_MAP END_MESSAGE_MAP() // ---------------------------------------------------------- // WM_INITDIALOG // Call CMain::OnFirstPrivate // ---------------------------------------------------------- BOOL CMain::OnInitDialog() { CDialog::OnInitDialog(); SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) ); SetWindowText( Dialog1Title ); BringWindowToTop(); PostMessage( PM_FIRST2 ); return TRUE; // return TRUE unless you set the focus to a control } // ---------------------------------------------------------- // SN_NEWDISKREQUIRED // You will receive this message // when CSetup shows the New Disk // Required dialog box. // ---------------------------------------------------------- afx_msg LRESULT CMain::OnNewDisk( WPARAM wParam, LPARAM lParam ) { return TRUE; }; // ---------------------------------------------------------- // WM_PAINT // Call ShowMainWindow CSETUP.DLL function // ---------------------------------------------------------- void CMain::OnPaint() { CPaintDC dc(this); RedrawWindow( NULL, NULL, RDW_NOFRAME | RDW_NOERASE ); // To avoid flashing ShowMainWindow( m_hWnd ); // The main function wich paint your window as a Setup Like window ( for PAINT ) RedrawWindow( NULL, NULL, RDW_NOFRAME | RDW_NOERASE ); // To avoid flashing } // ---------------------------------------------------------- // WM_PAINT // Call ShowMainWindow CSETUP.DLL function // ---------------------------------------------------------- void CMain::OnNcPaint() { RedrawWindow( NULL, NULL, RDW_NOERASE | RDW_VALIDATE ); // To avoid flashing ShowMainWindow( m_hWnd ); // The main function wich paint your window as a Setup Like window ( for PAINT ) RedrawWindow( NULL, NULL, RDW_NOERASE | RDW_VALIDATE ); // To avoid flashing } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CChoice1 dialog allows the user to choose Language and main Destination PATH // // ---------------------------------------------------------- // Constructor // ---------------------------------------------------------- CChoice1::CChoice1(CWnd* pParent /*=NULL*/) : CDialog(CChoice1::IDD, pParent) { //{{AFX_DATA_INIT(CChoice1) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } // ---------------------------------------------------------- // Data Exchange ( not used ) // ---------------------------------------------------------- void CChoice1::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CChoice1) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } // ---------------------------------------------------------- // Message MAP // ---------------------------------------------------------- BEGIN_MESSAGE_MAP(CChoice1, CDialog) //{{AFX_MSG_MAP(CChoice1) ON_BN_CLICKED(IDC_RADIOENGLISH, OnClickedRadioenglish) ON_BN_CLICKED(IDC_RADIOFRENCH, OnClickedRadiofrench) ON_EN_CHANGE(IDC_EDITSRCPATH, OnChangeEditsrcpath) ON_WM_DESTROY() ON_BN_CLICKED(IDC_BROWSE, OnBrowse) //}}AFX_MSG_MAP END_MESSAGE_MAP() // ---------------------------------------------------------- // WM_COMMAND:ONLANGUAGE // Change the language // ---------------------------------------------------------- void CChoice1::OnClickedRadioenglish() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// SetupSetLanguage( LANGUAGE_ENGLISH ); iLanguage = LANGUAGE_ENGLISH; SetDlgItemText( IDC_GROUPLANGUAGE, "Language... "); CString ProductName; ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire o∙ vous souhaitez installer ": "Please, give the directory in which you would like to install "; ProductName += szProductName; ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur' OK'":" and click on 'OK'"; SetDlgItemText( IDC_TEXTE, ProductName ); SetDlgItemText( IDCANCEL, "&Abort"); } // ---------------------------------------------------------- // WM_COMMAND:ONLANGUAGE // Change the language // ---------------------------------------------------------- void CChoice1::OnClickedRadiofrench() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// SetupSetLanguage( LANGUAGE_FRENCH ); iLanguage = LANGUAGE_FRENCH; SetDlgItemText( IDC_GROUPLANGUAGE, "Votre langage... "); CString ProductName; ProductName = ( iLanguage == LANGUAGE_FRENCH )? "Indiquer le rΘpertoire o∙ vous souhaitez installer ": "Please, give the directory in which you would like to install "; ProductName += szProductName; ProductName += ( iLanguage == LANGUAGE_FRENCH )?" et cliquer sur 'OK'":" and click on 'OK'"; SetDlgItemText( IDC_TEXTE, ProductName ); SetDlgItemText( IDCANCEL, "&Abandonner"); } // ---------------------------------------------------------- // WM_COMMAND:ONPATH // Change the path // ---------------------------------------------------------- void CChoice1::OnChangeEditsrcpath() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// CString TempDestName; GetDlgItemText( IDC_EDITSRCPATH, TempDestName.GetBuffer( 162 ), 160 ); TempDestName.ReleaseBuffer(); if ( TempDestName.GetLength() < 1 ) GetDlgItem( IDOK)->EnableWindow( FALSE ); else GetDlgItem( IDOK)->EnableWindow( TRUE ); } // ---------------------------------------------------------- // WM_COMMAND:ONBROWSE // Change the path using a box // ---------------------------------------------------------- void CChoice1::OnBrowse() { CString szDirValue; char szBuffer[_MAX_PATH]; GetDlgItem( IDC_EDITSRCPATH )->GetWindowText( szDirValue ); lstrcpy( szBuffer, (LPCSTR)szDirValue ); SetupBrowseDir( m_hWnd, szBuffer ); // 2.4 GetDlgItem( IDC_EDITSRCPATH )->SetWindowText( (LPCSTR)szBuffer ); GetDlgItem( IDC_EDITSRCPATH )->SetFocus(); GetDlgItem( IDC_EDITSRCPATH )->SendMessage( EM_SETSEL, (WPARAM)TRUE, MAKELONG( 0, -1L )); } // ---------------------------------------------------------- // WM_COMMAND:ONOK // Check the path thanks to // CSETUP functions // ---------------------------------------------------------- void CChoice1::OnOK() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// CString TempDestName, strKeep; GetDlgItemText( IDC_EDITSRCPATH, TempDestName.GetBuffer(162), 160 ); TempDestName.ReleaseBuffer(); if ( !IsFileName( TempDestName, FILENAME_DIRWITHSLASH, CHECK_ROOTDIRSEXIST) ) { FormatFileNameValid( TempDestName, TRUE, strKeep.GetBuffer(_MAX_PATH)); strKeep.ReleaseBuffer(); SetDlgItemText( IDC_EDITSRCPATH, strKeep ); } if ( IsFileName( TempDestName, FILENAME_DIRWITHSLASH, CHECK_ROOTDIRSEXIST) ) { UserPath = TempDestName; CDialog::OnOK(); } else { MessageBox( ( iLanguage == LANGUAGE_FRENCH )?"Le rΘpertoire mentionnΘ n' est pas valide.\nSi vous avez mentionnΘ des sous-rΘpertoires,\nceux-ci doivent exister.\n": "Directory name is not valid.\nIf you want to use sub-directories\nthey must exist.\n", Dialog1Title, MB_OK | MB_ICONEXCLAMATION ); (CEdit*)(GetDlgItem( IDC_EDITSRCPATH))->SetFocus(); ((CEdit*)(GetDlgItem( IDC_EDITSRCPATH)))->SetSel( 0, -1 ); } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // CChoice2 dialog allows the user to select files to install // // ---------------------------------------------------------- // Constructor // ---------------------------------------------------------- CChoice2::CChoice2(CWnd* pParent /*=NULL*/) : CDialog(CChoice2::IDD, pParent) { //{{AFX_DATA_INIT(CChoice2) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } // ---------------------------------------------------------- // Data Exchange ( Not use ) // ---------------------------------------------------------- void CChoice2::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CChoice2) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP } // ---------------------------------------------------------- // Message MAP // ---------------------------------------------------------- BEGIN_MESSAGE_MAP(CChoice2, CDialog) //{{AFX_MSG_MAP(CChoice2) ON_BN_CLICKED(IDB_CHANGEPATH, OnClickedChangepath) ON_BN_CLICKED(IDC_CHECK1, OnClickedCheck1) ON_BN_CLICKED(IDC_CHECK2, OnClickedCheck2) ON_BN_CLICKED(IDC_CHECK3, OnClickedCheck3) ON_BN_CLICKED(IDC_CHECK4, OnClickedCheck4) ON_BN_CLICKED(IDC_CHECK5, OnClickedCheck5) ON_BN_CLICKED(IDC_CHECK6, OnClickedCheck6) ON_BN_CLICKED(IDC_CHECK7, OnClickedCheck7) ON_BN_CLICKED(IDC_CHECK8, OnClickedCheck8) ON_BN_CLICKED(IDC_CHECK9, OnClickedCheck9) ON_BN_CLICKED(IDC_CHECK10, OnClickedCheck10) ON_BN_CLICKED(IDC_CHECK11, OnClickedCheck11) ON_BN_CLICKED(IDC_CHECK12, OnClickedCheck12) ON_BN_CLICKED(IDC_CHECK13, OnClickedCheck13) ON_BN_CLICKED(IDC_CHECK14, OnClickedCheck14) ON_BN_CLICKED(IDC_CHECK15, OnClickedCheck15) ON_WM_DESTROY() //}}AFX_MSG_MAP END_MESSAGE_MAP() // ---------------------------------------------------------- // WM_INITDIALOG // Check boxes managment // ---------------------------------------------------------- BOOL CChoice2::OnInitDialog() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// register int i=0; CDialog::OnInitDialog(); SetWindowText( Dialog3Title ); if ((hfontDlg = (HFONT) SendMessage(WM_GETFONT) )) { if (::GetObject(hfontDlg, sizeof(LOGFONT), (LPSTR) &lFont)) { lFont.lfWeight = FW_NORMAL; if (hfontDlg = CreateFontIndirect((LPLOGFONT) &lFont)) { SendDlgItemMessage( IDC_CHECK1, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK2, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK3, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK4, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK5, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK6, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK7, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK8, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK9, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK10, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK11, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK12, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK13, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK14, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_CHECK15, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K1, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K2, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K3, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K4, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K5, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K6, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K7, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K8, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K9, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K10, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K11, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K12, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K13, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K14, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_K15, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_GROUP, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_TEXTECSIZE, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_KCONFIG, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_TEXTETOTALSIZE, WM_SETFONT, (WPARAM) hfontDlg, 0); SendDlgItemMessage( IDC_KTOTAL, WM_SETFONT, (WPARAM) hfontDlg, 0); } } } // We resize the dialog box depending of number of items RECT r, r2, r3; GetWindowRect( &r3 ); GetDlgItem( IDC_CHECK1 )->GetWindowRect( &r2 ); GetDlgItem( IDC_GROUP )->GetWindowRect( &r ); GetDlgItem( IDC_GROUP )->SetWindowPos( NULL, 0,0, r.right-r.left, r.bottom - ( ((15- NumberOfSections)<9?15- NumberOfSections:9 ) * (r2.bottom-r2.top) )-r.top-12, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE ); GetDlgItem( IDC_TEXTECSIZE )->GetWindowRect( &r ); GetDlgItem( IDC_TEXTECSIZE )->SetWindowPos( NULL, r.left - r3.left, 2 + r.top -( ( (16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top-20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE ); GetDlgItem( IDC_KCONFIG )->GetWindowRect( &r ); GetDlgItem( IDC_KCONFIG )->SetWindowPos( NULL, r.left- r3.left, 2 + r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE ); GetDlgItem( IDC_TEXTETOTALSIZE )->GetWindowRect( &r ); GetDlgItem( IDC_TEXTETOTALSIZE )->SetWindowPos( NULL, r.left- r3.left, 2 + r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE ); GetDlgItem( IDC_KTOTAL )->GetWindowRect( &r ); GetDlgItem( IDC_KTOTAL )->SetWindowPos( NULL, r.left- r3.left, 2 + r.top -( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top -20 , 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE ); SetWindowPos( NULL, 0,0, r3.right-r3.left, r3.bottom - ( ((16 -NumberOfSections)<10?16-NumberOfSections:10) * (r2.bottom-r2.top) )-r3.top+20, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOMOVE ); // Set the dialog box value CString TempLabel; UserConfigSize = 0L; for ( i = 0 ; i < NumberOfSections ; i++ ) { if ( Section[i].Name.GetLength()> 0 ) { TempLabel = ( iLanguage == LANGUAGE_FRENCH)?Section[i].FLabel : Section[i].ELabel; if ( TempLabel.GetLength() > 0 ) { GetDlgItem( 120 + i )->ShowWindow( SW_SHOW ); GetDlgItem( 150 + i )->ShowWindow( SW_SHOW ); SetDlgItemText( 120 + i, TempLabel ); // --> label CheckDlgButton( 120 + i, Section[i].bSelected ); if ( Section[i].bSelected ) { UserConfigSize += Section[i].lSize; _ltoa( UserConfigSize, TempLabel.GetBuffer(12), 10 ); TempLabel.ReleaseBuffer(); TempLabel += " K"; SetDlgItemText( IDC_KCONFIG, TempLabel ); _ltoa( Section[i].lSize, TempLabel.GetBuffer(10), 10 ); TempLabel.ReleaseBuffer(); } else TempLabel = "0"; TempLabel += " K"; SetDlgItemText( 150 + i, TempLabel ); } } } SetClassWord( m_hWnd, GCW_HICON, (WORD)( (AfxGetApp())->LoadIcon( IDR_MAINFRAME )) ); Ctl3dSubclassDlg( m_hWnd, CTL3D_ALL ); CenterDialogBox( m_hWnd ); BringWindowToTop(); if ( iLanguage == LANGUAGE_FRENCH ) { SetDlgItemText( IDC_GROUP, "Installer... "); SetDlgItemText( IDC_TEXTECSIZE, "Taille de la sΘlection:"); SetDlgItemText( IDC_TEXTETOTALSIZE, "Espace disponible:"); SetDlgItemText( IDB_CHANGEPATH, "&RΘpertoire..."); SetDlgItemText( IDOK, "OK" ); SetDlgItemText( IDCANCEL, "Aba&ndonner" ); } _ltoa( AskForDriveSpace( GetDriveNumber( UserPath )), TempLabel.GetBuffer(15), 10 ); TempLabel.ReleaseBuffer(); TempLabel += " K"; SetDlgItemText( IDC_KTOTAL, TempLabel ); GetDlgItem( IDC_CHECK1 )->SetFocus(); return FALSE; } // ---------------------------------------------------------- // WM_COMMAND:ONPATH // Save the configuration and // Call the CChoice1 Dialog box // ---------------------------------------------------------- void CChoice2::OnClickedChangepath() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// register int i = 0; for ( i = 0 ; i < NumberOfSections ; i++ ) Section[i].bSelected = IsDlgButtonChecked( 120 + i ); EndDialog( IDCHANGEPATH ); } // ---------------------------------------------------------- // WM_COMMAND:ONOK // Check available disk size // ---------------------------------------------------------- void CChoice2::OnOK() { /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// register int i = 0; if ( UserConfigSize > AskForDriveSpace( GetDriveNumber( UserPath )) ) { if ( iLanguage == LANGUAGE_FRENCH ) MessageBox("Il n' y a pas assez d' espace libre\nsur l' unitΘ de destination pour installer\nla sΘlection que vous avez choisie.\n\nVeuillez modifier votre sΘlection ou changer de rΘpertoire." , Dialog1Title, MB_OK | MB_ICONEXCLAMATION ); else MessageBox("There is not enough free space\nto install the selected files.\n\nPlease, change your selection or the destination directory." , Dialog1Title, MB_OK | MB_ICONEXCLAMATION ); } else CDialog::OnOK(); } /////////////////////////////////////////////////////////// Generic ////////////////////////////////////////////////////////////////////// // ---------------------------------------------------------- // WM_COMMAND:ONCHECKxx ? // Check Box management // ---------------------------------------------------------- void CChoice2::OnClickedCheck1() { HandleCheckBox( 1 ); } void CChoice2::OnClickedCheck2() { HandleCheckBox( 2 ); } void CChoice2::OnClickedCheck3() { HandleCheckBox( 3 ); } void CChoice2::OnClickedCheck4() { HandleCheckBox( 4 ); } void CChoice2::OnClickedCheck5() { HandleCheckBox( 5 ); } void CChoice2::OnClickedCheck6() { HandleCheckBox( 6 ); } void CChoice2::OnClickedCheck7() { HandleCheckBox( 7 ); } void CChoice2::OnClickedCheck8() { HandleCheckBox( 8 ); } void CChoice2::OnClickedCheck9() { HandleCheckBox( 9 ); } void CChoice2::OnClickedCheck10() { HandleCheckBox( 10 ); } void CChoice2::OnClickedCheck11() { HandleCheckBox( 11 ); } void CChoice2::OnClickedCheck12() { HandleCheckBox( 12 ); } void CChoice2::OnClickedCheck13() { HandleCheckBox( 13 ); } void CChoice2::OnClickedCheck14() { HandleCheckBox( 14 ); } void CChoice2::OnClickedCheck15() { HandleCheckBox( 15 ); } void CChoice2::HandleCheckBox( int iD ) { CString Temp; if ( IsDlgButtonChecked( 120 + iD - 1 )) { UserConfigSize += Section[iD - 1].lSize; _ltoa( Section[iD - 1].lSize, Temp.GetBuffer( 12 ), 10 ); Temp.ReleaseBuffer(); Temp += " K"; SetDlgItemText( 150 + iD-1 , Temp ); Section[iD - 1].bSelected = TRUE; } else { UserConfigSize -= Section[iD - 1].lSize; SetDlgItemText(150 + iD-1, "0 K" ); Section[iD - 1].bSelected = FALSE; } _ltoa( UserConfigSize, Temp.GetBuffer( 12 ), 10 ); Temp.ReleaseBuffer(); Temp += " K"; SetDlgItemText( IDC_KCONFIG, Temp ); } void CChoice2::OnDestroy() { CDialog::OnDestroy(); ::DeleteObject( hfontDlg ); } void CChoice1::OnDestroy() { CDialog::OnDestroy(); ::DeleteObject( hfontDlg ); } void CFirst::OnDestroy() { CDialog::OnDestroy(); ::DeleteObject( hfontDlg ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Local functions //////////////////////////////////////////////// END OF THIS FILE ////////////////////////////////////////////////////////////////