VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 795
Left = 1230
TabIndex = 1
Top = 420
Width = 855
End
Begin VB.PictureBox Picture2
Height = 2955
Left = 210
ScaleHeight = 2895
ScaleWidth = 525
TabIndex = 0
Top = 150
Width = 585
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const LF_FACESIZE = 32
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 String
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As Byte
End Type
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 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 Declare Function SelectObject Lib "gdi32" (ByVal hDc As Long, ByVal hObject As Long) As Long
Private Sub Command1_Click()
Me.PrintForm
End Sub
Private Sub Picture2_Click()
Dim lF As LOGFONT
With lF
.lfEscapement = -898 '字体角度
.lfWidth = 5 '字体宽度
.lfHeight = 9 '字体高度
.lfCharSet = "宋体" '打印汉字
End With
Dim Ft As Long
Dim tS As String
tS = "1111111111111"
Ft = CreateFontIndirect(lF)
SelectObject Picture2.hDc, Ft
TextOut Picture2.hDc, 12, 0, tS, Len(tS)
DeleteObject Ft
End Sub
运行时可以显示,但一按COMMAND1打印时,除了PICTURE2上显示的字无法显示外,全部正常。我不知道这是为什么?为什么能显示在电脑上,就是打印不出来?
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 795
Left = 1230
TabIndex = 1
Top = 420
Width = 855
End
Begin VB.PictureBox Picture2
Height = 2955
Left = 210
ScaleHeight = 2895
ScaleWidth = 525
TabIndex = 0
Top = 150
Width = 585
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const LF_FACESIZE = 32
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 String
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As Byte
End Type
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 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 Declare Function SelectObject Lib "gdi32" (ByVal hDc As Long, ByVal hObject As Long) As Long
Private Sub Command1_Click()
Me.PrintForm
End Sub
Private Sub Picture2_Click()
Dim lF As LOGFONT
With lF
.lfEscapement = -898 '字体角度
.lfWidth = 5 '字体宽度
.lfHeight = 9 '字体高度
.lfCharSet = "宋体" '打印汉字
End With
Dim Ft As Long
Dim tS As String
tS = "1111111111111"
Ft = CreateFontIndirect(lF)
SelectObject Picture2.hDc, Ft
TextOut Picture2.hDc, 12, 0, tS, Len(tS)
DeleteObject Ft
End Sub
运行时可以显示,但一按COMMAND1打印时,除了PICTURE2上显示的字无法显示外,全部正常。我不知道这是为什么?为什么能显示在电脑上,就是打印不出来?
Option Explicit
Private Const LF_FACESIZE = 32
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 String
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As Byte
End Type
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 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 Declare Function SelectObject Lib "gdi32" (ByVal hDc As Long, ByVal hObject As Long) As Long
Private Sub Command1_Click()
Me.PrintForm
End Sub
Private Sub Picture1_Click()
Dim lF As LOGFONT
With lF
.lfEscapement = 24 '字体角度
.lfWidth = 5 '字体宽度
.lfHeight = 19 '字体高度
.lfCharSet = "宋体" '打印汉字
End With
Dim Ft As Long
Dim tS As String
Picture1.Cls
Picture1.AutoRedraw = True
tS = "1111111111111 "
Ft = CreateFontIndirect(lF)
SelectObject Picture1.hDc, Ft
TextOut Picture1.hDc, 12, 0, tS, Len(tS)
DeleteObject Ft
Set Picture1.Picture = Picture1.Image
End Sub
Set Picture1.Picture = Picture1.Image
我明天到单位再试一下.可以马上给您分数,谢谢您回答!