|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Transparent backcolorI 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 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 Show quoteHide quote "vul" <a**@optonline.net> wrote in message news:OzfRRHNtGHA.2368@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 > > 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: Show quoteHide quote > 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" <a**@optonline.net> wrote in message > news:OzfRRHNtGHA.2368@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 > > > > Thank you Tom.
Al <tommaso.gasta***@uniroma1.it> wrote in message Show quoteHide quote news:1154384340.457384.299270@i42g2000cwa.googlegroups.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" <a**@optonline.net> wrote in message >> news:OzfRRHNtGHA.2368@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 >> > >> > > |
|||||||||||||||||||||||