home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / fontview / fontview.txt < prev    next >
Text File  |  1991-05-30  |  5KB  |  194 lines

  1. Dim ValChangeFlag As Integer
  2. Dim CharChangeFlat As Integer
  3. Dim OldValueText As String
  4. Dim OldCharText As String
  5.  
  6. Sub Form_Load ()
  7.     ' Initialize form position
  8.     Left = (Screen.width - width) / 2
  9.     Top = (Screen.Height - Height) / 2
  10.  
  11.     ' Initialize font list
  12.     For I% = 0 To Screen.FontCount - 1
  13.         FontList.AddItem Screen.Fonts(I%)
  14.     Next I%
  15.     ' Set default font
  16.     FontList.ListIndex = 1
  17.     For I% = 0 To FontList.ListCount
  18.         If FontList.List(I%) = "Helv" Then
  19.             FontList.ListIndex = I%
  20.             Exit For
  21.         End If
  22.     Next I%
  23.     
  24.     'Initialize font size list
  25.     For I% = 6 To 48 Step 2
  26.         SizeList.AddItem Str$(I%)
  27.         
  28.     Next I%
  29.     SizeList.ListIndex = 3
  30.     
  31.     ' Initialize colors
  32.     ColorList.AddItem "0 - Black"
  33.     ColorList.AddItem "1 - Blue"
  34.     ColorList.AddItem "2 - Green"
  35.     ColorList.AddItem "3 - Cyan"
  36.     ColorList.AddItem "4 - Red"
  37.     ColorList.AddItem "5 - Magenta"
  38.     ColorList.AddItem "6 - Brown"
  39.     ColorList.AddItem "7 - White"
  40.     ColorList.AddItem "8 - Gray"
  41.     ColorList.AddItem "9 - Light Blue"
  42.     ColorList.AddItem "10 - Light Green"
  43.     ColorList.AddItem "11 - Light Cyan"
  44.     ColorList.AddItem "12 - Light Red"
  45.     ColorList.AddItem "13 - Light Magenta"
  46.     ColorList.AddItem "14 - Yellow"
  47.     ColorList.AddItem "15 - Bright White"
  48.     ColorList.ListIndex = 0
  49.     
  50.     ' Initialize font attributes OFF
  51.     Text1.FontBold = FALSE
  52.     Text1.FontItalic = FALSE
  53.     Text1.FontStrikethru = FALSE
  54.     Text1.FontUnderline = FALSE
  55.     
  56.     'Initialize Option buttons
  57.     DisplayText(0).Value = TRUE
  58.     DisplayText(1).Value = FALSE
  59.     
  60.     Text2Display$ = GetDisplayText()
  61.     ShowDisplayText
  62.     
  63. End Sub
  64.  
  65. Sub ckBold_Click ()
  66.     If ckBold.Value = CHECKED Then
  67.         Text1.FontBold = TRUE
  68.     Else
  69.         Text1.FontBold = FALSE
  70.     End If
  71. End Sub
  72.  
  73. Sub ckItalic_Click ()
  74.    Text1.FontItalic = Not Text1.FontItalic  ' Toggle Italic
  75. End Sub
  76.  
  77. Sub ckStrikeThrough_Click ()
  78.     Text1.FontStrikethru = Not Text1.FontStrikethru     ' Toggle Strikethru
  79. End Sub
  80.  
  81. Sub ckUnderline_Click ()
  82.     Text1.FontUnderline = Not Text1.FontUnderline   ' Toggle Underline
  83. End Sub
  84.  
  85. Sub ColorList_Click ()
  86.     ShowDisplayText
  87. End Sub
  88.  
  89. Sub SizeList_Click ()
  90.     ShowDisplayText
  91. End Sub
  92.  
  93. Sub FontList_Click ()
  94.     ckBold_Click
  95.     ShowDisplayText
  96. End Sub
  97.  
  98. Sub DisplayText_Click (Index As Integer)
  99.     Select Case Index
  100.         Case 0
  101.             DisplayText(Index + 1).Value = Not DisplayText(Index).Value
  102.         Case 1
  103.             DisplayText(Index - 1).Value = Not DisplayText(Index).Value
  104.             Text1.Text = ""
  105.             Text1.SetFocus
  106.     End Select
  107.     ShowDisplayText
  108. End Sub
  109.  
  110. Sub Form_Unload (Cancel As Integer)
  111.     End
  112. End Sub
  113.  
  114. Sub Text1_LostFocus ()
  115.     Text1.Text = RTrim$(Text1.Text) + " "
  116.     ckItalic.Enabled = TRUE
  117. End Sub
  118.  
  119. Function GetDisplayText$ ()
  120.         For I% = 33 To 255                          ' Make the standard text to display
  121.             ViewText$ = ViewText$ + Chr$(I%)
  122.         Next I%
  123.         ViewText$ = ViewText$ + " "                 ' Pad with space for Italic
  124.         GetDisplayText$ = ViewText$
  125. End Function
  126.  
  127. Sub ShowDisplayText ()
  128.     Text1.FontName = FontList.Text                  ' Get the font name
  129.     If Len(SizeList.Text) <> 0 Then Text1.FontSize = Val(SizeList.Text)             ' Get the font size
  130.     Text1.ForeColor = QBColor(Val(ColorList.Text))  ' Get the foreground color
  131.     If DisplayText(0).Value = TRUE Then
  132.         If Text1.Text <> Text2Display$ Then
  133.             Text1.Text = Text2Display$
  134.         Else
  135.             Text1.Text = Text1.Text + " "
  136.         End If
  137.     Else
  138.         Text1.Text = Text1.Text + " "
  139.     End If
  140. End Sub
  141.  
  142. Sub cmdQuit_Click ()
  143.     Unload FontViewer       ' Unload main form
  144. End Sub
  145.  
  146. Sub Text1_GotFocus ()
  147.     If DisplayText(0).Value = TRUE Then
  148.         DisplayText(0).SetFocus
  149.     Else
  150.         ckItalic.Value = FALSE
  151.         ckItalic.Enabled = FALSE
  152.         Text1.FontItalic = FALSE
  153.     End If
  154. End Sub
  155.  
  156. Sub Text1_KeyPress (KeyAscii As Integer)
  157.     If DisplayText(1).Value = TRUE Then
  158.         ckItalic.Enabled = TRUE
  159.     End If
  160. End Sub
  161.  
  162. Sub SingleCharSelect_Change ()
  163.     SingleChar.Text = Chr$(SingleCharSelect.Value)
  164.     SingleCharValue.Text = Format$(SingleCharSelect.Value)
  165.     ValChangeFlag = FALSE
  166.     CharChangeFlag = FALSE
  167. End Sub
  168.  
  169. Sub SingleCharValue_Change ()
  170.     If Len(SingleCharValue.Text) = 0 Then SingleCharValue.Text = "65"
  171.     If Val(SingleCharValue.Text) >= 0 And Val(SingleCharValue.Text) <= 255 Then
  172.         ValChangeFlag = TRUE
  173.         SingleCharSelect.Value = Val(SingleCharValue.Text)
  174.         OldValueText$ = SingleCharValue.Text
  175.     Else
  176.         SingleCharValue.Text = OldValueText$
  177.     End If
  178.  
  179.  
  180. End Sub
  181.  
  182. Sub SingleChar_Change ()
  183.     If Len(SingleChar.Text) = 0 Then SingleChar.Text = "A"
  184.     If Asc(Left$(SingleChar.Text, 1)) >= 0 And Asc(Left$(SingleChar.Text, 1)) <= 255 Then
  185.         CharChangeFlag = TRUE
  186.         SingleCharSelect.Value = Asc(SingleChar.Text)
  187.         OldCharText$ = SingleChar.Text
  188.     Else
  189.         SingleChar.Text = OldCharText$
  190.     End If
  191.  
  192. End Sub
  193.  
  194.