home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Windows 95 Special 2 / WIN95_2.bin / utils / envelop / envelop.6 / Tools / Bootcamp / basic / apisavas / apisavas.eto < prev    next >
Encoding:
Text File  |  1996-07-08  |  6.3 KB  |  217 lines

  1. Type APISaveAsMasterForm From SampleMasterForm
  2.   Dim SaveAsPanel As New SaveAsDialog
  3.   Dim btnSaveAs As New Button
  4.   Dim Label1 As New Label
  5.   Dim Label2 As New Label
  6.   Dim lblFilePath As New Label
  7.   Dim Label3 As New Label
  8.   Dim lblFileName As New Label
  9.   Dim Label5 As New Label
  10.   Dim lblDirectory As New Label
  11.   Dim Label4 As New Label
  12.   Dim txtTitle As New TextBox
  13.   Dim Label7 As New Label
  14.   Dim chkNoChangeDir As New CheckBox
  15.   Dim chkNoNetworkButton As New CheckBox
  16.   Dim chkPathMustExist As New CheckBox
  17.  
  18.   ' METHODS for object: APISaveAsMasterForm
  19.   Sub chkNoChangeDir_Click()
  20.     If chkNoChangeDir.Value == 0 Then 
  21.       SaveAsPanel.NoChangeDir = "False"
  22.     Else 
  23.       SaveAsPanel.NoChangeDir = "True"
  24.     End If
  25.   End Sub
  26.  
  27.   Sub chkNoNetworkButton_Click()
  28.     If chkNoNetworkButton.Value == 0 Then 
  29.       SaveAsPanel.NoNetworkButton = "False"
  30.     Else 
  31.       SaveAsPanel.NoNetworkButton = "True"
  32.     End If
  33.   End Sub
  34.  
  35.   Sub chkPathMustExist_Click()
  36.     If chkPathMustExist.Value == 0 Then 
  37.       SaveAsPanel.PathMustExist = "False"
  38.     Else 
  39.       SaveAsPanel.PathMustExist = "True"
  40.     End If
  41.   End Sub
  42.  
  43.   Function EchoDirectory(filepath As String) As String
  44.     Dim found As Integer
  45.     Dim startpos As Integer
  46.   
  47.     If filepath == "" Then 
  48.       EchoDirectory = ""
  49.     Else 
  50.       ' Locate the last "\" in the filepath string
  51.       startpos = 0
  52.       found = 1
  53.       Do While found <> 0
  54.         found = Instr(startpos, filepath, "\")
  55.         If found <> 0 Then 
  56.           startpos = found + 1
  57.         Else 
  58.           If startpos == 0 Then 
  59.             EchoDirectory = filepath
  60.           Else 
  61.             startpos = startpos - 2
  62.             EchoDirectory = Left(filepath, startpos)
  63.           End If
  64.         End If
  65.       Loop
  66.     End If
  67.   End Function
  68.  
  69.   Function EchoFilename(filepath As String) As String
  70.     Dim found As Integer
  71.     Dim startpos As Integer
  72.     Dim length As Integer
  73.   
  74.     If filepath == "" Then 
  75.       EchoFilename = ""
  76.     Else 
  77.       ' Locate the last "\" in the filepath string
  78.       startpos = 0
  79.       found = 1
  80.       length = Len(filepath)
  81.       Do While found <> 0
  82.         found = Instr(startpos, filepath, "\")
  83.         If found <> 0 Then 
  84.           startpos = found + 1
  85.         Else 
  86.           If startpos == 0 Then 
  87.             EchoFilename = filepath
  88.           Else 
  89.             startpos = startpos
  90.             EchoFilename = Mid(filepath, startpos, (length - startpos) + 1)
  91.           End If
  92.         End If
  93.       Loop
  94.     End If
  95.   End Function
  96.  
  97.   Sub ResetApplication_Click ()
  98.   
  99.     ' Initialize SaveAs Dialog Demonstration
  100.   
  101.     ' Set SaveAs panel defaults
  102.     SaveAsPanel.Filter = "All files (*.*)|*.*|"
  103.   
  104.     SaveAsPanel.NoChangeDir = "False"
  105.     SaveAsPanel.NoNetworkButton = "False"
  106.     SaveAsPanel.PathMustExist = "True"
  107.   
  108.     ' Set the checkbox defaults
  109.     chkNoChangeDir.Value = 0
  110.     chkNoNetworkButton.Value = 0
  111.     chkPathMustExist.Value = 1
  112.   
  113.     ' Clear out the file/directory labels
  114.     lblDirectory.Caption = ""
  115.     lblFileName.Caption = ""
  116.     lblFilePath.Caption = ""
  117.   
  118.   End Sub
  119.  
  120.   Sub btnSaveAs_Click()
  121.   
  122.     ' Insert the title in the SaveAs dialog
  123.     SaveAsPanel.Title = txtTitle.Text
  124.   
  125.     ' Post the File SaveAs dialog box - should default to current directory
  126.     SaveAsPanel.Execute
  127.   
  128.     ' If a filename was picked, then load the text file into the textedit box
  129.     If SaveAsPanel.FileName <> "" Then 
  130.       lblFilePath.Caption = SaveAsPanel.FileName
  131.       lblDirectory.Caption = EchoDirectory(SaveAsPanel.FileName)
  132.       lblFileName.Caption = EchoFilename(SaveAsPanel.FileName)
  133.     End If
  134.   End Sub
  135.  
  136. End Type
  137.  
  138. Begin Code
  139. ' Reconstruction commands for object: APISaveAsMasterForm
  140. '
  141.   With APISaveAsMasterForm
  142.     .Caption := "Windows SaveAs Dialog Demonstration"
  143.     .Move(7500, 855, 7800, 6075)
  144.     .CurrentY := 64
  145.     .SampleDir := "W:\Examples\apisavas\"
  146.     .SampleName := "apisavas"
  147.     With .SaveAsPanel
  148.       .FileName := ""
  149.       .Filter := "All files (*.*)|*.*|"
  150.       .Title := "dialog title"
  151.     End With  'APISaveAsMasterForm.SaveAsPanel
  152.     With .btnSaveAs
  153.       .Caption := "SaveAs"
  154.       .Move(3450, 4650, 1800, 450)
  155.     End With  'APISaveAsMasterForm.btnSaveAs
  156.     With .Label1
  157.       .Caption := "1. Click options below then the SaveAs button to select a file."
  158.       .ForeColor := 13107200
  159.       .Move(300, 300, 6300, 300)
  160.     End With  'APISaveAsMasterForm.Label1
  161.     With .Label2
  162.       .Caption := "File Path:"
  163.       .Move(300, 3150, 1050, 300)
  164.     End With  'APISaveAsMasterForm.Label2
  165.     With .lblFilePath
  166.       .BackColor := 16777215
  167.       .Move(1500, 3150, 5850, 300)
  168.       .BorderStyle := "Fixed Single"
  169.     End With  'APISaveAsMasterForm.lblFilePath
  170.     With .Label3
  171.       .Caption := "Filename:"
  172.       .Move(300, 3600, 1050, 300)
  173.     End With  'APISaveAsMasterForm.Label3
  174.     With .lblFileName
  175.       .BackColor := 16777215
  176.       .Move(1500, 3600, 5850, 300)
  177.       .BorderStyle := "Fixed Single"
  178.     End With  'APISaveAsMasterForm.lblFileName
  179.     With .Label5
  180.       .Caption := "Directory:"
  181.       .Move(300, 4050, 1050, 300)
  182.     End With  'APISaveAsMasterForm.Label5
  183.     With .lblDirectory
  184.       .BackColor := 16777215
  185.       .Move(1500, 4050, 5850, 300)
  186.       .BorderStyle := "Fixed Single"
  187.     End With  'APISaveAsMasterForm.lblDirectory
  188.     With .Label4
  189.       .Caption := "Dialog Title:"
  190.       .Move(300, 900, 1200, 300)
  191.     End With  'APISaveAsMasterForm.Label4
  192.     With .txtTitle
  193.       .Move(1500, 900, 5850, 360)
  194.     End With  'APISaveAsMasterForm.txtTitle
  195.     With .Label7
  196.       .Caption := "SaveAs Dialog Options:"
  197.       .Move(300, 1485, 2550, 300)
  198.     End With  'APISaveAsMasterForm.Label7
  199.     With .chkNoChangeDir
  200.       .Caption := "No Change Directory"
  201.       .Move(1500, 1890, 2700, 300)
  202.     End With  'APISaveAsMasterForm.chkNoChangeDir
  203.     With .chkNoNetworkButton
  204.       .Caption := "No Network Button"
  205.       .Move(1500, 2190, 2700, 300)
  206.     End With  'APISaveAsMasterForm.chkNoNetworkButton
  207.     With .chkPathMustExist
  208.       .Caption := "Path Must Exist"
  209.       .Move(1500, 2490, 2700, 300)
  210.       .Value := "Checked"
  211.     End With  'APISaveAsMasterForm.chkPathMustExist
  212.     With .helpfile
  213.       .FileName := "W:\Examples\apisavas\apisavas.hlp"
  214.     End With  'APISaveAsMasterForm.helpfile
  215.   End With  'APISaveAsMasterForm
  216. End Code
  217.