Anyone have any idea how to alleviate the hard coded "OK" string below?  This is 
obviously not internationalizable.

I have looked in the system headers for NetLib resources but cannot find any; as I 
mentionned earlier FrmGlueGetDefaultButtonID does not appear to be working for me.

-- Andr�

-----Original Message-----
From: Chris Faherty [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 23, 2003 5:59 PM
To: Palm Developer Forum
Subject: Re: Dismiss NetLibOpen modal dialog(s)


On Friday 23 May 2003 08:40 pm, Andre Schoorl wrote:

> My thought was to schedule an alarm before calling NetLibOpen (with an 
> interval greater than the NetLib timeout) and - provided NetLibOpen 
> hasn't succeeded - have it simulate pressing the default button in any 
> possible error dialogs (e.g., "PPP Timeout"):
>
>     FormPtr frmP = FrmGetActiveForm();
>     UInt16 defaultButton = FrmGlueGetDefaultButtonID(frmP);
>     ControlType* ctl = (ControlType*)FrmGetObjectPtr( frmP, 
> FrmGetObjectIndex( frmP, defaultButton ) ); CtlHitControl(ctl);

That's pretty much what I do.  Except I test every 2 seconds for the dialog 
while the NetLibOpen() is active.

    /*
     * This alarm is used to click-through any stupid dialogs that
     * stay on the screen waiting for "OK".
     */
    hit_ok_dialog();
    SetTimeOfNextAlarm(TimGetSeconds()+2, 1, 0);
    err = NetLibOpen(AppNetRefnum, &ifErrs);
    /* turn off my auto-OK timer */
    SetTimeOfNextAlarm(0, 1, 0);

void hit_ok_dialog(void)
{
    FormPtr frm;
    ControlPtr ptr;
    Word numobj;
    short i1;
    CharPtr lab;

    /*
     * I use this to click-through those annoying network
     * dialogs.
     */
    frm = FrmGetActiveForm();
    lab = (CharPtr)FrmGetTitle(frm);
    if (lab &&
        (StrCaselessCompare("Service Connection Progress", lab) == 0)) {
        numobj = FrmGetNumberOfObjects(frm);
        for (i1=0; i1 < numobj; i1++) {
            ptr = FrmGetObjectPtr(frm, i1);
            if ((ptr->attr.enabled) && (ptr->style == buttonCtl)) {
                lab = (CharPtr)CtlGetLabel(ptr);
                if (lab && (StrCaselessCompare("OK", lab) == 0)) {
                    CtlHitControl(ptr);
                }
            }
        }
    }
}

void AlarmTriggered(SysAlarmTriggeredParamType * cmdPBP)
{
    switch (cmdPBP->ref) {
    case 1:
        hit_ok_dialog();
        cmdPBP->purgeAlarm = true; /* don't sysAppLaunchCmdDisplayAlarm */
        /* make another try in 2 seconds */
        SetTimeOfNextAlarm(TimGetSeconds()+2, 1, 0);
        break;
    }
}

-- 
/* Chris Faherty <[EMAIL PROTECTED]> */

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


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

Reply via email to