home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / fontview / fontview.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  11.7 KB  |  374 lines

  1. VERSION 2.00
  2. Begin Form FontViewer 
  3.    BackColor       =   &H00808000&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Font Viewer"
  6.    ClientHeight    =   4275
  7.    ClientLeft      =   1080
  8.    ClientTop       =   1515
  9.    ClientWidth     =   7155
  10.    ForeColor       =   &H00FFFFFF&
  11.    Height          =   4680
  12.    Icon            =   FONTVIEW.FRX:0000
  13.    Left            =   1020
  14.    LinkMode        =   1  'Source
  15.    LinkTopic       =   "Form1"
  16.    MaxButton       =   0   'False
  17.    ScaleHeight     =   4275
  18.    ScaleWidth      =   7155
  19.    Top             =   1170
  20.    Width           =   7275
  21.    Begin TextBox Text1 
  22.       BackColor       =   &H00FFFFFF&
  23.       Height          =   1455
  24.       Left            =   195
  25.       MultiLine       =   -1  'True
  26.       ScrollBars      =   3  'Both
  27.       TabIndex        =   0
  28.       TabStop         =   0   'False
  29.       Top             =   2610
  30.       Width           =   6705
  31.    End
  32.    Begin CommandButton cmdQuit 
  33.       Caption         =   "Quit"
  34.       Height          =   1065
  35.       Left            =   5850
  36.       TabIndex        =   14
  37.       Top             =   1245
  38.       Width           =   1050
  39.    End
  40.    Begin Frame Frame2 
  41.       BackColor       =   &H00808000&
  42.       Caption         =   "&Display Text"
  43.       ForeColor       =   &H0000FFFF&
  44.       Height          =   1248
  45.       Left            =   3096
  46.       TabIndex        =   1
  47.       Top             =   1080
  48.       Width           =   2520
  49.       Begin TextBox SingleChar 
  50.          Height          =   396
  51.          Left            =   1968
  52.          TabIndex        =   18
  53.          Text            =   "A"
  54.          Top             =   720
  55.          Width           =   444
  56.       End
  57.       Begin OptionButton DisplayText 
  58.          BackColor       =   &H00808000&
  59.          Caption         =   "Custom"
  60.          ForeColor       =   &H00FFFFFF&
  61.          Height          =   300
  62.          Index           =   1
  63.          Left            =   216
  64.          TabIndex        =   12
  65.          Top             =   720
  66.          Width           =   984
  67.       End
  68.       Begin OptionButton DisplayText 
  69.          BackColor       =   &H00808000&
  70.          Caption         =   "Standard"
  71.          ForeColor       =   &H00FFFFFF&
  72.          Height          =   252
  73.          Index           =   0
  74.          Left            =   216
  75.          TabIndex        =   10
  76.          Top             =   360
  77.          Width           =   1104
  78.       End
  79.       Begin TextBox SingleCharValue 
  80.          FontBold        =   0   'False
  81.          FontItalic      =   0   'False
  82.          FontName        =   "MS Sans Serif"
  83.          FontSize        =   8.25
  84.          FontStrikethru  =   0   'False
  85.          FontUnderline   =   0   'False
  86.          Height          =   372
  87.          Left            =   1968
  88.          TabIndex        =   9
  89.          Text            =   "65"
  90.          Top             =   240
  91.          Width           =   444
  92.       End
  93.       Begin VScrollBar SingleCharSelect 
  94.          Height          =   948
  95.          Left            =   1440
  96.          Max             =   255
  97.          TabIndex        =   8
  98.          Top             =   216
  99.          Value           =   65
  100.          Width           =   300
  101.       End
  102.    End
  103.    Begin Frame Frame1 
  104.       BackColor       =   &H00808000&
  105.       Caption         =   "&Attributes"
  106.       ForeColor       =   &H0000FFFF&
  107.       Height          =   1248
  108.       Left            =   216
  109.       TabIndex        =   2
  110.       Top             =   1080
  111.       Width           =   2688
  112.       Begin CheckBox ckUnderline 
  113.          BackColor       =   &H00808000&
  114.          Caption         =   "Underline"
  115.          ForeColor       =   &H00FFFFFF&
  116.          Height          =   252
  117.          Left            =   1152
  118.          TabIndex        =   17
  119.          Top             =   720
  120.          Width           =   1212
  121.       End
  122.       Begin CheckBox ckItalic 
  123.          BackColor       =   &H00808000&
  124.          Caption         =   "Italic"
  125.          ForeColor       =   &H00FFFFFF&
  126.          Height          =   360
  127.          Left            =   210
  128.          TabIndex        =   7
  129.          Top             =   660
  130.          Width           =   840
  131.       End
  132.       Begin CheckBox ckStrikeThrough 
  133.          BackColor       =   &H00808000&
  134.          Caption         =   "Strikethrough"
  135.          ForeColor       =   &H00FFFFFF&
  136.          Height          =   228
  137.          Left            =   1152
  138.          TabIndex        =   16
  139.          Top             =   360
  140.          Width           =   1452
  141.       End
  142.       Begin CheckBox CkBold 
  143.          BackColor       =   &H00808000&
  144.          Caption         =   "Bold"
  145.          ForeColor       =   &H00FFFFFF&
  146.          Height          =   285
  147.          Left            =   210
  148.          TabIndex        =   15
  149.          Top             =   315
  150.          Width           =   720
  151.       End
  152.    End
  153.    Begin ComboBox ColorList 
  154.       BackColor       =   &H00E0FFFF&
  155.       Height          =   288
  156.       Left            =   4632
  157.       Style           =   2  'Dropdown List
  158.       TabIndex        =   13
  159.       Top             =   612
  160.       Width           =   2256
  161.    End
  162.    Begin ComboBox SizeList 
  163.       BackColor       =   &H00E0FFFF&
  164.       Height          =   288
  165.       Left            =   3408
  166.       Style           =   2  'Dropdown List
  167.       TabIndex        =   11
  168.       Top             =   612
  169.       Width           =   912
  170.    End
  171.    Begin ComboBox FontList 
  172.       BackColor       =   &H00E0E0E0&
  173.       Height          =   288
  174.       Left            =   216
  175.       Sorted          =   -1  'True
  176.       Style           =   2  'Dropdown List
  177.       TabIndex        =   6
  178.       Top             =   576
  179.       Width           =   2940
  180.    End
  181.    Begin Label Label3 
  182.       BackColor       =   &H00808000&
  183.       Caption         =   "&Color"
  184.       ForeColor       =   &H0000FFFF&
  185.       Height          =   252
  186.       Left            =   4632
  187.       TabIndex        =   3
  188.       Top             =   252
  189.       Width           =   1572
  190.    End
  191.    Begin Label Label2 
  192.       BackColor       =   &H00808000&
  193.       Caption         =   "&Size"
  194.       ForeColor       =   &H0000FFFF&
  195.       Height          =   255
  196.       Left            =   3420
  197.       TabIndex        =   4
  198.       Top             =   255
  199.       Width           =   750
  200.    End
  201.    Begin Label Label1 
  202.       BackColor       =   &H00808000&
  203.       Caption         =   "&Font"
  204.       ForeColor       =   &H0000FFFF&
  205.       Height          =   255
  206.       Left            =   285
  207.       TabIndex        =   5
  208.       Top             =   210
  209.       Width           =   1350
  210.    End
  211. Dim ValChangeFlag As Integer
  212. Dim CharChangeFlat As Integer
  213. Dim OldValueText As String
  214. Dim OldCharText As String
  215. Sub ckBold_Click ()
  216.     If ckBold.Value = CHECKED Then
  217.         Text1.FontBold = True
  218.     Else
  219.         Text1.FontBold = False
  220.     End If
  221. End Sub
  222. Sub ckItalic_Click ()
  223.    Text1.FontItalic = Not Text1.FontItalic  ' Toggle Italic
  224. End Sub
  225. Sub ckStrikeThrough_Click ()
  226.     Text1.FontStrikethru = Not Text1.FontStrikethru     ' Toggle Strikethru
  227. End Sub
  228. Sub ckUnderline_Click ()
  229.     Text1.FontUnderline = Not Text1.FontUnderline   ' Toggle Underline
  230. End Sub
  231. Sub cmdQuit_Click ()
  232.     Unload FontViewer       ' Unload main form
  233. End Sub
  234. Sub ColorList_Click ()
  235.     ShowDisplayText
  236. End Sub
  237. Sub DisplayText_Click (Index As Integer)
  238.     Select Case Index
  239.         Case 0
  240.             DisplayText(Index + 1).Value = Not DisplayText(Index).Value
  241.         Case 1
  242.             DisplayText(Index - 1).Value = Not DisplayText(Index).Value
  243.             Text1.Text = ""
  244.             Text1.SetFocus
  245.     End Select
  246.     ShowDisplayText
  247. End Sub
  248. Sub FontList_Click ()
  249.     ckBold_Click
  250.     ShowDisplayText
  251. End Sub
  252. Sub Form_Load ()
  253.     ' Initialize form position
  254.     Left = (Screen.width - width) / 2
  255.     Top = (Screen.Height - Height) / 2
  256.     ' Initialize font list
  257.     For I% = 0 To Screen.FontCount - 1
  258.         FontList.AddItem Screen.Fonts(I%)
  259.     Next I%
  260.     ' Set default font
  261.     FontList.ListIndex = 1
  262.     For I% = 0 To FontList.ListCount
  263.         If FontList.List(I%) = "Helv" Then
  264.             FontList.ListIndex = I%
  265.             Exit For
  266.         End If
  267.     Next I%
  268.     'Initialize font size list
  269.     For I% = 6 To 48 Step 2
  270.         SizeList.AddItem Str$(I%)
  271.         
  272.     Next I%
  273.     SizeList.ListIndex = 3
  274.     ' Initialize colors
  275.     ColorList.AddItem "0 - Black"
  276.     ColorList.AddItem "1 - Blue"
  277.     ColorList.AddItem "2 - Green"
  278.     ColorList.AddItem "3 - Cyan"
  279.     ColorList.AddItem "4 - Red"
  280.     ColorList.AddItem "5 - Magenta"
  281.     ColorList.AddItem "6 - Brown"
  282.     ColorList.AddItem "7 - White"
  283.     ColorList.AddItem "8 - Gray"
  284.     ColorList.AddItem "9 - Light Blue"
  285.     ColorList.AddItem "10 - Light Green"
  286.     ColorList.AddItem "11 - Light Cyan"
  287.     ColorList.AddItem "12 - Light Red"
  288.     ColorList.AddItem "13 - Light Magenta"
  289.     ColorList.AddItem "14 - Yellow"
  290.     ColorList.AddItem "15 - Bright White"
  291.     ColorList.ListIndex = 0
  292.     ' Initialize font attributes OFF
  293.     Text1.FontBold = False
  294.     Text1.FontItalic = False
  295.     Text1.FontStrikethru = False
  296.     Text1.FontUnderline = False
  297.     'Initialize Option buttons
  298.     DisplayText(0).Value = True
  299.     DisplayText(1).Value = False
  300.     Text2Display$ = GetDisplayText()
  301.     ShowDisplayText
  302. End Sub
  303. Sub Form_Unload (Cancel As Integer)
  304.     End
  305. End Sub
  306. Function GetDisplayText$ ()
  307.         For I% = 33 To 255                          ' Make the standard text to display
  308.             ViewText$ = ViewText$ + Chr$(I%)
  309.         Next I%
  310.         ViewText$ = ViewText$ + " "                 ' Pad with space for Italic
  311.         GetDisplayText$ = ViewText$
  312. End Function
  313. Sub ShowDisplayText ()
  314.     Text1.FontName = FontList.Text                  ' Get the font name
  315.     If Len(SizeList.Text) <> 0 Then Text1.FontSize = Val(SizeList.Text)             ' Get the font size
  316.     Text1.ForeColor = QBColor(Val(ColorList.Text))  ' Get the foreground color
  317.     If DisplayText(0).Value = True Then
  318.         If Text1.Text <> Text2Display$ Then
  319.             Text1.Text = Text2Display$
  320.         Else
  321.             Text1.Text = Text1.Text + " "
  322.         End If
  323.     Else
  324.         Text1.Text = Text1.Text + " "
  325.     End If
  326. End Sub
  327. Sub SingleChar_Change ()
  328.     If Len(SingleChar.Text) = 0 Then SingleChar.Text = "A"
  329.     If Asc(Left$(SingleChar.Text, 1)) >= 0 And Asc(Left$(SingleChar.Text, 1)) <= 255 Then
  330.         CharChangeFlag = True
  331.         SingleCharSelect.Value = Asc(SingleChar.Text)
  332.         OldCharText$ = SingleChar.Text
  333.     Else
  334.         SingleChar.Text = OldCharText$
  335.     End If
  336. End Sub
  337. Sub SingleCharSelect_Change ()
  338.     SingleChar.Text = Chr$(SingleCharSelect.Value)
  339.     SingleCharValue.Text = Format$(SingleCharSelect.Value)
  340.     ValChangeFlag = False
  341.     CharChangeFlag = False
  342. End Sub
  343. Sub SingleCharValue_Change ()
  344.     If Len(SingleCharValue.Text) = 0 Then SingleCharValue.Text = "65"
  345.     If Val(SingleCharValue.Text) >= 0 And Val(SingleCharValue.Text) <= 255 Then
  346.         ValChangeFlag = True
  347.         SingleCharSelect.Value = Val(SingleCharValue.Text)
  348.         OldValueText$ = SingleCharValue.Text
  349.     Else
  350.         SingleCharValue.Text = OldValueText$
  351.     End If
  352. End Sub
  353. Sub SizeList_Click ()
  354.     ShowDisplayText
  355. End Sub
  356. Sub Text1_GotFocus ()
  357.     If DisplayText(0).Value = True Then
  358.         DisplayText(0).SetFocus
  359.     Else
  360.         ckItalic.Value = False
  361.         ckItalic.Enabled = False
  362.         Text1.FontItalic = False
  363.     End If
  364. End Sub
  365. Sub Text1_KeyPress (KeyAscii As Integer)
  366.     If DisplayText(1).Value = True Then
  367.         ckItalic.Enabled = True
  368.     End If
  369. End Sub
  370. Sub Text1_LostFocus ()
  371.     Text1.Text = RTrim$(Text1.Text) + " "
  372.     ckItalic.Enabled = True
  373. End Sub
  374.