Ben,
I changed the program so I get the object in the AboutForm, but I still get
the error. I also moved the iTemp declaration out of the switch. :)
Here is the code:
static Boolean MainFormDoCommand(UInt16 command)
{
Boolean handled = false;
FormPtr frmP;
Int16 iTemp;
switch (command)
{
case MainOptionsAboutStarterApp:
MenuEraseStatus(0);
frmP = FrmInitForm (AboutForm);
FrmSetActiveForm(frmP);
// This line works, the control gets set
CtlSetValue((ControlType *)
FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, AboutTestCheckbox)),0);
// The control appears as set 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
CtlSetValue((ControlType *)
FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, AboutTestCheckbox)),0);
FrmDoDialog (frmP);
FrmDeleteForm (frmP);
handled = true;
break;
}
return handled;
}
Thanks!
Jon
"Ben Combee" <[EMAIL PROTECTED]> wrote in message
news:32404@palm-dev-forum...
>
> "Richard Burmeister" <[EMAIL PROTECTED]> wrote in message
> news:32402@palm-dev-forum...
> >
> > From: "Jon Zaring" <[EMAIL PROTECTED]>
> >
> > > frmP = FrmInitForm (AboutForm);
> > > FrmSetActiveForm(frmP);
> > > CtlSetValue((ControlType *)GetObjectPtr(AboutTestCheckbox),0);
> > > FrmDoDialog (frmP);
> > > Int16 iTemp = CtlGetValue((ControlType
> *)GetObjectPtr(AboutTestCheckbox));
> > > // The following line is erroring out on me . . . looks like the
stack
> is
> > clobbered
> > > CtlSetValue((ControlType *)GetObjectPtr(AboutTestCheckbox),0);
> > > FrmDoDialog (frmP); // Display the About Box.
> > > FrmDeleteForm (frmP);
> >
> > What environment are you using? CodeWarrior won't even compile this.
It
> > doesn't like the Int16 declaration in the middle of the switch inside of
> > MainFormDoCommand, complaining about "expression syntax error". Perhaps
> > your compiler doesn't like it either, but doesn't tell you.
>
> CodeWarrior with the PalmOS 3.5 SDK does like this, since Int16 and UInt16
> are the types that replaced SWord and Word. Also, the declaration is
legal
> if compiled as C++, although declarations in the middle of a switch are a
> bit unusual due to problems with constructor/destructor scoping.
>
> My guess at the error is your calls to GetObjectPtr -- that uses the
active
> form to look up the control, but the AboutTestCheckbox is an element of
your
> AboutForm which is only active during the call to FrmDoDialog. The rest
of
> the time, your form that's doing this calling is active, and it doesn't
have
> that control in it. You need to explicitly lookup the controls in the
> AboutForm in order to manipulate them.
>
> --
> Ben Combee
> Veriprise Wireless <http://www.veriprise.com>
>
>
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/