473,587 Members | 2,490 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 3957
vul
I found a pretty easy way to do that:
I place 2 labels on the form and added this code:

Label3.BackColo r = Color.Transpare nt

Label3.Location = New Point(0, 300)

Label3.ForeColo r = Color.Black

Label4.Parent = Label3

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

Label4.ForeColo r = Color.Gray

Everything looks very similar to what I have in VB6

Al

"vul" <aa*@optonline. netwrote in message
news:Oz******** ******@TK2MSFTN GP06.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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

'Format your label
Me.LabelTitle.T ext = "TITLE OF MY FORM"
Me.LabelTitle.F oreColor = Color.DarkBlue
Me.LabelTitle.F ont = New Font(FontFamily .GenericSansSer if, 40)

'Give your label a shadow
MakeShadowToLab el(Me.LabelTitl e, Color.DarkGray, 5)

End Sub

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

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

.BackColor = Color.Transpare nt
.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.BackColo r = Color.Transpare nt

Label3.Location = New Point(0, 300)

Label3.ForeColo r = Color.Black

Label4.Parent = Label3

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

Label4.ForeColo r = Color.Gray

Everything looks very similar to what I have in VB6

Al

"vul" <aa*@optonline. netwrote in message
news:Oz******** ******@TK2MSFTN GP06.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.itw rote in message
news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
Good.
You are offsetting the original position by 1 px.
'--------------------------------------------------------------

Public Class Form1

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load

'Format your label
Me.LabelTitle.T ext = "TITLE OF MY FORM"
Me.LabelTitle.F oreColor = Color.DarkBlue
Me.LabelTitle.F ont = New Font(FontFamily .GenericSansSer if, 40)

'Give your label a shadow
MakeShadowToLab el(Me.LabelTitl e, Color.DarkGray, 5)

End Sub

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

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

.BackColor = Color.Transpare nt
.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.BackCol or = Color.Transpare nt

Label3.Locatio n = New Point(0, 300)

Label3.ForeCol or = Color.Black

Label4.Paren t = Label3

Label4.Locatio n = New Point(-1, -1)

Label4.ForeCol or = Color.Gray

Everything looks very similar to what I have in VB6

Al

"vul" <aa*@optonline. netwrote in message
news:Oz******* *******@TK2MSFT NGP06.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
9486
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 control. My control draws a shape (circle, square, rectangle ...)
2
33509
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: --------------------------------------------------- this.BackColor = Color.Wheat; this.gameBackgroundBMP = new Bitmap(GetType(),"MyForm.backGround.bmp");
1
20163
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 I prefer don't insert a background in MyComponent, and using the MyApp one as general background with MyComponent positionned, but I am not able...
7
3570
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 to. Thus, when I set White to the transparent color of a Bitmap stored in the Image of a PictureBox and placed the PictureBox on a Form which has a...
4
2547
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 lblP1JoyRight.BackColor = clrLabelMove
2
7578
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 form are made transparent. What results is the label's backcolor appearing as blocks of 'control' colored background. Setting the label's backcolor...
2
7817
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 doesn't allow this so please don't remind me. If it can be done in C, C# or C++ then it should be able to be done in VB 2005. Since I don't know C++...
2
3646
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, ByVal e As System.EventArgs) Handles Me.Load Label1.Parent = PictureBox1 Label1.BackColor = Color.Transparent Label2.Parent = PictureBox2...
4
9344
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 written on the glass pane. i need to be able to see the control or form that is underneath the RichTextbox, and at the same time to be able to write...
0
7923
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7852
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7974
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5395
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.