symbian s60 CAknSelectionListDialog继承子类的使用
2008-12-22 17:39
363 查看
MyListDlg.h文件
class CMyListDlg: public CAknSelectionListDialog
{
public:
CMyListDlg(TInt& aOpenedItem, MDesCArray* aArray, MEikCommandObserver* aCommand);
virtual ~CMyListDlg();
static CMyListDlg* NewL(TInt& aOpenedItem, MDesCArray* aArray, TInt aMenuBarResourceId, MEikCommandObserver *aCommand = 0);
static CMyListDlg* NewLC(TInt& aOpenedItem, MDesCArray* aArray, TInt aMenuBarResourceId, MEikCommandObserver *aCommand = 0);
void ConstructL(TInt aMenuBarResourceId);
public:
TInt itemIndex;
TInt GetItemIndex();
};
MyList.cpp文件
#include "MyListDlg.h"
CMyListDlg::CMyListDlg(TInt& aOpenedItem, MDesCArray* aArray, MEikCommandObserver* aCommand)
: CAknSelectionListDialog(aOpenedItem, aArray, aCommand)
{
}
CMyListDlg::~CMyListDlg()
{
}
CMyListDlg* CMyListDlg::NewLC(TInt& aOpenedItem, MDesCArray* aArray, TInt aMenuBarResourceId, MEikCommandObserver* aCommand)
{
CMyListDlg* self = new(ELeave) CMyListDlg(aOpenedItem, aArray,aCommand);
CleanupStack::PushL(self);
self->ConstructL(aMenuBarResourceId);
return self;
}
CMyListDlg* CMyListDlg::NewL(TInt& aOpenedItem, MDesCArray* aArray, TInt aMenuBarResourceId, MEikCommandObserver* aCommand)
{
CMyListDlg* self = NewLC(aOpenedItem, aArray, aMenuBarResourceId, aCommand);
CleanupStack::Pop();
return self;
}
void CMyListDlg::ConstructL(TInt aMenuBarResourceId)
{
CAknSelectionListDialog::ConstructL(aMenuBarResourceId);
}
TInt CMyListDlg::GetItemIndex()
{
CEikMenuPane *temppane(this->iMenuBar->MenuPane());
itemIndex=temppane->SelectedItem();
temppane = NULL;
return itemIndex;
}
调用
CMyListDlg *mListDlg = CInstantAlertListDlg::NewL(mOpenedItem, mSymbols, R_CARRYQUOTE_SYMBOL_LIST_MENUBAR,this); //this代表调用CMyListDlg的类,监听
mListDlg->ExecuteLD(R_CARRYQUOTE_SYMBOL_LIST);
void CThisDlg::ProcessCommandL(TInt aCommand) //用来监听处理自定义的Menu items
{
TInt iMenuItemIndex=0; //Menu items的序号,即使命令的ID是相同的,I序号ndex都是不同的
if(EAknCmdOpen==aCommand)
{
iMenuItemIndex=mListDlg->GetItemIndex();
}
}
class CMyListDlg: public CAknSelectionListDialog
{
public:
CMyListDlg(TInt& aOpenedItem, MDesCArray* aArray, MEikCommandObserver* aCommand);
virtual ~CMyListDlg();
static CMyListDlg* NewL(TInt& aOpenedItem, MDesCArray* aArray, TInt aMenuBarResourceId, MEikCommandObserver *aCommand = 0);
static CMyListDlg* NewLC(TInt& aOpenedItem, MDesCArray* aArray, TInt aMenuBarResourceId, MEikCommandObserver *aCommand = 0);
void ConstructL(TInt aMenuBarResourceId);
public:
TInt itemIndex;
TInt GetItemIndex();
};
MyList.cpp文件
#include "MyListDlg.h"
CMyListDlg::CMyListDlg(TInt& aOpenedItem, MDesCArray* aArray, MEikCommandObserver* aCommand)
: CAknSelectionListDialog(aOpenedItem, aArray, aCommand)
{
}
CMyListDlg::~CMyListDlg()
{
}
CMyListDlg* CMyListDlg::NewLC(TInt& aOpenedItem, MDesCArray* aArray, TInt aMenuBarResourceId, MEikCommandObserver* aCommand)
{
CMyListDlg* self = new(ELeave) CMyListDlg(aOpenedItem, aArray,aCommand);
CleanupStack::PushL(self);
self->ConstructL(aMenuBarResourceId);
return self;
}
CMyListDlg* CMyListDlg::NewL(TInt& aOpenedItem, MDesCArray* aArray, TInt aMenuBarResourceId, MEikCommandObserver* aCommand)
{
CMyListDlg* self = NewLC(aOpenedItem, aArray, aMenuBarResourceId, aCommand);
CleanupStack::Pop();
return self;
}
void CMyListDlg::ConstructL(TInt aMenuBarResourceId)
{
CAknSelectionListDialog::ConstructL(aMenuBarResourceId);
}
TInt CMyListDlg::GetItemIndex()
{
CEikMenuPane *temppane(this->iMenuBar->MenuPane());
itemIndex=temppane->SelectedItem();
temppane = NULL;
return itemIndex;
}
调用
CMyListDlg *mListDlg = CInstantAlertListDlg::NewL(mOpenedItem, mSymbols, R_CARRYQUOTE_SYMBOL_LIST_MENUBAR,this); //this代表调用CMyListDlg的类,监听
mListDlg->ExecuteLD(R_CARRYQUOTE_SYMBOL_LIST);
void CThisDlg::ProcessCommandL(TInt aCommand) //用来监听处理自定义的Menu items
{
TInt iMenuItemIndex=0; //Menu items的序号,即使命令的ID是相同的,I序号ndex都是不同的
if(EAknCmdOpen==aCommand)
{
iMenuItemIndex=mListDlg->GetItemIndex();
}
}
相关文章推荐
- S60自定义对话框(继承CAknDialog和CAknTextQueryDialog)
- S60自定义对话框(继承CAknDialog和CAknTextQueryDialog)
- S60自定义对话框(继承CAknDialog和CAknTextQueryDialog)
- Symbian CTimer类中继承子类使用说明
- Symbian S60开发,在SettingList中使用RadioButton的问题及解决方法。
- Symbian S60 PKG中Platform UID的使用
- 使用Carbide.vs与VS.NET2003构建Symbian开发平台-S60 平台(三)
- [Symbian] CAknSettingItemList使用心得(转)
- JAVA进阶 面向对象程序设计——第4章 继承与多态【不同访问属性使子类在使用这些成员时不同】
- 使用Carbide.vs与VS.NET2003构建Symbian开发平台-S60 平台(二)
- 关于在CAknMessageQueryDialog里显示中文的问题
- Fragment初学4——使用Fragment的子类ListFragment
- 继承自QWidget的子类如何直接使用QSS样式
- PHP - 继承 - 子类使用父类方法
- DialogFragment和ListFragment使用
- choosePackage(选择package的功能)(ElementListSelectionDialog对话框)
- JAVA学习(10) 继承(6) 使用父类类型调用子类
- 使用Carbide.vs与VS.NET2003构建Symbian开发平台-S60 平台(五)
- how to use the CAknwaitDialog
- Symbian CAknSettingItemList使用心得