From: "Jon Zaring" <[EMAIL PROTECTED]>

> You've at least verified that the code works.

When I said it worked, I was not being entirely accurate.  Your code doesn't
restore the previously active form after doing the dialog.  Therefore, the
menu button won't work immediately after calling your about dialog.  To fix
that, you need to save the current form at the start and restore it after
deleting the dialog.  E.g.,

static Boolean MainFormDoCommand(UInt16 command)
{
 Boolean handled = false;
 FormPtr prevForm = FrmGetActiveForm();    // save previous form
 FormPtr frmP;
 Int16 iTemp;

 switch (command)
 {
  case MainOptionsAboutStarterApp:
     MenuEraseStatus(0);
     frmP = FrmInitForm (AboutForm);
     FrmSetActiveForm(frmP);
     // This line works, the control gets set (Cleared, actually.  0==clear;
1==set)
     CtlSetValue((ControlType *)FrmGetObjectPtr(frmP,
FrmGetObjectIndex(frmP, AboutTestCheckbox)),0);
     // The control appears as set (Cleared) on the form
     FrmDoDialog (frmP);
     // If the checkbox was changed, iTemp reflects the change
     iTemp = CtlGetValue((ControlType *)FrmGetObjectPtr(frmP,
FrmGetObjectIndex(frmP, AboutTestCheckbox)));
     // This next line crashes the program (It never crashed for me, but see
comments below.)
     CtlSetValue((ControlType *)FrmGetObjectPtr(frmP,
FrmGetObjectIndex(frmP, AboutTestCheckbox)),0);
     FrmDoDialog (frmP);
     if ( prevForm )
        FrmSetActiveForm( prevForm );    // restore previous form
     FrmDeleteForm (frmP);
     handled = true;
     break;
  }
 return handled;
}

After adding that code, if you manually check the Test checkbox when the
dialog is open, the checkbox will remain on the main form after the dialog
is closed, but only if the dialog was created with Save Behind checked.  The
checkbox will not appear on the main form if Save Behind is not checked on
the dialog form.  So, what appears to be happening is that if you try to set
the control's value after FrmDoDialog(), the OS behaves as if the control
existed on the main form and "restores" it there when the dialog closes.
The only obvious solution to me is to set the control value before
FrmDoDialog() and read the control value after FrmDoDialog(), and don't try
to set it after.



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