×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    20

    How can i draw a Custom control to my container?

    The next is my main code in container. my problem is my control iGridControl can't be seen.
    void CGridProAppView::ConstructL(const TRect& /*aRect*/)
    {
    // Create a window for this application view
    CreateWindowL();

    InitComponentArrayL();
    iGraphicDeal=CGraphicDeal::NewL();
    TRect gridRect = TRect(TPoint(15, 90), TSize(210, 140));
    iGridControl=CGridControl::NewL(*this, gridRect, iBackBufferContext);
    iGridControl->MakeVisible(ETrue);

    Components().AppendLC(iGridControl);
    CleanupStack::Pop(iGridControl);
    // Set the windows size

    SetExtentToWholeScreen();
    // Activate the window, which makes it ready to be drawn
    ActivateL();
    }

    the next is my code in CGridControl Class

    void CGridControl::ConstructL(const TRect& aRect)
    {
    SetContainerWindowL(iParent);
    }

    void CGridControl:raw(const TRect& aRect) const
    {

    iContent->SetPenColor(KRgbBlack);

    DrawGridRect();

    }

    void CGridControl:rawGridRect() const
    {
    for(TInt i=0;i <6;i++)
    {
    if(i <3)
    {

    iContent->DrawRect(TRect(TPoint((15+i*70),90),TSize(70,70)));
    }
    if(2 <i <6)
    {
    iContent->DrawRect(TRect(TPoint((15+(i-3)*70),160),TSize(70,70)));
    }
    }

    }

  2. #2
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,348

    Re: How can i draw a Custom control to my container?

    Don't forget to set your control's position and size when container size changed. For example:
    Code:
    void C***::SizeChanged()
        {
        ...
        iGrid->SetExtent(TPoint(5,5),TSize(70, 70));
        ...
        }
    Also do not forget to implement CountComponentControls and ComponentControl functions. For example:
    Code:
    CCoeControl* C***::ComponentControl( TInt /*aIndex*/) const
    {
    	return iGrid;
    }
     
    TInt C***::CountComponentControls() const
    {	
    	if(iGrid)
    		return 1;
    	else
    		return 0;
    }
    Last edited by A.A.M.; 2009-02-14 at 09:28.

  3. #3
    Super Contributor
    Join Date
    Jul 2008
    Location
    Chennai,India
    Posts
    889

    Re: How can i draw a Custom control to my container?

    You can have a look into the following implementation

    http://www.symbian.com/developer/tec...ode.guide.html

    I think there is also a working app-build and u cud import the bld.inf file into the carbide..
    It's either in the SDK or Forum Nokia...

Similar Threads

  1. Custom control query
    By kumar_sai123 in forum Symbian User Interface
    Replies: 0
    Last Post: 2009-01-02, 13:16
  2. problem Kernel Exec 3 on adding CEikRichTextEditor in custom control
    By praveenp in forum Symbian User Interface
    Replies: 9
    Last Post: 2008-09-02, 09:22
  3. Skin background in custom control
    By template60 in forum Symbian User Interface
    Replies: 9
    Last Post: 2008-03-25, 11:47
  4. custom Control during orientation
    By nms_pnr in forum Symbian User Interface
    Replies: 0
    Last Post: 2007-07-24, 13:31
  5. Custom drawing control
    By doctordwarf in forum Symbian
    Replies: 1
    Last Post: 2003-09-21, 16:53

Posting Permissions

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