/// <summary> /// 显示QQMessageBox消息框 /// </summary> /// <param name="owner">父窗体,默认为null,设置此参数可更改消息框的背景图与父窗体一致</param> /// <param name="msgText">提示文本</param> /// <param name="caption">消息框的标题</param> /// <param name="msgBoxIcon">消息框的图标枚举</param> /// <param name="msgBoxButtons">消息框的按钮,此值可为MessageBoxButtons.OK,MessageBoxButtons.OKCancelMessageBoxButtons.RetryCancel</param> public static DialogResult Show( Form owner = null, string msgText = "请输入提示信息", string caption = "提示", NuiMessageBoxIcon msgBoxIcon = NuiMessageBoxIcon.Information, NuiMessageBoxButtons msgBoxButtons = NuiMessageBoxButtons.OK) { using (NuiMessageBox msgBox = new NuiMessageBox(msgText, caption, msgBoxIcon, msgBoxButtons)) { if (owner != null) { msgBox.StartPosition = FormStartPosition.CenterParent; if (owner.BackgroundImage != null) { //使用父窗体的背景图片 MsgBoxBackgroundImg = owner.BackgroundImage; } if (owner.Icon != null) { msgBox.Icon = owner.Icon; } } else { msgBox.StartPosition = FormStartPosition.CenterScreen; } msgBox.ShowDialog(); return(msgBox.DialogResult); } }
private void LoadMsgBoxButtons(NuiMessageBoxButtons msgBoxButtons) { switch (msgBoxButtons) { case NuiMessageBoxButtons.OK: CreateOKButton(); break; case NuiMessageBoxButtons.OKCancel: CreateOKCancelButton(); break; case NuiMessageBoxButtons.RetryCancel: CreateRetryCancleButton(); break; default: break; } }
public NuiMessageBox(string msgText, string caption, NuiMessageBoxIcon msgBoxIcon, NuiMessageBoxButtons msgBoxButtons) { this.MessageText = msgText; this.Text = caption; LoadMsgBoxIcon(msgBoxIcon); LoadMsgBoxButtons(msgBoxButtons); InitializeComponent(); }