You can use another form that opens behind the message, follow an example I use in my projects:
public partial class FormShadow : Form
{
//Form Pai onde está o controle a ser exibido
public Form FormPai { get; set; }
/// <summary>
/// Form de destaque de controles e exibição de dicas
/// </summary>
/// <param name="_parent">Form que será escurecido</param>
/// <param name="_control">Controle que será destacado</param>
/// <param name="_message">Mensagem de dica</param>
/// <param name="_opacity">Transparencia do Form, 0=Invisivel, 1=Visivel, Recomendado 0.5</param>
public FormShadow(Form _parent, double _opacity = 0.5)
{
InitializeComponent();
//this.Parent = _parent.Parent;
//Define a chave de transparencia do form
this.TransparencyKey = Color.Magenta;
//Define a cor do sombreamento do form
this.AllowTransparency = true;
this.BackColor = Color.Black;
//Atribuição dos valores passados por parametro
this.FormPai = _parent;
this.Opacity = _opacity;
//Define visual do form
this.StartPosition = FormStartPosition.Manual;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.ShowInTaskbar = false;
if (this.FormPai != null)
{
this.Size = this.FormPai.Size;
this.Bounds = this.FormPai.Bounds;
this.Location = FormPai.PointToScreen(Point.Empty);
}
else
{
var rect = Screen.GetBounds(Point.Empty);
this.Size = rect.Size;
this.Bounds = rect;
this.Location = Point.Empty;
}
//Fechar com ESC
this.KeyPreview = true;
this.KeyDown += FormHighlightControl_KeyDown;
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (System.Diagnostics.Debugger.IsAttached) //Se em modo debug, não mostra em full screen pq atrapalha acessar o visual studio
{
this.Size = new Size(50, 50);
}
}
public static FormShadow Show(Form _parent, double _opacity = 0.5)
{
FormShadow instancia = new FormShadow(_parent, _opacity);
instancia.Show();
return instancia;
}
public static DialogResult ShowMessageBox(Form _parent, string title, string message, MessageBoxButtons btns = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Information, MessageBoxDefaultButton dbtn = MessageBoxDefaultButton.Button1, double _opacity = 0.5)
{
DialogResult d;
using (FormShadow instancia = new FormShadow(_parent, _opacity))
{
instancia.Show();
d = MessageBox.Show(new Form() { TopMost = true }, message, title, btns, icon);
instancia.Close();
}
return d;
}
//Fechar com ESC
void FormHighlightControl_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Escape)
{
this.Close();
}
}
}
Then it’s easy to show a Messagebox:
private void button1_Click(object sender, EventArgs e)
{
FormShadow.ShowMessageBox(this, "Teste de mensagem", "Mensagem de texto");
}
Upshot:
https://github.com/rovannlinhalis/WindowsFormsShadow
Note the override of the Onshown Method, it is set so that when running in the visual studio, it shows only one block of 50x50, because the form can disturb access to the visual while debugging.
Forms I know well, but this link should help: https://stackoverflow.com/questions/34947504/how-to-show-a-pop-up-message-with-dark-background
– Ricardo Pontual
In the image you have already gone through this question (https://stackoverflow.com/questions/17248748/c-sharp-dialog-form-with-blur-background) of the OS right? The answer in her didn’t help you?
– Focos
Using System.Windows.Media.Effects you achieve the same result more reliably and simply using only 3 lines. The problem is precisely what I had said earlier, the line I mentioned just above simply presents an error. I’ve seen that this method works, I just don’t know why my code is showing error.
– Oto Emerson