Ben Combee a écrit :

> At 03:48 PM 3/29/2004, you wrote:
> >Do I have to keep the ControlPtr returned by CtlNewControl or can I
> >forget about it and leave it up to the form to free the allocated memory
> >upon deletion? If I don't keep this ControlPtr, can I recover it later
> >in the usual way with FrmGetObjectPtrFromID?
>
> You can forget the pointer -- the actual control is stored in the form's
> block of memory.  Remember, anytime you add a control to a form, you may
> have invalidated all the pointers to the form and its controls that you've
> retrieved in the past.
>
> >I don't understand the API Reference explanation for the formPP argument
> >of CtlNewControl. Can't I just pass the results of FrmGetActiveForm()?
>
> Nope.  This is the way for CtlNewControl to pass you back the new form
> pointer, since adding the control may have caused the form to be moved in
> memory.

The form seems to be more than moved: I call CtlNewControl right after calling 
FrmInitForm for a modal dialog and pass it
&form. After that, several buttons see their text changed. I suspected a conflicting 
ID with internal object I didn't know
about, so I chose 10000, way above any resource in my application, to no avail.

Are there prerequistes for calling CtlNewControl (form visible, FrmDoDialog called, 
etc.)?


form = FrmInitForm( SessionForm );

CtlNewControl( ( void **) &form, SessionSumCheckbox, checkboxCtl, "Sum",
                       60, 30, 40, 12, boldFont, 0, false );

FrmSetEventHandler( form, ( FormEventHandlerPtr ) SessionHandleEvent );

FrmDoDialog( form );



--
Luc Le Blanc


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

Reply via email to