How to add a button to View?

Login to reply to this topic.
Sun, 2004-06-20 21:00
Joined: 2004-06-19
Forum posts: 1
Hi,

I need to add a button to View but I cannot find any examples about that. Could anyone please help me to solve the problem?

Thx

Mon, 2004-06-21 11:42
Joined: 2004-06-18
Forum posts: 7
How to add a button to View?
You can use QUB to catch a OK button to the view ,then see the source code ..
Thu, 2004-07-08 17:40
Joined: 2004-07-08
Forum posts: 13
How to add a button to View?
I want to add CommandButton to View and I use resource CMBUT:
- In .rss:
RESOURCE CMBUT r_ex_button
   {
   version=0;
   behavior=2;
   layout=1;
   extension=0;
   txt="";
   bmpfile="*";
   bmpid=EMbmExicon;
   bmpmask=EMbmExiconm;
   }
- In class appview:
   TResourceReader reader;
   iCoeEnv->CreateResourceReaderLC(reader,   R_EX_BUTTON);
   CEikCommandButton* button = new CEikCommandButton();
   button->ConstructFromResourceL(reader);
   CleanupStack::PopAndDestroy();
   button->SetContainerWindowL(*this);
   button->SetObserver(this);
   button->SetExtent(TPoint(0,0),TSize(20,20));

But it show and I only can see menu and exit emulator. I wrong? Please help me. Thanks.
Wed, 2004-07-14 16:05
Joined: 2004-07-12
Forum posts: 24
How to add a button to View?
Up!  Cry

/dev/gmaker

Wed, 2005-12-14 12:39
Joined: 2005-09-07
Forum posts: 16
Re: How to add a button to View?
It's very simple. Not need to RESOURCE.
For make Button on view you must:
1)Write in CExampleAppView class *.h-file
   
Code:
CEikCommandButton* iBtnTest;
2)...and include
Code:
#include "eikcmbut.h"

3)In *.cpp-file of CExampleAppView class  in ConstructL
Code:
iBtnTest = new (ELeave) CEikCommandButton();
CleanupStack::PushL(iBtnTest);
iBtnTest->SetTextL(_L("Test"));
iBtnTest->SetObserver(this);
iBtnTest->SetContainerWindowL(*this);
TSize size = iBtnTest->MinimumSize();
iBtnTest->SetExtent( TPoint(aRect.Width() - (size.iWidth + 5),
aRect.Height() - (size.iHeight + 36)),
size);
CleanupStack::Pop();
4)... in CountComponentControls
Code:
TInt counter = 0;
if (iBtnTest)   counter++;
return counter;
count this control...
5)... in ComponentControl
Code:
switch (aIndex)
{
                                 ................
case 4:
return iBtnTest;
                                 ................
default:
return NULL;
}
6)... in HandleControlEventL insert functionality for your Button
Code:
if(iBtnTest == aControl)
{
                 ........................
}
7)... and finally in ~CExampleAppView correct delete control
Code:
if(iBtnTest)
delete iBtnTest;

//для русских =)
//пишите в личку, отвечу на вопросы Wink

Per aspera ad astra

  • Login to reply to this topic.