Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Gurus*
Posted

You use it in your own derived controls, if you want your control to be able to have transparent or translucent areas in. If you set both those styles on, then when the time comes to paint your control you can do so using colors with an alpha component.

 

Microsoft URL on the topic

 

Windows Forms FAQ on the topic

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Nifty dimming credits...

 

After reading this thread, My previous thred about "Transparent Controls" is now fully answered :D Thanx Guys!!

 

One of the things I wanted to be able to do this for was for the creation of dimming and undimming text, almost like credits from the end of a movie or video game...

 

I ramped up this lil code to make it work the way I intended it to...

 

First, on form1, create label1 and out whatever text in it you want...

 

After the control comes into view, wait 3 seconds and watch again...

 

Dim x As Int16, xTag As Boolean

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 Me.Label1.BackColor = Color.FromArgb(0, Me.Label1.BackColor)

Also create a timer1 control on form1...

 

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
 If x >= 256 Then x = 255 : Timer1.Interval = 10 : xTag = True
 If x <= -1 Then x = 0 : Timer1.Interval = 10 : xTag = False
   Me.Label1.ForeColor = Color.FromArgb(x, 255, 0, 255)
 If xTag = False Then x += 1
 If xTag = True Then x -= 1
 If x >= 256 Then Timer1.Interval = 3000
 If x <= -1 Then Timer1.Interval = 3000
End Sub

UCM

>-)

  • 2 months later...
Posted

Transparency with multiple controls

 

I have an application that is drawing some boxes on a Panel, ( kinda like Visio). I have a class Box which has the following styles set

 

this.SetStyle( ControlStyles.SupportsTransparentBackColor, true);

this.BackColor = Color.Transparent;

 

Several boxes are added to a Panel like this.

 

Controls.Add( new Box() );

 

This appears to work, except when I drag another one box over another box. It appears that the transparent area shows through to the Panel and ignores the box that I am on top of. I want a transparent section but for it to show the box that I am on top of. Any way to do this?

  • 3 weeks later...
Posted
So it seems only the background form can have a single layer of transparent objects on top of it..Individual objects cannot keep their transparency if layered on top of one another...That's too bad..I was really hoping to have multiple transparent layers. There must be a way to do this...
Posted

transparency

 

Basically the way I fixed this was to not have my Box just be a regular class and not extend Control and basically rewrite the functionality of Control that I needed. The control that holds my Box class now directly calls 'paint' on the Box, which allows for transparency because you are just drawing on another control.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...