Results 1 to 5 of 5

Thread: The force of Usercontrols

  1. #1

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Lightbulb

    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:
    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
    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.

    Regards,

  3. #3

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386
    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.
    Hope this helps

    Crazy D

  5. #5

    Thread Starter
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width