VB.NET Transparency Issue on 3rd Party Controls

mpappert

Well-known member
Joined
Oct 5, 2002
Messages
58
Location
Ottawa, ON, Canada
Hey Everyone!

Ive read some of the other articles here about transparent controls, but none of them seem to apply to what Im trying to do ... I am using a third party tab control that mimics the XP style tabs under any OS (check out www.ciatheco.com - awesome group of developers) ...

However, when I add a label and place it on top of the tab control (which has a gradient background) and set the backcolor to "transparent" it shows through the colour of the form?!

Should it not show through the item underneath?

HELP!!!

Thanks in advance!
M.
 
I dont know about this specific control,
but if your using a TransparencyKey , your desktop bit-rate be 24 or less.
 
Well, I tried setting my desktop to 16-bit colour (had it set to 32-bpp) but that didnt work either .. heres a screenshot of what Im trying to do ... See how the label1 appears grey (picks up the colour from the background) instead of the tab control ...

M.
 

Attachments

  • screenshot.gif
    screenshot.gif
    11.2 KB · Views: 108
then this has nothing to do with TransparencyKey or 32 bit res.

It seems that setting the label to transparent does nothing. the only thing I can say is to set its BG color to the same as the control.

You can download this Color Picker I made a while back, use the Eye-Dropper to grab the color of any object on your desktop.
 
This is surprisingly easy to do. At runtime, in your Form_Load, stick this:

Label1.Parent = PictureBox1

Replacing PictureBox1 with whatever the name of your tab control is. The label will then get its background from that, assuming its backcolor is set to transparent.
 
Thought of that .. LOL .. but it uses a gradient background so that doesnt work .. not sure how the gradient is "painted" on the form ... would it help to know?

M.
 
A quick update .. if I set the transparency key to "pink" and the background of the label to "pink" it DOES have an effect ... the label becomes white .. but its still distinguishable from the background of the tab control ...
 
I know it had a gradient background, and my way works. I tested it, putting my label in a picturebox with the screenshot you posted as a background.

Remember, you wont get the effect at design time, only at runtime after you set the .Parent property.
 
Divil,

I believe you ... its just that its not working for me?! Could it be because this control is an ActiveX and not a .NET control? Or could it be the way that the control is being "drawn" .. or (oh no!) maybe its me!! LOL

Heres what Ive done ... Ive created an instance of this tab control, on it Ive place a label Label1 ... Ive sent the BackColor property to "Transparent" and in the Form Load event Ive added the following code:

[VB]
Private Sub frmPatientRecord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Label1.Parent = tabPatientRegistry

End Sub
[/VB]

It still appears with the background grey ... if you want to test out what I mean, you can download the controls at http://ciatheco.com/Support/Patches_Main.asp ..

Thanks everyone for your help!
M.
 
In further playing around, Ive gone back to the transparency key, and I realize now what was happening .. its like cutting a hole through the form where the transparency is set. I create a form, drop the tabcontrol on it, create a label on top of the tabcontrol. I set the Transparency Key on the form to "Pink" and then set the BackColor of the label to "Pink" and when I run it my desktop shows through the "transparent" part of the label .. very strange .. but could create some neat effects ... I guess thats how odd-shaped forms are created .. :)

Learn something new every day!!! :)

M.
 
I downloaded it but it says its a trial version and wouldnt run at runtime. However at design time I did notice that its not a control container, and the fact that its an ActiveX control really doesnt help either.

I dont know what to suggest, apart from not using ActiveX controls :)

Robby, the parent was as you thought (Label1.Parent = PictureBox1)
 
Ok ... what if I take a different venue? Is it possible to give the .net panel control a gradient background fill? Im told it could be done by overriding the OnPaint event? Can anyone point me to some sample code on how to do this as Ive never done this sort of thing before ..

Thanks!
M.
 
Code:
    Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
        Dim b As Brush

        b = New Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(0, Panel1.Height), Color.Red, Color.Green)
        e.Graphics.FillRectangle(b, Panel1.ClientRectangle)
    End Sub
 
Back
Top