Mark,

Thanks for the second set of eyes.  I should have known this because it's a
const char * that is being passed.

You are right about the new/delete.  Just as I was stopping development last
night (this morning) I started seeing memory leaks and was too frazzled to
see the mistake.

On your related note, I don't fully understand when to set bHandled to false
or not and when to return true or false.  Any insight to this would be
helpful.

Again, thanks for the input.  Much appreciated.

Nick.




"Mark F. Rodriguez" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Nick,
>
> The problem is the memory for CString is allocated locally in both your
> calls and needs to be around for the entire lifetime of the control. I
> suggest adding a member variable like
>
> CString m_controlLabel;
>
> to your header file and then writing your code like.
>
> Boolean CMyForm::OnOpen(EventPtr pEvent, Boolean& bHandled)
> {
>   theTime.SetToCurrentDateTime();
>   m_controlLabel = theTime.FormatDate(true);
>   CButton * pButton = new CButton(MyDateButton2);
>   pButton->SetLabel(m_controlLabel);
>   bHandled = false;
>   return true;
> }
>
>
>
> You can so something similar for the other method and things should
> work.
>
> On a different note you may want to give the framework a crack at
> handling the OnOpen method as well by setting return = false. The other
> thing that comes to mind is you typically want to match up new and
> delete to avoid memory leaks, but that's probably another post:-)
>
> Hope this helps,
> -Mark
>
>



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

Reply via email to