What is the opposite of form opacity?

bonedoc

Well-known member
Joined
May 4, 2006
Messages
112
Programming Experience
Beginner
Is there a way to darken a form or add a layer of black over the entire thing? I like opacity, but I have a situation that requires to darken it instead of make it clear. Maybe there is a way to color the entire form with a color that has low transparency?
 
Tell more about what it is to be used for, and how it should ideally work in regards to appearance and functionality, this goes for the form and individual controls on it. There exist some options to achieve similar to what you initially describe for different scenarios.
 
Basically, I want to gray out the forms that are behind the form being used. I dont know if you have ever used a mac before, something kind of like the dashboard they have.
 
In that case the easiest is to add a picturebox to form and set Dock=Fill and show a manipulated screenshot of form. Take a screenshot of ClientRectangle of form at convenience and draw semi-tranparent over this for dimming effect. I found the Leave and MouseLeave events convenient for this. When form is deactivated you add the picturebox and bring it to front, when activated you remove the picturebox again.

Other alternative is to attach/detach a paint event handler to all controls on form and in that handler draw semi-transparent shader over. Problem is some controls don't support this owner drawing.

Attached is .Net 2.0 project showing both techniques. You have to get the 2005 Express to have a look, because I'm not up to converting it to older VB.Net (2002 is also not available), or just browse the code in Notepad.. The Picturebox-way is absolutely best, but since you don't have Graphics.CopyFromScreen method new in .Net 2.0 so you have to find some way around this to get screenshot.
 

Attachments

  • vbnet20-shadeForms.zip
    48.9 KB · Views: 32
Back
Top