yyxmsg.cpp

来自「DOS下的图形界面开发包」· C++ 代码 · 共 64 行

CPP
64
字号
// 1993 (c) ALL RIGHTS RESERVED
// AUTHOR  BY XuYongYong

/* 	yyxmsg.cpp
*/
#include "yyxmsg.h"
#include "yyxmain.h"

MSGQueue::MSGQueue()
{
	this->Reset();
}

void MSGQueue::SendMessage (long int ID,long int Action,void *fptr)
{   asm cli;
	msg_array[first].ID =ID;
	msg_array[first].Action =Action;
	msg_array[first].fptr =fptr;

    oldfirst =first;
	first -=1;
	if ( first <0 )  first=MAXMSGNUM;
	if ( last==first ) {
//		puts("\007\007\007MSGQueue Overflow");
//		exit (100);
		error("\007\007\007MSGQueue Overflow");
	}
	asm sti;
}

BOOL MSGQueue::GetMessage (MSG& message)
{
	if ( first ==last ) return FALSE;
	message=msg_array[last];
	last -=1;
	if ( last <0)  last =MAXMSGNUM;
	return TRUE;
}

BOOL MSGQueue::PeekMessage (MSG& message)
{
	if ( first ==last ) return FALSE;
	message=msg_array[last];
	return TRUE;
}

BOOL MSGQueue::QueueFull ()
{ register int i;
	i = last - first;
	if ( i<0 ) i +=MAXMSGNUM;
	if ( i >= MSGFULLNUM ) return TRUE;
	return FALSE;
}

void MSGQueue::Reset ()
{
	first=last;
}

MSGQueue::~MSGQueue()
{
}

⌨️ 快捷键说明

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