Symbian捕获全局按键的解决方案
2010-02-06 20:55:00 来源:WEB开发网class CApaWindowGroupName;
// 该类是通过活动对象来处理键盘事件
class CGlobalCapturer : public CActive
{
public:
// New functions
void StartCapturingL();
~CGlobalCapturer();
CGlobalCapturer();
public:
// From CActive
void RunL();
protected:
virtual void DoCancel();
private:
// Data
// Session to the window server
// 用它来连接窗口服务器
RWsSession iWsSession;
// Window group created to listed to the events
// 用它来获取按键事件
RWindowGroup* iWindowGroup;
// Is used to hide window from the task switcher
// 这个就是用来在任务切换器中隐藏当前窗口的地方了
CApaWindowGroupName* iWindowGroupName;
// Handle to the capturing request
TInt32 iCaptureHandle;
// Number of keypresses already captured
TInt iCaptureCounter;
};
// Function Prototypes
#ifdef __WINS__
IMPORT_C TInt WinsMain(TAny* aParam);
#else
GLDEF_C TInt E32Main();
#endif
#endif // __GLOBALKEYCAPTURE_H__
这里是global key capture的源文件中定义的内容了
// Include Files
#include "GlobalKeyCapture.h"
#include
#include
#include
#include
// Constants
// Text strings created by wizard
_LIT( KTextConsoleTitle, "Console" );
_LIT( KTextFailed, " failed, leave code = %d" );
_LIT( KTextPressAnyKey, " [press any key to exit] " );
// Key to listen to
更多精彩
赞助商链接