Darken form when this shows another form

Wednesday, July 2, 2014

This is probably written in someone's handy snippet collection. I would like to darken any given form when a call to show another form as a dialog is performed.

This could probably be performed by some overlaying panel or image with a dark transparency, but I'm pretty sure someone has already done this in a well thought manner.

Something like an extension method to ShowDialog() that would turn the calling form darker when showing the new form and return back to its original state when the new form is closed:

public static class ExtensionMethods
public static DialogResult ShowDialog(this Form form, bool darken)
if (!darken)
return base.ShowDialog();
// Darken calling form (Asynchronously, non-blocking the new form)

DialogResult ret = base.ShowDialog();

// Remove dark overlay from calling form before Enabling it again.
return ret;


void bt_click(object sender, EventArgs e)
using(var newForm = new AnotherForm())
// This will show the new form while making the parent form darker.
// making it brighter once again when the new form is closed. (Animation)

Thank you.