SaveBehind, but only sometimes?

SaveBehind, but only sometimes?

Post by Ethan Shayn » Tue, 02 Apr 2002 08:11:54



I have form A (the main form), which consists of a list of entries.
From form A, the user can open form B, which allows them to add an
entry. From form B, then can hit either Ok or Cancel.

My problem is after they go back to form A, I only want to refresh the
list if the user hit Ok - there's no point if they hit Cancel, since
nothing changed.

I know I can make form A *always* refresh by unchecking "Save Behind"
for form B, and then making form A's frmUpdateEvent handler rebuild
the list. But if I make form B not "Save Behind," then I always need
to do this (correct?). Is there any way to make form A only redraw if
the user clicked the Ok button on form B, but not if the user clicked
the Cancel button on form B? If so, how?

        Thanks,
                Ethan Shayne

 
 
 

SaveBehind, but only sometimes?

Post by Ben Combe » Tue, 02 Apr 2002 13:08:45




Quote:> I have form A (the main form), which consists of a list of entries.
> From form A, the user can open form B, which allows them to add an
> entry. From form B, then can hit either Ok or Cancel.

> My problem is after they go back to form A, I only want to refresh the
> list if the user hit Ok - there's no point if they hit Cancel, since
> nothing changed.

> I know I can make form A *always* refresh by unchecking "Save Behind"
> for form B, and then making form A's frmUpdateEvent handler rebuild
> the list. But if I make form B not "Save Behind," then I always need
> to do this (correct?). Is there any way to make form A only redraw if
> the user clicked the Ok button on form B, but not if the user clicked
> the Cancel button on form B? If so, how?

Actually, you're only seeing the update events because you're using a
debug ROM.  Normally, saveBehind causes the OS to just save a copy of
the screen the form will obscure, which the OS then uses to redraw the
bottom form.

If you want form A to change based on form B, then I'd suggest using a
double buffering scheme where A updates itself based on the new data
when it gets a frmUpdateEvent with a special value.  Then in your form B
code that call FrmReturnToForm, make an explicit FrmUpdateForm call with
your special update code to A before returning.

You might find this all simplified a bit if form B was a dialog.  You
can do a lot with FrmDoDialog, since you can set up your own form dialog
handler by calling FrmSetEventHandler, and you can predraw the dialog
using FrmDrawForm before you cede control to the system.

--

CodeWarrior for Palm OS technical lead