I've struggled a bit lately with the ole "Save Behind" feature of a form. I
searched the forum archives and didn't quite get the answer I was looking
for and so I thought I would post my conclusions for future searches. Also,
if I have misunderstood this very odd feature, please let me know.
The save behind feature appears to be a bit misnamed. Not only does it save
the pixels of the form behind it and restores them on return, it also clears
the form on entry for pre OS 3.5. In other words, if you don't have this bit
set, your forms will appear "transparent" on devices pre 3.5. The solution
in the archives tends to be "turn on the save behind" bit when someone asks
why their forms are transparent. This is unfortunately not always the right
thing to do. You should only use the save behind feature when you know your
form will not change the content of the form underneath. Otherwise, you will
need to redraw the screen anyway and so you will get a flicker since it is
drawn the first time by OS for the save behind and the second time by your
code.
Unfortunately, not using the save behind feature has two odd consequences.
The first being the transparent dialog problem mentioned before and the
second is that pre 3.5 OSes also don't send an update event when a
FrmReturnToForm is executed. Under 3.5, an update event is posted and
everything works fine. Pre 3.5, no update is sent and so the "underneath"
form doesn't get redrawn.
Therefore, I've written the following two routines to solve these issues. I
will leave it up to the reader on how to implement the IsAtLeastOS35. If you
call these routines in place of their Palm OS counter part on forms with out
the save behind bit set, all will be fine. (A further enhancement would be
to check the save behind bit as well so these routines can be called always.
Lastly, if you pass a 0 for formID it will return and redraw the calling
form. The docs mention this for FrmReturnToForm but don't mention it for
FrmUpdateForm. It appears to work, however.
Regards,
//Ray
[EMAIL PROTECTED]
www.splashdata.com
void FrmDrawFormEx( FormPtr formP )
{
if ( IsAtLeastOS35() == false )
{
// pre 3.5 OS doesn't erase the background if "Save Behind" isn't set.
WinEraseWindow();
}
FrmDrawForm( formP );
}
void FrmReturnToFormEx( UInt16 formID )
{
FrmReturnToForm( formID );
if ( IsAtLeastOS35() == false )
FrmUpdateForm( formID, frmRedrawUpdateCode );
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/