Hi, all!
I'm trying to do an application that I want to capture key preses staying in
background using this example:
http://wiki.forum.nokia.com/index.ph..._in_background
Here is what I'm doing:
- Creating new Symbian C++ class, named CapturingKeys(Type of class is "Simple
Symbian Style C++ Class")
- Putting there code from example
- Adding ws32.lib apgrfx.lib and capability SwEvent
- #include <w32std.h>
#include <apgwgnam.h>
- changing KeyCapBGAppUi.h
- changing KeyCapBGAppUi.cppCode:#ifndef __KEYCAPBGAPPUI_h__ #define __KEYCAPBGAPPUI_h__ #include "CapturingKeys.h" ... class CKeyCapBGAppUi : public CAknAppUi, public MKeyCallBack { public: ... TBool KeyCapturedL(TWsEvent aEvent); private: ... private: ... CKeyCapturer *iKC; }; #endif
- running application on emulator. It's compiling well, but it doesn't capture anyCode:... void CKeyCapBGAppUi::ConstructL() { iKC = CKeyCapturer::NewL(*this); ... } ... TBool CKeyCapBGAppUi::KeyCapturedL(TWsEvent aEvent) { TApaTask task(iEikonEnv->WsSession( )); task.SetWgId(CEikonEnv::Static()->RootWin().Identifier()); task.BringToForeground(); return EFalse; } ...
key from background.
Well... changing CapturingKeys.cpp
replace string
withCode:iHandle = iWg.CaptureKey(EStdKeyHash, 0,0);
- Compiling... it run well but when I'm pressing #-key emulator is fallingCode:iHandle = iWg.CaptureKey('#', 0,0);
Also somewhere have found this example:
This application I even can't send to background - it is always on top...Code:... void CTry99AppUi::ConstructL() { // Initialise app UI with standard value. BaseConstructL(CAknAppUi::EAknEnableSkin); CEikonEnv::Static()->SetSystem( ETrue ); // capture hash '#' key permanently iHashKeyHandle = CEikonEnv::Static()->RootWin().CaptureKeyUpAndDowns(EStdKeyHash, 0, 0); // set application priority to foreground priority even if it goes to background CEikonEnv::Static()->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled ); // Make the application a high priority application CEikonEnv::Static()->RootWin().EnableReceiptOfFocus( ETrue ); CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront); // Create view object iAppView = CTry99AppView::NewL(ClientRect()); TApaTask task(iEikonEnv->WsSession()); task.SetWgId(CEikonEnv::Static()->RootWin().Identifier()); task.SendToBackground(); } ... void CTry99AppUi::HandleForegroundEventL(TBool aForeground) { // Make the application a high priority application if (aForeground) { CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront); } } void CTry99AppUi::HandleWsEventL (const TWsEvent &aEvent, CCoeControl *aDestination) { if (aEvent.Type() == EEventKey || aEvent.Type() == EEventKeyUp || aEvent.Type() == EEventKeyDown || aEvent.Type() == EEventKeyRepeat) { // This is for switching back to Application when Hash key is pressed if (EStdKeyHash == aEvent.Key()->iScanCode && EEventKey == aEvent.Type()) { TApaTask task(iEikonEnv->WsSession()); task.SetWgId(CEikonEnv::Static()->RootWin().Identifier()); task.BringToForeground(); return; } } CAknAppUi::HandleWsEventL(aEvent, aDestination); }
Can someone help me to do an application which can go background and will go foreground after pressing some key?




