Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I want to do form having opacity .30 but controls on form such as PictureBox is visible completely.

Thank You!!
Posted
Comments
Mukesh Pr@sad 30-Oct-14 2:04am    
have a look to this..
http://api.jquery.com/fadeto/
BillWoodruff 30-Oct-14 3:51am    
If you are working with a WinForms application, and you have a PictureBox on the Form, and you set the Form's opacity to less than opaque (< 100%), then the PictureBox, like everything else on the Form, will have its opacity set to that of the Form.

If you are working with Windows Forms, please describe in more detail what you are doing, and what you want to achieve ?

If you are working with some other technology stack, like Web whatever, please tag your question appropriately.
Philippe Mori 30-Oct-14 22:06pm    
This is a good question but what have you done so far.

You have to use 2 forms. The main form would have it opacity set to whatever you want but won't have any fully opaque controls.

You then create a second form having all opaque controls and put that form over the first one. On that second form, you use an otherwise unused color for the background where you want transparency. You the set that color as the TransparencyKey.

You then have to handle events like moving and sizing so that secondary form will stay at proper location.

You also need to handle activation so that you main form caption will appears to be active if you use a standard frame. This is a bit more tricky but it can be done as I have done it in one of our application. On another hand, if you don't use standard caption and frame, then you might not have to deal with that.

You might need to use Win API for some tricks depending on your application. If I remember well, in my application, I also have semi-transparent control so I need to have either form activated but the main one to appears as activated and I think I do use API for that (probably sending a WM_MESSAGE or something like that).

If the partially opaque part never need to be activated, then it is much simpler as in that case you can always activate main form when the secondary form is activated.
 
Share this answer
 
v2
 
Share this answer
 
Comments
anandd.mohit 30-Oct-14 2:13am    
pictureBox does not have opacity attribute
Philippe Mori 30-Oct-14 22:14pm    
The opacity is for the whole form. If you need opacity on part only, then you need multiple forms. See my solution.

On Windows Vista (and probably 7), you might also extend glass area. I'm not sure of what it does on Windows 8 or later. On those, transparency is not used much anymore.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900