home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- Caption = "Fonts"
- ClientHeight = 7305
- ClientLeft = 5400
- ClientTop = 3960
- ClientWidth = 7305
- LinkTopic = "Form1"
- ScaleHeight = 7305
- ScaleWidth = 7305
- Begin VB.TextBox Text2
- Height = 285
- Index = 1
- Left = 5400
- TabIndex = 22
- Text = "255"
- Top = 4680
- Width = 855
- End
- Begin VB.Frame Frame4
- Caption = "Font Color"
- Height = 1455
- Left = 4800
- TabIndex = 17
- Top = 3960
- Width = 2295
- Begin VB.TextBox Text2
- Height = 285
- Index = 2
- Left = 600
- TabIndex = 23
- Text = "0"
- Top = 1080
- Width = 855
- End
- Begin VB.TextBox Text2
- Height = 285
- Index = 0
- Left = 600
- TabIndex = 21
- Text = "0"
- Top = 360
- Width = 855
- End
- Begin VB.Label Label6
- Caption = "B:"
- Height = 255
- Left = 120
- TabIndex = 20
- Top = 1080
- Width = 375
- End
- Begin VB.Label Label5
- Caption = "G:"
- Height = 255
- Left = 120
- TabIndex = 19
- Top = 720
- Width = 255
- End
- Begin VB.Label Label4
- Caption = "R:"
- Height = 255
- Left = 120
- TabIndex = 18
- Top = 360
- Width = 375
- End
- End
- Begin VB.TextBox Text1
- Height = 285
- Index = 2
- Left = 1080
- TabIndex = 16
- Text = "20"
- Top = 6720
- Width = 1335
- End
- Begin VB.TextBox Text1
- Height = 285
- Index = 1
- Left = 1080
- TabIndex = 15
- Text = "50"
- Top = 6360
- Width = 1335
- End
- Begin VB.Frame Frame3
- Caption = "Font Attributes"
- Height = 1455
- Left = 240
- TabIndex = 10
- Top = 5640
- Width = 2415
- Begin VB.TextBox Text1
- Height = 285
- Index = 0
- Left = 840
- TabIndex = 14
- Text = "300"
- Top = 360
- Width = 1335
- End
- Begin VB.Label Label3
- Caption = "Width:"
- Height = 255
- Left = 120
- TabIndex = 13
- Top = 1080
- Width = 615
- End
- Begin VB.Label Label2
- Caption = "Height:"
- Height = 255
- Left = 120
- TabIndex = 12
- Top = 720
- Width = 615
- End
- Begin VB.Label Label1
- Caption = "Weight:"
- Height = 255
- Left = 120
- TabIndex = 11
- Top = 360
- Width = 735
- End
- End
- Begin VB.Frame Frame2
- Caption = "Font Style"
- Height = 1455
- Left = 2640
- TabIndex = 6
- Top = 3960
- Width = 1935
- Begin VB.CheckBox Check3
- Caption = "Strikeout"
- Height = 255
- Left = 120
- TabIndex = 9
- Top = 1080
- Width = 1215
- End
- Begin VB.CheckBox Check2
- Caption = "Underline"
- Height = 255
- Left = 120
- TabIndex = 8
- Top = 720
- Width = 1215
- End
- Begin VB.CheckBox Check1
- Caption = "Italic"
- Height = 255
- Left = 120
- TabIndex = 7
- Top = 360
- Width = 1215
- End
- End
- Begin VB.Frame Frame1
- Caption = "Font Name"
- Height = 1455
- Left = 240
- TabIndex = 2
- Top = 3960
- Width = 2055
- Begin VB.OptionButton Option3
- Caption = "Courier New"
- Height = 255
- Left = 120
- TabIndex = 5
- Top = 1080
- Width = 1695
- End
- Begin VB.OptionButton Option2
- Caption = "Times New Roman"
- Height = 195
- Left = 120
- TabIndex = 4
- Top = 720
- Width = 1695
- End
- Begin VB.OptionButton Option1
- Caption = "Arial"
- Height = 255
- Left = 120
- TabIndex = 3
- Top = 360
- Value = -1 'True
- Width = 1815
- End
- End
- Begin VB.PictureBox Picture1
- Height = 3615
- Left = 240
- ScaleHeight = 3555
- ScaleWidth = 6795
- TabIndex = 1
- Top = 120
- Width = 6855
- End
- Begin VB.CommandButton Command1
- Caption = "Show Font"
- Height = 495
- Left = 4200
- TabIndex = 0
- Top = 6480
- Width = 1575
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, _
- ByVal crColor As Long) As Long
- Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
- Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" _
- (lpLogFont As LOGFONT) As Long
- Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, _
- ByVal hObject As Long) As Long
- Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, _
- ByVal x As Long, ByVal y As Long, ByVal lpString As String, _
- ByVal nCount As Long) As Long
-
- Private Type RECT
- Left As Long
- Top As Long
- Right As Long
- Bottom As Long
- End Type
- Private Type LOGFONT
- lfHeight As Long
- lfWidth As Long
- lfEscapement As Long
- lfOrientation As Long
- lfWeight As Long
- lfItalic As Byte
- lfUnderline As Byte
- lfStrikeOut As Byte
- lfCharSet As Byte
- lfOutPrecision As Byte
- lfClipPrecision As Byte
- lfQuality As Byte
- lfPitchAndFamily As Byte
- lfFaceName As String * 50
- End Type
- Dim myLogFont As LOGFONT
- Private Sub Check1_Click()
- 'Italics
- myLogFont.lfItalic = Check1.Value
-
- End Sub
- Private Sub Check2_Click()
- 'Italics
- myLogFont.lfUnderline = Check2.Value
-
- End Sub
- Private Sub Check3_Click()
- 'Italics
- myLogFont.lfStrikeOut = Check3.Value
-
- End Sub
- Private Sub Command1_Click()
- Dim newFont As Long
- Dim oldFont As Long
- Dim retValue As Long
- Dim fontStr As String
- 'Set weight, height, width
- myLogFont.lfWeight = Val(Text1(0).Text)
- myLogFont.lfHeight = Val(Text1(1).Text)
- myLogFont.lfWidth = Val(Text1(2).Text)
- myLogFont.lfEscapement = 0
- Picture1.Cls
- 'Set color
- retValue = SetTextColor(Picture1.hdc, RGB(Val(Text2(0).Text), Val(Text2(1).Text), Val(Text2(2).Text)))
- 'Select font
- newFont = CreateFontIndirect(myLogFont)
- oldFont = SelectObject(Picture1.hdc, newFont)
- 'Print font
- fontStr = "Blah Blah Blah"
- retValue = TextOut(Picture1.hdc, 0, 0, fontStr, Len(fontStr))
- 'Select old font back into DC
- newFont = SelectObject(Picture1.hdc, oldFont)
- retValue = DeleteObject(newFont)
- End Sub
- Private Sub Form_Load()
- Picture1.ScaleMode = 3
- End Sub
- Private Sub Option1_Click()
- If Option1.Value = True Then
- myLogFont.lfFaceName = "Arial" + Chr$(0)
- End If
- End Sub
- Private Sub Option2_Click()
- If Option2.Value = True Then
- myLogFont.lfFaceName = "Times New Roman" + Chr$(0)
- End If
- End Sub
- Private Sub Option3_Click()
- If Option3.Value = True Then
- myLogFont.lfFaceName = "Courier New" + Chr$(0)
- End If
- End Sub
-