public static MsgBoxResult ShowDialog(this Control parentControl, string text, MsgBoxIcon icon, string caption, DefaultButton defaultBtn, params string[] buttonTxt) { using (var frm = new MsgBoxForm()) { frm.Init(text, icon, caption, defaultBtn, buttonTxt); var parentForm = parentControl?.SelfOrParentForm(); if (parentForm == null) { frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowInTaskbar = true; frm.TopMost = true; frm.ShowDialog(); } else if (!parentForm.Visible || parentForm.WindowState == FormWindowState.Minimized) { // The a form is not shown (e.g. minimized) , the Location and Size // cannot be trusted. Location can sometimes be a negative number. // Use CenterScreen is better than CenterParent, which can cause // frm to show on top left corner. frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog(); } else { frm.ShowDialog(parentForm); } return(frm.SelectionResult); } }
private void buttonStart_Click(object sender, EventArgs e) { if (!this.radioButtonInnoSetup.Checked) { this.mInnoSetup = false; } else { this.mInnoSetup = true; } MsgBoxForm msgBoxForm = new MsgBoxForm(this.mInnoSetup, this.mNoPreview, this.mNoCopy, this.mNoLink); msgBoxForm.ShowDialog(); }