Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to "dim" background of winform while displaying a dialog?

I'd like to implement a feature in my application where show a dialog to the user, and the main form (similar to how jQuery looks). My only idea is to take a screenshot of the form, place it as the background of a panel (with opacity to my liking) then pushing the panel over everything on the form. I have to believe there is a better way of doing this, any suggestions?

like image 392
stout Avatar asked Mar 29 '10 19:03

stout


2 Answers

The Opacity property is what you need to "dim" a form. You'll need to create an overlay, my code in this thread shows how to do this.

Be careful to not make it look like your program is displaying a UAC prompt. While perhaps appropriate in browsers, the user will never have any trouble recognizing that a window overlaid by a dialog is disabled. Controls paint themselves differently to make it clear.

like image 97
Hans Passant Avatar answered Sep 22 '22 14:09

Hans Passant


Why not just set the opacity to something like 50% of the parent window just before launching the modal dialog and then back to 100% when the modal dialog is dismissed? This isn't exactly what you're asking for serves the same function for the end user.

If you do want to do something like your JQuery example you would indeed have to do the screen cap/augment/set as background idea that you described.

like image 36
Paul Sasik Avatar answered Sep 23 '22 14:09

Paul Sasik