首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Symbian >> 用户界面 >> 正文
在消息对话框中创建链接
作者:Lee 译    文章来源:Nokia    更新时间:2007-4-17 9:48:44
今天翻译一篇Forum Nokia Blogs上的文章。

这篇文章使用CAknMessageQueryDialog 来创建突出的链接。通过它你可以相当简单在你的文字中的提供一个“更多”链接。同样这种技术也可以在许可对话框中使用。

当用户将光标移动到上面并选择它的时候,我们可以为每个需要链接的字符串提供一个回调函数。
Dialog with Link 
注意:工厂函数貌似被破坏,字符串参数是const TDesC&,但它已经被替换成TDesC&,这意味着当使用NewL的时候需要使用LIT

那么我们要作的第一件事情是构造消息对话框。为了简单起见,我们使用了默认的资源。

让我们来设置字符串: 我们将用资源和 StringLoader
 
CODE:
_LIT(KHeader, "Example Link Box");
_LIT(KLink1, "Link 1");
_LIT(KLink2, "Link 2");
_LIT(KMessageboxText, "Click here for Link 1\nhere for Link 2");

//Now we can setup the bits of the message box - NB note the cast in the NewL

void ShowLinkedMessageBox()
  {
  CAknMessageQueryDialog* dialog = CAknMessageQueryDialog::NewL(CONST_CAST(TDesC&, KMessageboxText()));
  CleanupStack::PushL(dialog);
  dialog->SetHeaderText(KHeader);

  // Now setup the text that will be linked and the action to be performed when they are selected.
  TCallBack callback1(CallbackText1);
  dialog->SetLink(callback1);
  dialog->SetLinkTextL(KLink1);

  TCallBack callback2(CallbackText2);
  dialog->SetLink(callback2);
  dialog->SetLinkTextL(KLink2);

  // Finally as its now leave-safe pop the dialog and run it
  CleanupStack::Pop(dialog);
  dialog->ExecuteLD(R_AVKON_MESSAGE_QUERY_DIALOG);
  }

这里有两个回调函数:
 
CODE:
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;
    }

是不是非常简单的实现了一个很酷的效果?

作者邮箱:paul@toddsoftware.com

源代码下载

译文出处:http://www.symbianx.cn/viewthread.php?tid=72&extra=page%3D1
相关文章:
MMI of UIQ (一)
Series 60应用程序开发[问题一] ERROR:failed to find version information for link.exe
symbian系统结构介绍
防止资源文件列表中出现保留的ID
深度探索C++对象模型(3)
上下文相关帮助本地化方案 (下)
解决运行makmake,abld时出现 LINK 错误
数据结构学习之排序
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号