Hi Evan.

Thanks for your answer. This cleared things out a bit for me. One thing
though, that I'm not totally sure of. Do I, under all circumstances, need to
allocate memory for the gadget's data (the one set with FrmSetGadgetData()),
even if the gadget isn't data aware in any way?

Kind regards, Ola Theander

> -----Original Message-----
> From: Evan Wise [mailto:[EMAIL PROTECTED]] 
> Sent: den 19 december 2001 20:05
> To: Palm Developer Forum
> Subject: Prblm: Gadget control and CtlHandleEvent(), no ctlEnterEvent?
> 
> 
> Ola,
> Gadgets are not like controls, actually I take this back; 
> they are dumb controls that simply provide a place for you do 
> whatever you please. Know that you are going to have to 
> handle everything about a gadget in your code as nothing 
> comes for free. I had to do a fair amount of 
> reading/coding/testing before I could get my gadgets to work 
> (not leak memory, act like a real button, not infinitely loop 
> on redraw if it moved). But, I felt infinitely cool once they 
> worked! In a nutshell you need to do the following: -when you 
> initialize/open your form you need to initialize your gadgets 
> this is done via FrmSetGadgetData (if you plan on having 
> memory associated with your gadget) and set the event handler 
> callback for the individual gadget using FrmSetGadgetHandler. 
> So now you have an allocated, event aware gadget; what now? 
> Well, you need to write your gadget event handler to process 
> the following four events: -formGadgetDeleteCmd - called when 
> the gadget is getting deleted, by frmCloseEvent. Remember to 
> free the memory you allocated using FrmSetGadgetData, if any. 
> There is a slight bug in the 4.0 paranoia settings. If you 
> have ALLOW_ACCESS_TO_INTERNALS_OF_FORMS defined and you are 
> attempting to delete the allocated memory you have to access 
> the data member of the struct. This is a bug in the SDK, know 
> that you are allowed to do this. -formGadgetDrawCmd - draws. 
> called when FrmDrawForm or updates are sent to your gadget 
> hosting form. -formGadgetEraseCmd - erases. called when the 
> screen is being updated or closed. I typically leave this one 
> empty as the system does a nice job of erasing the gadget. 
> -formGadgetHandleEventCmd - the "something happened in your 
> gadgets space" event. You now get to write a second event 
> handler to process events that may happen to your gadget. 
> This is by no means an exhaustive analysis but you should be 
> aware that gadgets, while flexible, can be a massive pain to 
> dev. The docs are not bad in providing help on what 
> prototypes and events / data you can expect in a gadget 
> handler. HTH. E/. 
> ________________________________________________________
> This message sent using the Infowave Wireless Business Engine(tm)
> 
> Evan Wise
> Sprite Herder
> infowave
> E: [EMAIL PROTECTED]
> T: 604 473 3779
> F: 604 473 3633
> 
> 
> 
> -- 
> For information on using the Palm Developer Forums, or to 
> unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
> 

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to