Here's some code:
on "Sync" button handler : {
 Err error;

 // HotSync database ID
 LocalID ID = DmFindDatabase(0, "HotSync");

 if(ID!=0){
 // switch. to HotSync
  error = SysUIAppSwitch(0, ID, sysAppLaunchCmdNormalLaunch, 0);
  if(!error) {
   UInt16 cardNoP;
   LocalID dbIDP;

   // get ID and cardNo for the current app
   // return SysErrParamErr if any error occured
   error = SysCurAppDatabase (&cardNoP,&dbIDP);

   if(!error) {

    // set an alarm to tell the application it should be launched after hot
sync occures
    // return almErrMemory if insufficient memory or almErrFull
    error = AlmSetAlarm (cardNoP, dbIDP, cmdAlarmAfterHotSync,
TimGetSeconds(), true);
   }
  }
 } else {
  // database not found
  error = DmGetLastErr ();
 }

 return error;
}

inside InitInstance( ... )  function :

// some staff ....

case sysAppLaunchCmdDisplayAlarm :

  // check what type of alert was received
  switch (((SysDisplayAlarmParamType*)m_pCommandPBP)->ref) {

    // some staff ....
   case cmdAlarmAfterHotSync: // HotSync was started
    LocalID ID = DmFindDatabase(cardNoP, "HotSync");

    if(ID == 0) {
     // database not found
     error = DmGetLastErr();
    }

    // try to open HotSync database
    DmOpenRef dtref = DmOpenDatabase (cardNoP,ID, dmModeWrite);
    unsigned short openCountP;

    if(dtref != 0){
     // get the database open count
     // Returns 0 if no error, or dmErrInvalidParam if an invalid parameter
was passed.
     error = DmOpenDatabaseInfo (dtref, &ID, &openCountP, NULL, NULL, NULL);
     DmCloseDatabase(dtref);
    }

    // if the database was not open or there is only one application that
has it open (InfoPack.)
    // then HotSync has already exit
    if((dtref == 0)||(openCountP <= 1)){

     // go back to the caller
     error = SysUIAppSwitch(cardNoP, dbIDP, sysAppLaunchCmdNormalLaunch, 0);
    } else {
    // set alarm to wait for HotSync to exit
     error = AlmSetAlarm (cardNoP, dbIDP, cmdAlarmAfterHotSync,
TimGetSeconds(), true);
    }
    break;
    // other staff ...


"Avilla, Dane" <[EMAIL PROTECTED]> wrote in message
news:72928@palm-dev-forum...
>
> Would you post your solution to the list for future reference?  I'm
curious
> how you solved this problem.
>
> Thanks,
>
> -DGA
>
> > I've fixed my problem.
> > Thank everyone for assistance
>
>



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