By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,703 Members | 1,400 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,703 IT Pros & Developers. It's quick & easy.

Can opacity/transparency be adjusted within components?

P: n/a
I know that I can change the opacity of an entire form, but is there a
way to control opacity to specific controls or components?

For example I want to create a form that is semi-transparent (maybe
looks like a sheet of green glass) but has elements or graphics on top
that I want to be opaque. Perhaps I want the sheet of glass to have
writing or other graphics "painted" on the surface. Is there some way
to mix varying transparencies within a form?
Feb 19 '06 #1
Share this Question
Share on Google+
12 Replies


P: n/a
http://www.kjmsolutions.com/downloads/transparent.zip

I hope this gets you started.

--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com

"Patrick Dugan" <pa******@netins.net> wrote in message
news:uW**************@TK2MSFTNGP09.phx.gbl...
I know that I can change the opacity of an entire form, but is there a way
to control opacity to specific controls or components?

For example I want to create a form that is semi-transparent (maybe looks
like a sheet of green glass) but has elements or graphics on top that I
want to be opaque. Perhaps I want the sheet of glass to have writing or
other graphics "painted" on the surface. Is there some way to mix varying
transparencies within a form?

Feb 19 '06 #2

P: n/a
That is interesting but not what I was wanted. I want the form to be
transparent so that the desktop background appears through it while
other elements on that same form are opaque.

vbnetdev wrote:
http://www.kjmsolutions.com/downloads/transparent.zip

I hope this gets you started.

Feb 19 '06 #3

P: n/a
Hi Patrick,

Any controls on a form that have the same BackColor property as the
TransparencyKey property of the Form will be displayed Transparent. All
other controls will be displayed Opaque. So, firstly set your Form's
Transparency Key property to a particular color. Then set your Form's
BackColor to the same color as the TransparencyKey color. Now, to display
any control as opaque, make sure it's BackColor is different from the Form's
BackColor.

HTH,

Cerebrus.
"Patrick Dugan" <pa******@netins.net> wrote in message
news:43**************@netins.net...
That is interesting but not what I was wanted. I want the form to be
transparent so that the desktop background appears through it while
other elements on that same form are opaque.

vbnetdev wrote:
http://www.kjmsolutions.com/downloads/transparent.zip

I hope this gets you started.

Feb 20 '06 #4

P: n/a
Thanks for the reply. I'm not trying to make the form (or parts of it)
completely transparent. I want to adjust the opacity level (0% through
100%) on the form and use different opacity levels for other controls or
graphics within that form. Transparent colors are all or nothing and do not
contain a percentage of transparency. Since there are no opacity settings
for anything besides the form I assume that this is simply not possible.

"Cerebrus99" <zo*****@sify.com> wrote in message
news:ui*************@TK2MSFTNGP12.phx.gbl...
Hi Patrick,

Any controls on a form that have the same BackColor property as the
TransparencyKey property of the Form will be displayed Transparent. All
other controls will be displayed Opaque. So, firstly set your Form's
Transparency Key property to a particular color. Then set your Form's
BackColor to the same color as the TransparencyKey color. Now, to display
any control as opaque, make sure it's BackColor is different from the
Form's
BackColor.

HTH,

Cerebrus.
"Patrick Dugan" <pa******@netins.net> wrote in message
news:43**************@netins.net...
That is interesting but not what I was wanted. I want the form to be
transparent so that the desktop background appears through it while
other elements on that same form are opaque.

vbnetdev wrote:
> http://www.kjmsolutions.com/downloads/transparent.zip
>
> I hope this gets you started.
>


Feb 20 '06 #5

P: n/a
Hi Patrick,

I saw your post and thought that this might be helpful:

http://www.bobpowell.net/transcontrols.htm

Chris

Feb 20 '06 #6

P: n/a
Thanks Chris. I guess I'm not explaining what I am trying to do very well.
If I create a form and give it an opacity of 50% the form will appear
translucent on the desktop. Any control on that form will also be 50%
translucent.
I want the form itself to be 50% translucent but a control or picturebox on
that form to be completely opaque. I cannot make a control opaque while the
form is translucent but I want to. As an example think of an old green
glass coke bottle. The bottle itself is translucent but the graphics on the
bottle are opaque. I can see through the green glass but not through the
graphics. I want the form (or the background of that form) to be
translucent (not transparent) but have graphics on top that are opaque.

