Search code examples
.netwinformsscreensystem.drawing

Window dimming in WinForms .NET


Many times I've seen an effect in Adobe Flash that gradually reduces visibility of the background window, for example when you preview a video or image (in Lightbox). It would be great to have such effect in WinForms. After searching the web for relevant solution, I've found a program that dims the entire screen. Obviously, this works differently, a semi-transparent bar is stretched to the screen area. I would like to find the same thing for the application window (so when we display a dialog, main form will appear slightly darker).

Any suggestions?


Solution

  • I answered a very similar question before, see:

    WinForm Control with Opacity

    The Shroud() and Unshroud() methods dim and undim the form.

    You can modify that to do what you want (using a timer; instead of dimming the bitmap (see example code) you can do the dimming on Paint() and make it time-dependent.

    Send me a comment if you need a code sample, I can work one out for you.