×

Discussion Board

Results 1 to 10 of 10

Threaded View

  1. #1
    Regular Contributor
    Join Date
    May 2008
    Posts
    73

    Question Custom control doesn't display in a custom dialog

    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;
    	}
    Last edited by curiouswalker; 2010-07-13 at 10:47.

Similar Threads

  1. Replies: 0
    Last Post: 2010-04-29, 16:13
  2. (Please Help Me)Custom control In a Dialog
    By praveen.nitdgp@gmail.com in forum Symbian User Interface
    Replies: 0
    Last Post: 2008-02-20, 06:12
  3. Custom Control in a Dialog
    By wernerkriel in forum Symbian User Interface
    Replies: 7
    Last Post: 2007-11-12, 15:37
  4. Replies: 1
    Last Post: 2006-06-26, 07:14
  5. yucca help, question about custom control in dialog
    By mobileworm in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-10-05, 17:23

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×