MQuickGUI and windows forms

Roy Berube

05-08-2008 05:19:43

I'm trying to get the kinks ironed out of a Mogre app using MQuickGUI and windows forms. The problem is I can't find a way to capture when the windows form is exiting using the form's closing x icon. The exit handler that should work doesn't get called. Here is a snippet:

public void CreateEventHandler()
{
mRoot.FrameStarted += new FrameListener.FrameStartedHandler(FrameStarted);
//This doesn't ever make the call. Intercepted by qgui?
this.FormClosing += new FormClosingEventHandler(Exit);
//etc. for keyboard and mouse handlers..

This was working just fine when I was using BetaGui. The form does close but the program is left hanging without a proper exit.

Any ideas?

Roy Berube

05-08-2008 06:08:32

I did manage to find a workaround by doing a check in the framestarted callback:
if (mWindow.IsClosed == true) { return false; }; //return false: application shutdown

It now shuts down neatly like it should. However I still wouldn't mind knowing why the forms shutdown callback doesn't ever fire.

Mephs

05-08-2008 14:47:17

I did manage to find a workaround by doing a check in the framestarted callback:
if (mWindow.IsClosed == true) { return false; }; //return false: application shutdown

It now shuts down neatly like it should. However I still wouldn't mind knowing why the forms shutdown callback doesn't ever fire.


Are you using mWindow.Disposed?

Roy Berube

06-08-2008 04:04:24

The problem turns out I was trying to use the wrong windows form-one that wasn't attached to the ogre window. I'm not using OgreWindow-which has a properly instantiated windows form- so that is why it didn't work.

OgreWindow does this to get windows messages:

while (mRoot != null && mRoot.RenderOneFrame())
System.Windows.Forms.Application.DoEvents();

I think avoiding the unneeded call to DoEvents every frame is a better choice so I'll stick with what I have.