Can anyone tell me what is wrong with the following basic hack? When I run
this with the line "handled = oldTrap(fld, 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;
}