Symbian捕获全局按键的解决方案
2010-02-06 20:55:00 来源:WEB开发网// why not to demonstrate this either?
TBuf<256> cmdLine;
RProcess().CommandLine( cmdLine );
MainL( cmdLine );
// Delete active scheduler
CleanupStack::PopAndDestroy(scheduler);
}
// Global Functions
// 本函数将初始化异常处理栈,创建console对象创建完毕后调用DoStartL,开始进入按键捕获
//捕获完毕后,销毁对象和异常处理栈
GLDEF_C TInt Start()
{
// Create cleanup stack
__UHEAP_MARK;
CTrapCleanup* cleanup = CTrapCleanup::New();
// Create output console
TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
if (createError)
return createError;
// Run application code inside TRAP harness, wait keypress when terminated
TRAPD(mainError, DoStartL());
if (mainError)
console->Printf(KTextFailed, mainError);
console->Printf(KTextPressAnyKey);
console->Getch();
delete console;
delete cleanup;
__UHEAP_MARKEND;
return KErrNone;
}
////////////////////////////////////
// CGlobalCapturer
////////////////////////////////////
// Constructor
CGlobalCapturer::CGlobalCapturer() :
CActive( EPriorityNormal )
{
// nothing
}
// Destructor
CGlobalCapturer::~CGlobalCapturer()
{
delete iWindowGroupName;
delete iWindowGroup;
iWsSession.Close();
}
// Cancel listening to key presses
void CGlobalCapturer::DoCancel()
{
iWindowGroup->CancelCaptureKey( iCaptureHandle );
}
// 活动对象的初始化,连接symbian的窗口服务器,创建了一个新的窗口群,并把它的名字设为全局的
更多精彩
赞助商链接