×
Namespaces

Variants
Actions

Displaying links in a CAknMessageQueryDialog

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code ExampleArticle
Created: Paul.Todd (09 Sep 2008)
Last edited: hamishwillee (20 Jul 2012)
Reviewer Approved    Thumbs up icon sm.jpg

Contents

Overview

In a message box it is often preferable to use a hotlink to allow the user to learn about that topic. For example when installing applications, a link is used to provide more information on the certificate the file was signed with. This looks like a regular html link but clicking on it will display a new dialog box or perform some other action, depending on what the developer has chosen to do in the callback.


Hearders Required:

#include <aknmessagequerydialog.h> //CAknMessageQueryDialog
#include <aknnotewrappers.h> //CAknInformationNote

Library required:

LIBRARY avkon.lib  //CAknMessageQueryDialog
LIBRARY eikctl.lib eikcdlg.lib//CAknInformationNote

This code snippet shows how to provide the same functionality.

Source file

LOCAL_C TInt CallbackText1(TAny* /*aAny*/)
{
CAknInformationNote* msg = new (ELeave) CAknInformationNote(ETrue);
msg->ExecuteLD(_L("You clicked the first link"));
return EFalse;
}
 
LOCAL_C TInt CallbackText2(TAny* /*aAny*/)
{
CAknInformationNote* msg = new (ELeave) CAknInformationNote(ETrue);
msg->ExecuteLD(_L("You clicked the second link"));
return EFalse;
}
 
LOCAL_C void DisplayMessageBox()
{
_LIT(KHeader, "Example Link Box");
_LIT(KLink1, "Link 1");
_LIT(KLink2, "Link 2");
_LIT(KMessageboxText, "Click here for Link 1\nhere for Link 2");
__ASSERT_DEBUG(KMessageboxText().Find(KLink1) != KErrNotFound, User::Panic(_L("Link 1 missing"), 1));
__ASSERT_DEBUG(KMessageboxText().Find(KLink2) != KErrNotFound, User::Panic(_L("Link 2 missing"), 2));
 
CAknMessageQueryDialog* dialog = CAknMessageQueryDialog::NewL(CONST_CAST(TDesC&, KMessageboxText()));
CleanupStack::PushL(dialog);
 
dialog->SetHeaderText(KHeader);
 
TCallBack callback1(CallbackText1);
dialog->SetLink(callback1);
dialog->SetLinkTextL(KLink1);
 
TCallBack callback2(CallbackText2);
dialog->SetLink(callback2);
dialog->SetLinkTextL(KLink2);
 
CleanupStack::Pop(dialog);
dialog->ExecuteLD(R_AVKON_MESSAGE_QUERY_DIALOG);
}

Postconditions

The messagebox is displayed and the user can select links.

Supplementary material

This source provides a

  • You can test link handling code in a simple, executable application into which this code snippet has been patched. The application is available for download at: ExampleStub linked messagebox.zip
  • You can examine all the changes that are required to add message box links in an application. The changes are provided in the unified diff format: linked messagebox.diff.zip
  • For general information on applying the patch, see Using Diffs.
  • For unpatched stub applications, see Example stub.

Notes

If the link text provided is not found you will get USER 130 panic at runtime unless you are running a debug build and have used the __ASSERT_DEBUG method as showed above to spot those issues before showing your dialog.

See also

This page was last modified on 20 July 2012, at 09:09.
50 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×