home *** CD-ROM | disk | FTP | other *** search
/ On Hand / On_Hand_From_Softbank_1994_Release_2_Disc_2_1994.iso / 00202 / s / disk1 / fontdial.fr_ / fontdial.bin
Text File  |  1993-04-28  |  6KB  |  178 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. End
  67. Option Explicit
  68. Dim Shared FntNum As Integer
  69.  
  70. Sub cmdCancel_Click ()
  71.     ' Hide dialog
  72.     FontDialog.Hide
  73. End Sub
  74.  
  75. Sub cmdOK_Click ()
  76.     ' Hide dialog
  77.     FontDialog.Hide
  78.     ' Change font for Printer object to selected font.
  79.     Printer.FontName = lstMatchFonts.List(FntNum)
  80.     ' Declare local variable
  81.     Dim F
  82.     ' Apply selected font to all labels
  83.     For F = 0 To 6
  84.         Card.lblDay(F).FontName = lstMatchFonts.List(FntNum)
  85.         Card.lblInTime(F).FontName = lstMatchFonts.List(FntNum)
  86.         Card.lblOutTime(F).FontName = lstMatchFonts.List(FntNum)
  87.         Card.lblHours(F).FontName = lstMatchFonts.List(FntNum)
  88.     Next F
  89.     Card.lblTotal.FontName = lstMatchFonts.List(FntNum)
  90.     Card.lblRegTotal.FontName = lstMatchFonts.List(FntNum)
  91.     Card.lblRegHrs.FontName = lstMatchFonts.List(FntNum)
  92.     Card.lblOverTotal.FontName = lstMatchFonts.List(FntNum)
  93.     Card.lblOverHrs.FontName = lstMatchFonts.List(FntNum)
  94. End Sub
  95.  
  96. Sub Form_Load ()
  97.     ' Position form in middle of screen
  98.     FontDialog.Left = (Screen.Width - FontDialog.Width) / 2
  99.     FontDialog.Top = (Screen.Height - FontDialog.Height) / 2
  100.     ' Match available printer fonts to screen fonts and load
  101.     ' list of matches in list box
  102.     GetFonts
  103. End Sub
  104.  
  105. Sub Form_Resize ()
  106.     ' As long as the dialog is not minimized.
  107.     If FontDialog.WindowState = 0 Then
  108.         ' Keep the height and width constant while displaying
  109.         ' a border that looks resizable.
  110.         FontDialog.Height = 2970
  111.         FontDialog.Width = 4425
  112.     End If
  113. End Sub
  114.  
  115. Sub GetFonts ()
  116.     ' Declare variable array to store list of matched font names
  117.     ' from available screen and printer fonts.
  118.     Dim BothFonts()
  119.     ' Declare local variables
  120.     Dim PTarget
  121.     Dim Match
  122.     Dim MatchCnt
  123.     Dim PBarW
  124.     Dim PBarH
  125.     Dim Item
  126.     ' Initialize MatchCnt
  127.     MatchCnt = 0
  128.     ' Display cancel dialog for font select
  129.     CancelFont.Show
  130.     ' Initialize variable to track height of progress bar in cancel dialog
  131.     PBarH = CancelFont.picProgress.ScaleHeight
  132.     ' For each font in printer font list
  133.     For PTarget = 0 To (Printer.FontCount - 1)
  134.         ' Try to match each font in screen font list
  135.         For Match = 0 To (Screen.FontCount - 1)
  136.             ' Yield processing to detect cmdCancel_Click
  137.             DoEvents
  138.             ' On a match...
  139.             If Printer.Fonts(PTarget) = Screen.Fonts(Match) Then
  140.                 ' Increment match counter
  141.                 MatchCnt = MatchCnt + 1
  142.                 ' Size array to hold matched font names
  143.                 ReDim Preserve BothFonts(MatchCnt)
  144.                 ' Add font name to matched font list
  145.                 BothFonts(MatchCnt - 1) = Printer.Fonts(PTarget)
  146.                 ' Exit loop to get next printer font
  147.                 Match = Screen.FontCount - 1
  148.             End If
  149.             ' Calculate percent progress
  150.             PBarW = (Match + 1) * (PTarget + 1)
  151.             ' Update progress bar
  152.             CancelFont.picProgress.Line (0, 0)-(PBarW, PBarH), QBColor(1), BF
  153.         ' Check next screen font
  154.         Next Match
  155.     ' Try to match next printer font
  156.     Next PTarget
  157.     ' Remove cancel dialog
  158.     Unload CancelFont
  159.     ' Load matched font list in list box
  160.     For Item = 0 To MatchCnt - 1
  161.         ' If list item isn't blank...
  162.         If BothFonts(Item) <> "" Then
  163.             lstMatchFonts.AddItem BothFonts(Item)
  164.         End If
  165.     Next Item
  166. End Sub
  167.  
  168. Sub lstMatchFonts_Click ()
  169.     FntNum = lstMatchFonts.ListIndex
  170.     lblFontDemo.FontName = lstMatchFonts.List(FntNum)
  171. End Sub
  172.  
  173. Sub lstMatchFonts_DblClick ()
  174.     FntNum = lstMatchFonts.ListIndex
  175.     lblFontDemo.FontName = lstMatchFonts.List(FntNum)
  176. End Sub
  177.  
  178.