home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l407 / 4.ddi / FONTDIAL.FR_ / FONTDIAL.bin (.txt)
Encoding:
Visual Basic Form  |  1993-04-28  |  5.6 KB  |  169 lines

  1. VERSION 2.00
  2. Begin Form FontDialog 
  3.    AutoRedraw      =   -1  'True
  4.    Caption         =   "Select Font"
  5.    ClipControls    =   0   'False
  6.    ControlBox      =   0   'False
  7.    Height          =   2955
  8.    Left            =   1140
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   2550
  13.    ScaleWidth      =   4305
  14.    Top             =   2055
  15.    Width           =   4425
  16.    Begin ListBox lstMatchFonts 
  17.       Height          =   1590
  18.       Left            =   240
  19.       TabIndex        =   0
  20.       Top             =   600
  21.       Width           =   2415
  22.    End
  23.    Begin CommandButton cmdOK 
  24.       Caption         =   "OK"
  25.       Height          =   375
  26.       Left            =   2880
  27.       TabIndex        =   1
  28.       Top             =   600
  29.       Width           =   1215
  30.    End
  31.    Begin CommandButton cmdCancel 
  32.       Caption         =   "Cancel"
  33.       Height          =   375
  34.       Left            =   2880
  35.       TabIndex        =   3
  36.       Top             =   1200
  37.       Width           =   1215
  38.    End
  39.    Begin Label lblFontDemo 
  40.       Alignment       =   2  'Center
  41.       AutoSize        =   -1  'True
  42.       BackColor       =   &H00FFFFFF&
  43.       Caption         =   "Sample"
  44.       FontBold        =   -1  'True
  45.       FontItalic      =   0   'False
  46.       FontName        =   "MS Sans Serif"
  47.       FontSize        =   12
  48.       FontStrikethru  =   0   'False
  49.       FontUnderline   =   0   'False
  50.       ForeColor       =   &H000000C0&
  51.       Height          =   315
  52.       Left            =   3000
  53.       TabIndex        =   4
  54.       Top             =   1920
  55.       Width           =   945
  56.    End
  57.    Begin Label lblFList 
  58.       AutoSize        =   -1  'True
  59.       Caption         =   "Available Fonts"
  60.       Height          =   195
  61.       Left            =   240
  62.       TabIndex        =   2
  63.       Top             =   240
  64.       Width           =   1320
  65.    End
  66. Option Explicit
  67. Dim Shared FntNum As Integer
  68. Sub cmdCancel_Click ()
  69.     ' Hide dialog
  70.     FontDialog.Hide
  71. End Sub
  72. Sub cmdOK_Click ()
  73.     ' Hide dialog
  74.     FontDialog.Hide
  75.     ' Change font for Printer object to selected font.
  76.     Printer.FontName = lstMatchFonts.List(FntNum)
  77.     ' Declare local variable
  78.     Dim F
  79.     ' Apply selected font to all labels
  80.     For F = 0 To 6
  81.         Card.lblDay(F).FontName = lstMatchFonts.List(FntNum)
  82.         Card.lblInTime(F).FontName = lstMatchFonts.List(FntNum)
  83.         Card.lblOutTime(F).FontName = lstMatchFonts.List(FntNum)
  84.         Card.lblHours(F).FontName = lstMatchFonts.List(FntNum)
  85.     Next F
  86.     Card.lblTotal.FontName = lstMatchFonts.List(FntNum)
  87.     Card.lblRegTotal.FontName = lstMatchFonts.List(FntNum)
  88.     Card.lblRegHrs.FontName = lstMatchFonts.List(FntNum)
  89.     Card.lblOverTotal.FontName = lstMatchFonts.List(FntNum)
  90.     Card.lblOverHrs.FontName = lstMatchFonts.List(FntNum)
  91. End Sub
  92. Sub Form_Load ()
  93.     ' Position form in middle of screen
  94.     FontDialog.Left = (Screen.Width - FontDialog.Width) / 2
  95.     FontDialog.Top = (Screen.Height - FontDialog.Height) / 2
  96.     ' Match available printer fonts to screen fonts and load
  97.     ' list of matches in list box
  98.     GetFonts
  99. End Sub
  100. Sub Form_Resize ()
  101.     ' As long as the dialog is not minimized.
  102.     If FontDialog.WindowState = 0 Then
  103.         ' Keep the height and width constant while displaying
  104.         ' a border that looks resizable.
  105.         FontDialog.Height = 2970
  106.         FontDialog.Width = 4425
  107.     End If
  108. End Sub
  109. Sub GetFonts ()
  110.     ' Declare variable array to store list of matched font names
  111.     ' from available screen and printer fonts.
  112.     Dim BothFonts()
  113.     ' Declare local variables
  114.     Dim PTarget
  115.     Dim Match
  116.     Dim MatchCnt
  117.     Dim PBarW
  118.     Dim PBarH
  119.     Dim Item
  120.     ' Initialize MatchCnt
  121.     MatchCnt = 0
  122.     ' Display cancel dialog for font select
  123.     CancelFont.Show
  124.     ' Initialize variable to track height of progress bar in cancel dialog
  125.     PBarH = CancelFont.picProgress.ScaleHeight
  126.     ' For each font in printer font list
  127.     For PTarget = 0 To (Printer.FontCount - 1)
  128.         ' Try to match each font in screen font list
  129.         For Match = 0 To (Screen.FontCount - 1)
  130.             ' Yield processing to detect cmdCancel_Click
  131.             DoEvents
  132.             ' On a match...
  133.             If Printer.Fonts(PTarget) = Screen.Fonts(Match) Then
  134.                 ' Increment match counter
  135.                 MatchCnt = MatchCnt + 1
  136.                 ' Size array to hold matched font names
  137.                 ReDim Preserve BothFonts(MatchCnt)
  138.                 ' Add font name to matched font list
  139.                 BothFonts(MatchCnt - 1) = Printer.Fonts(PTarget)
  140.                 ' Exit loop to get next printer font
  141.                 Match = Screen.FontCount - 1
  142.             End If
  143.             ' Calculate percent progress
  144.             PBarW = (Match + 1) * (PTarget + 1)
  145.             ' Update progress bar
  146.             CancelFont.picProgress.Line (0, 0)-(PBarW, PBarH), QBColor(1), BF
  147.         ' Check next screen font
  148.         Next Match
  149.     ' Try to match next printer font
  150.     Next PTarget
  151.     ' Remove cancel dialog
  152.     Unload CancelFont
  153.     ' Load matched font list in list box
  154.     For Item = 0 To MatchCnt - 1
  155.         ' If list item isn't blank...
  156.         If BothFonts(Item) <> "" Then
  157.             lstMatchFonts.AddItem BothFonts(Item)
  158.         End If
  159.     Next Item
  160. End Sub
  161. Sub lstMatchFonts_Click ()
  162.     FntNum = lstMatchFonts.ListIndex
  163.     lblFontDemo.FontName = lstMatchFonts.List(FntNum)
  164. End Sub
  165. Sub lstMatchFonts_DblClick ()
  166.     FntNum = lstMatchFonts.ListIndex
  167.     lblFontDemo.FontName = lstMatchFonts.List(FntNum)
  168. End Sub
  169.