WEB开发网
开发学院手机开发Symbian 开发 Symbian捕获全局按键的解决方案 阅读

Symbian捕获全局按键的解决方案

 2010-02-06 20:55:00 来源:WEB开发网   
核心提示:// 定义需要捕获的全局按键,这里是Left Arrow,Symbian捕获全局按键的解决方案(3),左方向键const TUint KKeyCode = EKeyLeftArrow;// Capture KNumberOfPressesToCapture key presses// 定义捕获多少次的,这里只定义了3次

// 定义需要捕获的全局按键,这里是Left Arrow,左方向键

const TUint KKeyCode = EKeyLeftArrow;

// Capture KNumberOfPressesToCapture key presses

// 定义捕获多少次的,这里只定义了3次,可以根据需要修改

const TInt KNumberOfPressesToCapture = 3;

// Global Variables

// write all messages to this console

// 用于显示的console,可以根据需要改成别的,不过最好不要用于做违法的事情。

LOCAL_D CConsoleBase* console;

// Local Functions

// 创建按键捕获类的对象capture,并做了一些异常防护工作。然后调用capturer->StartCapturingL()初始化

//活动对象

LOCAL_C void MainL(const TDesC& )

{

console->Write( _L( "Starting key capturing " ) );

// Create capturer

CGlobalCapturer* capturer = new (ELeave) CGlobalCapturer();

CleanupStack::PushL( capturer );

// And start capturing

capturer->StartCapturingL();

// In a real application you should use CActiveSchedulerWait,

// but in this small demo application we know that there is just

// a single inner loop and no CActiveSchedulerWait "protection" is

// needed

CActiveScheduler::Start();

// Cleanup. Demo completed

CleanupStack::PopAndDestroy( capturer );

}

// Main function. Is TRAPD outside, in Start()

// 创建用于按键捕获的活动对象调度器然后调用MainL(symbian是多么?嗦的一个系统啊,需要绕这么多圈

//子,不过这些都是为了保证系统可以“万无一失”的运行)

LOCAL_C void DoStartL()

{

// Create active scheduler (to run active objects)

CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();

CleanupStack::PushL(scheduler);

CActiveScheduler::Install(scheduler);

// Call main function with command line

// Command line is not really needed for this demo, but

上一页  1 2 3 4 5 6  下一页

Tags:Symbian 捕获 全局

编辑录入:coldstar [复制链接] [打 印]
赞助商链接