MessageBox should be drawn at top

Apr 21, 2010 at 6:39 PM

Do you have any idea why this happen :

-Take the tutorial solution
-In WinFormsExample class Add a button, and Show a MessageBox when you click on it
-Launch the tutorial as winform host and test your button

The messagebox doesn't appear and is behind every others windows....

That's really important for my editor to have the classic behavior !

Thank you ;)

 

 

Coordinator
Apr 21, 2010 at 8:51 PM
Edited Apr 21, 2010 at 8:52 PM

Yup, you're right.

It's a nice and easy fix.
Open up WinFormsHost.cs.

In the OnPaint method, it's calling Invalidate() at the end - this is to make sure it draws the next frame. However, this is saturating the event queue, so your message box isn't working right.

The answer is to remove the Invalidate call from OnPaint and put it the Idle event, like so:

In the constructor:

		System.Windows.Forms.Application.Idle += new EventHandler(Application_Idle);

And add the event method:

		void Application_Idle(object sender, EventArgs e)
		{
			if (autoRedraw)
				Invalidate();
		}

Apr 21, 2010 at 8:59 PM

That's quick and that's working.

Thank you !