Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / April 2006

Tip: Looking for answers? Try searching our database.

Transparent Label over Background Image?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thomas Bandt - 21 Mar 2006 17:06 GMT
Hi all,

I've set a background image for my form in OnPaintBackground().
In the layer above I have a set of buttons and labels. Now the
label controls inherits the background color of the parent
control, which is the form ... so I have a ugly white background
under my labels text.

I tried to set the background color of the form to Color.Transparent,
I also placed a panel control in the form - but nothing worked.

Does anyone has an idea to get this working?

Signature

Gruß, Thomas
http://blog.thomasbandt.de/

Chris Tacke [MVP] - 21 Mar 2006 18:43 GMT
Override OnPaint and draw the text at the label position manually.

-Chris

> Hi all,
>
[quoted text clipped - 8 lines]
>
> Does anyone has an idea to get this working?
Brian Nantz - 21 Mar 2006 18:45 GMT
You could draw the text yourself instead of using labels.  I'm not sure
how to do this in mobile but on the desktop I have set the color to a
unused color (like purple) and then filter out that color to make it
transparent.

> Hi all,
>
[quoted text clipped - 8 lines]
>
> Does anyone has an idea to get this working?
Thomas Bandt - 22 Mar 2006 11:33 GMT
Brian Nantz schrieb:
> You could draw the text yourself instead of using labels.  I'm not sure
> how to do this in mobile but on the desktop I have set the color to a
> unused color (like purple) and then filter out that color to make it
> transparent.

Thank you guys. And you're sure there is no more comfortable way to go?

Signature

Gruß, Thomas
http://blog.thomasbandt.de/

Minh - 21 Apr 2006 04:16 GMT
you can create your custom control that will draw its parent background color
onto itself and then draw the text over.  If the parent happens to have an
image background, get that image and draw the portion of the image that the
custom label control is on.

Here is the sample code:

public class CustomLabel : Control {
 protected override void OnPaint(PaintEventArgs e)
 {       
       e.Graphics.DrawImage(parentBackgroundImage, new Rectangle(0, 0,
this.Width, this.Height), new Rectangle(this.Left, this.Top, this.Width,
this.Height), GraphicsUnit.Pixel);
       e.Graphics.DrawString(text, font, brush, new RectangleF(0, 0,
this.Width, this.Height)
 }
}

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.