×

Discussion Board

Results 1 to 7 of 7

Thread: Button Array

  1. #1
    Super Contributor
    Join Date
    Jun 2008
    Posts
    593

    Unhappy Button Array

    hi,
    i want to create a button array...
    i dont undertand how i shud initialize it...
    CAknButton* iButton[] = .....

    plz help!!!
    Nital Shah

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,752

    Re: Button Array

    This is not necessarily a good idea, empty brackets require an immediate initializer list, but in that case why would you call it a member variable, etc.
    Technically
    Code:
    CAknButton *iButton[] = {CAknButton::NewL(...),CAknButton::NewL(...),CAknButton::NewL(...)};
    may compile, but it doubtfully makes any sense.
    In Symbian C++ you would rather use pointer arrays anyway, like
    Code:
    RPointerArray<CAknButton> iButtons;
    or
    Code:
    CArrayPtr<CAknButton> *iButtons;
    and fill them later.

  3. #3
    Super Contributor
    Join Date
    Jun 2008
    Posts
    593

    Re: Button Array

    thanks for replying..

    i wud b knwing the number of buttons to b created at runtime....

    so i ll be initializing
    Code:
    CArrayPtr<CAknButton> *iButtons;
    in header

    den in InitializeControls,
    how will i inialize this array???
    like for icons in Listbox, v have :

    Code:
    CArrayPtr< CGulIcon >* icons = NULL;		
    	icons = new (ELeave) CAknIconArray( 1 );
    so how will it be for CAknButton??
    Nital Shah

  4. #4
    Super Contributor
    Join Date
    Jun 2008
    Posts
    593

    Smile Re: Button Array

    ok.. i got it...

    Code:
    CArrayPtrFlat<CAknButton> *iButton = new (ELeave) CArrayPtrFlat<CAknButton>(10);
    Nital Shah

  5. #5
    Super Contributor
    Join Date
    Jun 2008
    Posts
    593

    Unhappy Re: Button Array

    i did it this way.....

    Code:
    	int var = 10;
    	iButtonArray = new (ELeave) CArrayPtrFlat<CAknButton>(var);
    
    	for(int i = 0;i<9 ;i++)
    		{
    			CAknButton* iButton1 = static_cast< CAknButton* >
    							( EikControlFactory::CreateByTypeL( EAknCtButton ).iControl );
    			iButton1->ConstructFromResourceL ( R_BUTTON_IMAGE_DEMO2_CONTAINER_BUTTON1 );
    			
    			iButton1->SetContainerWindowL ( *this );
    			iButton1->SetRect ( TRect ( 
    										TPoint ( i+ 16, 19 ) , 
    										TSize ( 16, 16 ) )  
    										 ) ; 
    			iButton1->SetObserver( ( MCoeControlObserver* ) iCommandObserver ); 
    			iButtonArray->AppendL(iButton1);
    		
    		}
    but instead of getting multiple buttons in my view, i see only one button......
    i think this is bcz m using the same Button1..
    any option to this?????
    Nital Shah

  6. #6
    Super Contributor
    Join Date
    Jun 2008
    Posts
    593

    Re: Button Array

    i was making mistake somewhere else... so finally its done
    Nital Shah

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,752

    Re: Button Array

    Cool, nice job.

Similar Threads

  1. Compilation array in Double Pointer Array.
    By SymbianTH in forum Open C/C++
    Replies: 3
    Last Post: 2009-09-29, 10:23
  2. Detroy app when user press hang up button (red button)
    By ammanage in forum Mobile Java General
    Replies: 9
    Last Post: 2009-09-21, 19:29
  3. Difference between array of pointes and pointer to an array
    By Pradeep Chandra in forum Open C/C++
    Replies: 2
    Last Post: 2008-09-15, 13:45
  4. How to copy a array to a array of a struct?
    By ramanathan1 in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2004-08-26, 15:51

Posting Permissions

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