iDevGames Forums
Carbon Apple quit Event troubles - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Carbon Apple quit Event troubles (/thread-7784.html)



Carbon Apple quit Event troubles - deekpyro - May 6, 2002 02:51 PM

I'm working on a new emulator that is carbonized, but I'm having some difficulty with the Apple Quit Event Handler...

Here's my code...

pascal short AEQuit(const AppleEvent* aev, AppleEvent* reply, SInt32 refCon);
pascal short AEQuit(const AppleEvent* aev, AppleEvent* reply, SInt32 refCon)
{
Application.Terminate();
return noErr;
}

.......then later......

void NApplication::InstallAEHandlers()
{
short err;
AEEventHandlerUPP eventFunc;

/* eventFunc = NewAEEventHandlerUPP(AEQuit); */
err = AEInstallEventHandler(kCoreEventClass,kAEQuitApplication,eventFunc,0,false);

/* eventFunc = NewAEEventHandlerUPP(AEUnhandled); */
err = AEInstallEventHandler(kCoreEventClass,kAEOpenDocuments,eventFunc,0,false);
err = AEInstallEventHandler(kCoreEventClass,kAEPrintDocuments,eventFunc,0,false);
err = AEInstallEventHandler(kCoreEventClass,kAEOpenApplication,eventFunc,0,false);
}



The stuff commented it is what it's giving me a compiler error on. The compiler error is:

Error: function call 'NewAEEventHandlerUPP(pascal short (const AEDesc *, AEDesc *, long))' does not match 'NewAEEventHandlerUPP(pascal short (*)(const AEDesc *, AEDesc *, unsigned long))'
NApplication.cpp line 119 eventFunc = NewAEEventHandlerUPP(AEQuit);

and it says practically the same thing for the next one too.

Any thoughts?


Carbon Apple quit Event troubles - jefftkd - May 6, 2002 03:04 PM

Quote:pascal short AEQuit(const AppleEvent* aev, AppleEvent* reply, SInt32 refCon);

This needs to return "pascal short *" (a pointer), not pascal short (a value).

Jeff Cool


Carbon Apple quit Event troubles - OneSadCookie - May 6, 2002 05:26 PM

I'd guess that it's actually that you need a UInt32 final parameter rather than an SInt32.

Let us know Smile


Carbon Apple quit Event troubles - deekpyro - May 7, 2002 06:24 AM

It turns out it was the UInt32 that fixed my problem...well not exactly. I'm not getting compiler errors on it anymore but when I run it in X it doesn't quit from the programs application menu!!! Any ideas why?