lunedì 17 marzo 2008

Setting list view with Skins

Last week, I faced the problem (in Symbian 9.x) in creating a Setting List View : a view defined with a CAknSettingItemList cointainer.

In this view you can set, for example, some parameters of your application (choose your default storage memory: phone or memory card; your preferred Internet access point, and so on).
The drawback was that didn't work the CAknEnumeratedTextPopupSettingItem for choosing a list of items. Every time I opened that item, my application crashed.

I found the solution : I had to enable the skin support in my application.
To do this, in the ConstructL() method of your AppUi class, define:

void CYourAppUi::ConstructL()
{
BaseConstruct(EAknEnableSkin);
....
}

venerdì 14 marzo 2008

Net60 : THE MIRACLE

Eureka!!!!!!!!

I've just runned a simple application fully deployed with Microsoft .NET Compact Framework 1.0 (written in C#) in a Symbian 9.x smartphone (Nokia N73).

The "miracle" is made by Net60, a .NET Compact Framework implementation for Symbian OS 9.x, developed by Red Five Labs.

Download for free Net60 beta 3 from : http://www.redfivelabs.com

Set text into Label component

In Symbian, a label object is a CEikLabel object.
In order to set the text label, in the construct method of your container you can use the SetText() method.
It works fine. But, if at the beginning you set a null text (for example, the empty literal _L("") ) you may run into a drawback: if you wish call SetText() for a second time (for example, for changing the displayed text), the text didn't change at all : for ever the label will display the empty text label :-( !

To avoid that, I have discovered a simple trick : write the first SetText() call in your construct method (ConstructL()) as follow:

_LIT(KManySpacesStr," ");
myLabel->SetText(KManySpacesStr);

Add spaces into KManySpacesStr to reach the expected maximum label text lenght.

lunedì 10 marzo 2008

Send app. to background

Here the code to send your GUI application in background:

#include <apgtask.h>
// link against: apgrfx.lib

TApaTask task(iEikonEnv->WsSession( ));
TInt wgId = CEikonEnv::Static()->RootWin().Identifier();
task.SetWgId(wgId);

task.SendToBackground();

Foreground event

How to detect when your application is sent to background or bring into foreground ?
In your AppUi class, You have to re-implement the method:

void HandleForegroundEventL(TBool aForeground)

When called, aForeground says that, if true, your application is bring into foreground, while if false, your application is sent to background.

Here the implementation:

void CYourAppUi::HandleForegroundEventL(TBool aForeground)
{
// ..do something..

CAknViewAppUi::HandleForegroundEventL(aForeground);
}

venerdì 7 marzo 2008

Simulate key pressing

Here the code:

TBool SendKey(TInt aScanCode)
{
TRawEvent ev1;
ev1.Set(TRawEvent::EKeyDown, aScanCode);
UserSvr::AddEvent(ev1); // SwEvent
User::After(100000);
TRawEvent ev2;
ev2.Set(TRawEvent::EKeyUp, aScanCode);
UserSvr::AddEvent(ev2); // SwEvent
}

Get current time and date

Simply, use the class TTime:

TTime mytime;
mytime.HomeTime();

Home time is the same time as a wall clock would show.

Instead, to get the Universal Time (UTC), use:

mytime.UniversalTime();

Now we could convert the time&date to a string object (called descriptor in Symbian):

TBuf<100> dateStr;
_LIT(KDateString,"%D%M%Y%/0%1%/1%2%/2%3%/3");
mytime.FormatL(dateStr,KDateString);
// dateString contains "07/03/2008"
, for example

TBuf<100> timeStr;
_LIT(KTimeString,"%-B%:0%J%:1%T%:2%S%:3%+B");
mytime.FormatL(timeStr,KTimeString);
//
timeStr contains "16:10:59", for example