473,382 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Transparent backcolor

vul
I used to use creating headers (label at the top of the screen) for VB6
forms as 2 labels shifted a little bit with different for colors to get a
simulation of a shadow. I set BackColor of both labels to Transparent.
Everything works fine.
I'm trying to use the same approach with VB 2005 windows forms. Although I'm
setting labels backcolors to transparent, it is not transparent and the
label located behind is not visible.
I tried to create a simple sample with labels in VB6 and convert to VB 2005.
VB6 version works as I want, VB 2005 version doesn't.
How do I make the label real transparent?

Thank you
Al
Jul 31 '06 #1
3 3936
vul
I found a pretty easy way to do that:
I place 2 labels on the form and added this code:

Label3.BackColor = Color.Transparent

Label3.Location = New Point(0, 300)

Label3.ForeColor = Color.Black

Label4.Parent = Label3

Label4.Location = New Point(-1, -1)

Label4.ForeColor = Color.Gray

Everything looks very similar to what I have in VB6

Al

"vul" <aa*@optonline.netwrote in message
news:Oz**************@TK2MSFTNGP06.phx.gbl...
>I used to use creating headers (label at the top of the screen) for VB6
forms as 2 labels shifted a little bit with different for colors to get a
simulation of a shadow. I set BackColor of both labels to Transparent.
Everything works fine.
I'm trying to use the same approach with VB 2005 windows forms. Although
I'm setting labels backcolors to transparent, it is not transparent and
the label located behind is not visible.
I tried to create a simple sample with labels in VB6 and convert to VB
2005. VB6 version works as I want, VB 2005 version doesn't.
How do I make the label real transparent?

Thank you
Al


Jul 31 '06 #2
Good.
You are offsetting the original position by 1 px.
'--------------------------------------------------------------

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Format your label
Me.LabelTitle.Text = "TITLE OF MY FORM"
Me.LabelTitle.ForeColor = Color.DarkBlue
Me.LabelTitle.Font = New Font(FontFamily.GenericSansSerif, 40)

'Give your label a shadow
MakeShadowToLabel(Me.LabelTitle, Color.DarkGray, 5)

End Sub

Sub MakeShadowToLabel(ByRef Label As Label, ByVal ColorUmbra As
Color, ByVal Offset As Integer)

Dim LabelForShadow As New Label
With LabelForShadow
.Location = Label.Location
.Location.Offset(Offset, Offset)
.Text = Label.Text
.Font = Label.Font
.Size = Label.Size
.TextAlign = Label.TextAlign
'add possible properties to maintain

.BackColor = Color.Transparent
.ForeColor = ColorUmbra
.Parent = Label.Parent
End With

With Label
.Location = New Point(-Offset, -Offset)
.Parent = LabelForShadow
End With

End Sub

End Class

-tom

http://cam70.sta.uniroma1.it/community/
vul ha scritto:
I found a pretty easy way to do that:
I place 2 labels on the form and added this code:

Label3.BackColor = Color.Transparent

Label3.Location = New Point(0, 300)

Label3.ForeColor = Color.Black

Label4.Parent = Label3

Label4.Location = New Point(-1, -1)

Label4.ForeColor = Color.Gray

Everything looks very similar to what I have in VB6

Al

"vul" <aa*@optonline.netwrote in message
news:Oz**************@TK2MSFTNGP06.phx.gbl...
I used to use creating headers (label at the top of the screen) for VB6
forms as 2 labels shifted a little bit with different for colors to get a
simulation of a shadow. I set BackColor of both labels to Transparent.
Everything works fine.
I'm trying to use the same approach with VB 2005 windows forms. Although
I'm setting labels backcolors to transparent, it is not transparent and
the label located behind is not visible.
I tried to create a simple sample with labels in VB6 and convert to VB
2005. VB6 version works as I want, VB 2005 version doesn't.
How do I make the label real transparent?

Thank you
Al
Jul 31 '06 #3
vul
Thank you Tom.
Al

