mpappert Posted February 5, 2003 Posted February 5, 2003 Hey Everyone! I've read some of the other articles here about transparent controls, but none of them seem to apply to what I'm trying to do ... I am using a third party tab control that mimics the XP style tabs under any OS (check out http://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. Quote
Moderators Robby Posted February 5, 2003 Moderators Posted February 5, 2003 I don't know about this specific control, but if your using a TransparencyKey , your desktop bit-rate be 24 or less. Quote Visit...Bassic Software
mpappert Posted February 5, 2003 Author Posted February 5, 2003 Well, I tried setting my desktop to 16-bit colour (had it set to 32-bpp) but that didn't work either .. here's a screenshot of what I'm trying to do ... See how the label1 appears grey (picks up the colour from the background) instead of the tab control ... M. Quote
Moderators Robby Posted February 5, 2003 Moderators Posted February 5, 2003 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 it's 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. Quote Visit...Bassic Software
*Gurus* divil Posted February 5, 2003 *Gurus* Posted February 5, 2003 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. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
mpappert Posted February 5, 2003 Author Posted February 5, 2003 Thought of that .. LOL .. but it uses a gradient background so that doesn't work .. not sure how the gradient is "painted" on the form ... would it help to know? M. Quote
mpappert Posted February 5, 2003 Author Posted February 5, 2003 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 it's still distinguishable from the background of the tab control ... Quote
*Gurus* divil Posted February 5, 2003 *Gurus* Posted February 5, 2003 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 won't get the effect at design time, only at runtime after you set the .Parent property. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
*Gurus* divil Posted February 5, 2003 *Gurus* Posted February 5, 2003 A quick test I knocked up - Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Moderators Robby Posted February 5, 2003 Moderators Posted February 5, 2003 hmm, learn something new every day... Divil, where is the Parent (Label1.Parent = PictureBox1) Quote Visit...Bassic Software
mpappert Posted February 5, 2003 Author Posted February 5, 2003 Divil, I believe you ... it's just that it's 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 it's me!! LOL Here's what I've done ... I've created an instance of this tab control, on it I've place a label 'Label1' ... I've sent the BackColor property to "Transparent" and in the Form Load event I've added the following code: Private Sub frmPatientRecord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Parent = tabPatientRegistry End Sub 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. Quote
mpappert Posted February 6, 2003 Author Posted February 6, 2003 In further playing around, I've gone back to the transparency key, and I realize now what was happening .. it's 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 that's how odd-shaped forms are created .. :) Learn something new every day!!! :) M. Quote
*Gurus* divil Posted February 6, 2003 *Gurus* Posted February 6, 2003 I downloaded it but it says it's a trial version and wouldn't run at runtime. However at design time I did notice that it's not a control container, and the fact that it's an ActiveX control really doesn't help either. I don't know what to suggest, apart from not using ActiveX controls :) Robby, the parent was as you thought (Label1.Parent = PictureBox1) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
mpappert Posted February 8, 2003 Author Posted February 8, 2003 Ok ... what if I take a different venue? Is it possible to give the .net panel control a gradient background fill? I'm told it could be done by overriding the OnPaint event? Can anyone point me to some sample code on how to do this as I've never done this sort of thing before .. Thanks! M. Quote
*Gurus* divil Posted February 8, 2003 *Gurus* Posted February 8, 2003 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 Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.