Hi Michael,

Thanks for your code. I guess my mistake lies at the point of not
keeping a global MemHandle  . And instead of doing that, I retrieve
from the the form itself using "FrmGetTitle" and "MemPtrRecoverHandle"
to do the resizing.

As what Robert has said, I might be resizing (most likely) the resource
memory
instead the one I allocated to the title and that cause the error.

Thank you guys for all the help. Last but not least, I think I have a
greater
insight into memory management which I think it is one of the most
difficult aspect of Palm programming as compared with normal desktop
programming.

Best Regards
Andy

Michael Glickman <[EMAIL PROTECTED]> wrote in message
news:69211@palm-dev-forum...
>
> You probably  need to relocate MemHandleUnlock,
> because the form doesn't know anyhting about your handle,
> therefore a coreect way is:
>
> static MemHandle titleH = NULL;
>
>     static void UpdateTitle ( const Char *database_record)
> {
> if (titleH) {
>      MemHandleUnlock(titleH);
>    FrmSetTitle(frm, NULL);
>      titleH  = MemHandleResize(titleH, StrLen(database_record)+1) );
> } else
>      titleH  = MemHandleNew( StrLen(database_record)+1) );
>
> if (titleH) {
>    char *titlePtr = MemHandleLock(titleH);
>
>    if (titlePtr) {
> StrCopy(titlePtr, database_record);
>   FrmSetTitle(FrmGetActiveForm(), titlePtr)
>    }
> }
>
> }
>
> Don't forget to unlock and release memory before exit!
> Michael




-- 
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