You're probably writing more than was allocated.  I find the best
way to deal with triggers is to have a global Char * variable and
you can free/allocate it.  Then you'd do:


Char *gTriggerLabel;

static void someFunc(void) 
{
        ControlPtr ctl;
        Char date[dowLongDateStrLen];

        ctl = GetObjectPtr(DetailsDateSelTrigger);
        DateToDOWDMFormat(....., date);

        if (gTriggerLabel != NULL)
                MemPtrFree(gTriggerLabel);

        gTriggerLabel = MemPtrNew(StrLen(date) + 1);
        StrCopy(gTriggerLabel, date);
        CtlSetLabel(ctl, gTriggerLabel);
}


Don't forget to free gTriggerLabel when you leave the form/app
        

> -----Original Message-----
> From: Stephen Bentley [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, October 03, 2002 11:24 AM
> To: Palm Developer Forum
> Subject: select trigger woes
> 
> 
> I borrowed the following code snipet, the GetObjectPtr 
> function, and the 
> details form itself from the OS 3.5 datebook example:
> 
> ctl = GetObjectPtr (DetailsDateSelTrigger);
> label = (Char *)CtlGetLabel (ctl);    // OK to cast; we call 
> CtlSetLabel
> DateToDOWDMFormat (details->when.date.month, details->when.date.day, 
>       details->when.date.year + firstYear, 
> sysPrefs.dateFormat, label);
> CtlSetLabel (ctl, label);
> 
> but I constantly get GARBAGE in the ctl pointer that is 
> returned.  Yet when
> I run the complete datebook example project in debug it works fine.  
> 
> Can anyone tell me why I can't get a valid pointer on this 
> stupid control? 
> It's driving me nuts.  I seem to always have problems with 
> select triggers.
> 
> Thanks!
> 
> Stephen
> 
> 
> -- 
> For information on using the Palm Developer Forums, or to 
> unsubscribe, please see http://www.palmos.com/dev/support/forums/
> 

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

Reply via email to