home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-06-25 | 36.4 KB | 1,118 lines |
- // DIALOGS.C - The code for the dialog boxes
-
- /*****************************************************************************
-
- CenterDialog Centers a dialog box on the screen and changes
- the caption to relfect the "PACKAGENAME" field
- if the .INF file.
-
- ReallyCancel Displays a YES/NO MessageBox asking the user
- if they *really* want to cancel the app. If the
- user replies NO, then the focus of the message
- box is put on the IDOK button of the calling
- dialog.
-
- StartUpDlgProc This displays a dialog box saying "Reading .INF
- File...", and it kills itself when done. The
- timer code is to allow the message queue to clear
- and paint the dialog box. Also, it ensures the
- dialog box lives for at least 1/2 second, so the
- human can read it.
-
- FixupDirectory Checks the given filename to be sure that at least
- a drive letter has been indicated, and removes
- a trailing backslah character if there is one.
-
- InstallDirDlgProc Displays a dialog box that asks the user which
- directory to install the apps in. Once user
- clicks IDOK button, the app tries to create the
- directory, and any child directories from the
- .INF file. If there was a failure, the dialog
- warns the user and lets them try again. Calls
- the DosMakeDir function.
-
- IndexGivenIndex This routine converts a virtual (listbox position
- index) into a physical index for the FileInfo
- data structure. Essentially, it searches the
- FileInfo structure for the first occurence of
- the Index field matching the given index. When
- this index is found, the physical array index
- of this FileInfo record is given.
-
- AddItem Sets or Resets the bSelected field in the FileInfo
- structure, given the virtual index, and it adds
- or deletes the item from the listbox. If the item's
- flags indicate that extra invisble files must also
- be selected or deseleted, then this routine will
- catch them also.
-
- InPreviousSelection Since the Multiselect listbox does not provide a
- way to determine the "current" selection, a few
- routines, like this one, must be used to figure
- the "lone star" item that was most recently
- selected. The theory is: Keep a data strcuture
- that knows al the items selected. When a new item
- is selected, check all the items selected versus
- the data strcuture, which should contain the previous
- state. One item in the data structure should be
- different, this is the "lone star". This particular
- routine tells you if an index is in an array.
-
- SelectDlgProc This dialog allows the user to select or unselect
- file groups for installation. This dialog is
- brought up only if the bSelected field of ANY
- FileInfo element is FALSE (which means the .INF
- file flags were not ALL "R").
-
- InsertDiskDlgProc If there is any type of file copying error,
- such as a sharing violation, copy error, file
- not found, ect, this dialog box asks the user
- to insert the install disk in the drive indicated
- in an edit control. Due to a problem with Kernel,
- it is not possible to tell the user which type of
- erorr occured, only that *an* erorr occurred.
-
- CreateSourceDir Given a source directory reference number, this
- routine builds a null-terminated string that
- contains the fully qualified directory name, along
- with the subdirectory on the installation disk.
-
- CreateSourceDisk Same as CreateSourceDir, except the subdirectory
- on the installation disk is not included. This
- is displayed in the InsertDiskDlgProc's eit control.
-
- ChangeSourceDir If the user indicates a new installation disk, this
- routine changes the DiskInfo data structure so
- the program doesn't prompt the user for every file
- on the disk.
-
- CreateDestDir Given a destinataion directory reference number,
- this routine builds a null-terminated string that
- contains the fully qualified directory name, along
- with any child directories indicated in the
- [directories] section of the .INF file.
-
- FileCopyDlgProc This dialog displays the status of the file copying
- process, with the gas gauge. If there is a file
- copying error, the InsetDiskDlgProc is called.
-
- GetNextFileNumber This routine finds the nect application that needs
- to be installed in the Program Manager. If the
- app is to be installed in a new group, then the
- group is created.
-
- IconCopyDlgProc This dialog displays the status of the icon adding
- process, with the gas gauge. The user can cancel
- this process (foolishly, of course).
-
- *****************************************************************************/
-
- #include "windows.h"
-
- #include <dos.h>
-
- #include "bincode.h"
- #include "bincode1.h"
- #include "gasgauge.h"
-
- char szNewDisk[65];
- char szNewDiskName[65];
-
- extern LONG FAR PASCAL ResetController ( void );
-
- /********************************************************************/
- void CenterDialog ( HWND hDlg )
- {
- RECT rc;
-
- GetWindowRect(hDlg,&rc);
- SetWindowPos(hDlg,NULL,
- (GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2,
- (GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 3,
- 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
-
- SetWindowText ( hDlg, (LPSTR)szCaptionName );
- }
- /********************************************************************/
- void CenterDialogAtBottom ( HWND hDlg )
- {
- RECT rc;
-
- GetWindowRect(hDlg,&rc);
- SetWindowPos(hDlg,NULL,
- (GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2,
- (GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)),
- 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
-
- SetWindowText ( hDlg, (LPSTR)szCaptionName );
- }
- /********************************************************************/
- BOOL ReallyCancel ( HWND hDlg )
- {
- BOOL retval;
-
- retval = (IDYES == MessageBox ( hDlg,
- "Do you Really Want to exit Setup?",
- "Setup",
- MB_ICONQUESTION | MB_YESNO ));
- if (!retval) SetFocus ( GetDlgItem ( hDlg, IDOK ));
- return retval;
- }
- /********************************************************************/
- DLGPROC StartUpDlgProc ( DIALOG_PARAMS )
- {
- switch (msg)
- {
- case WM_INITDIALOG:
-
- FillGlobalInfoStructures ( ); // Need this for caption title...
- CenterDialog ( hDlg );
- SetTimer ( hDlg, 1, 500, NULL );
- return FALSE;
-
- case WM_TIMER:
-
- KillTimer ( hDlg, 1 );
-
- FillDiskInfoStructures (); // Get [disk] info read in
- FillFileInfoStructures (); // Get [apps] info read in
- FillDirInfoStructures (); // Get [directories] info read in
- FillProgmanInfoStructures (); // Get [progman] info read in
-
- PostMessage ( hDlg, WM_COMMAND, IDCANCEL, 0L );
- break;
-
- case WM_COMMAND:
-
- if (wParam == IDCANCEL)
- EndDialog (hDlg, TRUE);
- break;
-
- default:
-
- return FALSE;
-
- } // end switch
-
- return TRUE;
- }
- /********************************************************************/
- BOOL FixupDirectory ( char* DirName )
- {
- int Len = lstrlen ( (LPSTR)DirName );
-
- if ( '\\' == DirName[Len-1] )
- DirName[Len-1] = 0; // whack off the backslash
-
- if (Len < 4) return FALSE; // Gotta have at least a drive and a directory!
-
- if (
- (!isalpha(DirName[0])) || // Make sure the drive letter
- (DirName[1] != ':') || // colon
- (DirName[2] != '\\') // backslash is there
- ) return FALSE;
-
- return TRUE; // Looks semi-okay, let's let
- // DOS take it from here...
- }
- /********************************************************************/
- DLGPROC InstallDirDlgProc ( DIALOG_PARAMS )
- {
- char ChildDir[64];
- int i;
- BOOL Sucess;
-
- switch (msg)
- {
- case WM_INITDIALOG:
-
- CenterDialog ( hDlg );
- SetDlgItemText ( hDlg, IDD_EDIT, (LPSTR)DirInfo[0].szDirectory );
- SetDlgItemText ( hDlg, IDD_APPNAME, (LPSTR)szPackageName );
- SetFocus ( GetDlgItem ( hDlg, IDD_EDIT ));
- SendDlgItemMessage ( hDlg, IDD_EDIT, EM_LIMITTEXT, 53, 0L);
- SendDlgItemMessage ( hDlg, IDD_EDIT, EM_SETSEL, 0, MAKELONG (0,32767));
- return FALSE;
-
- case WM_COMMAND:
-
- switch (wParam)
- {
- case IDCANCEL:
-
- if (ReallyCancel( hDlg ))
- EndDialog ( hDlg, FALSE );
- break;
-
- case IDOK:
-
- GetDlgItemText ( hDlg, IDD_EDIT, (LPSTR)DirInfo[0].szDirectory, 63 );
- if (FixupDirectory(DirInfo[0].szDirectory))
- {
- if (DosMakeDir((LPSTR)DirInfo[0].szDirectory)) // If parent dir possible
- {
- Sucess = TRUE;
- for ( i = 1; ((i < NumDirs) && (Sucess)); i++ ) // make the children if any
- {
- sprintf ( ChildDir, "%s%s", DirInfo[0].szDirectory, DirInfo[i].szDirectory );
- Sucess = DosMakeDir((LPSTR)ChildDir);
- }
- if (Sucess)
- EndDialog ( hDlg, TRUE );
- else
- {
- MessageBox ( hDlg, "Setup is unable to create the sub-directory. "
- "Please choose a different directory, or check "
- "your hard disk and run Setup again.",
- "Setup", MB_OK | MB_ICONHAND );
- SetFocus ( GetDlgItem ( hDlg, IDD_EDIT ));
- }
- }
- else
- {
- MessageBox ( hDlg, "Setup was unable to create the directory. Please "
- "enter another directory, or check your hard disk "
- "and run Setup again.",
- "Setup", MB_OK | MB_ICONHAND );
- SetFocus ( GetDlgItem ( hDlg, IDD_EDIT ));
- }
- }
- else
- {
- MessageBox ( hDlg, "Please enter a valid directory name, with drive "
- "letter and full path. For example: C:\WEP",
- "Setup", MB_OK | MB_ICONHAND );
- SetFocus ( GetDlgItem ( hDlg, IDD_EDIT ));
- }
- break;
-
- default:
-
- return FALSE;
- }
- break;
-
- default:
-
- return FALSE;
-
- } // end switch
-
- return TRUE;
- }
-
- #ifdef SIMPLESETUP
-
-
- // In the simple setup, this routine will NEVER get called, this is only
- // here so we dont have the unresolved export in the .DEF file.
-
- DLGPROC SelectDlgProc( DIALOG_PARAMS )
- {
- return FALSE;
- }
-
- #endif
-
- #ifdef COMPLEXSETUP
-
- /*****************************************************************************/
- int IndexGivenIndex ( int Index )
- {
- int i;
-
- for ( i = 0 ; i < NumFiles; i++ )
- if (FileInfo[i].Index == Index) return i;
- return 0;
- }
- /*****************************************************************************/
- void AddItem ( HWND hSourceListBox, HWND hDestListBox,
- int Index, BOOL bRemove )
- {
- char szString[80], i;
- int NumToBackTrack, StartingSpot;
-
- if (Index == LB_ERR )
- {
- MessageBeep (0);
- return;
- }
-
- if (bRemove)
- {
- SendMessage (hDestListBox, LB_GETTEXT, Index, (LONG)(LPSTR)szString );
- // Locate the string in the source listbox
- Index = SendMessage ( hSourceListBox, LB_FINDSTRING, -1, (LONG)(LPSTR)szString );
-
- StartingSpot = IndexGivenIndex(Index);
- for ( i = StartingSpot;
- i <= StartingSpot+FileInfo[StartingSpot].ExtraFiles;
- i++)
- FileInfo[i].bSelected = FALSE;
-
- // Delete the string
- Index = SendMessage ( hDestListBox, LB_FINDSTRING, -1, (LONG)(LPSTR)szString );
- if (Index != LB_ERR)
- SendMessage (hDestListBox, LB_DELETESTRING, Index, 0L );
- else
- MessageBeep (0);
- return;
- }
- else
- {
- SendMessage (hSourceListBox, LB_GETTEXT, Index, (LONG)(LPSTR)szString );
- StartingSpot = IndexGivenIndex(Index);
- if (!FileInfo[StartingSpot].bSelected)
- SendMessage (hDestListBox, LB_ADDSTRING, Index, (LONG)(LPSTR)szString );
- for ( i = StartingSpot; i <= StartingSpot+FileInfo[StartingSpot].ExtraFiles; i++)
- {
- FileInfo[i].bSelected = TRUE;
- }
- }
- }
- /*****************************************************************************/
- //
- // Returns TRUE if SourceSelections[i] is also in PreviousSelections
-
-
- BOOL InPreviousSelection(int *SourceSelections, int *PreviousSourceSelections,
- int i, int SizePreviousSource )
- {
- int j;
-
- for ( j = 0; j < SizePreviousSource; j++ )
- if (PreviousSourceSelections[j] == SourceSelections[i]) return TRUE;
-
- return FALSE;
- }
- /******************************************************************************\
- *
- * Select Files Dialog
- * |
- \******************************************************************************/
- DLGPROC SelectDlgProc( DIALOG_PARAMS )
- {
- static int i, j, index, LastToAdd, viscount, counter;
- static HWND hSourceList, hDestList, hDescriptionBox;
- HBRUSH hGrayBrush;
- static LONG SumTotal, TotalBytes, AvailableBytes;
- char szStatus[80];
- char szString[80];
- int tabs[2];
-
- static int NumSourceSelections;
- static int SourceSelections[MAXFILES];
-
- static int PreviousNumSourceSelections;
- static int PreviousSourceSelections[MAXFILES];
-
- static int NumDestSelections;
- static int DestSelections[MAXFILES];
-
- int Selections[MAXFILES];
-
- switch (msg)
- {
- case WM_INITDIALOG:
-
- CenterDialog ( hDlg );
-
- hSourceList = GetDlgItem ( hDlg, IDD_LISTSELECT );
- hDestList = GetDlgItem ( hDlg, IDD_LISTINSTALLED );
- hDescriptionBox = GetDlgItem ( hDlg, IDD_COMMENT );
-
- tabs[0] = 60; // Tab stop
- tabs[1] = 65; // Tab stop
-
- SendMessage ( hSourceList, LB_SETTABSTOPS, 2, (LONG)(LPSTR)tabs);
- SendMessage ( hDestList, LB_SETTABSTOPS, 2, (LONG)(LPSTR)tabs);
-
- viscount = 0;
- counter = 0;
-
- for ( i = 0; i < NumFiles; i++ )
- if (!FileInfo[i].bInvisible) viscount++;
-
- SendMessage ( hSourceList, WM_SETREDRAW, FALSE, 0L );
-
- for ( i = 0; i < NumFiles; i++ )
- if (!FileInfo[i].bInvisible)
- {
- if ( counter == (viscount-1))
- SendMessage ( hSourceList, WM_SETREDRAW, TRUE, 0L );
- sprintf ( szString, "%s\t%ldK", FileInfo[i].szDescription, FileInfo[i].BytesRequired/1024L );
- SendMessage ( hSourceList, LB_ADDSTRING, 0, (LONG)(LPSTR)szString );
- counter++;
- }
-
- SetFocus ( GetDlgItem ( hDlg, IDCANCEL ));
- return FALSE;
-
- case WM_COMMAND:
-
- switch (wParam)
- {
- case IDCANCEL:
-
- if (ReallyCancel( hDlg ))
- EndDialog ( hDlg, FALSE );
- break;
-
- case IDOK:
-
- EndDialog (hDlg, TRUE);
- break;
-
- case IDD_LISTSELECT: // Look for notify messages here...
-
- // Clear the other listbox's selections if any...
-
- if (NumDestSelections = SendMessage ( hDestList, LB_GETSELITEMS,
- MAXFILES, (LONG)(LPSTR)DestSelections ))
- {
- SendMessage ( hDestList, LB_SETSEL, 0, (LONG)-1 );
- InvalidateRect ( hDestList, NULL, TRUE );
- NumDestSelections = 0;
- }
-
- switch (HIWORD (lParam))
- {
- case LBN_SELCHANGE:
-
- // Save the previous state
-
- PreviousNumSourceSelections = NumSourceSelections;
- for ( i = 0; i < PreviousNumSourceSelections; i++)
- PreviousSourceSelections[i] = SourceSelections[i];
-
- // Get the current state
-
- NumSourceSelections = SendMessage ( hSourceList, LB_GETSELITEMS,
- MAXFILES, (LONG)(LPSTR)SourceSelections );
-
- // Now, let's figure out which one is the "new" selection...
-
- index = -1;
-
- // First, check to see if the user just selected one...
-
- for ( i = 0; (i < NumSourceSelections) && (index == -1); i++)
- if (!InPreviousSelection(SourceSelections,PreviousSourceSelections,
- i,PreviousNumSourceSelections))
- index = SourceSelections[i];
-
- // If the user just de-selected one, then we look inversely
-
- if ( -1 == index )
- for ( i = 0; (i < PreviousNumSourceSelections) && (index == -1); i++)
- if (!InPreviousSelection(PreviousSourceSelections,SourceSelections,
- i,NumSourceSelections))
- index = PreviousSourceSelections[i];
-
- // If index still is -1, then no selection changes were made,
- // and we cant do squat. So we wont update comment.
-
- if (-1 != index)
- {
- // Fill in the comment window
- SetDlgItemText ( hDlg, IDD_COMMENT, FileInfo[IndexGivenIndex(index)].szComment );
- }
-
- break;
-
- default:
-
- return FALSE;
-
- } // switch (HIWORD...
-
- break;
-
- case IDD_LISTINSTALLED:
-
- // If the user is clicking on the remove listbox, clear the comment
- // box to avoid confusing their brain cells, if anything was selected.
-
- if (NumSourceSelections = SendMessage ( hSourceList, LB_GETSELITEMS,
- MAXFILES, (LONG)(LPSTR)SourceSelections ))
- {
- SendMessage ( hSourceList, LB_SETSEL, 0, (LONG)-1 );
- InvalidateRect ( hSourceList, NULL, TRUE );
- SetDlgItemText ( hDlg, IDD_COMMENT, (LPSTR)"" );
- NumSourceSelections = 0;
- }
- break;
-
- case IDD_ADD:
-
- // Update the listbox current selection tallies
-
- NumSourceSelections = SendMessage ( hSourceList, LB_GETSELITEMS,
- MAXFILES, (LONG)(LPSTR)SourceSelections );
- NumDestSelections = SendMessage ( hDestList, LB_GETSELITEMS,
- MAXFILES, (LONG)(LPSTR)DestSelections );
-
- for ( i = 0; i < NumSourceSelections; i++ )
- if (!FileInfo[IndexGivenIndex(SourceSelections[i])].bSelected)
- AddItem ( hSourceList, hDestList, SourceSelections[i], FALSE );
-
- SendMessage ( hSourceList, LB_SETSEL, 0, (LONG)-1 );
- SendMessage ( hDestList, LB_SETSEL, 0, (LONG)-1 );
-
- // These next two lines are to fix a bug in the MS Listbox
-
- InvalidateRect ( hSourceList, NULL, TRUE );
- InvalidateRect ( hDestList, NULL, TRUE );
-
- SetDlgItemText ( hDlg, IDD_COMMENT, (LPSTR)"" );
- PostMessage( hDlg, WM_COMMAND, IDM_SHOWSTATUS, 0L );
- break;
-
- case IDD_DELETE:
-
- // Update the listbox current selection tallies
-
- NumSourceSelections = SendMessage ( hSourceList, LB_GETSELITEMS,
- MAXFILES, (LONG)(LPSTR)SourceSelections );
- NumDestSelections = SendMessage ( hDestList, LB_GETSELITEMS,
- MAXFILES, (LONG)(LPSTR)DestSelections );
-
- // We have to do this backwards in order to delete the right ones...
-
- for ( i = NumDestSelections-1; i >= 0 ; i-- )
- AddItem ( hSourceList, hDestList, DestSelections[i], TRUE );
-
- SendMessage ( hSourceList, LB_SETSEL, 0, (LONG)-1 );
- SendMessage ( hDestList, LB_SETSEL, 0, (LONG)-1 );
-
- // These next two lines are to fix a bug in the MS Listbox
-
- InvalidateRect ( hSourceList, NULL, TRUE );
- InvalidateRect ( hDestList, NULL, TRUE );
-
- PostMessage( hDlg, WM_COMMAND, IDM_SHOWSTATUS, 0L );
- break;
-
- case IDD_ADDALL:
-
- // Find out the last item that will actually be added
-
- LastToAdd = viscount - 1;
- while (LastToAdd && FileInfo[IndexGivenIndex(LastToAdd)].bSelected)
- LastToAdd--;
-
- SendMessage ( hDestList, WM_SETREDRAW, FALSE, 0L );
- for ( i = 0; i < viscount; i++)
- {
- if ( i == LastToAdd)
- SendMessage ( hDestList, WM_SETREDRAW, TRUE, 0L );
- if (!FileInfo[IndexGivenIndex(i)].bSelected)
- AddItem ( hSourceList, hDestList, i, FALSE );
- }
- PostMessage( hDlg, WM_COMMAND, IDM_SHOWSTATUS, 0L );
- break;
-
- case IDM_SHOWSTATUS:
-
- TotalBytes = 0;
- SumTotal = 0;
- for ( i = 0; i < NumFiles; i++ )
- {
- if (FileInfo[i].bSelected)
- TotalBytes += FileInfo[i].BytesRequired;
- SumTotal += FileInfo[IndexGivenIndex(i)].BytesRequired;
- }
-
- // Dont let them install nothing
-
- if (!TotalBytes)
- EnableWindow ( GetDlgItem ( hDlg, IDOK ), FALSE );
- else
- EnableWindow ( GetDlgItem ( hDlg, IDOK ), TRUE );
-
- AvailableBytes = DosDiskFreeSpace ( DirInfo[0].szDirectory[0]-'@' );
-
- sprintf (szStatus, "Disk Space Needed: %ldK", TotalBytes/1024L);
- SetDlgItemText ( hDlg, IDD_KSELECTED, szStatus );
- sprintf (szStatus, "Available: %ldK", AvailableBytes/1024L);
- SetDlgItemText ( hDlg, IDD_KFREE, szStatus );
- sprintf (szStatus, "Remaining: %ldK", AvailableBytes/1024L-TotalBytes/1024L );
- SetDlgItemText ( hDlg, IDD_KREMAINING, szStatus );
- if (SumTotal > AvailableBytes )
- EnableWindow ( GetDlgItem ( hDlg, IDD_ADDALL), FALSE );
-
- break;
- }
- return TRUE;
-
- default: return FALSE;
- }
- return TRUE;
- }
-
- #endif
-
- /********************************************************************/
- DLGPROC InsertDiskDlgProc ( DIALOG_PARAMS )
- {
- switch (msg)
- {
- case WM_INITDIALOG:
-
- MessageBeep (0);
- CenterDialog ( hDlg );
- SetDlgItemText ( hDlg, IDD_EDIT, (LPSTR) szNewDisk );
- SetDlgItemText ( hDlg, IDD_TEXT, (LPSTR) szNewDiskName );
- SetFocus ( GetDlgItem ( hDlg, IDD_EDIT ));
- SendDlgItemMessage ( hDlg, IDD_EDIT, EM_LIMITTEXT, 53, 0L);
- SendDlgItemMessage ( hDlg, IDD_EDIT, EM_SETSEL, 0, MAKELONG (0,32767));
- return FALSE;
-
- case WM_COMMAND:
-
- switch (wParam)
- {
- case IDCANCEL:
-
- if (ReallyCancel( hDlg )) EndDialog ( hDlg, FALSE );
- break;
-
- case IDOK:
-
- GetDlgItemText ( hDlg, IDD_EDIT, (LPSTR) szNewDisk, 64 );
- EndDialog ( hDlg, TRUE );
- break;
-
- default:
-
- return FALSE;
- }
- break;
-
- default:
-
- return FALSE;
-
- } // end switch
-
- return TRUE;
- }
- /********************************************************************/
- LPSTR CreateSourceDir ( int ReferenceNumber )
- {
- static char szDirectory[65];
- int i, Index;
-
- Index = -1;
-
- for ( i = 0; i < NumDisks; i++ )
- if ( DiskInfo[i].DiskNumber == FileInfo[ReferenceNumber].DiskNumber )
- Index = i;
-
- if ( -1 == Index )
- {
- MessageBox ( GetFocus (), "BAD INF FILE!", "Setup", MB_OK );
- return (LPSTR)NULL;
- }
-
- sprintf ( szDirectory, "%s%s", DiskInfo[Index].szSrcDir,
- FileInfo[ReferenceNumber].szMasterSrcDir );
-
- return (LPSTR) szDirectory;
- }
- /********************************************************************/
- LPSTR CreateSourceDisk ( int ReferenceNumber )
- {
- static char szDirectory[65];
- int i, Index;
-
- Index = -1;
-
- for ( i = 0; i < NumDisks; i++ )
- if ( DiskInfo[i].DiskNumber == FileInfo[ReferenceNumber].DiskNumber )
- Index = i;
-
- if ( -1 == Index )
- {
- MessageBox ( GetFocus (), "BAD INF FILE!", "Setup", MB_OK );
- return (LPSTR)NULL;
- }
-
- sprintf ( szDirectory, DiskInfo[Index].szSrcDir );
- sprintf ( szNewDiskName, DiskInfo[Index].szDiskTitle );
-
- return (LPSTR) szDirectory;
- }
- /********************************************************************/
- void ChangeSourceDir ( int ReferenceNumber )
- {
- int i, Index;
-
- Index = -1;
-
- for ( i = 0; i < NumDisks; i++ )
- if ( DiskInfo[i].DiskNumber == FileInfo[ReferenceNumber].DiskNumber )
- Index = i;
-
- if ( -1 == Index )
- {
- MessageBox ( GetFocus (), "BAD INF FILE!", "Setup", MB_OK );
- return (LPSTR)NULL;
- }
-
- i = strlen ( szNewDisk ); // Add a backslah if needed
- if (i >= 1)
- if (szNewDisk[i-1] != '\\')
- {
- szNewDisk[i ] = '\\';
- szNewDisk[i+1] = 0;
- }
-
- sprintf ( DiskInfo[Index].szSrcDir, szNewDisk );
- }
- /********************************************************************/
- LPSTR CreateDestDir ( int ReferenceNumber )
- {
- static char szDirectory[65];
- int i, Index;
-
- if ('0' == FileInfo[ReferenceNumber].DirectoryNumber )
- sprintf ( szDirectory, "%s", DirInfo[0].szDirectory); // Parent only
- else
- {
- Index = FileInfo[ReferenceNumber].DirectoryNumber - 'A'+1;
- sprintf ( szDirectory, "%s%s", DirInfo[0].szDirectory, // Parent
- DirInfo[Index].szDirectory); // Child
- }
-
- return (LPSTR) szDirectory;
- }
- /********************************************************************/
- DLGPROC FileCopyDlgProc ( DIALOG_PARAMS )
- {
- static int FileNumber, CopyNumber;
- static HWND hGauge;
- int i, FileCount;
- char szMsg[80];
- BOOL Success;
- MSG message;
-
-
- switch (msg)
- {
- case WM_INITDIALOG:
-
- CenterDialog ( hDlg );
-
- hGauge = GetDlgItem ( hDlg, IDD_GASGAUGE );
-
- FileNumber = 0;
- CopyNumber = 0;
-
- FileCount = 0;
- for ( i = 0; i < NumFiles; i++ )
- if (FileInfo[i].bSelected) FileCount++;
-
- PostMessage ( hGauge, WM_COMMAND, GG_SETRANGE, (LONG)FileCount);
- PostMessage ( hGauge, WM_COMMAND, GG_SETVALUE, 0L );
-
- SetTimer ( hDlg, 1, 1500, NULL );
-
- return FALSE;
-
-
- case WM_TIMER:
-
- KillTimer ( hDlg, 1 );
- PostMessage ( hDlg, WM_COMMAND, IDM_COPYFILE, 0L );
- break;
-
- case WM_COMMAND:
-
- switch (wParam)
- {
- case IDCANCEL:
-
- if (ReallyCancel( hDlg )) EndDialog ( hDlg, FALSE );
- break;
-
- case IDOK:
-
- EndDialog ( hDlg, TRUE );
- break;
-
- case IDM_COPYFILE:
-
- if (FileInfo[FileNumber].bSelected)
- {
- SetDlgItemText ( hDlg, IDD_FILEDESCRIPTION, (LPSTR)FileInfo[FileNumber].szDescription );
- SetDlgItemText ( hDlg, IDD_SOURCEDIR , CreateSourceDir (FileNumber ) );
- SetDlgItemText ( hDlg, IDD_DESTDIR , CreateDestDir (FileNumber ) );
- SetDlgItemText ( hDlg, IDD_FILENAME , (LPSTR)FileInfo[FileNumber].szFileName );
-
-
- SetCursor ( LoadCursor ( NULL, IDC_WAIT ));
-
- Success = CopyFile ( CreateSourceDir (FileNumber ),
- CreateDestDir (FileNumber ),
- (LPSTR)FileInfo[FileNumber].szFileName,
- FileInfo[FileNumber].bCompressed );
-
- if (Success)
- {
- CopyNumber++;
- PostMessage ( hGauge, WM_COMMAND, GG_SETVALUE, (LONG)CopyNumber );
-
- // This will allow task switching while copying, and
- // The gas gauge can update itself.
-
- while (PeekMessage (&message, hDlg, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&message);
- DispatchMessage(&message);
- }
- }
- else // Copy Error!
- {
- if (!CopyError) // If file not found
- {
- //ResetController();
- sprintf ( szNewDisk, CreateSourceDisk (FileNumber ));
-
-
- // Before prompting user for a new disk, let's try the directory
- // that setup came from
-
- if ( lstrcmp ((LPSTR)szNewDisk,(LPSTR)szCurrentInstallDir) )
- {
- lstrcpy ( (LPSTR)szNewDisk,(LPSTR)szCurrentInstallDir);
- ChangeSourceDir (FileNumber);
- FileNumber--; // Backup and try again
- }
- else
- {
- if (Success = DisplayDialogBox ( (LPSTR)"INSERTDISK", InsertDiskDlgProc ))
- {
- BringWindowToTop ( hDlg ); // Pretty things up
- ChangeSourceDir (FileNumber);
- FileNumber--; // Backup and try again
- }
- else
- {
-
- // Since we are aborting, we must clear out all those
- // WM_COMMAND-COPY messages and etc. Otherwise
- // the user has to cancel a bunch of times.
-
- while (PeekMessage (&message, hDlg, 0, 0, PM_REMOVE))
- {
- if (message.message != WM_COMMAND)
- {
- TranslateMessage(&message);
- DispatchMessage(&message);
- }
- }
- EndDialog ( hDlg, FALSE );
- FileNumber--; // Just to be sure
- return TRUE;
- }
- }
- }
- else // File copying error
- {
- MessageBox ( hDlg, "An error occurred while copying files to your hard disk. "
- "Please correct the problem and run Setup again.",
- "Setup", MB_OK | MB_ICONHAND );
-
- while (PeekMessage (&message, hDlg, 0, 0, PM_REMOVE))
- {
- if (message.message != WM_COMMAND)
- {
- TranslateMessage(&message);
- DispatchMessage(&message);
- }
- }
- EndDialog ( hDlg, FALSE );
- FileNumber--; // Just to be sure
- return TRUE;
- }
- }
-
- }
-
- FileNumber++;
-
- if (FileNumber < NumFiles)
- PostMessage ( hDlg, WM_COMMAND, IDM_COPYFILE, 0L );
- else
- PostMessage ( hDlg, WM_COMMAND, IDOK, 0L );
- break;
-
- default:
-
- return FALSE;
- }
- break;
-
- default:
-
- return FALSE;
-
- } // end switch
-
- return TRUE;
- }
- /********************************************************************/
- void GetNextFileNumber ( int *FileNumber, int *GroupNumber )
- {
- BOOL bNextGroup = FALSE;
- BOOL bFoundNextItem = FALSE;
-
- do
- {
- while ((!bFoundNextItem) && ((*FileNumber) < NumFiles))
- {
- if (
- (FileInfo[*FileNumber].bProgmanIcon) &&
- ((int)(FileInfo[*FileNumber].ProgmanGroupNumber-'A') == (*GroupNumber))
- )
- bFoundNextItem = TRUE;
- else
- (*FileNumber)++;
- }
-
- if (bFoundNextItem) return;
-
- // If we reach this line, then we have to move to the next group,
- // which means it is time to add a progman group...
-
- (*GroupNumber)++;
- *FileNumber = 0; // Start at begining of list again...
-
- ProgmanManageGroup ( (LPSTR)PManInfo[*GroupNumber].szCaption,
- (LPSTR)PManInfo[*GroupNumber].szGroupFilename,
- TRUE ); // TRUE = delete group first
-
- ProgmanManageGroup ( (LPSTR)PManInfo[*GroupNumber].szCaption,
- (LPSTR)PManInfo[*GroupNumber].szGroupFilename,
- FALSE ); // FALSE = Add group, not delete
- }
- while ((*GroupNumber) < NumPManGroups );
-
- }
- /********************************************************************/
- DLGPROC IconCopyDlgProc ( DIALOG_PARAMS )
- {
- static int FileNumber, CopyNumber, GroupNumber;
- static HWND hGauge;
- static int i, FileCount;
- char szMsg[80];
- BOOL Success;
- MSG message;
-
-
- switch (msg)
- {
- case WM_INITDIALOG:
-
- CenterDialogAtBottom ( hDlg );
-
- hGauge = GetDlgItem ( hDlg, IDD_GASGAUGE );
-
- FileNumber = 0;
- CopyNumber = 0;
- GroupNumber = -1;
-
- FileCount = 0;
-
- for ( i = 0; i < NumFiles; i++ )
- if (FileInfo[i].bProgmanIcon) FileCount++;
-
- PostMessage ( hGauge, WM_COMMAND, GG_SETRANGE, (LONG)FileCount);
- PostMessage ( hGauge, WM_COMMAND, GG_SETVALUE, 0L );
-
- SetTimer ( hDlg, 1, 1500, NULL );
-
- return FALSE;
-
-
- case WM_TIMER:
-
- KillTimer ( hDlg, 1 );
- PostMessage ( hDlg, WM_COMMAND, IDM_ADDICON, 0L );
- break;
-
- case WM_COMMAND:
-
- switch (wParam)
- {
- case IDCANCEL:
-
- if (ReallyCancel( hDlg ))
- {
- ProgManClose ( );
- EndDialog ( hDlg, FALSE );
- }
- break;
-
- case IDOK:
-
- EndDialog ( hDlg, TRUE );
- break;
-
- case IDM_ADDICON:
-
- // Get next Icon to copy. If new group, create the group
- GetNextFileNumber ( &FileNumber, &GroupNumber );
- BringWindowToTop ( hDlg ); // We want to see!!
-
- SetDlgItemText ( hDlg, IDD_FILEDESCRIPTION, (LPSTR)FileInfo[FileNumber].szDescription );
-
- wsprintf ( (LPSTR)szMsg,
- "%s\\%s",
- CreateDestDir (FileNumber ),
- (LPSTR)FileInfo[FileNumber].szFileName );
-
- SetCursor ( LoadCursor ( NULL, IDC_WAIT ));
-
- ProgmanAddItem ( FileInfo[FileNumber].szProgManName, szMsg );
- FileNumber++;
-
- CopyNumber++;
- PostMessage ( hGauge, WM_COMMAND, GG_SETVALUE, (LONG)CopyNumber );
-
- // This will allow task switching while adding, and
- // The gas gauge can update itself.
-
- while (PeekMessage (&message, hDlg, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&message);
- DispatchMessage(&message);
- }
-
- if (CopyNumber < FileCount)
- PostMessage ( hDlg, WM_COMMAND, IDM_ADDICON, 0L );
- else
- {
- ProgManClose ( );
- PostMessage ( hDlg, WM_COMMAND, IDOK, 0L );
- }
- break;
-
- default:
-
- return FALSE;
- }
- break;
-
- default:
-
- return FALSE;
-
- } // end switch
-
- return TRUE;
- }
-
-