📄 msgobject.cpp
字号:
#include "GOS.h"
#include "msgobject.h"
LRESULT CMsgObject::SendMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
PTHREAD pThread=GetMQThread();
PTHREAD pCur=GetCurrentThread();
if(pThread==pCur)
return MsgProc(message,wParam,lParam);
else
{
CMutex lock(pThread);
MSG msg={this,message,wParam,lParam};
pThread->InsertMessage(NULL,msgSendMessage,WPARAM(&lock),LPARAM(&msg));
lock.LockEx(pCur,INFINITE);
SwitchToThread();
return msg.wParam;
}
}
HANDLE CMsgObject::PostMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
return GetMQThread()->InsertMessage(this,message,wParam,lParam);
}
void CMsgObject::PulseMessageEvent(HANDLE hMsg,WPARAM wParam, LPARAM lParam)
{
PMSG pMsg=&(PMSGLE(hMsg)->msg);
pMsg->pObj=this;
pMsg->wParam=wParam;
pMsg->lParam=lParam;
GetMQThread()->PulseMessage(hMsg);
}
HANDLE CMsgObject::SetMessageEvent(int nPriority)
{
if(!nPriority)
nPriority=PriorityNormal;
return GetMQThread()->InsertMessage(this,
MakeEventMessage(nPriority),0,0);
}
BOOL CMsgObject::RemoveMessage(HANDLE hMsg)
{
return GetMQThread()->RemoveMessage(hMsg,hMsg);
}
BOOL CMsgObject::RemoveMessage(UINT nMessage)
{
return GetMQThread()->RemoveMessage(this,nMessage);
}
BOOL CMsgObject::RemoveAllMessage()
{
return GetMQThread()->RemoveMessage(this);
}
HANDLE CMsgObject::SetTimer(UINT nIDEvent,UINT nElapse,int nPriority)
{
return GetMQThread()->InsertMessage(this,
MakeTimerMessage(nPriority),GetTickCount()+nElapse,MAKELONG(nIDEvent,nElapse));
}
void CMsgObject::SetTimer(HANDLE hMsg,UINT nElapse)
{
MSG& msg=PMSGLE(hMsg)->msg;
msg.wParam=GetTickCount()+nElapse;
msg.lParam=MAKELONG(LOWORD(msg.lParam),nElapse);
}
BOOL CMsgObject::KillTimer(UINT nIDEvent)
{
return GetMQThread()->RemoveTimerMessage(this,nIDEvent);
}
LRESULT CMsgObject::MsgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case msgGetMQThread:
wParam=WPARAM(&g_pKernel);
default:
wParam=0;
}
return wParam;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -