Results 1 to 3 of 3

Thread: Making Colored Background on BMP Images Transparent (User Control Question)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    965

    Making Colored Background on BMP Images Transparent (User Control Question)

    I do have the User Control from a previous Visual Basic 6.0 project that allows certain colors to become transparent. But what I'd like to find out is, how can I make a certain color combination transparent using a User Control in Visual Basic 2008 Express?

  2. #2
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: Making Colored Background on BMP Images Transparent (User Control Question)

    Can we see the code from the user control?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2008
    Location
    St. John's, Newfoundland, Canada
    Posts
    965

    Re: Making Colored Background on BMP Images Transparent (User Control Question)

    It's a bit lengthy, here goes...

    Code:
    Private Sub UserControl_Initialize()
    UserControl.BackStyle = 0
    End Sub
    
    'Initialize Properties for User Control
    Private Sub UserControl_InitProperties()
    
    End Sub
    
    'Load property values from storage
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    
        UserControl.MaskColor = m_MaskColor
        Set Picture = PropBag.ReadProperty("Picture", Nothing)
        UserControl.MaskColor = PropBag.ReadProperty("MaskColor", &H8000000F)
        Set MaskPicture = PropBag.ReadProperty("MaskPicture", Nothing)
        UserControl.ScaleHeight = PropBag.ReadProperty("ScaleHeight", 3600)
        UserControl.ScaleLeft = PropBag.ReadProperty("ScaleLeft", 0)
        UserControl.ScaleMode = PropBag.ReadProperty("ScaleMode", 1)
        UserControl.ScaleTop = PropBag.ReadProperty("ScaleTop", 0)
        UserControl.ScaleWidth = PropBag.ReadProperty("ScaleWidth", 4800)
    End Sub
    
    'Write property values to storage
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    
        Call PropBag.WriteProperty("Picture", Picture, Nothing)
        Call PropBag.WriteProperty("MaskColor", UserControl.MaskColor, &H8000000F)
        Call PropBag.WriteProperty("MaskPicture", MaskPicture, Nothing)
        Call PropBag.WriteProperty("ScaleHeight", UserControl.ScaleHeight, 3600)
        Call PropBag.WriteProperty("ScaleLeft", UserControl.ScaleLeft, 0)
        Call PropBag.WriteProperty("ScaleMode", UserControl.ScaleMode, 1)
        Call PropBag.WriteProperty("ScaleTop", UserControl.ScaleTop, 0)
        Call PropBag.WriteProperty("ScaleWidth", UserControl.ScaleWidth, 4800)
    End Sub
    
    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MappingInfo=UserControl,UserControl,-1,Picture
    Public Property Get Picture() As Picture
    Attribute Picture.VB_Description = "Returns/sets a graphic to be displayed in a control."
        Set Picture = UserControl.Picture
    End Property
    
    Public Property Set Picture(ByVal New_Picture As Picture)
        Set UserControl.Picture = New_Picture
        PropertyChanged "Picture"
    End Property
    
    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MappingInfo=UserControl,UserControl,-1,MaskColor
    Public Property Get MaskColor() As Long
    Attribute MaskColor.VB_Description = "Returns/sets the color that specifies transparent areas in the MaskPicture."
        MaskColor = UserControl.MaskColor
    End Property
    
    Public Property Let MaskColor(ByVal New_MaskColor As Long)
        UserControl.MaskColor() = New_MaskColor
        PropertyChanged "MaskColor"
    End Property
    
    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MappingInfo=UserControl,UserControl,-1,MaskPicture
    Public Property Get MaskPicture() As Picture
    Attribute MaskPicture.VB_Description = "Returns/sets the picture that specifies the clickable/drawable area of the control when BackStyle is 0 (transparent)."
        Set MaskPicture = UserControl.MaskPicture
    End Property
    
    Public Property Set MaskPicture(ByVal New_MaskPicture As Picture)
        Set UserControl.MaskPicture = New_MaskPicture
        PropertyChanged "MaskPicture"
    End Property
    
    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MappingInfo=UserControl,UserControl,-1,ScaleHeight
    Public Property Get ScaleHeight() As Single
    Attribute ScaleHeight.VB_Description = "Returns/sets the number of units for the vertical measurement of an object's interior."
        ScaleHeight = UserControl.ScaleHeight
    End Property
    
    Public Property Let ScaleHeight(ByVal New_ScaleHeight As Single)
        UserControl.ScaleHeight() = New_ScaleHeight
        PropertyChanged "ScaleHeight"
    End Property
    
    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MappingInfo=UserControl,UserControl,-1,ScaleLeft
    Public Property Get ScaleLeft() As Single
    Attribute ScaleLeft.VB_Description = "Returns/sets the horizontal coordinates for the left edges of an object."
        ScaleLeft = UserControl.ScaleLeft
    End Property
    
    Public Property Let ScaleLeft(ByVal New_ScaleLeft As Single)
        UserControl.ScaleLeft() = New_ScaleLeft
        PropertyChanged "ScaleLeft"
    End Property
    
    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MappingInfo=UserControl,UserControl,-1,ScaleMode
    Public Property Get ScaleMode() As Integer
    Attribute ScaleMode.VB_Description = "Returns/sets a value indicating measurement units for object coordinates when using graphics methods or positioning controls."
        ScaleMode = UserControl.ScaleMode
    End Property
    
    Public Property Let ScaleMode(ByVal New_ScaleMode As Integer)
        UserControl.ScaleMode() = New_ScaleMode
        PropertyChanged "ScaleMode"
    End Property
    
    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MappingInfo=UserControl,UserControl,-1,ScaleTop
    Public Property Get ScaleTop() As Single
    Attribute ScaleTop.VB_Description = "Returns/sets the vertical coordinates for the top edges of an object."
        ScaleTop = UserControl.ScaleTop
    End Property
    
    Public Property Let ScaleTop(ByVal New_ScaleTop As Single)
        UserControl.ScaleTop() = New_ScaleTop
        PropertyChanged "ScaleTop"
    End Property
    
    'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
    'MappingInfo=UserControl,UserControl,-1,ScaleWidth
    Public Property Get ScaleWidth() As Single
    Attribute ScaleWidth.VB_Description = "Returns/sets the number of units for the horizontal measurement of an object's interior."
        ScaleWidth = UserControl.ScaleWidth
    End Property
    
    Public Property Let ScaleWidth(ByVal New_ScaleWidth As Single)
        UserControl.ScaleWidth() = New_ScaleWidth
        PropertyChanged "ScaleWidth"
    End Property

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