How to add button?
| Thu, 2006-02-23 19:39 | |
|
Hello.
I'm a beginer in develope. I want to write a simple application. But I don't know how to add button. in C# it is very easy Button btn1 = new Button(); Button.text = "Button 1"; Button.parent = this; or (Controls.Add(btn1)); But how the same thing make in the C in CodeWarrior. Thx |
|






Forum posts: 239
U can try with following lines
iCmdBtn->SetContainerWindowL(*this);
iCmdBtn->SetTextL(_L("Button Name"));
//iCmdOkBtn->GetColor(TLogicalColor::EColorControlText,TRgb::Red);
iCmdOkBtn->SetObserver((MCoeControlObserver*)this);
iCmdOkBtn->SetExtent(TPoint(10,22), TSize(110,35));
BR
---------------
Bhatt Kavita
Forum posts: 5
{
// Create a window for this application view
CreateWindowL();
// Set the windows size
SetRect(aRect);
iCmdBtn = new (ELeave) CEikCommandButton();
iCmdBtn->SetContainerWindowL(*this);
iCmdBtn->SetTextL(_L("Button Name"));
//iCmdOkBtn->GetColor(TLogicalColor::EColorControlText,TRgb::Red);
iCmdOkBtn->SetObserver((MCoeControlObserver*)this);
iCmdOkBtn->SetExtent(TPoint(10,22), TSize(110,35));
// Activate the window, which makes it ready to be drawn
ActivateL();
}
error
Warning : tool exit status == 1
Error : undefined identifier 'iCmdBtn'
GameAppView.cpp line 49
Error : undefined identifier 'iCmdBtn'
GameAppView.cpp line 50
Error : undefined identifier 'iCmdBtn'
GameAppView.cpp line 51
Error : undefined identifier 'iCmdOkBtn'
GameAppView.cpp line 53
Error : undefined identifier 'iCmdOkBtn'
GameAppView.cpp line 54
Error : Compile failed
Forum posts: 239
Don't forget to include "eikcmbut.h" file and its corresponding lib "eikcoctl.lib" and then create its instance in your header file like
//.h file
CEikCommandButton* iCmdBtn;
//.cpp
In .cpp file use like this
iCmdBtn = new (ELeave) CEikCommandButton();
....
.....
And sorry for my above post ,by mistake I type the variable wrong.It is iCmdBtn not iCmdBtnOk.
And yeah don't forgot to put .lib in ur mmp file.and then compile afresh.
Cheers
---------------
Bhatt Kavita
Forum posts: 5
Now i can compile it.
But i did not see the button and how to change Application name?
Forum posts: 5
Control().AppendL(iCmdBtn);
?