We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Custom MessageBox makes all the application flash

JuanPabloPonce
on
Medium Priority
263 Views
Last Modified: 2012-05-06
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

Comment
Watch Question

CERTIFIED EXPERT

Commented:
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.

Author

Commented:
Thanks for your anwer, but it doesn't worke in this case.
illusioSoftware Architect / Team Leader
CERTIFIED EXPERT

Commented:
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.


Author

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.
Actually, this was an issue of a third party control that was solved by upgrading it's version.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT

Commented:
thanks for the update
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.