×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    4

    Closing a CAknViewAppUi dialog

    Hi -

    I'm working on a Series 60 app which has been stable and working correctly for some time but now requires modification; I have to change the way one of its dialogs is handled. Currently I'm instantiating a CAknSelectionListDialog object in a method of a CAknViewAppUi-derived class to display some options. While the dialog is being displayed and if a phone call is received, or the red key is pressed, my app puts itself correctly in the background. Later when the application is, say, selected from the running apps list, it comes to the foreground still displaying the dialog. I now need it to close the dialog when put into the background.

    I can trap the red keypress in my implementation of HandleWsEventL() but can't get the dialog to terminate itself. Can anyone suggest a solution?

    Thanks in advance,

    Dan

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Bangalore,India
    Posts
    2,146

    Re: Closing a CAknViewAppUi dialog

    Welcome to the forum...

    Well the way to close the dialog is to force a call to the OkToExitL function of the dialog, and since that is a protected function u cant call it directly..however what u can do is to derive your dialog class from the CAknSelectionListDialog and then call the TryExitL on the dialog instance tht u have..which would force a call to the OkToExitL and then the dialog would be closed..

    So what u can do is when u have captured the red key..u close your dialog..and before that u save/cleanup whatever u want to..so that u dont leave anything unattended..:)

    Cheers
    mayank

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    4

    Re: Closing a CAknViewAppUi dialog

    Thanks - I'll give that a try.

    Dan

  4. #4
    Registered User
    Join Date
    Aug 2007
    Posts
    4

    Re: Closing a CAknViewAppUi dialog

    Hi Mayank -

    I've tried as you suggested by adding creating a class derived from CAknSelectionListDialog but now get a KERN_EXEC 3 at the point of closing the dialog. The appropriate sections of my code are -


    //////////////////////////////////////////
    CConfigAppUi is a CAknViewAppUi-derived class


    void CConfigAppUi::ShowConfigurationDialogL()
    {
    // Create an array to hold the command IDs corresponding to the list items
    RArray<TInt> commandArray;
    CleanupClosePushL(commandArray);

    // Create an array to hold the text for the currently applicable list items
    CDesCArrayFlat* listArray = new (ELeave) CDesCArrayFlat(8);
    CleanupStack::PushL(listArray);

    /*
    .
    .
    Menu items loaded into listArray and array of commands built
    .
    .
    */

    // Construct and prepare the dialog
    TInt selectedItem = 0;
    iConfigurationDialog = CConfigurationDialog::NewL(selectedItem, listArray, 0);
    iConfigurationDialog->PrepareLC(R_CONFIG_DIALOG);

    /*
    .
    .
    Icon items items added
    .
    .
    */

    // Execute the dialog
    TInt result = iConfigurationDialog->RunLD();

    // Check the result and (if not cancelled) which item was selected
    if (result)
    {
    // Work out which command the selected item corresponds to
    TInt commandId = iCommandArray[selectedItem];
    switch (commandId)
    {
    /*
    .
    . Appropriate sub-menu is selected
    .
    .
    */
    }
    }
    else
    {
    /*
    .
    . Flag dialog end
    .
    .
    */
    }

    // Clean-up the command array
    CleanupStack::PopAndDestroy(); // commandArray
    }

    void CConfigAppUi::HandleWsEventL(const TWsEvent &aEvent, CCoeControl *aDestination)
    {
    switch (aEvent.Type())
    {
    case KAknUidValueEndKeyCloseEvent:
    {
    // Close the dialog
    if(iConfigurationDialog)
    {
    iConfigurationDialog->OwnTryExitL(EEikBidOk);
    delete iConfigurationDialog;
    iConfigurationDialog = NULL;
    /*
    .
    . Flag dialog end
    .
    .
    */
    }
    break;
    }
    default:
    {
    // Pass on to default handler
    CAknViewAppUi::HandleWsEventL(aEvent, aDestination);
    break;
    }
    }
    }

    //////////////////////////////////////////
    CConfigurationDialog is a CAknSelectionListDialog-derived class

    CConfigurationDialog::CConfigurationDialog(TInt& aOpenedItem, MDesCArray* aArray, MEikCommandObserver* aCommand)
    : CAknSelectionListDialog(aOpenedItem, aArray, aCommand)
    {
    }

    CConfigurationDialog::~CConfigurationDialog()
    {
    }

    CConfigurationDialog* CConfigurationDialog::NewLC(TInt& aOpenedItem, MDesCArray* aArray, TInt aMenuBarResourceId, MEikCommandObserver* aCommand)
    {
    CConfigurationDialog* self = new (ELeave) CConfigurationDialog(aOpenedItem, aArray, aCommand);
    CleanupStack::PushL(self);
    self->ConstructL();
    return(self);
    }

    CConfigurationDialog* CConfigurationDialog::NewL(TInt& aOpenedItem, MDesCArray* aArray, TInt aMenuBarResourceId, MEikCommandObserver* aCommand)
    {
    CConfigurationDialog* self = CConfigurationDialog::NewLC(aOpenedItem, aArray, aMenuBarResourceId, aCommand);
    CleanupStack::Pop(self);
    return(self);
    }

    void CConfigurationDialog::ConstructL()
    {
    }

    void CConfigurationDialog::ProcessCommandL(TInt aCommandId)
    {
    CAknDialog::ProcessCommandL(aCommandId);
    }

    TBool CConfigurationDialog::OkToExitL(TInt aButtonId)
    {
    TBool result = CAknDialog::OkToExitL(aButtonId);
    return(result);
    }

    TKeyResponse CConfigurationDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
    {
    TKeyResponse result = CAknSelectionListDialog::OfferKeyEventL(aKeyEvent, aType);
    return(result);
    }

    void CConfigurationDialog::OwnTryExitL(TInt aButtonId)
    {
    TryExitL(aButtonId);
    }

    The error seems to occur at "delete iConfigurationDialog;" in HandleWsEventL().

    It's probably blindingly obvious what the problem is but I havn't done much work on series 60 front ends before, prefering to work on the back-end stuff, but have "inherited" that side of the work from a now ex-colleague.

    Thanks in advance for any help,

    Dan

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    13

    Re: Closing a CAknViewAppUi dialog

    Since you are calling a RunLD() on the dialog the dialog object gets destroyed automatically at the end of the OwnTryExitL() which in turn is calling OkToExitL().Hence the delete is not required.
    So i suppose calling a delete on it again might be the reason for
    the Kern-Exec 3.

  6. #6
    Registered User
    Join Date
    Aug 2007
    Posts
    4

    Re: Closing a CAknViewAppUi dialog

    Hi - got dragged off this project onto something else but I'm back on it now. I've done as karthikn suggested (thanks), but now have the problem identical to that outlined by fsiegel in their query "Derive from CAknSelectionListDialog?"

    Does anyone know a solution to this?

    Thanks in advance again

    Dan

Similar Threads

  1. [announce] wait dialog wrapper 0.2
    By lfd in forum Symbian
    Replies: 10
    Last Post: 2008-03-21, 11:03
  2. closing Form dialog without exit_key_handler
    By vipul.mobiance in forum Symbian
    Replies: 1
    Last Post: 2005-12-21, 13:34
  3. unmodal dialog...
    By GeKI in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-10-24, 12:02
  4. Closing a dialog after HandleListBoxEventL
    By Hude in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-06-02, 07:29
  5. Wait dialog vs. Global note - problems...
    By bjorn.rudolfsson in forum Symbian
    Replies: 0
    Last Post: 2003-06-25, 15:40

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •