home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vidlibp / vidlib.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-07  |  14.1 KB  |  460 lines

  1. VERSION 2.00
  2. Begin Form VidLib 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Video Library"
  6.    ClientHeight    =   3000
  7.    ClientLeft      =   2775
  8.    ClientTop       =   1770
  9.    ClientWidth     =   3345
  10.    Height          =   3690
  11.    HelpContextID   =   1
  12.    Icon            =   VIDLIB.FRX:0000
  13.    KeyPreview      =   -1  'True
  14.    Left            =   2715
  15.    LinkTopic       =   "Form1"
  16.    MaxButton       =   0   'False
  17.    ScaleHeight     =   3000
  18.    ScaleWidth      =   3345
  19.    Top             =   1140
  20.    Width           =   3465
  21.    Begin PictureBox rptPrint 
  22.       Height          =   480
  23.       Left            =   2925
  24.       ScaleHeight     =   450
  25.       ScaleWidth      =   1170
  26.       TabIndex        =   7
  27.       Top             =   0
  28.       Width           =   1200
  29.    End
  30.    Begin PictureBox dlgOpen 
  31.       Height          =   480
  32.       Left            =   0
  33.       ScaleHeight     =   450
  34.       ScaleWidth      =   1170
  35.       TabIndex        =   8
  36.       Top             =   0
  37.       Width           =   1200
  38.    End
  39.    Begin CommandButton cmdHelp 
  40.       Caption         =   "He&lp"
  41.       Height          =   540
  42.       HelpContextID   =   400
  43.       Left            =   1710
  44.       TabIndex        =   4
  45.       Top             =   1500
  46.       Width           =   1230
  47.    End
  48.    Begin CommandButton cmdExit 
  49.       Cancel          =   -1  'True
  50.       Caption         =   "E&xit"
  51.       Height          =   540
  52.       HelpContextID   =   100
  53.       Left            =   1710
  54.       TabIndex        =   5
  55.       Top             =   2175
  56.       Width           =   1230
  57.    End
  58.    Begin CommandButton cmdPreferences 
  59.       Caption         =   "P&references"
  60.       Height          =   540
  61.       HelpContextID   =   300
  62.       Left            =   1710
  63.       TabIndex        =   3
  64.       Top             =   825
  65.       Width           =   1230
  66.    End
  67.    Begin CommandButton cmdRepair 
  68.       Caption         =   "Rep&air"
  69.       Height          =   540
  70.       HelpContextID   =   100
  71.       Left            =   270
  72.       TabIndex        =   2
  73.       Top             =   2175
  74.       Width           =   1230
  75.    End
  76.    Begin CommandButton cmdPrint 
  77.       Caption         =   "&Print"
  78.       Height          =   540
  79.       HelpContextID   =   100
  80.       Left            =   270
  81.       TabIndex        =   1
  82.       Top             =   1500
  83.       Width           =   1230
  84.    End
  85.    Begin CommandButton cmdMaintain 
  86.       Caption         =   "&Maintain"
  87.       Default         =   -1  'True
  88.       Height          =   540
  89.       HelpContextID   =   200
  90.       Left            =   270
  91.       TabIndex        =   0
  92.       Top             =   825
  93.       Width           =   1230
  94.    End
  95.    Begin Label lblTitle 
  96.       BackColor       =   &H00FFFFFF&
  97.       BackStyle       =   0  'Transparent
  98.       Caption         =   "Video Library"
  99.       FontBold        =   -1  'True
  100.       FontItalic      =   0   'False
  101.       FontName        =   "MS Sans Serif"
  102.       FontSize        =   18
  103.       FontStrikethru  =   0   'False
  104.       FontUnderline   =   0   'False
  105.       Height          =   435
  106.       Left            =   450
  107.       TabIndex        =   6
  108.       Top             =   225
  109.       Width           =   2340
  110.    End
  111.    Begin Menu mnuFile 
  112.       Caption         =   "&File"
  113.       HelpContextID   =   100
  114.       Begin Menu mnuFileSelect 
  115.          Caption         =   "&Select"
  116.          HelpContextID   =   100
  117.          Shortcut        =   +{F2}
  118.       End
  119.       Begin Menu mnuFileCopy 
  120.          Caption         =   "&Copy"
  121.          HelpContextID   =   100
  122.          Shortcut        =   ^{F2}
  123.       End
  124.       Begin Menu mnuFileRepair 
  125.          Caption         =   "&Repair"
  126.          HelpContextID   =   100
  127.       End
  128.       Begin Menu mnuFileBar1 
  129.          Caption         =   "-"
  130.       End
  131.       Begin Menu mnuFilePrint 
  132.          Caption         =   "&Print"
  133.          HelpContextID   =   100
  134.       End
  135.       Begin Menu mnuFileBar2 
  136.          Caption         =   "-"
  137.       End
  138.       Begin Menu mnuFileExit 
  139.          Caption         =   "E&xit"
  140.          HelpContextID   =   100
  141.       End
  142.    End
  143.    Begin Menu mnuEdit 
  144.       Caption         =   "&Edit"
  145.       HelpContextID   =   200
  146.       Begin Menu mnuEditGenre 
  147.          Caption         =   "&Genre"
  148.          HelpContextID   =   200
  149.          Shortcut        =   {F3}
  150.       End
  151.       Begin Menu mnuEditRating 
  152.          Caption         =   "&Rating"
  153.          HelpContextID   =   200
  154.          Shortcut        =   {F4}
  155.       End
  156.       Begin Menu mnuEditVideo 
  157.          Caption         =   "&Video"
  158.          HelpContextID   =   200
  159.       End
  160.    End
  161.    Begin Menu mnuOptions 
  162.       Caption         =   "&Options"
  163.       HelpContextID   =   300
  164.       Begin Menu mnuOptionsPreferences 
  165.          Caption         =   "&Preferences"
  166.          HelpContextID   =   300
  167.          Shortcut        =   {F5}
  168.       End
  169.    End
  170.    Begin Menu mnuHelp 
  171.       Caption         =   "&Help"
  172.       HelpContextID   =   400
  173.       Begin Menu mnuHelpContents 
  174.          Caption         =   "&Contents"
  175.          HelpContextID   =   400
  176.       End
  177.       Begin Menu mnuHelpMain 
  178.          Caption         =   "&Main"
  179.          HelpContextID   =   400
  180.       End
  181.       Begin Menu mnuHelpSearch 
  182.          Caption         =   "&Search"
  183.          HelpContextID   =   400
  184.          Shortcut        =   +{F1}
  185.       End
  186.       Begin Menu mnuHelpUsing 
  187.          Caption         =   "&Using Help"
  188.          HelpContextID   =   400
  189.       End
  190.       Begin Menu mnuHelpAuthor 
  191.          Caption         =   "Au&thor"
  192.          HelpContextID   =   400
  193.          Shortcut        =   +^{F1}
  194.       End
  195.       Begin Menu mnuHelpBar1 
  196.          Caption         =   "-"
  197.       End
  198.       Begin Menu mnuHelpAbout 
  199.          Caption         =   "&About"
  200.          HelpContextID   =   400
  201.          Shortcut        =   ^{F1}
  202.       End
  203.    End
  204. ' Subsystem: Main
  205. ' Module:    VidLib.Frm
  206. ' Date:      01/02/94
  207. ' Author:    Richard Stauch
  208. ' Notes:
  209. ' This is the initial form the user sees when the program begins.
  210. Option Explicit
  211. DefInt A-Z
  212. Sub cmdExit_Click ()
  213. ' Call the Exit routine from the File menu.
  214.   mnuFileExit_Click
  215. End Sub
  216. Sub cmdHelp_Click ()
  217. ' Call the Main routine from the Help menu.
  218.   mnuHelpContents_Click
  219. End Sub
  220. Sub cmdMaintain_Click ()
  221. ' Call the Video routine from the Edit menu.
  222.   mnuEditVideo_Click
  223. End Sub
  224. Sub cmdPreferences_Click ()
  225. ' Call the Preferences routine from the Options menu.
  226.   mnuOptionsPreferences_Click
  227. End Sub
  228. Sub cmdPrint_Click ()
  229. ' Call the Print routine from the File menu.
  230.   mnuFilePrint_Click
  231. End Sub
  232. Sub cmdRepair_Click ()
  233. ' Call the Repair routine from the File menu.
  234.   mnuFileRepair_Click
  235. End Sub
  236. Sub Form_Load ()
  237. ' Load the initial Video Library form.
  238. Dim INIFile As Integer  ' Pointer to Information file.
  239. Dim I As Integer        ' Length of Windows directory string.
  240. Dim TempStr As String   ' Temp for Information file data.
  241. Dim WinDir As String    ' Windows directory, where INI file is.
  242. ' Set copy options.
  243.   GenreCopy% = True
  244.   RatingCopy% = True
  245.   VideoCopy% = True
  246.   ReplaceData% = True
  247. ' Set preference defaults.
  248.   DefaultPath$ = CurDir$
  249.   DefaultName$ = "VidLib.MDB"
  250.   DefaultReport$ = "Short"
  251.   DefaultOutput$ = "Window"
  252. ' If there's a problem with the INI file, these are the defaults.
  253.   On Error GoTo NormalDefault
  254. ' Prepare variable space for the DLL routine.
  255.   WinDir$ = String(255, 0)
  256. ' Get the Windows program directory.
  257.   I% = GetWindowsDirectory(ByVal WinDir$, Len(WinDir$))
  258. ' The return variable I% has the length of the string in
  259. ' WinDir$. The rest of it's prepared length is wasted.
  260.   ChDir Left$(WinDir$, I%)
  261. ' Set the Help File name.
  262.   If Right$(CurDir$, 1) = "\" Then
  263.     HelpName$ = CurDir$ & "VidLib.HLP" & Chr$(0)
  264.   Else
  265.     HelpName$ = CurDir$ & "\VidLib.HLP" & Chr$(0)
  266.   End If
  267. ' Set the Application help file name.
  268.   App.HelpFile = HelpName$
  269. ' Set the dialog box help file name.
  270.   dlgOpen.HelpFile = HelpName$
  271. ' Now, open the INI file for input only.
  272.   INIFile% = FreeFile ' Get the next file number from the system.
  273.   Open "VidLib.INI" For Input As INIFile%
  274.   Do Until EOF(INIFile%)
  275.   ' Look up the preference settings.
  276.     Line Input #INIFile%, TempStr$
  277.     If TempStr$ = "[File]" Then
  278.     ' This is the File section.
  279.       For I% = 1 To 2
  280.         Line Input #INIFile%, TempStr$
  281.         If Left$(TempStr$, 5) = "Path=" Then
  282.         ' This is the prefered Path.
  283.           DefaultPath$ = Right$(TempStr$, Len(TempStr$) - 5)
  284.         End If
  285.         If Left$(TempStr$, 5) = "Name=" Then
  286.         ' This is the prefered File name.
  287.           DefaultName$ = Right$(TempStr$, Len(TempStr$) - 5)
  288.         End If
  289.       Next I% ' File section.
  290.     End If ' "File"
  291.     If TempStr$ = "[Print]" Then
  292.     ' This is the Print section.
  293.       For I% = 1 To 2
  294.         Line Input #INIFile%, TempStr$
  295.         If Left$(TempStr$, 7) = "Report=" Then
  296.         ' This is the prefered report name.
  297.           DefaultReport$ = Right$(TempStr$, Len(TempStr$) - 7)
  298.         End If
  299.         If Left$(TempStr$, 7) = "Output=" Then
  300.         ' This is the prefered Output direction.
  301.           DefaultOutput$ = Right$(TempStr$, Len(TempStr$) - 7)
  302.         End If
  303.       Next I% ' Print section.
  304.     End If ' "Print"
  305.   Loop ' EOF(INIFile%)
  306. ' Close the INI file.
  307.   Close #INIFile%
  308. ' Set the current drive:\directory.
  309.   ChDir DefaultPath$
  310. NormalDefault:
  311. ' Set the path\name of the main *.MDB file.
  312.   PathName$ = SetPathString(DefaultName$)
  313.   TempName$ = SetPathString("VidTmp.MDB")
  314.   CopyName$ = PathName$
  315.   Exit Sub
  316. End Sub
  317. Sub mnuEditGenre_Click ()
  318. ' Edit the Genre table.
  319. ' Define the table for the Generic form.
  320.   Generic$ = "G"
  321. ' During the Form_Load event,
  322. ' the VidGen form will Show itself.
  323.   Load VidGen
  324. End Sub
  325. Sub mnuEditRating_Click ()
  326. ' Edit the Rating table.
  327. ' Define the table for the Generic form.
  328.   Generic$ = "R"
  329. ' During the Form_Load event,
  330. ' the VidGen form will Show itself.
  331.   Load VidGen
  332. End Sub
  333. Sub mnuEditVideo_Click ()
  334. ' Edit the Video table.
  335. ' During the Form_Load event,
  336. ' the VidMaint form will Show itself.
  337.   Load VidMaint
  338. End Sub
  339. Sub mnuFileCopy_Click ()
  340. ' Copy data from the current file to another.
  341.   VidCopy.Show MODAL ' The MODAL form will not
  342.                      ' allow any other form in
  343.                      ' this application to accept
  344.                      ' input.
  345. End Sub
  346. Sub mnuFileExit_Click ()
  347. ' Remove the main Video Library window from the screen,
  348. ' and End the program. But first, quit the Help engine.
  349. Dim R As Integer
  350.   R% = WinHelp(VidLib.hWnd, Chr$(0), HELP_QUIT, CLng(0))
  351.   End
  352. End Sub
  353. Sub mnuFilePrint_Click ()
  354. ' Print the data, using the default form/output.
  355.   If DefaultOutput$ = "Window" Then
  356.   ' Output to a window. The user can select to
  357.   ' send data to the printer at that time.
  358.     rptPrint.Destination = 0
  359.   ElseIf DefaultOutput$ = "Printer" Then
  360.   ' Output to the printer.
  361.     rptPrint.Destination = 1
  362.   ElseIf DefaultOutput$ = "File" Then
  363.   ' Output to a file.
  364.     rptPrint.Destination = 2
  365.   End If
  366.   If DefaultReport$ = "Short" Then
  367.   ' Output the Short report.
  368.     rptPrint.ReportFileName = "Short.RPT"
  369.   Else
  370.   ' Output the Long report.
  371.     rptPrint.ReportFileName = "Long.RPT"
  372.   End If
  373. ' Generate the report.
  374.   rptPrint.Action = 1
  375. End Sub
  376. Sub mnuFileRepair_Click ()
  377. ' Repair the database.
  378.   If GenericCancelBox(MBC_REPAIRDATA) = False Then
  379.   ' User pressed the OK button.
  380.     Screen.MousePointer = HOURGLASS ' Indicate "Wait".
  381.   ' Repair the database.
  382.     RepairDatabase PathName$
  383.   ' Remove any deleted records.
  384.     CompactDatabase PathName$, TempName$
  385.   ' If there's a problem, it's probably the BAK file is missing.
  386.     On Error GoTo KillError
  387.   ' Delete the backup (BAK) file.
  388.     Kill CurDir$ + "VidLib.BAK"
  389.   ' Let Windows handle the errors.
  390.     On Error GoTo 0
  391.   ' The original file is now the backup (BAK) file.
  392.     Name PathName$ As SetPathString("VidLib.BAK")
  393.   ' The repaired database is now the default file.
  394.     Name TempName$ As PathName$
  395.     Screen.MousePointer = DEFAULT ' Indicate "Continue".
  396.   End If
  397.   Exit Sub
  398. KillError:
  399. ' ".BAK" file doesn't exist.
  400.   Resume Next
  401. End Sub
  402. Sub mnuFileSelect_Click ()
  403. ' Select the file to use as the default.
  404. Dim I As Integer, J As Integer, OK As Integer
  405. ' The SelectPath function gets user input, and validates it.
  406.   OK% = SelectPath()
  407.   If OK% Then
  408.   ' The selected file and path are valid.
  409.     I% = Len(PathName$) ' The length of the fully qualified file name.
  410.     J% = Len(dlgOpen.Filetitle) ' The length of the simple file name.
  411.   ' Set the default file name.
  412.     DefaultName$ = Right$(PathName$, J%)
  413.   ' Set the default path.
  414.     DefaultPath$ = Left$(PathName$, I% - J%)
  415.     If Len(DefaultPath$) > 3 Then
  416.     ' Remove the trialing back-slash if necessary.
  417.       DefaultPath$ = Left$(DefaultPath$, Len(DefaultPath$) - 1)
  418.     End If
  419.   ' Set the temporary file name for the Repair routine.
  420.     TempName$ = SetPathString("VidTmp.MDB")
  421.   ' Set the current drive and directory.
  422.     ChDrive Left$(DefaultPath$, 2)
  423.     ChDir DefaultPath$
  424.   End If
  425. End Sub
  426. Sub mnuHelpAbout_Click ()
  427. ' Display the About dialog box.
  428.   VidAbout.Show MODAL
  429. End Sub
  430. Sub mnuHelpAuthor_Click ()
  431. ' Display information about the Author of this application.
  432. Dim R As Integer
  433.   R% = WinHelp(VidLib.hWnd, HelpName$, HELP_CONTEXT, CLng(VIDLIB_AUTHOR))
  434. End Sub
  435. Sub mnuHelpContents_Click ()
  436. ' Start the WinHelp engine with the Index topic.
  437. Dim R As Integer
  438.   R% = WinHelp(VidLib.hWnd, HelpName$, HELP_INDEX, CLng(0))
  439. End Sub
  440. Sub mnuHelpMain_Click ()
  441. ' Display the first help topic in the Main help group.
  442. Dim R As Integer
  443.   R% = WinHelp(VidLib.hWnd, HelpName$, HELP_CONTEXT, CLng(VIDLIB_MAIN))
  444. End Sub
  445. Sub mnuHelpSearch_Click ()
  446. ' Display the Search help topic in the Help file.
  447. Dim R As Integer
  448.   R% = WinHelp(VidLib.hWnd, HelpName$, HELP_CONTEXT, CLng(VIDLIB_SEARCH))
  449. End Sub
  450. Sub mnuHelpUsing_Click ()
  451. ' Open the Windows help file with the Using topic.
  452. Dim R As Integer
  453.   R% = WinHelp(VidLib.hWnd, Chr$(0), HELP_HELPONHELP, CLng(0))
  454. End Sub
  455. Sub mnuOptionsPreferences_Click ()
  456. ' Load the Preferences dialog box.
  457. ' The Form_Load event with Show itself.
  458.   Load VidPref
  459. End Sub
  460.