home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l406 / 3.ddi / SETUP1.FR_ / SETUP1.bin (.txt)
Encoding:
Visual Basic Form  |  1992-10-21  |  12.5 KB  |  301 lines

  1. VERSION 2.00
  2. Begin Form Setup1 
  3.    BackColor       =   &H00400000&
  4.    Caption         =   "Test App Setup"
  5.    ControlBox      =   0   'False
  6.    FillStyle       =   0  'Solid
  7.    FontBold        =   -1  'True
  8.    FontItalic      =   -1  'True
  9.    FontName        =   "MS Sans Serif"
  10.    FontSize        =   24
  11.    FontStrikethru  =   0   'False
  12.    FontUnderline   =   0   'False
  13.    ForeColor       =   &H00000000&
  14.    Height          =   2535
  15.    Icon            =   SETUP1.FRX:0000
  16.    Left            =   1800
  17.    LinkMode        =   1  'Source
  18.    LinkTopic       =   "Form3"
  19.    MaxButton       =   0   'False
  20.    MinButton       =   0   'False
  21.    ScaleHeight     =   142
  22.    ScaleMode       =   3  'Pixel
  23.    ScaleWidth      =   376
  24.    Top             =   2265
  25.    Width           =   5760
  26.    Begin Label Label2 
  27.       BorderStyle     =   1  'Fixed Single
  28.       Caption         =   "To customize this setup program, modify the FORM_LOAD event procedure in this form."
  29.       Height          =   435
  30.       Left            =   15
  31.       TabIndex        =   1
  32.       Top             =   15
  33.       Visible         =   0   'False
  34.       Width           =   5625
  35.    End
  36.    Begin Label Label1 
  37.       BorderStyle     =   1  'Fixed Single
  38.       Caption         =   "This label used for DDE connection to the Program Manager"
  39.       Height          =   390
  40.       Left            =   15
  41.       TabIndex        =   0
  42.       Top             =   525
  43.       Visible         =   0   'False
  44.       Width           =   5610
  45.    End
  46. Const APPNAME = "Loan Application"
  47. Const APPDIR = "C:\LOAN"    ' The default install directory
  48. ' Set the total uncompressed file sizes
  49. ' by adding the sizes of the files
  50. Const WINSYSNEEDED = 40896  ' Files that go into WINDOWS and SYSTEM directory
  51. Const OTHERNEEDED = 12555   ' Files that don't go into the WINDOWS or SYSTEM directory
  52. Sub DrawBackground ()
  53.     Setup1.CurrentY = 5
  54.     Setup1.CurrentX = 5
  55.     Setup1.ForeColor = QBColor(15)
  56.     Print APPNAME + " Setup"
  57. End Sub
  58. Sub Form_Load ()
  59.     '----------
  60.     ' Initialize
  61.     '----------
  62.     dialogCaption$ = APPNAME + " Setup"
  63.     ShowMainForm dialogCaption$
  64.     '----------------------------------------------------
  65.     ' SETUP.EXE passes the source drive in a command
  66.     ' argument.  If it is empty,  that means the user
  67.     ' executed this .exe directly.  In that case, show
  68.     ' a dialog to get the desired source directory.
  69.     '----------------------------------------------------
  70.     SourcePath$ = Command$
  71.     If SourcePath$ = "" Then
  72.         title$ = dialogCaption$
  73.         caption1$ = "Please enter the drive or path containing the " + APPNAME + " source files."
  74.         caption2$ = "Install From:"
  75.         defaultDrive$ = "A:"
  76.         defaultText$ = "A:\"
  77.         ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, SourcePath$, outButton$
  78.         If outButton$ = "exit" Then GoTo ErrorSetup
  79.     Else
  80.         If Right$(SourcePath$, 1) <> "\" Then
  81.             SourcePath$ = SourcePath$ + "\"
  82.         End If
  83.     End If
  84.     '--------------------
  85.     ' Get Destination Path
  86.     '--------------------
  87.     title$ = dialogCaption$
  88.     caption1$ = "If you want to install the test application in a different directory and/or drive, type the name of the directory."
  89.     caption2$ = "Install To:"
  90.     defaultDrive$ = "C:"
  91.     defaultText$ = APPDIR
  92.     ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, destPath$, outButton$
  93.     If outButton$ = "exit" Then GoTo ErrorSetup
  94.     '---------------------
  95.     ' Sample Option Dialog
  96.     '---------------------
  97. '    ReDim Caption(1 To 4) As String
  98. '    ReDim choice(1 To 4) As Integer
  99. '    title$ = dialogCaption$
  100. '    numOptions = 4
  101. '    Caption(1) = "Sample Option 1"
  102. '    Caption(2) = "Sample Option 2"
  103. '    Caption(3) = "Sample Option 3"
  104. '    Caption(4) = "Sample Option 4"
  105. '    helpTxt$ = "Choose your options!   These options are not actually used by this setup program, but by looking in the SETUP1.FRM code you can see how to implement your own option dialogs."
  106. '    ShowOptionDialog title$, numOptions, Caption$(), helpTxt$, choice(), outButton$
  107. '    If outButton$ = "exit" Then
  108. '        GoTo ErrorSetup
  109. '    Else
  110. '        If choice(1) Then MsgBox "Option #1 Selected", 48, "SETUP"
  111. '        If choice(2) Then MsgBox "Option #2 Selected", 48, "SETUP"
  112. '        If choice(3) Then MsgBox "Option #3 Selected", 48, "SETUP"
  113. '        If choice(4) Then MsgBox "Option #4 Selected", 48, "SETUP"
  114. '    End If
  115.     '-----------------------------------------
  116.     ' Dim disk space variables as Long Integers
  117.     '-----------------------------------------
  118.     Dim winSpaceFree As Long
  119.     Dim sourceSpaceFree As Long
  120.     Dim destSpaceFree As Long
  121.     Dim totalNeeded As Long
  122.     winDir$ = GetWindowsDir$()
  123.     winSysDir$ = GetWindowsSysDir$()
  124.     '---------------------------------------------------------
  125.     ' If the Windows \SYSTEM directory is a subdirectory
  126.     ' of the Windows directory, the proper place for
  127.     ' installation of .VBXs and shared .DLLs is the
  128.     ' Windows \SYSTEM directory.
  129.     '
  130.     ' If the Windows \SYSTEM directory is *not* a subdirectory
  131.     ' of the Windows directory, then the user is running a
  132.     ' shared version of Windows, and the proper place for
  133.     ' installation of .VBXs and shared .DLLs is the
  134.     ' Windows directory.
  135.     '---------------------------------------------------------
  136.     If InStr(winSysDir$, winDir$) = 0 Then
  137.         winSysDir$ = winDir$
  138.     End If
  139.     '---------------------------------
  140.     ' Get Drive Letters of directories
  141.     '---------------------------------
  142.     winDrive$ = UCase$(Left$(winDir$, 1))
  143.     destDrive$ = UCase$(Left$(destPath$, 1))
  144.     sourceDrive$ = UCase$(Left$(SourcePath$, 1))
  145.     '---------------------------------
  146.     ' Compute free disk space variables
  147.     '---------------------------------
  148.     winSpaceFree = GetDiskSpaceFree(winDrive$)
  149.     destSpaceFree = GetDiskSpaceFree(destDrive$)
  150.     '-----------------------------------------
  151.     ' Check for enough disk space.
  152.     '
  153.     ' Some components are being installed into the
  154.     ' Windows\SYSTEM directory.
  155.     '
  156.     ' So if the main destination path is on a
  157.     ' different drive than the drive with
  158.     ' the Windows \SYSTEM directory, we have to
  159.     ' check both drives.
  160.     '
  161.     ' An example of this is when the user is installing
  162.     ' the main product to drive D:, but the Windows
  163.     ' directory is on drive c:
  164.     ' -----------------------------------------
  165.     totalNeeded = WINSYSNEEDED + OTHERNEEDED
  166.     If winDrive$ = destDrive$ Then
  167.         If destSpaceFree < totalNeeded Then
  168.             MsgBox "There is not enough disk space on drive " + destDrive$ + ":   An estimated" + Str$(totalNeeded - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  169.             GoTo ErrorSetup
  170.         End If
  171.     Else
  172.         If winSpaceFree < WINSYSNEEDED Then
  173.             MsgBox "There is not enough disk space on drive " + winDrive$ + ":  An estimated" + Str$(WINSYSNEEDED - winSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  174.             GoTo ErrorSetup
  175.         End If
  176.         If destSpaceFree < OTHERNEEDED Then
  177.             MsgBox "There is not enough disk space on drive " + destDrive$ + ":  An estimated" + Str$(OTHERNEEDED - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  178.             GoTo ErrorSetup
  179.         End If
  180.         
  181.     End If
  182.     '----------------------------
  183.     ' Create destination directory
  184.     '----------------------------
  185.     If Not CreatePath(destPath$) Then GoTo ErrorSetup
  186.     '-----------------------------------------------------------
  187.     ' Show Status Dialog -- This stays up while copying files
  188.     ' It is required by the CopyFile routine
  189.     '-----------------------------------------------------------
  190.     ShowStatusDialog dialogCaption$, totalNeeded
  191.     '-----------
  192.     ' Copy Files
  193.     '-----------
  194.     ' Test to see if loan.exe is on the disk, if not then you know the user
  195.     ' did not insert the first disk
  196.     If Not PromptForNextDisk(1, SourcePath$ + "loan.ex_") Then GoTo ErrorSetup
  197.     ' Install loan.exe and grid.vbx in the destPath$
  198.     If Not CopyFile(SourcePath$, destPath$, "loan.ex_", "loan.exe") Then GoTo ErrorSetup
  199.     If Not CopyFile(SourcePath$, winSysDir$, "grid.vb_", "grid.vbx") Then GoTo ErrorSetup
  200.     ' If you have more than one distribution disk, call PromptForNextDisk after
  201.     ' you have installed all the files from the previous disk. This line tests to
  202.     ' see if foo.da_ is on disk 2. If not, you know the user has not inserted disk 2.
  203.     ' The call to PromptForNextDisk is commented out, since loan.exe can be installed
  204.     ' from a single distribution disk.
  205.     ' If Not PromptForNextDisk(2, SourcePath$ + "foo.da_") Then GoTo ErrorSetup
  206.     ' If Not CopyFile(SourcePath$, destPath$, "foo.da_", "foo.dat", 0) Then GoTo ErrorSetup
  207.     '--------------------------------------------------
  208.     ' File Copying is over, so unload the status dialog
  209.     '--------------------------------------------------
  210.     Unload StatusDlg
  211.     '-----------------------------------------------------------
  212.     ' Show static message while working on DDE to Program Manager
  213.     '-----------------------------------------------------------
  214.     ShowStaticMessageDialog dialogCaption$, "Creating Program Manager Icon..."
  215.     '--------------------------------------
  216.     ' Create program manager group and icon
  217.     '--------------------------------------
  218.     CreateProgManGroup Setup1, "My Loan Application", "LOAN.GRP"
  219.     CreateProgManItem Setup1, destPath$ + "LOAN.EXE", "My Loan Application"
  220.     '-------------------------------------------------
  221.     ' Since SETUP.EXE copies your setup program to the Windows
  222.     ' directory, it is possible for your user to
  223.     ' execute this program directly.
  224.     '
  225.     ' As a usability feature, you may wish to insert code
  226.     ' here to install a program manager icon that executes
  227.     ' your setup program in the windows drive.  This
  228.     ' allows th user to re-run setup at a later time to
  229.     ' install options that were not installed the first
  230.     ' time.
  231.     '-------------------------------------------------
  232.     '-------------------
  233.     ' Hide Static Message
  234.     '-------------------
  235.     MessageDlg.Hide
  236.     '------------------
  237.     ' Show Final message
  238.     '------------------
  239.     MsgBox APPNAME + " Installation is Complete!", 48, dialogCaption$
  240. ExitSetup:
  241.     Setup1.Hide
  242.     RestoreProgMan         'Show the program manager
  243.     End
  244.     Exit Sub
  245. ErrorSetup:
  246.     MsgBox APPNAME + " is not properly installed.  Please re-run setup at a later time to install the Test Application properly.", 48, dialogCaption$
  247.     End
  248.     Exit Sub
  249. End Sub
  250. Sub Form_Paint ()
  251.     DrawBackground
  252. End Sub
  253. '---------------------------------------------------------------
  254. ' Sets the form's caption, Paints 3-D Background Text, Shows Form
  255. '---------------------------------------------------------------
  256. Sub ShowMainForm (Caption$)
  257.     Screen.MousePointer = 11
  258.     Setup1.Caption = Caption$
  259.     Setup1.Move 0, 0, Screen.Width, Screen.Height * .85
  260.     Setup1.Show
  261.     Setup1.Refresh
  262.     Setup1.ScaleMode = 2
  263.     Setup1.FontSize = 24
  264.     Setup1.FontBold = True
  265.     Setup1.FontItalic = True
  266.     DrawBackground
  267. End Sub
  268. Sub ShowPathDialog (title$, caption1$, caption2$, defaultDrive$, defaultText$, SourcePath$, outButton$)
  269.         Screen.MousePointer = 11
  270.         Load PathDlg
  271.         PathDlg.Caption = title$
  272.         PathDlg.Label1.Caption = caption1$
  273.         PathDlg.Label2.Caption = caption2$
  274.         PathDlg.inDrive.Tag = defaultDrive$
  275.         PathDlg.Text1.Text = defaultText$
  276.         PathDlg.Text1.SelStart = 0
  277.         PathDlg.Text1.SelLength = Len(defaultText$)
  278.         CenterForm PathDlg
  279.         Screen.MousePointer = 0
  280.         PathDlg.Show 1
  281.         
  282.         SourcePath$ = PathDlg.outPath.Tag
  283.         outButton$ = PathDlg.outButton.Tag
  284.         Unload PathDlg
  285. End Sub
  286. Sub ShowStaticMessageDialog (title$, Caption$)
  287.     Load MessageDlg
  288.     CenterForm MessageDlg
  289.     MessageDlg.Caption = title$
  290.     MessageDlg.Label.Caption = Caption$
  291.     MessageDlg.Show
  292.     MessageDlg.Refresh
  293. End Sub
  294. Sub ShowStatusDialog (title$, totalBytes As Long)
  295.     Load StatusDlg
  296.     StatusDlg.Caption = title$
  297.     StatusDlg.total.Tag = Str$(totalBytes)
  298.     CenterForm StatusDlg
  299.     StatusDlg.Show
  300. End Sub
  301.