View Full Version : MessageBox with NULL hwnd crashes May 2009x86

05 May 2009, 02:36 AM
More explanation of the title. I was running Maya2009 x86 on my 64-bit Vista system using a plugin I have been working on. I have used MessageBox() with a NULL first parameter for, well a long time, and often pop up some progress message during development.

This worked fine in my testing until I tried a 32-bit version of the plugin on the 32-bit version of Maya. Crashes every time. I tried using the Mel command "confirmDialog", but it only works on the 32-bit version when there is one button, with two -buttons items it also crashes. I am not sure this is a Maya issue, probably a Windows one.

I found a workaround for the MessageBox() crash by using this:
MessageBox( GetForegroundWindow(), "text", "title", MB_OK )
which works well here (with either MB_OK or MB_YESNO).

I'm compiling it with VisualStudio 2008.

Is this a known issue? Or just perhaps a problem here?

05 May 2009, 03:30 PM
This could be totally unrelated, however, I would recommend compiling your plug-in with the same compiler used for whichever version of Maya you're compiling for. There have been spurious crashes known to occur when you don't do this. Of course many people have been able to successfully run their plug-ins using the wrong compiler. It all depends on which methods your plug-in invokes.

Maya 8.0 VC2003
Maya 8.5 VC2005 non-SP1
Maya 2008 VC2005 SP1
Maya 2009 VC2005 SP1

05 May 2009, 12:07 AM
Thanks, I didn't know that. And I would not be surprised if the windows interaction issues were found to be rooted in the VC 2008 runtime itself.

Time to move my stuff back to VC 2005. I know that Maya 2008 does not use VC 2008 because a friend had to install the VC 2008 runtime package to use a test version I sent him.

05 May 2009, 12:58 AM
I'm on 32bit vista, vs2008, and maya2009.
I just did a quick test and I didn't run into any crashes. :curious:

Here's my code:

#include <maya/MPxCommand.h>
#include <maya/MFnPlugin.h>

class TestCmd : public MPxCommand
static void* creator()
return new TestCmd();
virtual MStatus doIt(const MArgList &args);

MStatus TestCmd::doIt(const MArgList &args)
MessageBox(0, "test", "test", MB_OK);
MessageBox(0, "test", "test", MB_YESNO);
return MS::kSuccess;

MStatus initializePlugin( MObject obj ) {
MFnPlugin plugin( obj, "Autodesk", "1.0", "Any" );
plugin.registerCommand( "testCmd", TestCmd::creator );
return MS::kSuccess;

MStatus uninitializePlugin( MObject obj ) {
MFnPlugin plugin( obj );
plugin.deregisterCommand( "testCmd" );
return MS::kSuccess;

05 May 2009, 04:27 PM
I don't have a functional 32-bit Vista box to test on; I had the crash running the 32-bit version of maya on Vista 64-bit. As I noted, I never had trouble with MessageBox() before, or with Maya itself, other than having to try to synchronize my preferences between two versions. :/

I am working on Keilun's suggestion to compile with VS2005. Only trouble was, I had uninstalled it, and have to reinstall it first. I expect to have results soon. It may be better in the end, there are some users out there without the VS 2008 runtime package already installed.

<* Wes *>

EDIT: So I have recompiled everything under VS 2005 (Sp1) and tested. I have the exact same problem with MessageBox(NULL, ...). I suspect it has more to do with unfixed microsoft issues of running 32-bit programs under Windows Vista 64-bits. I don't think it's a maya bug, but it appears to be a gotcha for anyone running the 32-bit version of maya on their shiny new 64-bit box (solution: download the 64-bit version, it starts at least twice as fast).

CGTalk Moderation
05 May 2009, 04:27 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.