home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_BAS / PWBROW.ZIP / PRINT.FRM < prev    next >
Text File  |  1994-01-27  |  10KB  |  313 lines

  1. VERSION 2.00
  2. Begin Form frmPrint 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Print Version Information"
  6.    ClientHeight    =   2190
  7.    ClientLeft      =   3600
  8.    ClientTop       =   2115
  9.    ClientWidth     =   6330
  10.    Height          =   2655
  11.    Icon            =   PRINT.FRX:0000
  12.    Left            =   3510
  13.    LinkTopic       =   "Form2"
  14.    ScaleHeight     =   2190
  15.    ScaleWidth      =   6330
  16.    Top             =   1740
  17.    Width           =   6510
  18.    Begin CommonDialog cdFont 
  19.       Left            =   3840
  20.       Top             =   1800
  21.    End
  22.    Begin CommandButton cbFont 
  23.       Caption         =   "Select &Font ..."
  24.       Height          =   375
  25.       Left            =   2280
  26.       TabIndex        =   5
  27.       Top             =   1680
  28.       Width           =   1455
  29.    End
  30.    Begin Frame Frame1 
  31.       BackColor       =   &H00C0C0C0&
  32.       Caption         =   "Print What"
  33.       Height          =   1095
  34.       Left            =   120
  35.       TabIndex        =   4
  36.       Top             =   960
  37.       Width           =   1935
  38.       Begin OptionButton obDirectory 
  39.          BackColor       =   &H00C0C0C0&
  40.          Caption         =   "&Entire Directory"
  41.          Height          =   255
  42.          Left            =   120
  43.          TabIndex        =   11
  44.          Top             =   720
  45.          Width           =   1695
  46.       End
  47.       Begin OptionButton obSelected 
  48.          BackColor       =   &H00C0C0C0&
  49.          Caption         =   "&Selected Files"
  50.          Height          =   255
  51.          Left            =   120
  52.          TabIndex        =   10
  53.          Top             =   360
  54.          Value           =   -1  'True
  55.          Width           =   1575
  56.       End
  57.    End
  58.    Begin CommandButton cbCancel 
  59.       Cancel          =   -1  'True
  60.       Caption         =   "Cancel"
  61.       Height          =   375
  62.       Left            =   4440
  63.       TabIndex        =   3
  64.       Top             =   1680
  65.       Width           =   735
  66.    End
  67.    Begin CommandButton cbOK 
  68.       Caption         =   "OK"
  69.       Default         =   -1  'True
  70.       Height          =   375
  71.       Left            =   5400
  72.       TabIndex        =   2
  73.       Top             =   1680
  74.       Width           =   735
  75.    End
  76.    Begin TextBox tbTitle 
  77.       Height          =   285
  78.       Left            =   1320
  79.       TabIndex        =   1
  80.       Top             =   240
  81.       Width           =   4935
  82.    End
  83.    Begin Label lblDir 
  84.       BackStyle       =   0  'Transparent
  85.       Height          =   255
  86.       Left            =   1080
  87.       TabIndex        =   9
  88.       Top             =   720
  89.       Width           =   5175
  90.    End
  91.    Begin Label Label3 
  92.       Alignment       =   1  'Right Justify
  93.       BackStyle       =   0  'Transparent
  94.       Caption         =   "Directory:"
  95.       Height          =   255
  96.       Left            =   0
  97.       TabIndex        =   8
  98.       Top             =   720
  99.       Width           =   975
  100.    End
  101.    Begin Label Label2 
  102.       BackStyle       =   0  'Transparent
  103.       Caption         =   "Current Font:"
  104.       Height          =   255
  105.       Left            =   2280
  106.       TabIndex        =   7
  107.       Top             =   1080
  108.       Width           =   1335
  109.    End
  110.    Begin Label lblFont 
  111.       BackStyle       =   0  'Transparent
  112.       Height          =   255
  113.       Left            =   2280
  114.       TabIndex        =   6
  115.       Top             =   1320
  116.       Width           =   3855
  117.    End
  118.    Begin Label Label1 
  119.       Alignment       =   1  'Right Justify
  120.       BackStyle       =   0  'Transparent
  121.       Caption         =   "Report &Title:"
  122.       Height          =   255
  123.       Left            =   0
  124.       TabIndex        =   0
  125.       Top             =   240
  126.       Width           =   1215
  127.    End
  128. End
  129. Dim IDs(16) As String
  130. Dim IDLen(16) As Integer
  131. Dim MaxLen As Integer
  132. Dim LineHeight As Integer
  133.  
  134. Sub cbCancel_Click ()
  135.     Unload frmPrint
  136. End Sub
  137.  
  138. Sub cbFont_Click ()
  139.     Const CF_EFFECTS = &H200
  140.     Const CF_PRINTERFONTS = &H2
  141.     Const CF_FORCEFONTEXIST = &H10000
  142.     
  143.     cdFont.FontName = Printer.FontName
  144.     cdFont.Flags = CF_EFFECTS Or CF_PRINTERFONTS Or CF_FORCEFONTEXIST
  145.     cdFont.Action = 4 ' get font
  146.     lblFont.Caption = cdFont.FontName
  147.     Printer.FontName = cdFont.FontName
  148.     MaxLen = 0 ' invalidate width information
  149. End Sub
  150.  
  151. Sub cbOK_Click ()
  152.     Dim FullName As String
  153.  
  154.     frmPrint.MousePointer = 11 ' hourglass
  155.     If MaxLen = 0 Then InitID
  156.  
  157.     If obSelected.Value = True Then ' Selected files Only
  158.         For i = 0 To frmBrowse!filBrowse.ListCount - 1
  159.             If frmBrowse!filBrowse.Selected(i) Then
  160.                 FullName = frmBrowse!filBrowse.Path + "\" + frmBrowse!filBrowse.List(i)
  161.                 PrintOne (FullName)
  162.             End If
  163.         Next
  164.     Else    ' print all files in directory
  165.         For i = 0 To frmBrowse!filBrowse.ListCount - 1
  166.             FullName = frmBrowse!filBrowse.Path + "\" + frmBrowse!filBrowse.List(i)
  167.             PrintOne (FullName)
  168.         Next
  169.     End If
  170.     
  171.     Printer.EndDoc
  172.     
  173.     frmPrint.MousePointer = 0 ' normal
  174.     Unload frmPrint
  175. End Sub
  176.  
  177. Sub Form_Load ()
  178.     frmPrint.Top = PrintTop
  179.     frmPrint.Left = PrintLeft
  180.     lblFont.Caption = Printer.FontName
  181.     lblDir.Caption = frmBrowse!lblCurDir.Caption
  182.     tbTitle.Text = "Version information for directory " + lblDir.Caption
  183.     If frmBrowse!filBrowse.ListIndex < 0 Then ' no files selected
  184.         obSelected.Enabled = False ' disable "Selected Files"
  185.         obDirectory.Value = True ' Force "Entire Directory"
  186.     End If
  187. End Sub
  188.  
  189. Sub Form_Unload (Cancel As Integer)
  190.     If frmPrint.WindowState <> 1 Then
  191.         ' window not minimized
  192.         PrintTop = frmPrint.Top
  193.         PrintLeft = frmPrint.Left
  194.     End If
  195. End Sub
  196.  
  197. Sub InitID ()
  198.     Dim i As Integer
  199.     Static BeenHere As Integer
  200.  
  201.     If Not BeenHere Then
  202.         IDs(0) = "Name: "
  203.         IDs(1) = "Last Modified: "
  204.         IDs(2) = "Size: "
  205.         IDs(3) = "Description: "
  206.         IDs(4) = "File Version: "
  207.         IDs(5) = "Company Name: "
  208.         IDs(6) = "Language: "
  209.         IDs(7) = "Original Name: "
  210.         IDs(8) = "Internal Name: "
  211.         IDs(9) = "Comments: "
  212.         IDs(10) = "Copyright: "
  213.         IDs(11) = "Trademarks: "
  214.         IDs(12) = "Product Name: "
  215.         IDs(13) = "Product Version: "
  216.         IDs(14) = "Special Build: "
  217.         IDs(15) = "Private Build: "
  218.         BeenHere = True
  219.     End If
  220.  
  221.     For i = 0 To 15
  222.         IDLen(i) = Printer.TextWidth(IDs(i))
  223.         If IDLen(i) > MaxLen Then MaxLen = IDLen(i)
  224.     Next
  225.     LineHeight = Printer.TextHeight("X")
  226. End Sub
  227.  
  228. Sub PrintOne (FullName As String)
  229.     Dim VerInfoPresent As Integer
  230.     Dim VI As VerInfo
  231.     Dim PageNo As String
  232.     Dim TotHeight As Integer
  233.     Static CurDateTime As String
  234.  
  235.     If CurDateTime <= " " Then
  236.         CurDateTime = Format(Now, "dddd, mmmm d, yyyy \a\t h:mm AM/PM")
  237.     End If
  238.     VerInfoPresent = GetFileVersion(FullName, VI)
  239.     If VerInfoPresent Then ' compute height of into to be printed
  240.         TotHeight = 17 * LineHeight
  241.     Else
  242.         TotHeight = 4 * LineHeight
  243.     End If
  244.     If (Printer.CurrentY + TotHeight + 1) > Printer.ScaleHeight Then Printer.NewPage
  245.     
  246.     If Printer.CurrentY = 0 Then ' top of page
  247.         Printer.Print ' leave some top margin
  248.         Printer.Print CurDateTime;
  249.         PageNo = "Page:" + Str$(Printer.Page)
  250.         Printer.CurrentX = Printer.ScaleWidth - Printer.TextWidth(PageNo)
  251.         Printer.Print PageNo
  252.         Printer.Print tbTitle
  253.     End If
  254.  
  255.     Printer.CurrentY = Printer.CurrentY + (LineHeight / 2)
  256.     Printer.Line (Printer.CurrentX, Printer.CurrentY)-(Printer.ScaleWidth, Printer.CurrentY)
  257.     Printer.CurrentY = Printer.CurrentY + (LineHeight / 2)
  258.     
  259.     Printer.CurrentX = MaxLen - IDLen(0)
  260.     Printer.Print IDs(0);
  261.     Printer.FontBold = True
  262.     Printer.Print FullName
  263.     Printer.FontBold = False
  264.     
  265.     Printer.CurrentX = MaxLen - IDLen(1)
  266.     Printer.Print IDs(1); Format$(FileDateTime(FullName), "dddd, mmmm d, yyyy \a\t h:mm AM/PM")
  267.  
  268.     Printer.CurrentX = MaxLen - IDLen(2)
  269.     Printer.Print IDs(2); Format$(FileLen(FullName), "###,###,###,##0 \b\y\t\e\s")
  270.  
  271.     If Not VerInfoPresent Then Exit Sub ' no Version info available
  272.  
  273.     Printer.CurrentX = MaxLen - IDLen(3)
  274.     Printer.Print IDs(3); VI.FileDescription
  275.     
  276.     Printer.CurrentX = MaxLen - IDLen(4)
  277.     Printer.Print IDs(4); VI.FileVersion
  278.     
  279.     Printer.CurrentX = MaxLen - IDLen(5)
  280.     Printer.Print IDs(5); VI.CompanyName
  281.     
  282.     Printer.CurrentX = MaxLen - IDLen(6)
  283.     Printer.Print IDs(6); VI.Language
  284.     
  285.     Printer.CurrentX = MaxLen - IDLen(7)
  286.     Printer.Print IDs(7); VI.OriginalFileName
  287.     
  288.     Printer.CurrentX = MaxLen - IDLen(8)
  289.     Printer.Print IDs(8); VI.InternalName
  290.     
  291.     Printer.CurrentX = MaxLen - IDLen(9)
  292.     Printer.Print IDs(9); VI.Comments
  293.     
  294.     Printer.CurrentX = MaxLen - IDLen(10)
  295.     Printer.Print IDs(10); VI.LegalCopyright
  296.     
  297.     Printer.CurrentX = MaxLen - IDLen(11)
  298.     Printer.Print IDs(11); VI.LegalTrademarks
  299.     
  300.     Printer.CurrentX = MaxLen - IDLen(12)
  301.     Printer.Print IDs(12); VI.ProductName
  302.     
  303.     Printer.CurrentX = MaxLen - IDLen(13)
  304.     Printer.Print IDs(13); VI.ProductVersion
  305.     
  306.     Printer.CurrentX = MaxLen - IDLen(14)
  307.     Printer.Print IDs(14); VI.SpecialBuild
  308.     
  309.     Printer.CurrentX = MaxLen - IDLen(15)
  310.     Printer.Print IDs(15); VI.PrivateBuild
  311. End Sub
  312.  
  313.