Hi,

I'm new in palm programming. When I tried to run my program use POSE
I got this error:
medIn(1.0)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.

what my program does: create a database, populate with data and display the 
data to a form.

Any help will be greatly appreciated.

-paul

The following are my codes:
-----------------------------------------------------------------

static void InitializePassword(void)
{
    User u1 = {1,"Joe","palm1"};
    User *users[1];
    UInt16 numUser = sizeof(users)/sizeof(users[0]);
    UInt16 i;
    users[0] = &u1;
    for(i=0;i<numUser;i++){
      UInt16 index = dmMaxRecordIndex;
      MemHandle h = DmNewRecord(loginDB,&index,DBSize);
      if(h){
        PackUser(users[i],h);
        DmReleaseRecord(loginDB,index,true);
      }
    }
}

/* The main entry point */
UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
    Err error;
    Err err = 0;
    UInt16 pass= 123;

    error = RomVersionCompatible (ourMinVersion, launchFlags);
    if (error) return (error);

    if(((error = DmCreateDatabase(0,"logDB",'LOGB','lodb',false))!
        =dmErrAlreadyExists)&&(error!=0))
        {
          FrmAlert(DBCreationErrorAlert);
          return(0);
        }

        loginDB = DmOpenDatabaseByTypeCreator
                 ('lodb','LOGB',dmModeReadWrite);
        numRecords = DmNumRecords(loginDB);

        if( numRecords == 0 )
        {
            InitializePassword();
        }

        showDB(numRecords);
        switch (cmd)
        {
                case sysAppLaunchCmdNormalLaunch:
                case sysAppLaunchCmdURLParams:
                           GoToURL("file:mainA.pqa");
                default:
                        break;
        }

        DmCloseDatabase(loginDB);
       return( 0 );
}

static void showDB(UInt16 numRecords)
{
  FormPtr form;
  User usr;
  EventType event;
  UInt16        attributes;
  FieldPtr      nameField;
  FieldPtr      passwordField;
  UInt16        offset = OffsetOf(PackedUser, name);
  MemHandle     userHandle = DmGetRecord(loginDB, numRecords);
  DmRecordInfo(loginDB, numRecords, &attributes, NULL, NULL);

  genflag1 = 0;

  form = FrmInitForm(DisplayForm);
  FrmSetEventHandler(form, displayEvent);
  FrmSetActiveForm(form);

  UnpackUser(&usr, MemHandleLock(userHandle));
  nameField = GetObjectFromActiveForm(DisplayNameField);
  passwordField = GetObjectFromActiveForm(DisplayPasswordField);

  SetFieldTextFromStr(DisplayNameField,(Char*)usr.name);
  SetFieldTextFromStr(DisplayPasswordField,(Char*)usr.password);

  FrmDrawForm(form);

  do
  {
        EvtGetEvent(&event, -1);
        if ( SysHandleEvent(&event) )
                continue;
        FrmDispatchEvent( &event );
   }while( event.eType != appStopEvent && genflag1 == 0 );

  MemHandleUnlock(userHandle);
  DmReleaseResource(userHandle);
  return;
}

static Boolean displayEvent( EventType* event)
{
        if (event->eType ==  ctlSelectEvent )
                genflag1 = 1;

        return (false); // done
}



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


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

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


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