我正在将VB6 ActiveX Dll转换为VB.net。为了支持遗留系统,我需要COM接口以与更新前相同的方式工作。
我有两个实例,其中一个VB6 ColorConstant作为VB6中的一个属性来回传递。
VB6
Public Property Let ProgressBarColor(color As ColorConstants)
userform.ProgressBarColor = color
End Property
Public Property Get ProgressBarColor() As ColorConstants
ProgressBarColor = userform.ProgressBarColor
End Property以下是我在.Net中的内容
VB.NET
Public Property ProgressBarColor() As Long
Get
userform.ProgressBarColor
End Get
Set(ByVal Value As Long)
ProgressBarColor = System.Drawing.ColorTranslator.FromOle(Value)
End Set
End Property有没有一种方法可以让VB.Net以颜色常量的方式处理这个问题?
发布于 2014-07-18 16:29:34
在VB6中,颜色表示为Longs,在VB.NET中,颜色表示为结构。
来源
在VisualBasic6.0中,颜色由Long类型的值表示;在Visual 2008中,颜色是颜色类型。在VisualBasic6.0中,为八种标准颜色提供了常量;在Visual 2008中,有超过100种命名颜色。 Tip 若要查找不是标准颜色的VisualBasic6.0颜色的等效值,可以使用ColorTranslator类并将VisualBasic6.0颜色的长值传递给它。 颜色常数 在VisualBasic6.0中,为可用于将颜色映射到用户的系统首选项的系统颜色提供了常量。在Visual 2008中,系统颜色为SystemColors类型。
为了在功能上保持向后,您必须继续将颜色作为Longs传递,将代码更改为使用ColorTranslator类,如下所示:
Public Property ProgressBarColor() As Int32
Get
Return System.Drawing.ColorTranslator.ToOle(userform.ProgressBarColor)
End Get
Set(ByVal value As Int32)
userform.ProgressBarColor = System.Drawing.ColorTranslator.FromOle(value)
End Set
End Propertyhttps://stackoverflow.com/questions/24829450
复制相似问题