Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

S60中为对话框添加菜单及响应命令的方法

From Wiki
Jump to: navigation, search
Article Metadata

文章
beover1984 在 29 Jul 2007 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

首先在RSS文件中建立菜单和对话框资源

RESOURCE MENU_BAR r_test_menu_bar
{
titles=
{
MENU_TITLE
{
txt = ""; // the text is not used in Series 60
menu_pane = r_test_menu_pane;
}
};
}
RESOURCE MENU_PANE r_test_menu_pane
{
items =
{
MENU_ITEM
{
command = ECmdMenuTest;
txt = TEST_TEXT;
}
};
}
 
RESOURCE DIALOG test_dialog
{
……
buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK;
……..
}


然后需要实现一个从CaknDialog派生的对话框类,并重写OkToExitL()和ProcessCommandL()函数用于显示菜单和命令响应.

TBool CTestDialog::OkToExitL(TInt aButtonId)
{
if ( aButtonId == EAknSoftkeyOptions ) // press options button
{
CAknDialog:DisplayMenuL(); // display the menu
}
else if ( aButtonId == EAknSoftkeyBack )
{
return ETrue;
}
 
return EFalse;
}
 
void CTestDialog::ProcessCommandL( TInt aCommandId )
{
switch ( aCommandId )
{
case EcmdMenuTest:
{
CAknInformationNote *note = new (ELeave) CAknInformationNote;
note->ExecuteLD( _L( "Test" ) );
}
break;
}
CAknDialog::HideMenu(); // hide the menu after commands finished
}
This page was last modified on 15 December 2011, at 06:25.
177 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.

×