symbian s60 CAknSelectionListDialog继承子类的使用

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();
 }
}

你可能感兴趣的:(list,null,Class,Symbian,menu)