在用VB制作軟件封面和界面時經常要用到三維字體,一般的方法是先用專門的軟件(如Xara3d等)制作出三維字體的圖片,然后再用圖片框等控件顯示出來。這樣雖然簡單,但其缺點有二:一是要額外增加控件和圖片,這樣勢必會增加程序的大;二是在VB中圖片的加載速度不敢恭維。如能用VB直接編程制作出三維字體,豈不美哉!以下是本人的一點“小技”,請笑納!
先在VB中新建一個“工程”,然后在窗體上放置四個Command。以下是源程序:
先聲明如下“通用變量”:
Dim posx, posy As Integer '文字的顯示位置
Dim txtwidth As Integer '文字輪廓寬度
Dim str As String '欲顯示的文字
Private Sub Command1_Click() '顯示凸起三維文字
Dim i As Integer
str = "顯示凸起三維文字"
Me.Cls
Me.ForeColor = RGB(255, 255, 255)
For i = 1 To txtwidth
Me.CurrentX = posx - i
Me.CurrentY = posy - i
Me.Print str
Next i
Me.ForeColor = RGB(0, 0, 0)
For i = 1 To txtwidth
Me.CurrentX = posx + i
Me.CurrentY = posy + i
Me.Print str
Next i
Me.ForeColor = RGB(0, 0, 255)
Me.CurrentX = posx
Me.CurrentY = posy
Me.Print str
End Sub
Private Sub Command2_Click() '顯示凹陷三維文字
Dim i As Integer
str = "顯示凹陷三維文字"
Me.Cls
Me.ForeColor = RGB(0, 0, 0)
For i = 1 To txtwidth
Me.CurrentX = posx - i
Me.CurrentY = posy - i
Me.Print str
Next i
Me.ForeColor = RGB(255, 255, 255)
For i = 1 To txtwidth
Me.CurrentX = posx + i
Me.CurrentY = posy + i
Me.Print str
Next i
Me.ForeColor = RGB(0, 0, 255)
Me.CurrentX = posx
Me.CurrentY = posy
Me.Print str
End Sub
Private Sub Command3_Click() '顯示陰影三維文字
str = "顯示陰影三維文字"
Me.Cls
Me.ForeColor = RGB(100, 100, 100)
Me.CurrentX = posx + txtwidth
Me.CurrentY = posy + txtwidth
Me.Print str
Me.ForeColor = RGB(0, 0, 255)
Me.CurrentX = posx
Me.CurrentY = posy
Me.Print str
End Sub
Private Sub Command4_Click() '顯示傾斜三維文字
Dim i As Integer
str = "顯示傾斜三維文字"
Me.Cls
Me.ForeColor = RGB(100, 100, 100)
For i = 1 To txtwidth
Me.CurrentX = x + i
Me.CurrentY = y + i
Me.Print str
Next i
Me.ForeColor = RGB(0, 0, 255)
Me.CurrentX = posx
Me.CurrentY = posy
Me.Print str
End Sub
Private Sub Form_Load()
posx = 100
posy = 100
txtwidth = 50
Me.FontSize = 30
End Sub
以上程序在win98/vb6.0/233下調試通過。
文章來源于領測軟件測試網 http://www.kjueaiud.com/
版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
技術支持和業務聯系:info@testage.com.cn 電話:010-51297073
老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月