"Chris Dunaway" <du******@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Hi Patrick,

I saw your post and thought that this might be helpful:

http://www.bobpowell.net/transcontrols.htm

Chris

Feb 20 '06 #7

P: n/a
Sorry, I re-read it and the link I posted does not help. I don't know
how to do what you want.

Feb 20 '06 #8

P: n/a
I found this code which can be put in the sub New of a form:

If (Me.Site Is Nothing) OrElse (Me.Site.DesignMode = False)
Then
Me.frontForm = New Form
Dim tempList As New ArrayList(Me.Controls.Count)

For Each c As Control In Me.Controls
tempList.Add(c)
Next

For Each c As Control In tempList
Me.Controls.Remove(c)
Me.frontForm.Controls.Add(c)
Next

Me.Controls.Clear()
Me.AddOwnedForm(Me.frontForm)
Me.frontForm.BackColor = Color.Magenta
Me.frontForm.TransparencyKey = Color.Magenta
Me.frontForm.Show()
Me.SendToBack()
Me.frontForm.BringToFront()
Me.frontForm.Bounds = Me.Bounds
Me.frontForm.ShowInTaskbar = False
Me.frontForm.FormBorderStyle =
Windows.Forms.FormBorderStyle.None
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
End If
then set the form's opacity to something. It gives the desired effect,
but a way to move the form needs to be found.

Feb 20 '06 #9

P: n/a

What is the "frontform" in "Me.frontForm" ? I have tried changing the name
of the form to "frontForm" but that isn't recognized. The editor doesn't
recognize the "frontForm" associated with "Me" Is there an import I need to
add? I added "system.windows.forms.form" but it made no difference either.
I'd like to test that code but it won't compile at the moment.
"Chris Dunaway" <du******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I found this code which can be put in the sub New of a form:

If (Me.Site Is Nothing) OrElse (Me.Site.DesignMode = False)
Then
Me.frontForm = New Form
Dim tempList As New ArrayList(Me.Controls.Count)

For Each c As Control In Me.Controls
tempList.Add(c)
Next

For Each c As Control In tempList
Me.Controls.Remove(c)
Me.frontForm.Controls.Add(c)
Next

Me.Controls.Clear()
Me.AddOwnedForm(Me.frontForm)
Me.frontForm.BackColor = Color.Magenta
Me.frontForm.TransparencyKey = Color.Magenta
Me.frontForm.Show()
Me.SendToBack()
Me.frontForm.BringToFront()
Me.frontForm.Bounds = Me.Bounds
Me.frontForm.ShowInTaskbar = False
Me.frontForm.FormBorderStyle =
Windows.Forms.FormBorderStyle.None
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
End If
then set the form's opacity to something. It gives the desired effect,
but a way to move the form needs to be found.

Feb 21 '06 #10

P: n/a
I'm sorry. That is just another variable declared at the top of the
form:

Dim frontFomr As Form

The code just creates another form (frontForm), sets its background to
Magenta and makes that color transparent with the transparency key. It
then positions form directly over the top of the semi transparent form.
So there are two forms. The one on the bottom is the semi-transparent
one, the one on the top (frontForm) is completely transparent except
for the controls.

It's really kind of a hack.

Feb 21 '06 #11

P: n/a
Holy **** it works! Thanks! I have some code that can move the form:
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
' This allows you to move the form around and still allow other mouse
capture events to come through...
Dim msg As New Message
Const WM_SYSCOMMAND As Long = &H112
Const MOUSE_MOVE As Long = &HF012
msg.HWnd = Me.Handle
msg.Msg = WM_SYSCOMMAND
msg.WParam = New IntPtr(MOUSE_MOVE)
Me.Capture = False
Call Me.WndProc(msg)
End Sub
However when I use this the form itself moves but the controls do not. Very
weird to see that. Still a neat trick though. Thanks!

"Chris Dunaway" <du******@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
I'm sorry. That is just another variable declared at the top of the
form:

Dim frontFomr As Form

The code just creates another form (frontForm), sets its background to
Magenta and makes that color transparent with the transparency key. It
then positions form directly over the top of the semi transparent form.
So there are two forms. The one on the bottom is the semi-transparent
one, the one on the top (frontForm) is completely transparent except
for the controls.

It's really kind of a hack.

Feb 21 '06 #12

P: n/a
When you move one form, you would have to move the other at the same
time.

Feb 22 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.