先封装一个MESSAGEBOX控件
FrontLinkMessage.cs
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace FrontLinkControls { public partial class FrontLinkMessage : Form { public enum BeepType { SimpleBeep = -1, IconAsterisk = 0x00000040, IconExclamation = 0x00000030, IconHand = 0x00000010, IconQuestion = 0x00000020, Ok = 0x00000000, } [DllImport("coredll.dll", EntryPoint = "MessageBeep")] public static extern bool MessageBeepCE(BeepType beepType); [DllImport("user32.dll", EntryPoint = "MessageBeep")] public static extern bool MessageBeepWin(uint uType); public static bool MessageBeep(BeepType beepType) { if ( Win32.m_PlatformCE ) { return MessageBeepCE(beepType); } else { return MessageBeepWin((uint)beepType); } } private const int buttonLocation = 58; private string message; private MessageBoxIcon icon; private MessageBoxButtons button; private MessageBoxDefaultButton defaultButton; private Rectangle textRect; Graphics g; public FrontLinkMessage(string msg, string title, MessageBoxButtons btn, MessageBoxIcon icon, MessageBoxDefaultButton defaultBtn) { InitializeComponent(); this.message = msg; this.icon = icon; this.button = btn; this.defaultButton = defaultBtn; this.Text = title; g = this.CreateGraphics(); MeasureSize(); } public void MeasureSize() { textRect = new Rectangle(58, 26, 130, 50); SizeF textSize = g.MeasureString(message, this.Font); float f; int i = 0, formHeight = 0; if (textSize.Width > textRect.Width) { int linesCount = 0; string[] content = message.Split('\n'); for (i = 0; i < content.Length; i++) { SizeF subTextSize = g.MeasureString(content[i], this.Font); if (subTextSize.Width < textRect.Width) { linesCount++; } else { // 确定需要几行显示 f = subTextSize.Width / textRect.Width; linesCount += Convert.ToInt32(Math.Ceiling(f)); } } formHeight = Convert.ToInt32(Math.Ceiling(textSize.Height / content.Length)) * linesCount + 26 + buttonLocation + 23; } else { formHeight = Convert.ToInt32(Math.Ceiling(textSize.Height) + 26 + buttonLocation + 23); } // 窗体高度 if (formHeight > 260) { formHeight = 260; } textRect = new Rectangle(58, 26, 130, formHeight); this.Size = new Size(210, formHeight); // center f = (320 - this.Height - 20) / 2; i = f < 0 ? 0 : Convert.ToInt32(f); this.Location = new Point(15, i); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (this.Site != null && this.Site.DesignMode) { return; } SolidBrush brush = new SolidBrush(Color.Black); StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Near; e.Graphics.DrawString(message, this.Font, brush, textRect, format); brush.Dispose(); if (button == MessageBoxButtons.YesNo) { btnOk.Visible = false; btnYes.Visible = true; btnNo.Visible = true; picInfo.Visible = false; picQ.Visible = true; btnYes.Top = this.Height - buttonLocation; btnNo.Top = this.Height - buttonLocation; if (defaultButton == MessageBoxDefaultButton.Button1) { btnYes.Focus(); } else { btnNo.Focus(); } } else { btnOk.Visible = true; btnYes.Visible = false; btnNo.Visible = false; picInfo.Visible = true; picQ.Visible = false; btnOk.Focus(); btnOk.Top = this.Height - buttonLocation; } } private void btnOk_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; this.Close(); } private void btnYes_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Yes; this.Close(); } private void btnNo_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.No; this.Close(); } private static FrontLinkMessage instance = null; public static void Show(string msg) { Show(msg, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); } public static DialogResult Show(string msg, string title, MessageBoxButtons btn, MessageBoxIcon icon, MessageBoxDefaultButton defaultBtn) { // 20100702, can not showDialog when instance is already visible if (instance != null && instance.Visible) { return DialogResult.No; } if (msg == null) { msg = ""; } if (title == null) { title = ""; } if (instance == null) { instance = new FrontLinkMessage(msg, title, btn, icon, defaultBtn); instance.Disposed +=new EventHandler(disposeInstance); } else { instance.message = msg; instance.Text = title; instance.icon = icon; instance.button = btn; instance.defaultButton = defaultBtn; instance.MeasureSize(); } if (icon == MessageBoxIcon.Question) { MessageBeep(BeepType.IconQuestion); } else { MessageBeep(BeepType.IconAsterisk); } return instance.ShowDialog(); } private static void disposeInstance(object sender, EventArgs e) { instance.Disposed -= new EventHandler(disposeInstance); instance = null; } private void MyMsgBox_KeyDown(object sender, KeyEventArgs e) { if (button == MessageBoxButtons.OK) { btnOk_Click(null, null); } else { switch (e.KeyCode) { case Keys.F12: //if (btnYes.Focused) //{ // btnYes_Click(null, null); //} //else if (btnNo.Focused) //{ // btnNo_Click(null, null); //} //break; case Keys.Escape: btnNo_Click(null, null); break; case Keys.F11: //if (btnYes.Focused) //{ // btnYes_Click(null, null); //} //else if ( btnNo.Focused ) //{ // btnNo_Click(null, null); //} //break; case Keys.Enter: btnYes_Click(null, null); break; } } } } }
FrontLinkMessage.Designer.cs
namespace FrontLinkControls { partial class FrontLinkMessage { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> //protected override void Dispose(bool disposing) //{ // if (disposing && (components != null)) // { // components.Dispose(); // } // base.Dispose(disposing); //} #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrontLinkMessage)); this.btnOk = new System.Windows.Forms.Button(); this.btnYes = new System.Windows.Forms.Button(); this.btnNo = new System.Windows.Forms.Button(); this.picInfo = new System.Windows.Forms.PictureBox(); this.picQ = new System.Windows.Forms.PictureBox(); this.SuspendLayout(); // // btnOk // this.btnOk.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold); this.btnOk.Location = new System.Drawing.Point(69, 45); this.btnOk.Name = "btnOk"; this.btnOk.Size = new System.Drawing.Size(72, 27); this.btnOk.TabIndex = 0; this.btnOk.Text = "确定"; this.btnOk.Click += new System.EventHandler(this.btnOk_Click); // // btnYes // this.btnYes.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold); this.btnYes.Location = new System.Drawing.Point(112, 45); this.btnYes.Name = "btnYes"; this.btnYes.Size = new System.Drawing.Size(72, 27); this.btnYes.TabIndex = 1; this.btnYes.Text = "是(&Y)"; this.btnYes.Click += new System.EventHandler(this.btnYes_Click); // // btnNo // this.btnNo.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold); this.btnNo.Location = new System.Drawing.Point(27, 45); this.btnNo.Name = "btnNo"; this.btnNo.Size = new System.Drawing.Size(72, 27); this.btnNo.TabIndex = 2; this.btnNo.Text = "否(&N)"; this.btnNo.Click += new System.EventHandler(this.btnNo_Click); // // picInfo // this.picInfo.Image = ((System.Drawing.Image)(resources.GetObject("picInfo.Image"))); this.picInfo.Location = new System.Drawing.Point(0, 0); this.picInfo.Name = "picInfo"; this.picInfo.Size = new System.Drawing.Size(45, 42); // // picQ // this.picQ.Image = ((System.Drawing.Image)(resources.GetObject("picQ.Image"))); this.picQ.Location = new System.Drawing.Point(0, 0); this.picQ.Name = "picQ"; this.picQ.Size = new System.Drawing.Size(45, 42); // // FrontLinkMessage // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.ClientSize = new System.Drawing.Size(208, 75); this.ControlBox = false; this.Controls.Add(this.picQ); this.Controls.Add(this.picInfo); this.Controls.Add(this.btnNo); this.Controls.Add(this.btnYes); this.Controls.Add(this.btnOk); this.Font = new System.Drawing.Font("Arial", 10F, System.Drawing.FontStyle.Bold); this.KeyPreview = true; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "FrontLinkMessage"; this.Text = "MyMsgBox"; this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MyMsgBox_KeyDown); this.ResumeLayout(false); } #endregion private System.Windows.Forms.Button btnOk; private System.Windows.Forms.Button btnYes; private System.Windows.Forms.Button btnNo; private System.Windows.Forms.PictureBox picInfo; private System.Windows.Forms.PictureBox picQ; } }
FrontLinkMessage.resx
<?xml version="1.0" encoding="utf-8"?> <root> <!-- Microsoft ResX Schema Version 2.0 The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the various data types are done through the TypeConverter classes associated with the data types. Example: ... ado.net/XML headers & schema ... <resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="version">2.0</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <value>[base64 mime encoded serialized .NET Framework object]</value> </data> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <comment>This is a comment</comment> </data> There are any number of "resheader" rows that contain simple name/value pairs. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support text/value conversion through the TypeConverter architecture. Classes that don't support this are serialized and stored with the mimetype set. The mimetype is used for serialized objects, and tells the ResXResourceReader how to depersist the object. This is currently not extensible. For a given mimetype the value must be set accordingly: Note - application/x-microsoft.net.object.binary.base64 is the format that the ResXResourceWriter will generate, however the reader can read any of the formats listed below. mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"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GxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPG xsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGAAAAxsPGxsPGxsPGxsPGxsPGxsPG xsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPG xsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGAAAAxsPGxsPG xsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPG xsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPG xsPGAAAA </value> </data> <data name="picQ.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value> Qk2WEwAAAAAAADYAAAAoAAAAKQAAACgAAAABABgAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAAxsPGxsPG xsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPG xsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGaMbD xsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbD xsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbD xmjGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8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xsbDxsbD xsbDxsbDxsbDxsbDxsbDxsbDxsbDxsbDxmjGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bG w8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bG w8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8bGw8ZoxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPG xsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPG xsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGxsPGaA== </value> </data> <metadata name="$this.FormFactorShadowProperty" xml:space="preserve"> <value>WEBPAD</value> </metadata> <metadata name="$this.Skin" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> </metadata> </root>
使用方法
using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; namespace FrontLinkControls { public class Message { /// <summary> /// 弹出错误提示框 /// </summary> /// <param name="str">提示错误信息</param> public static void Error(string content) { Error(content, "错误"); } /// <summary> /// 弹出错误提示框 /// </summary> /// <param name="str">提示错误信息</param> /// <param name="title">显示标题</param> public static void Error(string content, string title) { FrontLinkMessage.Show(content, title, MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); } /// <summary> /// 报告一个警告 /// </summary> /// <param name="strMsg"></param> public static void Exclamation(string content) { FrontLinkMessage.Show(content, "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } /// <summary> /// 报告一个提示 /// </summary> /// <param name="strMsg"></param> public static void Success(string content) { FrontLinkMessage.Show(content, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); } public static bool AskQuestion(string content) { DialogResult dialogResult = FrontLinkMessage.Show(content, "提问", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (dialogResult == DialogResult.Yes) return true; else return false; } } }