第一步、添加一个抽象类,在该类中定义共同的方法和属 ?
如果方法名称是VB关键字,可以修改(如Line方法,本例中改为pLine方法);如果参数形式不符合VB语法,也可作相应修改(如本例中Line方法的参数,应为"(X1,Y1)-(X2,Y2),Forcolor,BF",显然,在VB中的参数不能用这种形式;还有Print方法,
打印参数之间、后面可以跟逗号、分号等,也要相应改变,并且不能提供全部原来Print方法功能)
:
类名:IMyPrinter,为简化,示例中仅包含作为示例的接口。
Public Property Get CurrentX() As Single
End Property
Public Property Let CurrentX(ByVal RHS As Single)
End Property
Public Sub EndDoc()
End Sub
Public Property Get Font() As stdole.Font
End Property
Public Property Set Font(ByVal RHS As stdole.Font)
End Property
Public Sub PLine(ByVal X1 As Single, ByVal Y1 As Single, ByVal X2 As Single, _
ByVal Y2 As Single, Optional ByVal HasB As Boolean = False, _
Optional ByVal HasF As Boolean = False)
End Sub
Public Function ScaleX(ByVal Width As Single, Optional ByVal FromScale As Variant,
_
Optional ByVal ToScale As Variant) As Single
End Function
Public Function TextWidth(ByVal Str As String) As Single
End Function
Public Property Let Width(ByVal RHS As Long)
End Property
Public Property Get Width() As Long
End Property
Public Sub PPrint(Optional ByVal F0D1H2 As Integer = 0, Optional PrnInfo)
End Sub