×

Discussion Board

Results 1 to 10 of 10
  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.

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

    Re: Custom control doesn't display in a custom dialog

    From this post (http://discussion.forum.nokia.com/fo...ontrol-problem), I know as a child control of dialog it has to be window owning, but this will bring a new problem, the custom control displays from top left of the phone screen, other than from top-left point of the client rectangle, and no matter what I do to try to move this control into client rectangle, it just keeps still, and fills the whole screen.

    see following picture,
    Last edited by curiouswalker; 2010-07-13 at 11:14.

  3. #3
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Custom control doesn't display in a custom dialog

    Quote Originally Posted by curiouswalker View Post
    see following picture,
    can you put the iamge some where else might be a picasa or ovi i am not able to use / open the rapidshare link

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

    Re: Custom control doesn't display in a custom dialog

    upload the snapshot to ovi, please see following link,


  5. #5
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Custom control doesn't display in a custom dialog

    Quote Originally Posted by curiouswalker View Post
    upload the snapshot to ovi, please see following link,

    still can't access this.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: Custom control doesn't display in a custom dialog

    I do not know the answer, but I can see all the image.
    There is a ClientRect-sized blue rectangle, but positioned in the top-left corner of the screen (instead its normal position in the "middle"). Below it there is a white area (unused space probably) of the size of the Status Pane, and finally the Control Pane in its normal location, with two softkeys.

  7. #7
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Custom control doesn't display in a custom dialog

    poor me i can't see the images.

    If that is the case might you have to control the client rect properly. try logging to find out what is the actual value.

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

    Re: Custom control doesn't display in a custom dialog

    Quote Originally Posted by wizard_hu_ View Post
    I do not know the answer, but I can see all the image.
    There is a ClientRect-sized blue rectangle, but positioned in the top-left corner of the screen (instead its normal position in the "middle"). Below it there is a white area (unused space probably) of the size of the Status Pane, and finally the Control Pane in its normal location, with two softkeys.
    It is a custom dialog which has flag EEikDialogFlagFillAppClientRect, and this dialog contains a custom control which draws a blue rectangle in the application client rectangle. All these are supposed to be shown bellow the appliction status pane, following are the related code:

    Code:
    RESOURCE DIALOG r_setting_list_dialog
        {
        flags = EEikDialogFlagFillAppClientRect;
        buttons = R_AVKON_SOFTKEYS_OK_BACK;
        items =
            {
            DLG_LINE
                {
                id = ESettingListControl;
                type = KAknCtLastControlId;
                control = SETTING_ITEM_LIST
                	{
                	title = qtn_setting;
                	items = 
                		{
                		SETTING_ITEM
                			{
                			identifier = ESettingItemAccessPoint;
                		    name = qtn_settings_iap;
                		    options =
                		    	{
                		    	SETTING_ITEM_OPTION
                		            {
                		            value = ECMNET;
                		            text = qtn_settings_cmnet;
                		            },
                		        SETTING_ITEM_OPTION
                		            {
                		            value = EGPRS;
                		            text = qtn_settings_gprs;
                		            },
                				SETTING_ITEM_OPTION
                					{
                					value = EAuto;
                					text = qtn_settings_auto;
                					}		            
                		         	};
                			},
                   };
                }
            };
        }
    
    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);
           }

  9. #9
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Custom control doesn't display in a custom dialog

    what i wanted to say is put the rect for dialog properly in PostLayoutDynInitL()

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

    Re: Custom control doesn't display in a custom dialog

    Quote Originally Posted by skumar_rao View Post
    what i wanted to say is put the rect for dialog properly in PostLayoutDynInitL()
    This works, thank you so much. It seems dialog has to set the rectanles for all its child controls.

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
  •  
×