On 10/24/06, Jay <[EMAIL PROTECTED]> wrote:
MY QUESTION: Why isn't the active form pointer passed in
to "mainFormEventHandler(...)" by the calling function
...
Is it slower to do that (use the stack)? Did Palm, Inc., just want to be
free to hide the implementation of the form-to-handler association??
i'm not a palmsource employee - but, i can probably put a few cents
into this disucssion - and, i've written a tonne of gui handling code for
the palmos :)
here is the most obvious answer:
A. you dont always need a reference to the active form
thats pretty much it. if you always needed the reference; then i am sure
that it would have been put as a parameter within the callback itself. if
you take a few minutes to look at the event type structure; you'll see that
what palmsource has actually done is optimized a lot for you.
why call:
FrmGetActiveForm() .. FrmGetObjectPtr() ...
when, in the ctlSelect event - there is a "e ->
data.ctlSelect.pControl" object?
90% of the time; unless you are doing something semi-funky, you can get
everything you need from within the event structure itself - most people dont
bother to look in there.
keep in mind; palmos was written by a bunch of apple developers - specifically
with history around the newton devices. any decision to do the event handlers
in a specific way were probably decided back then. keep in mind, the original
devices had only 16mhz 68000 devices - not the power horses we have today.
there could be a bunch of reasons not to pass a parameter that isn't always
needed - and, yes, stack space would definately be one of them - in addition
to wasteful use of the cpu to even deal with the parameter in the first place.
FrmDispatchEvent + event handler callbacks were created to allow the
devleoper to seperate events specific to a known form from other event handling
routines; you dont need to use event handlers, in fact, you can write your
whole application in a while loop calling EvtGetEvent() and then processing
the appropriate events (without even having a form at all)
anyhow - my 2c ;)
--
// Aaron Ardiri
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/