Hello Friends
How to get event/notification for any key press or screen is touched in Non UI application.
Please suggest some links or piece of code.
Hello Friends
How to get event/notification for any key press or screen is touched in Non UI application.
Please suggest some links or piece of code.
"Any" is not really possible, but you can use CaptureKey for getting keypresses when your application is not visible (either non-GUI or GUI). Search for it in the Wiki, and you can find a really simple test code in http://www.developer.nokia.com/Commu...is-key-capture, which may help in understanding the Wiki example too.
Capturing screen touches is not really supported as I know. You can experiment having some top-priority invisible window, but it is not trivial at least.
Hi Wizard
I have displayed an image using exact code at http://www.developer.nokia.com/Commu...tion_framework. I want to capture pointer events when displayed image is at top.
is it possibly in this scenario.
Note: I am not using any custom control.
Friends,
I have to capture pointer events in the following Scenario.
1.In a NON UI application i have displayed an image.
2. I need to be notified when user touches the screen so that i can remove/close image.
For reference i have pasted the code i am using to display an image
#include <apgwgnam.h> //CApaWindowGroupName
#include "WindowDrawer.h"
#include <coedef.h> //for ECoeWinPriorityAlwaysAtFront
CWindowDrawer* CWindowDrawer::NewL(void)
{
CWindowDrawer* self = CWindowDrawer::NewLC(void);
CleanupStack::Pop(self);
return self;
}
CWindowDrawer* CWindowDrawer::NewLC(void)
{
CWindowDrawer* self = new (ELeave) CWindowDrawer(void);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
// the active object priority should be relatively low
CWindowDrawer::CWindowDrawer(void):CActive(EPriorityLow)
{
}
CWindowDrawer::~CWindowDrawer()
{
Cancel();
if(iMyFont)
{
iScreenDevice->ReleaseFont(iMyFont);
iMyFont = NULL;
}
delete iWindowGc;
iWindowGc = NULL;
delete iScreenDevice;
iScreenDevice = NULL;
iWindow.Close();
iWindowGroup.Close();
iWsSession.Close();
}
void CWindowDrawer::ConstructL(void)
{
CActiveScheduler::Add(this);
User::LeaveIfError(iWsSession.Connect());
iScreenDevice=new (ELeave) CWsScreenDevice(iWsSession);
User::LeaveIfError(iScreenDevice->Construct());
User::LeaveIfError(iScreenDevice->CreateContext(iWindowGc));
TFontSpec MyeFontSpec (KFontArial, 12*15);
MyeFontSpec.iTypeface.SetIsProportional(ETrue);
User::LeaveIfError(iScreenDevice->GetNearestFontInTwips(iMyFont,MyeFontSpec));
iWindowGroup=RWindowGroup(iWsSession);
User::LeaveIfError(iWindowGroup.Construct((TUint32)&iWindowGroup, EFalse));
// iWindowGroup.SetOrdinalPosition(0,ECoeWinPriorityNormal);
iWindowGroup.SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront);
iWindowGroup.EnableReceiptOfFocus(EFalse);
CApaWindowGroupName* winGroupName=CApaWindowGroupName::NewLC(iWsSession);
winGroupName->SetHidden(ETrue);
winGroupName->SetWindowGroupName(iWindowGroup);
CleanupStack::PopAndDestroy();
iWindow=RWindow(iWsSession);
User::LeaveIfError(iWindow.Construct(iWindowGroup, (TUint32)&iWindow));
TPixelsTwipsAndRotation SizeAndRotation;
iScreenDevice->GetDefaultScreenSizeAndRotation(SizeAndRotation);
iWindow.Activate();
iWindow.SetExtent(TPoint(0,0),SizeAndRotation.iPixelSize);
iWindow.SetBackgroundColor(KRgbBlue);
// iWindow.SetOrdinalPosition(0,ECoeWinPriorityNormal);
iWindow.SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
iWindow.SetNonFading(ETrue);
iWindow.SetVisible(ETrue);
Draw();
iWsSession.RedrawReady(&iStatus);
SetActive();
}
void CWindowDrawer::RunL()
{
if (iStatus != KErrCancel)
{
TWsRedrawEvent e;
iWsSession.GetRedraw(e);
// if Windows Server does not want a redraw the window handle is 0
if (e.Handle() != 0)
{
// draw our only window
Draw();
}
iWsSession.RedrawReady(&iStatus);
SetActive();
}
}
void CWindowDrawer::Draw(void)
{
iWindowGc->Activate(iWindow);
TRect DrwRect(TPoint(0,0), iWindow.Size());
iWindow.Invalidate(DrwRect);
iWindow.BeginRedraw();
iWindowGc->Clear(DrwRect);
if(iMyFont)
{
iWindowGc->UseFont(iMyFont);
TInt StartY ((DrwRect.Height() - iMyFont->HeightInPixels()) / 2);
iWindowGc->DrawText(KtxHelloThere,TRect(0,StartY,DrwRect.Width(),(StartY + iMyFont->HeightInPixels())),iMyFont->AscentInPixels(), CGraphicsContext::ECenter, 0);
}
iWindow.EndRedraw();
iWindowGc->Deactivate();
iWsSession.Flush();
}
void CWindowDrawer::DoCancel()
{
iWsSession.RedrawReadyCancel();
}
Pointer events are just simple Window Server events. You can get Window Server events via RWsSession::EventReady+GetEvent.
Note that this is not called capturing, that is why it may work without any wild hack.
Thnx i could get pointer events successfully.
What if i want to receive key press events in addition to pointer events? What should i do to receive any key press event.
If your window is focused, keypresses are WS events too.
If your window is not focused, CaptureKey, as suggested in #2 already.
Is there any way to disable all notification programatically
"All"? Probably there is no way for that.
actaully some of applications are hiding or managed to disable "Data packet connectio onhold/active" notification, low charging and charger plug in. May hide atleast these three notifications
1. Packet data connection on hold
2. Charging is low.
3. Notification while we plugin charger
Hi again.
I have been facing a strange issue.
I could successsfully display an image over call buble. After fresh installation of my application on Nokia 5800. I could display image as many times as i call. Butttttttttt when i restart phone then i could never display image rather application crashes.
Please suggest what should i do?
For reference i have already posted my code plz see in #4.