Hello everybody,
I made a custom control and want it to be displayed in a custom dialog, but after showing this dialog (calling ExecuteLD) custom control was not displayed in the screen. I have tried and found that without this dialog my custom control can be correctly shown to screen using AppUi()->AddToStackL( *this, iList );
Please see following code snippet and give me some suggestion, thanks.
Code:class CSettingListDialog : public CAknDialog { public: static CSettingListDialog* NewL(TInt aResourceId, CSettingData* aData, MSettingObserver* aObs) { CSettingListDialog* self = new (ELeave) CSettingListDialog(aResourceId, aObs); CleanupStack::PushL(self); self->ConstructL(aData); CleanupStack::Pop(self); return self; } ~CSettingListDialog() { delete iSettingData; iSettingData = NULL; } TInt RunDlgLD() { return CAknDialog::ExecuteLD(R_SETTING_LIST_DIALOG); } void SizeChanged() { // Update screen iList->SetExtent(Position(),Size()); DrawNow(); } private: void PreLayoutDynInitL() { } void PostLayoutDynInitL() { } CSettingListDialog(TInt aResourceId, MSettingObserver* aObs) : iResourceId(aResourceId), iSettingObs(aObs) { } void ConstructL(CSettingData* aData) { iSettingData = aData->CloneL(); } SEikControlInfo CreateCustomControlL(TInt aControlType) { SEikControlInfo controlInfo; controlInfo.iControl = NULL ; controlInfo.iTrailerTextId = 0 ; controlInfo.iFlags = 0 ; iList = new (ELeave) CSettingListControl(this); iList->SetSettingObserverL(iSettingObs); iList->InitSettingList(iSettingData); switch (aControlType) { case KAknCtLastControlId: { controlInfo.iControl = iList; break; } default: return CEikDialog::CreateCustomControlL(aControlType); break; } return controlInfo; } private: TInt iResourceId; MSettingObserver* iSettingObs; CSettingData* iSettingData; CSettingListControl* iList; };Code:CSettingListControl::CSettingListControl(CCoeControl* aParent) : iParent(aParent) { } CSettingListControl::~CSettingListControl() { // release } void CSettingListControl::ConstructFromResourceL(TResourceReader& aReader) { if (iParent) { SetContainerWindowL(*iParent); } else { CreateWindowL(); } iHighlightItem = 0; iFirstItemInView = 0; iHighlightOption = 0; iSettingList = CSettingList::NewL(); TPtrC title = aReader.ReadTPtrC(); // LTEXT title iSettingList->SetTitleL(title); const TInt numberOfItems = aReader.ReadInt16(); iTotalItems = numberOfItems; // read resource from reader // read resource from reader // read resource from reader CreateSettingDataL(NULL); CreatePicturesL(); CreateScrollBarL(); ActivateL(); } void CSettingListControl::SetSettingObserverL(MSettingObserver* aObs) { iSettingObs = aObs; } void CSettingListControl::InitSettingList(CSettingData* aSettingData) { if (aSettingData) { delete iSettingData; iSettingData = NULL; iSettingData = aSettingData->CloneL(); } } void CSettingListControl::CreateSettingDataL(CSettingData* aData) { if (aData) { iSettingData = aData->CloneL(); } else { iSettingData = CSettingData::NewL(); } } void CSettingListControl::CreatePicturesL() { _LIT(KPicurePath,"\\resource\\apps\\TomMail.mbm"); iArrow = iEikonEnv->CreateBitmapL(KPicurePath,EMbmTommailArrow); iArrow_mask = iEikonEnv->CreateBitmapL(KPicurePath,EMbmTommailArrow_mask); // create more pictures like the above code } void CSettingListControl::CreateScrollBarL() { iScrollBarFrame = new ( ELeave ) CEikScrollBarFrame( this, NULL ); iScrollBarFrame->CreateDoubleSpanScrollBarsL( ETrue, EFalse ); iScrollBarFrame->SetTypeOfVScrollBar( CEikScrollBarFrame::EDoubleSpan ); iScrollBarFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn ); } void CSettingListControl::Draw(const TRect& aRect) const { CWindowGc& gc = SystemGc(); TRect rect = Rect(); gc.SetBrushColor(KRgbBlue); gc.SetBrushStyle(CWindowGc::ESolidBrush); gc.DrawRect(rect); gc.DiscardBrushPattern(); gc.Clear(rect); TRect clientRect = rect; const TInt cellHeight = rect.Height() / CELLNUM; // draw someting here, // too many code here I have to remove them away or this furum won't let me post } void CSettingListControl::SizeChanged() { DrawNow(); } void CSettingListControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) { CCoeControl::HandlePointerEventL(aPointerEvent); } TKeyResponse CSettingListControl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) { if (aType != EEventKey) return EKeyWasNotConsumed; // do something here return response; }






