您的位置:首页 > 其它

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();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: