It's more likely that you did something in your form that has corrupted things - 
usually this is something like using FrmCopyLabel or FrmCopyTitle with a label or 
title that was larger than the label or title originally set for the form.

Make sure you haven't done something in your form to corrupt the form's data 
structures first, then start wondering about more esoteric causes...

K

-----Original Message-----
From: kcorey [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, October 01, 2002 2:50 AM
To: Palm Developer Forum
Subject: Ugh...form madness!


Hi All,

Here's a strange one. 

First, the background: Running on Pose 3.4,
platform41_Vx_full_Dbg_enUS.rom, 8192K on device, Windows XP, all
debugging options turned on, except for screen access.

My game didn't use forms at all up until now because it handled all
output to the screen by itself...the code was working just fine, but now
I'm putting in a registration form, and I'm having no end of trouble.

The funny thing, (and why I'm sending this out for comment) is that if I
comment out the FrmDoDialog function call from the following form
handler, the problem goes away (unfortunately, so does the form).

My form handling code is below.  All field handling has been removed to
simplify things.

Boolean getVerified()
{
        FormPtr frm = FrmInitForm(regForm);
        short hitButton;
        FieldPtr regField=FrmGetObjectPtr(frm,
                FrmGetObjectIndex(frm,regCode));

        FrmSetFocus(frm,FrmGetObjectIndex(frm,regCode));

        hitButton=FrmDoDialog(frm);  // Comment this out to run fine.

        FrmDeleteForm(frm);

        return true;
}

The form itself works correctly, responding to text entry, displaying
help when clicked on, etc.  When the OK button is clicked, my program
continues on in the setup function, doing various things like setting
the screen depth, allocating memory for the sprites, and drawing various
off-screen bitmaps, including calling 'DrawShips' for showing how many
ships the player has left. (The code for DrawShips is below).

DrawShips works when called (even multiple times) from my setup
function...then my setup function is left, and my main loop is entered.

The first time through the loop, the DrawShips function is called again,
except that this time it crashes inside the system function
WinPushDrawState().  The error reads "roids just read from memory
location 0x80000020. This access usually indicates that the application
is calling a Window Manager function without first establishing a valid
DrawWindow."

Between the working DrawShips function(s) and the failing one, there's
no call to set any window parameters.  These are _all_ the system
functions that are called between invocations: PrefGetAppPreferences,
PrefSetAppPreferences, TimGetTicks, EvtGetEvent, SysHandleEvent, and
KeyCurrentState. (I single stepped through the code in the debugger to
make sure.)

The event returned for EvtGetEvent is a nilEvent.

Clearly, there's a side effect of form handling going on here, but I
don't have a clue where to look.

DrawShips looks like this:
void DrawShips()
{
  RectangleType r;

  // Draw the number of ships
  WinPushDrawState();    /// <----CRASHES HERE!
  WinSetDrawWindow(shipWinH);
  WinSetForeColor(0);
  if (!pow_drawContext.useSonyHiRes) {
    WinEraseRectangle(&shipRect,0);
  } else {
    HRWinEraseRectangle(pow_drawContext.hrLibRefNum,&shipRect,0);
  }

  DrawBitmapInWin(famShips,0,0);

  if (GameStatus.numships<4) {
    RctSetRectangle(&r,
      GameStatus.numships*10+(GameStatus.numships>0?4:0),
      0,
      100,
      20);
    WinEraseRectangle(&r,0);
  }

  WinSetDrawWindow(drawWinH);
  WinPopDrawState();
}

I've taken a look at the source code in the 4.0 ROMS for
WinPushDrawState, but can't see what might be causing this sort of
thing.

If I use the debugger, and single-step up to the trap that calls
WinPushDrawState, there are no registers with an address of 0x80000020,
and upon looking at the code for WinPushDrawState, I don't see where
this might have happened.

Is there a way I might look at my System's Global varibles? 
Specifically the global graphics state "GState"?

-Ken


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


------------------------------------------

The information in this transmittal and any attachments is privileged and confidential 
and is intended only for the recipient(s) listed above. You are hereby notified that 
any unauthorized distribution or copying of this transmittal or its attachments is 
prohibited. If you have received this transmittal in error, please notify Invivodata 
immediately at (831) 438-9550.

------------------------------------------


--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to