⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventqueue.cpp

📁 symbian,使用dll服务捕获按键,比设置优先级更能提高按键响应.
💻 CPP
字号:

#include "EventQueue.h"

_LIT(KGLobalName, "HAnimGlobe");

CEventQueue* CEventQueue::NewL(MEventQueue& aNotify)
{
	CEventQueue* queue = new ( ELeave ) CEventQueue(aNotify); 
	CleanupStack::PushL( queue );
	queue->ConstructL();
	CleanupStack::Pop();
	return queue;
}
	
CEventQueue::CEventQueue(MEventQueue& aNotify):CActive( CActive::EPriorityStandard ), iEventNotify(aNotify)
{
	CActiveScheduler::Add( this );  
}
	
CEventQueue::~CEventQueue()	
{
	Cancel();
	iMsgQueue.Close();
}

void CEventQueue::ConstructL()
{	
	TInt ret = iMsgQueue.OpenGlobal(KGLobalName);
	if (ret != KErrNone)
	{
		iMsgQueue.CreateGlobal(KGLobalName, 5, sizeof(TInt), EOwnerProcess);
		GetEvent();
	}
	else
	{
		iMsgQueue.Close();
		ret = iMsgQueue.CreateGlobal(KGLobalName, 5, sizeof(TInt), EOwnerProcess);
		GetEvent();
	}
}

void CEventQueue::RunL()	
{
	if (iStatus.Int() == KErrNone)
	{
		TInt data;
		TInt err = iMsgQueue.Receive( &data, sizeof(TInt) );
		if (err == KErrNone)
			iEventNotify.EventNotify(data);

		GetEvent();
	}
}
	
TInt CEventQueue::RunError()
{
	GetEvent();
	return -1;
}
	
void CEventQueue::GetEvent()
{
	if (IsActive())
		return;

	iMsgQueue.NotifyDataAvailable( iStatus );
	SetActive();
}
	
void CEventQueue::DoCancel()
{
	iMsgQueue.CancelDataAvailable();
}

void CEventQueue::SendEvent()
{
	TInt nExitNum=1;
	iMsgQueue.Send(&nExitNum,sizeof(nExitNum));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -