第二种方法
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 sub Picture1_Click()
dim S as string
s="DEMO"
picture1.cls
TextOut picture1.hdc,10,10,s,len(s)
picture1.refresh
end sub
可以用窗体及PictureBox 控件加载图片,并在需要的位置填写文字,然后打印该图片。如:利用PictureBox 控件
1、加载图片
Picture1.Picture = LoadPicture("D:\xxxx.jpg")
2、在图片中填写文字
Picture1.FontSize = 40
Picture1.ForeColor = vbRed
Picture1.Print "中国(China)"
3、打印该图片
Printer.PaintPicture Picture1, 0, 0
Printer.EndDoc
VB6.0中使用函数功能,可实现在vb的picture图中写文字,且字号及字体颜色可按要求改变,代码如下:Option
Explicit
Dim
xx,
yy
As
Integer
Dim
fnt
As
Long
Dim
txt
As
String
Dim
colvb
As
String
Dim
wp
As
Variant
Public
Function
xp(colvb
As
Variant,
xx
As
Variant,
yy
As
Variant,
fnt
As
Variant,
txt
As
Variant)
Picture1.ForeColor
=
colvb
'QBColor(14)
Picture1.CurrentX
=
xx
Picture1.CurrentY
=
yy
Picture1.FontSize
=
fnt
Picture1.Print
txt
'
End
Function
Private
Sub
Form_Load()
Picture1.AutoRedraw
=
True
xx
=
500
yy
=
500
fnt
=
24
colvb
=
vbRed
txt
=
"这是VB对PICTURE图片框的图片上写字的演示"
wp
=
xp(colvb,
xx,
yy,
fnt,
txt)
xx
=
500
yy
=
2500
fnt
=
48
colvb
=
vbGreen
txt
=
"字号调大的演示"
wp
=
xp(colvb,
xx,
yy,
fnt,
txt)
End
Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)