×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    5

    Add a control (e.g. button) programmatically

    Hi,

    yeah its me again, i know this sucks but please help

    i want to add a button programmatically to my view. i do this for example in the HandleCommandL() method is with this code:

    Code:
    //ETestButtonCtrl is a button that is defined in the resource file
    CEikTextButton* button = LocateControlByUniqueHandle<CEikTextButton>(ETestButtonCtrl);
    
    //now i want to add a button to the parent of ETestButtonCtrl
    MCoeLayoutManager* l = button->LayoutManager();
    
    //i create my button and add it to container control
    CEikTextButton* b = new CEikTextButton();
    this->AddControlLC(b,ETestButtonCtrl2);
    l->AttachL(*b);
    
    //set needed stuff and format
    b->SetUniqueHandle(ETestButtonCtrl2);
    
    _LIT(buttonText,"Click My Button");
    b->SetTextL(buttonText,CEikTextButton::EFirst);
    b->SetPosition(TPoint(50,50));
    b->SetSize(TSize(100,30));
    
    b->SetParent(button->Parent());
    b->MakeVisible(ETrue);
    b->SetContainerWindowL(*button->Parent());
    
    //now draw it
    b->DrawNow();
    The problem is that the button is not displayed after this code is executed (note theres not panic code so the code should be ok from my perspective). Can anyone please tell me why the button is not displayed? I'm pretty sure i forgot something.

    Thx in advance for helping.
    Last edited by ViRuSTriNiTy; 2008-01-02 at 21:06.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: Add a control (e.g. button) programmatically

    The methods LocateControlByUniqueHandle, AddControlLC, etc. do not exist on S60 (they are UIQ-specific I think, Avkon Views work in a different way with a lower level support), so they will not sound familiar to most developers here.
    Normally you can get usable (for UIQ too) answers to generic Symbian-related questions here, but UIQ-only features are better discussed on developer.uiq.com.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    5

    Re: Add a control (e.g. button) programmatically

    yeah thats right but the dev.uiq was offline yesterday so i thought "ok its basic stuff, those s60 people can answer this too" ;)

    ok, i posted this question in dev.uiq, lets see if somebody can help.

    thx.

    :edit:
    i think the problem is a refresh that is missing. if i use this code in ViewConstructL of my view it adds the button and button is rendered correctly.

    now the question is: how can i refresh the layout manager? i cannt find a way to retrieve a reference to the current used layout manager, theres only a SetLayoutManagerL() function but no Get...().

    thx for helping.
    Last edited by ViRuSTriNiTy; 2008-01-02 at 21:47.

Similar Threads

  1. Multi Page Dialog
    By amitaggarwal in forum Symbian
    Replies: 6
    Last Post: 2008-04-18, 09:53
  2. RFCOMM flow control questions
    By kuusitalo in forum Bluetooth Technology
    Replies: 0
    Last Post: 2004-08-10, 08:57
  3. ActivateL() vs DrawNow()
    By tommylkc in forum Symbian User Interface
    Replies: 2
    Last Post: 2003-11-07, 11:08
  4. aliasing with the Nokia 30 (User Control Mode)
    By seamusdillon in forum Nokia M2M
    Replies: 9
    Last Post: 2003-07-02, 06:02
  5. D211
    By arleth in forum Multimodecards
    Replies: 7
    Last Post: 1970-01-01, 02:00

Posting Permissions

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