各位大哥,我想将后台运行的UI程序通过响应按键事件转入前台运行。搜索了一下网上的例子,照着葫芦画瓢。
在UI类中加入
再添加一个方法:Code:void CMyWalletAppUi::ConstructL() { // Initialise app UI with standard value. BaseConstructL(CAknAppUi::EAknEnableSkin); iSmsShield = CSmsShield::NewL(); // Create view object iAppView = CMyWalletAppView::NewL(ClientRect()); iAppView->SetMopParent(this); //iAppView->ConstructL( ClientRect() ); iEikonEnv->RootWin().CaptureKey(EStdKeyRightShift,0,0 ); iEikonEnv->RootWin().CaptureKeyUpAndDowns(19,0, 0); AddToStackL( iAppView ); }
结果,在前台运行时,按abc键,弹出 ScanCode:50 ,通过aKeyEvent.iCode取值都是0TKeyResponse CMyWalletAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType)
{
TBuf<64> text;
_LIT(KErrorStr, "ScanCode: %d");
text.Format(KErrorStr, aKeyEvent.iScanCode);
(new (ELeave) CAknInformationNote)->ExecuteLD(text);
}
转入后台就没有任何响应了。
SOS

Reply With Quote



