home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD6454652000.psc / Interface.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-06-05  |  8.1 KB  |  308 lines

  1. VERSION 4.00
  2. Begin VB.Form Interface 
  3.    Caption         =   "Floppy Imaging "
  4.    ClientHeight    =   4440
  5.    ClientLeft      =   2910
  6.    ClientTop       =   1815
  7.    ClientWidth     =   2730
  8.    Height          =   4860
  9.    Icon            =   "Interface.frx":0000
  10.    Left            =   2850
  11.    LinkTopic       =   "Interface"
  12.    MaxButton       =   0   'False
  13.    ScaleHeight     =   4440
  14.    ScaleWidth      =   2730
  15.    Top             =   1455
  16.    Width           =   2850
  17.    Begin VB.Timer Windows 
  18.       Enabled         =   0   'False
  19.       Interval        =   1000
  20.       Left            =   2340
  21.       Top             =   2190
  22.    End
  23.    Begin VB.CommandButton Command 
  24.       Caption         =   "Windows   Format"
  25.       Height          =   645
  26.       Index           =   5
  27.       Left            =   720
  28.       TabIndex        =   4
  29.       Top             =   3525
  30.       Width           =   1380
  31.    End
  32.    Begin VB.Timer Wipe 
  33.       Enabled         =   0   'False
  34.       Interval        =   1000
  35.       Left            =   2340
  36.       Top             =   1710
  37.    End
  38.    Begin VB.Timer Format 
  39.       Enabled         =   0   'False
  40.       Interval        =   1000
  41.       Left            =   2340
  42.       Top             =   1170
  43.    End
  44.    Begin VB.Timer Restore 
  45.       Enabled         =   0   'False
  46.       Interval        =   1000
  47.       Left            =   2340
  48.       Top             =   675
  49.    End
  50.    Begin VB.Timer Save 
  51.       Enabled         =   0   'False
  52.       Interval        =   1000
  53.       Left            =   2325
  54.       Top             =   195
  55.    End
  56.    Begin VB.CommandButton Command 
  57.       Caption         =   "Remove All Data And Formatting"
  58.       Height          =   690
  59.       Index           =   4
  60.       Left            =   705
  61.       TabIndex        =   3
  62.       Top             =   2655
  63.       Width           =   1395
  64.    End
  65.    Begin VB.CommandButton Command 
  66.       Caption         =   "Wipe Data And Fat From Disk"
  67.       Height          =   735
  68.       Index           =   3
  69.       Left            =   705
  70.       TabIndex        =   2
  71.       Top             =   1770
  72.       Width           =   1380
  73.    End
  74.    Begin VB.CommandButton Command 
  75.       Caption         =   "Restore Image To Disk"
  76.       Height          =   705
  77.       Index           =   2
  78.       Left            =   705
  79.       TabIndex        =   1
  80.       Top             =   930
  81.       Width           =   1380
  82.    End
  83.    Begin VB.CommandButton Command 
  84.       Caption         =   "Save Floppy Image"
  85.       Height          =   675
  86.       Index           =   1
  87.       Left            =   705
  88.       TabIndex        =   0
  89.       Top             =   120
  90.       Width           =   1380
  91.    End
  92.    Begin MSComDlg.CommonDialog SaveAs 
  93.       Left            =   2310
  94.       Top             =   3150
  95.       _ExtentX        =   847
  96.       _ExtentY        =   847
  97.       _Version        =   327681
  98.    End
  99.    Begin MSComDlg.CommonDialog Images 
  100.       Left            =   2310
  101.       Top             =   2655
  102.       _ExtentX        =   847
  103.       _ExtentY        =   847
  104.       _Version        =   327681
  105.    End
  106. Attribute VB_Name = "Interface"
  107. Attribute VB_Creatable = False
  108. Attribute VB_Exposed = False
  109. Option Explicit
  110. Private Declare Function SHFormatDrive Lib "shell32" _
  111.     (ByVal hwnd As Long, ByVal Drive As Long, ByVal fmtID As Long, _
  112.     ByVal options As Long) As Long
  113. Dim i As Integer
  114. Dim TheImage As String
  115. Dim TheName As String
  116. Dim RtnA As String
  117. Private Sub DisableCommands()
  118. For i = 1 To 5
  119. Command(i).Enabled = False
  120. End Sub
  121. Private Sub EnableCommands()
  122. For i = 1 To 5
  123. Command(i).Enabled = True
  124. End Sub
  125. Private Sub NameImage()
  126. Dim MsgRtn As Integer
  127. On Error GoTo Out:
  128. With Images
  129.     .Flags = cdlOFNPathMustExist
  130.     .Flags = .Flags Or cdlOFNHideReadOnly
  131.     .Flags = .Flags Or cdlOFNNoChangeDir
  132.     .Flags = .Flags Or cdlOFNExplorer
  133.     .Flags = .Flags Or cdlOFNNoValidate
  134.     .Filter = "Floppy Images (*.img)|*.img|"
  135.     .DialogTitle = "Type a name for the image"
  136.     .FileName = "*.img"
  137.     .InitDir = App.Path
  138.     .CancelError = True
  139.     .Action = 2
  140. End With
  141.   If IsFile(Images.FileName) Then
  142.   MsgRtn = MsgBox("File exists, do you want to overwrite it?", vbYesNo)
  143.     If MsgRtn = vbYes Then
  144.     TheName = Images.FileName
  145.        If Right(TheName, 4) <> ".img" Then
  146.        TheName = TheName & ".img"
  147.        End If
  148.     Else
  149.     TheName = ""
  150.     End If
  151.   Else
  152.   TheName = Images.FileName
  153.     If Right(TheName, 4) <> ".img" Then
  154.     TheName = TheName & ".img"
  155.     End If
  156.   End If
  157. Exit Sub
  158. TheName = ""
  159. End Sub
  160. Private Sub OpenImage()
  161. On Error GoTo Out:
  162. With Images
  163.     .Flags = cdlOFNPathMustExist
  164.     .Flags = .Flags Or cdlOFNHideReadOnly
  165.     .Flags = .Flags Or cdlOFNNoChangeDir
  166.     .Flags = .Flags Or cdlOFNExplorer
  167.     .Flags = .Flags Or cdlOFNNoValidate
  168.     .Filter = "Floppy Images (*.img)|*.img|"
  169.     .DialogTitle = "Select a Floppy Image"
  170.     .FileName = "*.img"
  171.     .InitDir = App.Path
  172.     .CancelError = True
  173.     .Action = 1
  174. End With
  175.   If IsFile(Images.FileName) Then
  176.   TheImage = Images.FileName
  177.   Else
  178.   TheImage = ""
  179.   End If
  180. Exit Sub
  181. TheImage = ""
  182. End Sub
  183. Private Sub Form_Load()
  184. Me.Left = (Screen.Width - Me.Width) / 2
  185. Me.Top = (Screen.Height - Me.Height) / 2
  186. Shell "Notepad.exe " & App.Path & "\ReadMe.txt", 1
  187. End Sub
  188. Private Sub Format_Timer()
  189. If Not TaskRunning Then
  190.   If IsFile(App.Path & "\Temp") Then
  191.   Kill App.Path & "\Temp"
  192.   End If
  193.   If IsFile(App.Path & "\Temp.img") Then
  194.   Kill App.Path & "\Temp.img"
  195.   End If
  196. EnableCommands
  197. Format.Enabled = False
  198. End If
  199. End Sub
  200. Private Sub Restore_Timer()
  201. If Not TaskRunning Then
  202.   If IsFile(App.Path & "\Temp.img") Then
  203.   Kill App.Path & "\Temp.img"
  204.   End If
  205. EnableCommands
  206. Restore.Enabled = False
  207. End If
  208. End Sub
  209. Private Sub Save_Timer()
  210. If Not TaskRunning Then
  211. EnableCommands
  212.   If IsFile(App.Path & "\Temp.img") Then
  213.   Name App.Path & "\Temp.img" As TheName
  214.   End If
  215. Save.Enabled = False
  216. End If
  217. End Sub
  218. Private Sub Command_Click(Index As Integer)
  219. Dim MsgRtn As Integer
  220. If CheckDriveA Then
  221. DisableCommands
  222. Select Case Index
  223.   Case 1
  224.   NameImage
  225.   If TheName = "" Then
  226.   EnableCommands
  227.   Else
  228.   MsgRtn = MsgBox("Creating disk image " & TheName & ", continue?", vbYesNo)
  229.     If MsgRtn = vbYes Then
  230.     ChDir App.Path
  231.     TaskID = ExecuteTask(App.Path & "\Save.bat")
  232.     Save.Enabled = True
  233.     Else
  234.     EnableCommands
  235.     End If
  236.   End If
  237. '*************
  238.   Case 2
  239.   OpenImage
  240.   If TheImage = "" Then
  241.   EnableCommands
  242.   Else
  243.   MsgRtn = MsgBox("Restoring disk image " & TheImage & " to the disk in Drive A:, continue?", vbYesNo)
  244.     If MsgRtn = vbYes Then
  245.     FileCopy TheImage, App.Path & "\Temp.img"
  246.     ChDir App.Path
  247.     TaskID = ExecuteTask(App.Path & "\Restore.bat")
  248.     Restore.Enabled = True
  249.     Else
  250.     EnableCommands
  251.     End If
  252.   End If
  253. '**********
  254.   Case 3
  255.   MsgRtn = MsgBox("All information on disk will be lost. Continue?", vbYesNo)
  256.   If MsgRtn = vbYes Then
  257.   CreateBlank 2847, App.Path & "\temp"
  258.   ChDir App.Path
  259.   TaskID = ExecuteTask(App.Path & "\Format.bat")
  260.   Format.Enabled = True
  261.   Else
  262.   EnableCommands
  263.   End If
  264. '**********
  265.   Case 4
  266.   MsgRtn = MsgBox("All information and formatting on disk will be lost. Continue?", vbYesNo)
  267.   If MsgRtn = vbYes Then
  268.   CreateBlank 2880, App.Path & "\temp.img"
  269.   ChDir App.Path
  270.   TaskID = ExecuteTask(App.Path & "\Wipe.bat")
  271.   Wipe.Enabled = True
  272.   Else
  273.   EnableCommands
  274.   End If
  275. '***********
  276.   Case 5
  277.   TaskID = ExecuteTask(SHFormatDrive(Me.hwnd, 0, 0&, 0&))
  278.   Windows.Enabled = True
  279.   Case Else
  280. End Select
  281. End If
  282. End Sub
  283. Private Function CheckDriveA() As Boolean
  284. On Error GoTo Out:
  285. RtnA = Dir("A:\*.*")
  286. CheckDriveA = True
  287. Exit Function
  288. CheckDriveA = False
  289. MsgBox "Error reading drive A, insert disk and retry."
  290. End Function
  291. Private Sub Windows_Timer()
  292. If Not TaskRunning Then
  293. EnableCommands
  294. Windows.Enabled = False
  295. End If
  296. End Sub
  297. Private Sub Wipe_Timer()
  298. Dim RetVal As Long
  299. If Not TaskRunning Then
  300.   If IsFile(App.Path & "\Temp.img") Then
  301.   Kill App.Path & "\Temp.img"
  302.   End If
  303. EnableCommands
  304. RetVal = SHFormatDrive(Me.hwnd, 0, 0&, 0&)
  305. Wipe.Enabled = False
  306. End If
  307. End Sub
  308.