×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    10

    How to get an view object ref or pointer from container obj

    Hi!

    Could I get a pointer or a reference to the view object from container(CCoeControl derived object)? I need to do it in an api terms. I found MObjectProvider(MopSupplyObject(...)) could be usefull. Have anybody used this technique? Are there any other ways?

  2. #2
    Super Contributor
    Join Date
    Jun 2006
    Location
    Moscow, Russia
    Posts
    803

    Re: How to get an view object ref or pointer from container obj

    So, there is a container class derived from CCoeControl which has CCoeControl derived objects. You need to get access to these objects. Do I understand your question correctly?
    If I do, than you can do it the following way:
    1) S60 3rd Ed: you can get a reference to component array using CCoeControl::Components() and than get the control you need. For example:
    Code:
    CCoeControl* ctrl = Components().At(iCtrlId).iControl;
    2) Pre-3rd Ed: it also can be done via CCoeControl::ComponentControl().

    But to use both of the described methods you need to know the ID of the control you need...
    Regards,
    ivey

  3. #3
    Registered User
    Join Date
    Aug 2005
    Posts
    10

    Re: How to get an view object ref or pointer from container obj

    Actually no. The situation is as follows:
    I have a view based application. Every view got one composit control(container) that holds other controls(container acts like controls provider). So I need to get access to that view which this container belongs to using no own code(I mean I don't want to provide container with extra methods to add view pointer or modifing constructor for the same reason).
    Here is the code:
    void CMyView:oActivateL(...)
    {
    if (!iContainer)
    {
    iContainer = new (ELeave) CMyContainer;
    iContainer->SetMopParent(this);
    iContainer->ConstructL( ClientRect() );
    AppUi()->AddToStackL( *this, iContainer );
    }
    }

    I hope this time I've described problem clearly =)
    Last edited by Komarov Dmitriy; 2006-10-20 at 14:45.

  4. #4
    Super Contributor
    Join Date
    Jun 2006
    Location
    Moscow, Russia
    Posts
    803

    Re: How to get an view object ref or pointer from container obj

    OK, now I understand what you need. You can do it as follows:
    Code:
    CMyAppUi* appUi = (CMyAppUi*)iEikonEnv->AppUi();
    CMyView* view = (CMyView*)appUi->View(KMyViewId);
    Here I assume that your CMyAppUi is inherited from CAknViewAppUi and CMyView is inherited from CAknView.
    Regards,
    ivey

  5. #5
    Registered User
    Join Date
    Aug 2005
    Posts
    10

    Re: How to get an view object ref or pointer from container obj

    Thanks! That is definitely should work.

  6. #6
    Regular Contributor
    Join Date
    Dec 2006
    Posts
    94

    Re: How to get an view object ref or pointer from container obj

    Hi Ivey,

    When I implemented the code
    PHP Code:
    CMyViewview = (CMyView*)appUi->View(KMyViewId); 
    I got the error appUI is a undefined identifier.

    Where and how should I define it?

    Regards,
    NN
    Last edited by netra; 2008-03-17 at 07:24.
    --------------------------------------------------------------
    To know what-to-do is more important than to know how-to-do !
    --------------------------------------------------------------

  7. #7
    Regular Contributor
    Join Date
    Dec 2006
    Posts
    94

    Re: How to get an view object ref or pointer from container obj

    Sorry for a stupid mistake ..I have defined it as AppUI.but now I m getting

    error: illegal use of incomplete struct/union/class 'CAknViewAppUi'

    What may be the reason ?
    Thanks..
    Last edited by netra; 2008-03-17 at 07:25.
    --------------------------------------------------------------
    To know what-to-do is more important than to know how-to-do !
    --------------------------------------------------------------

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,737

    Re: How to get an view object ref or pointer from container obj

    This message appears when you try to use a class with a mere forward-declaration. So #include the header file.

Similar Threads

  1. View vs. Container
    By mikea1 in forum Symbian
    Replies: 5
    Last Post: 2006-01-12, 09:06
  2. Switching from container to another view
    By mohit2201 in forum Symbian
    Replies: 1
    Last Post: 2005-12-03, 09:12
  3. is it possible to create&draw CCoeContol object outside of any view?
    By donDonald in forum Symbian User Interface
    Replies: 3
    Last Post: 2005-09-26, 06:23
  4. Activating View in Container
    By mmfcassius in forum Symbian
    Replies: 4
    Last Post: 2004-10-26, 11:51
  5. About the pointer between view and container
    By mingkit in forum Symbian
    Replies: 2
    Last Post: 2003-08-24, 09:22

Posting Permissions

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