如图,我想做一个自定义控件,想加一些类似picturebox的Appearance属性和BackColor属性,并将它们传递给控件内部的picturebox。但是我用如下代码可以实现值的传递:Public Property Get Appearance() As Integer
Appearance = Picture1.Appearance
End PropertyPublic Property Let Appearance(ByVal a1 As Integer)
Picture1.Appearance = a1
End PropertyPublic Property Get BackColor() As Long
BackColor = Picture1.BackColor
End PropertyPublic Property Let BackColor(ByVal c1 As Long)
Picture1.BackColor = c1
End Property但添加到工程中的是效果如下:
请问高手,如何把自定义属性做得跟普通控件属性效果一样呢?

解决方案 »

  1.   

    Public Enum ControlAppearance
        Flat = 0
        [3D] = 1
    End EnumPublic Property Get Appearance() As ControlAppearance
        Appearance = Picture1.Appearance
    End PropertyPublic Property Let Appearance(ByVal a1 As ControlAppearance)
        Picture1.Appearance = a1
    End PropertyPublic Property Get BackColor() As OLE_COLOR
        BackColor = Picture1.BackColor
    End PropertyPublic Property Let BackColor(ByVal c1 As OLE_COLOR)
        Picture1.BackColor = c1
    End Property
      

  2.   

    感谢老鸟的回答,还有一点,自定义控件中的picturebox的picture属性,如何传递?是不是要定义一个loadpicture方法呢?没搞懂。
      

  3.   

    自己回答:Public Property Get Picture() As Picture
        Set Picture = Picture1.Picture
    End PropertyPublic Property Set Picture(ByVal pp As Picture)
        Set Picture1.Picture = pp
    End Property可传递picture属性。谢谢各位的回答。
      

  4.   

    Public Property Get Picture() As IPictureDisp
        Set Picture = Picture1.Picture
    End PropertyPublic Property Set Picture(ByVal RHS As IPictureDisp)
        Set Picture1.Picture = RHS
    End Property