PDA

View Full Version : Carbon Apple quit Event troubles


deekpyro
2002.05.06, 05: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,kAEQuitAppli cation,eventFunc,0,false);

/* eventFunc = NewAEEventHandlerUPP(AEUnhandled); */
err = AEInstallEventHandler(kCoreEventClass,kAEOpenDocum ents,eventFunc,0,false);
err = AEInstallEventHandler(kCoreEventClass,kAEPrintDocu ments,eventFunc,0,false);
err = AEInstallEventHandler(kCoreEventClass,kAEOpenAppli cation,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?

jefftkd
2002.05.06, 06:04 PM
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:

OneSadCookie
2002.05.06, 08:26 PM
I'd guess that it's actually that you need a UInt32 final parameter rather than an SInt32.

Let us know :)

deekpyro
2002.05.07, 09: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?