-
February 7th, 2011, 03:56 PM
#1
Opaque controls on a completely transparent form
Folks,
As everyone have noticed, the Form class has the Opacity property. It sets the opacity of the form and all of the controls. But is it possible to have opaque controls (e.g. picture boxes) on a transparent form?
At the moment, I can think of two workarounds.
(1) Form.Region is set to a disjoint region, which includes only “real estate” under the controls. In this case, what would be the best place to set the region of the form?
(2) Separate Form object for each control.
Any suggestion, insight or reference is really appreciated!
- Nick
-
February 7th, 2011, 05:20 PM
#2
Re: Opaque controls on a completely transparent form
Hello Nick.
I'm not certain that I'm doing what you had in mind, but I think it is possible to render the form 'invisible' yet have the controls quite visible so that they appear to be 'floating' rather than contained in a form. How ?
1. On the form properties, set the transparency key to whatever color the BackColor is set while retaining the 100% opacity setting.
2. set the FormBorderStyle to 'none'
3. Add the picturebox as one normally would and load your image.
4. Give some consideration to how you'll close the form ... perhaps a context menu when clicking on the image (or any one of a million and one alternate mechanisms) ?
Last edited by ThermoSight; February 7th, 2011 at 05:37 PM.
-
February 8th, 2011, 12:27 AM
#3
Re: Opaque controls on a completely transparent form
Originally Posted by ThermoSight
1. On the form properties, set the transparency key to whatever color the BackColor is set while retaining the 100% opacity setting.
...
That was illuminating. Thanks.
One thing that makes this problem a little more interesting is that one of the controls is a picture with irregular outline. The image itself is drawn with only a few colors, so I can use fuchsia as key color for transparency. I know that I can write a straightforward function that will generate a region, provided a bitmap and a color key. Then this region can be assigned to Control.Region property. But is there a standard picture-box-type control that has a built-in feature like Form.TransparencyKey? (Wishful thinking?)
Color.Transparent constant there is. Is there a way of somehow selecting Color.Transparent and drawing with it?
Cheers,
- Nick
Last edited by kender_a; February 8th, 2011 at 12:32 PM.
Reason: more added
-
February 8th, 2011, 12:44 PM
#4
Re: Opaque controls on a completely transparent form
Hi Nick.
I am unaware of a control property analogous to Form.TransparencyKey, but this might be of some interest to you. Regrettably, I'm in a rush to get out the door or I'd try it myself. Anyway, be that as it may, check this out and see if this item from the Visual Studio 2010 'Help' section has any relevance ...
This is what I shudda done (and will do in the future) ... oh well, live and learn I guess.
http://msdn.microsoft.com/en-us/library/wk5b13s4.aspx - let's see if this is any better.
See ya.
bill
Last edited by ThermoSight; February 8th, 2011 at 08:09 PM.
-
February 8th, 2011, 09:50 PM
#5
Re: Opaque controls on a completely transparent form
Originally Posted by ThermoSight
Hey Bill,
Actually, I was able to find the article from the GUID in the original version of the link.
The article, however, deals with custom controls. It suggests to call the protected method SetStyle().
May be, after all, assigning Form.Region is the way to go.
- Nick
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|