How can i have types and enumerations that can be put in my activeX ocx so that i can use them both within the usercontrols and in the project using the controls?
Printable View
How can i have types and enumerations that can be put in my activeX ocx so that i can use them both within the usercontrols and in the project using the controls?
This is very easy, but it works only in VB5 and VB6.
Let's say I have a user control with a Picturebox on it and I need a property that will specify only certain colors (red, blue, green, black) for the picturebox on the user control:
Add this user control to the other project and try to assign value to the MyColor property, it will drop down the list with available values for this property.Code:Option Explicit
Public Enum MyColor
RED = vbRed
BLUE = vbBlue
GREEN = vbGreen
BLACK = vbBlack
End Enum
Public Property Get MyColor() As MyColor
MyColor = Picture1.BackColor
End Property
Public Property Let MyColor(ByVal New_MyColor As MyColor)
Picture1.BackColor = New_MyColor
PropertyChanged "MyColor"
End Property
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Picture1.BackColor = PropBag.ReadProperty("MyColor", BLACK)
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("MyColor", Picture1.BackColor, BLACK)
End Sub
Regards,
Ok, I just got mixed up that with a usercontrol i had in a project. What about the type How can i make a type listed in the object browser?
If you mean a userdefined type, you can't. At least, you can't let is show in the property bag in a drop down list.
But, you can just create a type as you create the enum in the ocx, and you can use it both within the ocx as in the project where you use the ocx.
Nope, i can't do that. I don't like it, i have never liked it but i have to go back to creating classmodules instead, sometimes i really need the types :(