VB6.0类模板的问题
我想在类模板(text3d)制作一个能够实现3D文字效果的功能的模板。X 代表容器对象 比如form frame Picture 中显示对象。
然后调用就可以在指定的容器上实现文字的效果。比如我想在窗体form1上显示的
话。我应该怎么让X知道是form2窗上显示
以下是类模板(text3d)代码:
Option Explicit
Public kind As String '定义3D文字的效果样式
Public inside As String '定义要显示的文字内容
Public colorR As Integer, colorG As Integer, colorB As Integer '定义文
字的前颜色
Public X As Integer, Y As Integer '文字容器的显示位置
Public Width As Integer '定义文字的3D轮廓宽度
Public Sub ProtuberantEffect() '3D文字效果方法一
Dim i As Integer
X.ForeColor = RGB(255, 255, 255)
For i = 1 To Width
X.CurrentX = X - i
X.CurrentY = Y - i
X.Print inside
Next i
X.ForeColor = RGB(0, 0, 0)
For i = 1 To Width
X.CurrentX = X + i
X.CurrentY = Y + i
X.Print inside
Next i
X.ForeColor = RGB(colorR, colorG, colorB)
X.CurrentX = X
X.CurrentY = Y
X.Print inside
End Sub
Private Sub Class_Initialize() '初始化
colorR = 155: colorG = 0: colorB = 0
X = 150: Y = 150
End Sub
-----------------------------
以下是窗体上的代码:
Private Sub Command1_Click()
Dim myobj As text3d
Set myobj = New text3d
myobj.inside = "文字效果"
myobj.ProtuberantEffect
End Sub
--------------------编程问答-------------------- Option Explicit
Public kind As String '定义3D文字的效果样式
Public inside As String '定义要显示的文字内容
Public colorR As Integer, colorG As Integer, colorB As Integer '定义文
Public obj As Object
Public x As Integer, Y As Integer '文字容器的显示位置
Public Width As Integer '定义文字的3D轮廓宽度
Public Sub ProtuberantEffect() '3D文字效果方法一
Dim i As Integer
obj.ForeColor = RGB(255, 255, 255)
For i = 1 To Width
obj.CurrentX = x - i
obj.CurrentY = Y - i
obj.Print inside
Next i
obj.ForeColor = RGB(0, 0, 0)
For i = 1 To Width
obj.CurrentX = x + i
obj.CurrentY = Y + i
obj.Print inside
Next i
obj.ForeColor = RGB(colorR, colorG, colorB)
obj.CurrentX = x
obj.CurrentY = Y
obj.Print inside
End Sub
Private Sub Class_Initialize() '初始化
colorR = 155: colorG = 0: colorB = 0
x = 150: Y = 150
End Sub
Private Sub Command1_Click()
Dim myobj As text3d
Set myobj = New text3d
myobj.inside = "文字效果"
myobj.Width = 10
Set myobj.obj = Me
myobj.ProtuberantEffect
End Sub
--------------------编程问答-------------------- 高手 真的非常感谢 我原先以为要去做个ACTIVEX DLL 的文件才可以啊
谢谢
本来我是会提供 分的 可是这新号字没有 不好意思啊 ! --------------------编程问答-------------------- 对了高手 我要是想把它做成控件 那我有什么办法来通过属性给OBJ 付值 比如我在T列表框中选择 frame picture 等对象
补充:VB , 基础类