If you are patching FldHandleEvent, then your call to the old trap is not
correct. It shoul be:
handled = oldTrap(fld, event);
Also, do you have something like:
typedef Boolean (*MyTrapType)(FieldPtr, EventPtr);
and
MyTrapType oldTrap;
Regards
Bozidar
> >Can anyone tell me what is wrong with the following basic hack?
> When I run
> >this with the line "handled = oldTrap(event)" commented out, it runs but
> >consumes the event, as you would expect. If I un-comment that
> line, I get
> >the "Fatal Error" dialog and a reset for my troubles.
> >
> >This is a copy of the sample code from the HackAPI html with the
> change to
> >make it handle FldHandleEvent(FieldPtr fld, EventPtr event).
> I'm using CW5
> >and the 0xA13B.rsrc from the traps.zip published on www.roadcoders.com.
> >This seems too simple to be causing these kind of problems! What am I
> >missing?
> >
> >#include <Pilot.h>
> >
> >#define myCreator 'test'
> >#define myResID 1000
> >
> >Boolean MyFldHandleEventTrap(FieldPtr fld, EventPtr event);
> >
> >Boolean MyFldHandleEventTrap(FieldPtr fld, EventPtr event)
> >{
> > Boolean (*oldTrap)(FieldPtr, EventPtr);
> > DWord value;
> > Boolean handled = false;
> >
> > // Get the old trap address from HackMaster.
> > FtrGet(myCreator, myResID, &value);
> >
> > // Set the procedure pointer and initialize
> > oldTrap = (Boolean (*)(FieldPtr, EventPtr))value;
> >
> > // Test - something more significant will be added here ...
> > SndPlaySystemSound(sndWarning);
> >
> > // If not handled, call the old routine
> > if (!handled) {
> > //handled = oldTrap(fld, event); <-- This seems to be the problem line
> > }
> >
> > return handled;
> >
> >}
>
>
>
>
>