第二种方法
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
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
=
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条)