×
Namespaces

Variants
Actions
Revision as of 09:25, 15 December 2011 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

From Nokia Developer 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 09:25.
199 page views in the last 30 days.
×