In article <2088@palm-dev-forum>, [EMAIL PROTECTED] wrote:

> Documentation for FrmSetTitle says:
> 
> "...This function redraws the title but does not erase the old one
> first. If the new title is shorter than the old one, the end of the
> old title will still be visible. To avoid this, you can hide the
> title using FrmHideObject, then show it using FrmShowObject, after
> using FrmSetTitle."
> 
> Both FrmHideObject and FrmShowObject require an object index to be
> passed. How can one get the object index for title? Constructor
> doesn't generate ID for it...
> 
> Please explain me... :-)
> 
> Ivan

That's the easy part. You can just asume, that the title has 
index 0 (i.e is the first object of your form). To be sure it 
really is the title (the form could have no title at all) you 
can also check the object type. See my code for FormUpdateTitle 
to change the title of a form:

void FormUpdateTitle(FormPtr formPtr, CharPtr s, Boolean copy) {
    Boolean visible;

    if (FrmGetObjectType(formPtr, 0) == frmTitleObj) {
        
        visible = FrmVisible(formPtr);
        
        if (visible) FrmHideObject(formPtr, 0);
        if (copy) FrmCopyTitle(formPtr, s); else FrmSetTitle(formPtr, s);
        if (visible) FrmShowObject(formPtr, 0);
   }
}

The difficult part is, that it doesn't work as advertised. The old 
title is NOT erased by this call (even with the explicit call to 
FrmHideObject). So if the title gets shorter it will look ugly! 
I've added the following lines to the code, to work around this. 

if (visible) {
    WinEraseWindow();
    FrmUpdateForm(FrmGetFormId(formPtr) , frmRedrawUpdateCode);
}

Any comments? Is this a bug in PalmOS 2 up to 3.5? Because the 
3.5 documentation for FrmSetTitle states:

This function redraws the title but does not erase the old one first. If
the new title is shorter than the old one, the end of the old title will
still be visible. To avoid this, you can hide the title using
FrmHideObject, then show it using FrmShowObject, after using
FrmSetTitle.

So my code should work without the work around? Or do you see a 
bug in my code? Do you have a better work around?
-- 
Remo <[EMAIL PROTECTED]>                       /   /   /   /
----------------------------------------- -===(o<0=0=0=0=0=0=0=0>===-
Do NOT remove .nospam from email address!          \   \   \   \

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to