Hi Robert,

Robert McKenzie <[EMAIL PROTECTED]> wrote in message
news:69206@palm-dev-forum...
>
> Using FrmSetTitle will work, but your intuition that you should do more is
> quite correct.  You have created a memory leak here.  You should save your
> title pointer (easiest as a global) and dispose of the memory referenced
on
> the form close event.

Will FrmCloseEvent() to unload all the resources allocated to the
form ?

>You should also null this pointer on form open.  If
> you need to change the title multiple times, then you can dispose of a
prior
> version (if the title pointer global is non-null), create a new one, and
> give it to the form.  The reason to save the title pointer as a global and
> not just to retrieve it from the form is that you must distinguish between
> the title given in the resource (whose memory you don't want to free) and
> ones that you set.  (Of course there are other ways to do this, but this
> seems most direct to me.)

That explain why it doesn't work for me when I tried to retrieve the
previous
handle allocated to the title.

--------------------------------------------------------------------------
titlePtr = FrmGetTitle( FrmGetActiveForm() );
titleH = MemPtrRecoverHandle(titlePtr);
MemHandleResize(titleH, StrLen(new_title_from_database)+1);
titlePtr = MemHandleLock(titleH);

StrCopy(titlePtr, new_title_from_database);

FrmSetTitle(frm, titlePtr);
--------------------------------------------------------------------------

So sorry for this coming novice question, how do you declare global
variables as I'm writing a few"C" files. I'm not too sure when will the
variable cease to exsist. Is it possible to declare a variable that
exist throught the lifespan of the program using CodeWarrior 7 ?

 > As to your overlapping problem, find the index of the form title object,
> call FrmHideObject on it prior to changing the title, then FrmShowObject
on
> it after changing the title.  To determine the title object's index, use a
> simple loop (index=0; index<FrmGetNumberOfObjects(); index++). call
> FrmGetObjectType(), and compare the returned value against a frmTitleObj.
> When you get a bingo, you will have the title's index.

Hmmm....sounds like a brilliant idea ! I do get the idea behind the above
description,
but I don't quite know how to fill up "FrmGetObjectType" as it require me to
fill up the objectIndex as mentioned in the Palm OS API.


Thank you for all the tips that you have shared with me ! It's really
eye opening for a novice like me.

Have a nice day !

Best Regards
Andy




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