473,513 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3946
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
9471
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
33504
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
20159
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
3558
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
2542
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
7571
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
7813
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
3632
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
9330
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...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.