<to**************@uniroma1.itwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
Good.
You are offsetting the original position by 1 px.
'--------------------------------------------------------------

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Format your label
Me.LabelTitle.Text = "TITLE OF MY FORM"
Me.LabelTitle.ForeColor = Color.DarkBlue
Me.LabelTitle.Font = New Font(FontFamily.GenericSansSerif, 40)

'Give your label a shadow
MakeShadowToLabel(Me.LabelTitle, Color.DarkGray, 5)

End Sub

Sub MakeShadowToLabel(ByRef Label As Label, ByVal ColorUmbra As
Color, ByVal Offset As Integer)

Dim LabelForShadow As New Label
With LabelForShadow
.Location = Label.Location
.Location.Offset(Offset, Offset)
.Text = Label.Text
.Font = Label.Font
.Size = Label.Size
.TextAlign = Label.TextAlign
'add possible properties to maintain

.BackColor = Color.Transparent
.ForeColor = ColorUmbra
.Parent = Label.Parent
End With

With Label
.Location = New Point(-Offset, -Offset)
.Parent = LabelForShadow
End With

End Sub

End Class

-tom

http://cam70.sta.uniroma1.it/community/
vul ha scritto:
>I found a pretty easy way to do that:
I place 2 labels on the form and added this code:

Label3.BackColor = Color.Transparent

Label3.Location = New Point(0, 300)

Label3.ForeColor = Color.Black

Label4.Parent = Label3

Label4.Location = New Point(-1, -1)

Label4.ForeColor = Color.Gray

Everything looks very similar to what I have in VB6

Al

"vul" <aa*@optonline.netwrote in message
news:Oz**************@TK2MSFTNGP06.phx.gbl...
>I used to use creating headers (label at the top of the screen) for VB6
forms as 2 labels shifted a little bit with different for colors to get
a
simulation of a shadow. I set BackColor of both labels to Transparent.
Everything works fine.
I'm trying to use the same approach with VB 2005 windows forms.
Although
I'm setting labels backcolors to transparent, it is not transparent and
the label located behind is not visible.
I tried to create a simple sample with labels in VB6 and convert to VB
2005. VB6 version works as I want, VB 2005 version doesn't.
How do I make the label real transparent?

Thank you
Al


Jul 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul Schnitter | last post by:
Update: My custom control is based on the article "Creating Visual Basic .NET controls from scratch" in "Adventures in .NET" on MSDN. It is designed to be a replacement for the VB6 shape...
2
by: Alex Gray | last post by:
Hi, I'm trying to make my PictureBox transparent to the BackgroundImage of the Form, not the BackColor of the form. Here's what i have: ---------------------------------------------------...
1
by: Efkas | last post by:
My application have some level : 1. MyButton class with Label inheritance 2. MyComponent as User Control loading and positionning some of MyButtons 3. MyApp loading and positionning MyComponent ...
7
by: Peter Oliphant | last post by:
Using MakeTransparent one can supposedly turn a color used in a Bitmap to transparent. But, it looks to me like all it does it set these pixels to the color BackColor of the Control it's attached...
4
by: jcrouse | last post by:
I am using the following code to move a label on a form at runtime: If myMousedown = lblP1JoyRight.Name Then If lblP1JoyRight.BackColor.Equals(Color.Transparent) Then bTransCk = True ...
2
by: Dean Slindee | last post by:
It appears that I have two routines that don't play well together! First routine: a form's background is shaded with a gradient color. Second routine: then, the background of all labels on the...
2
by: edoepke | last post by:
VISUAL BASIC ONLY: I have Googled until my fingers are sore. Is there a way to make a ListBox or TextBox control transparent (ie: transparent background)? I know it's a function of Framework that...
2
by: Pascal | last post by:
Je veux que mes label soit transparent aussi sur mes picturebox alors j'écris : i want my labels to be transparent on my pictureboxes so i wrote : Private Sub Form1_Load(ByVal sender As Object,...
4
by: ray well | last post by:
in my app i need to make a RichTextbox control transparent. i need it to be a like a pane of glass lying on a sheet of paper, where u can see everything on the sheet of paper not covered by text...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.