transparent OCX with transparent label 
Author Message
 transparent OCX with transparent label

Someone have an example about how create an transparent custom control with
a Transparent Label

Eugenio



Fri, 11 Jun 2004 05:37:53 GMT  
 transparent OCX with transparent label
Instead of using a Label control, just print the caption on the UserControl
and transfer it to the MaskPicture.

Here is an example of a simple UserControl with a Caption property only:

Option Explicit

'Property Variables:
Dim msCaption As String

Public Property Get Caption() As String
    Caption = msCaption
End Property

Public Property Let Caption(ByVal New_Caption As String)
    msCaption = New_Caption
    PropertyChanged "Caption"
    Call DrawCaption
End Property

'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
    msCaption = UserControl.Ambient.DisplayName
End Sub

'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    msCaption = PropBag.ReadProperty("Caption", "")
    Call DrawCaption
End Sub

Private Sub UserControl_Resize()
    Call DrawCaption
End Sub

'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    Call PropBag.WriteProperty("Caption", msCaption, "")
End Sub

Private Sub DrawCaption()

    With UserControl
        'Turn on AutoRedraw, so we can draw to the Image
        .AutoRedraw = True
        'Clear previous Caption
        Set .Picture = LoadPicture()
        .Cls
        'Center the Caption
        .CurrentX = (.ScaleWidth - .TextWidth(msCaption)) / 2
        .CurrentY = (.ScaleHeight - .TextHeight(msCaption)) / 2
        'Print the Caption
        UserControl.Print msCaption
        'Match the MaskColor to the BackColor for transparency
        .MaskColor = .BackColor
        'Persist the Image to the Picture
        Set .Picture = .Image
        'Pass the same Image to the MaskPicture
        Set .MaskPicture = .Image
        'No need for AutoRedraw anymore
        .AutoRedraw = False
        'Make it transparent
        .BackStyle = 0
    End With

End Sub



Quote:
> Someone have an example about how create an transparent custom control
with
> a Transparent Label

> Eugenio



Fri, 11 Jun 2004 21:20:31 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. BUG: Transparent Label on Transparent Control Does Not Display

2. Transparent UserControl with transparent label - Anyone?

3. Transparent UserControl with transparent label

4. Transparent Label on Transparent User Control Problem

5. BUG: Transparent Label on Transparent Control Does Not Display

6. Looking for Transparent OCX to make forms transparent

7. Looking for Transparent OCX to make forms transparent

8. OCX with transparent label

9. Labels - Transparent labels flash whenever they get changed

10. Transparent MSChart ctrl or transparent PictureBox

11. Transparent controls are not Transparent in VC++

12. Transparent Form Is Not Transparent

 

 
Powered by phpBB® Forum Software