Custom MessageBox makes all the application flash

I have a form that is used as a custom message box, the code snippet attached is one of the ways it is called.

But I have a problem with this, when you click the OK button all the application flashes, and for a while you can see the applications that are backwards.

Am I doing something wrong with this?

Please help me.
public static DialogResult ShowBox(IWin32Window owner, string sMsg) 
        {
            myMsgBox = new MsgBox();
            myMsgBox.lblHeader.Text = "DOMI";
            myMsgBox.lblMessage.Text = sMsg;
            SetMessageBoxButtons(MessageBoxButtons.OK);
            SetMessageBoxIcon(MessageBoxIcon.None);
            SetMessageBoxDefaultButton(MessageBoxDefaultButton.Button1);
            SetResize(false);
            myMsgBox.TopLevel = true;
            myMsgBox.ShowDialog(owner);
            return result;
        }

Open in new window

JuanPabloPonceAsked:
Who is Participating?
 
JuanPabloPonceAuthor Commented:
Actually, this was an issue of a third party control that was solved by upgrading it's version.
0
 
p_davisCommented:
you can try suspending layout for the form
 Form f = new Form();
                        f.SuspendLayout();
and then when you are done with the message box
f.ResumeLayout()

not sure if that will work in this case, or not.
0
 
JuanPabloPonceAuthor Commented:
Thanks for your anwer, but it doesn't worke in this case.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
illusioSoftware Architect / Team LeaderCommented:
Try:

DialogResult result = MessageBox.Show(owner, sMsg, "DOMI", MessageBoxButtons.OK, MessageBoxIcon.None);

Or drop the myMsgBox.TopLevel = True; <-- HORROR !!! It prevents you from using ANY program.

Kind regards.


0
 
JuanPabloPonceAuthor Commented:
Thanks, I'll take in consideration the TopLevel suggetsion.

About the using of the standard MessageBox it is impossible, the idea is to have a custom message box that uses styles and colors.
0
 
p_davisCommented:
thanks for the update
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.