This is a very simple form that shows a message on screen which fades away almost right away (which should be just enough time to get the message over)
The message is shown in its own thread so that the calling code can continue right away without waiting for the message to disappear
Usage: frmMessage.Show("Your message here");
Code:
//the normal usings (windows.forms, system.drawing) +
//using System.Drawing.Drawing2D;
public class frmMessage:Form
{
private readonly Color
foreCol = Color.White,
backCol = Color.Navy;
private Font fnt = new Font(FontFamily.GenericSerif,25);
private frmMessage(ref string message)
{
this.SuspendLayout();
this.ControlBox=false;
Label l = new Label();
l.Text=message;
l.Dock=DockStyle.Fill;
l.Font=fnt;
l.TextAlign=ContentAlignment.MiddleCenter;
l.BackColor=backCol;
l.ForeColor=foreCol;
Controls.Add(l);
this.StartPosition=FormStartPosition.CenterScreen;
this.FormBorderStyle=FormBorderStyle.None;
Graphics g = l.CreateGraphics();
this.ClientSize=Size.Ceiling(g.MeasureString(message,fnt));
this.TopMost=true;
this.ResumeLayout();
new System.Threading.Thread(new System.Threading.ThreadStart(start)).Start();
}
public static void Show(string message)
{
new frmMessage(ref message);
}
private void start()
{
this.Show();
for(double d = 1 ; d > 0 ; d-=.04)
{
this.Opacity=d;
System.Threading.Thread.Sleep((int)(90*d));
Application.DoEvents();
}
this.Close();
}
}