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

📄 dispmsgview.cpp

📁 实现了无线传感器网络中的一个路由协议算法。
💻 CPP
字号:
// DispMsgView.cpp : implementation file
//

#include "stdafx.h"
#include "SimSensor.h"
#include "DispMsgView.h"
#include "SimSensorDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "Msg.h"
/////////////////////////////////////////////////////////////////////////////
// CDispMsgView

IMPLEMENT_DYNCREATE(CDispMsgView, CScrollView)

CDispMsgView::CDispMsgView()
{
	//pHead = NULL;
    //pTail = NULL;
	//InitializeCriticalSection(&Locked);
}

CDispMsgView::~CDispMsgView()
{
}


BEGIN_MESSAGE_MAP(CDispMsgView, CScrollView)
	//{{AFX_MSG_MAP(CDispMsgView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDispMsgView drawing

void CDispMsgView::OnInitialUpdate()
{
	CScrollView::OnInitialUpdate();

	CSize sizeTotal;
	// TODO: calculate the total size of this view
	sizeTotal.cx = sizeTotal.cy = 100;
	SetScrollSizes(MM_TEXT, sizeTotal);
}

void CDispMsgView::OnDraw(CDC* pDC)
{
	CSimSensorDoc * pDoc =(CSimSensorDoc *)GetDocument();
	CString Str;
	CMsg *pMsg = pDoc->MsgBuff.GetMsg();
	while ( pMsg!=NULL ) {
		Str.Format("Received Msg:((%d,%d),(%d,%d),%d,data)",pMsg->Destination.x,pMsg->Destination.y,pMsg->Origination.x,pMsg->Origination.y,pMsg->Type); 
		pDC->TextOut (0,0,Str);
		DELETE_OBJECT(pMsg);
	    pMsg = pDoc->MsgBuff.GetMsg();
	}

	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CDispMsgView diagnostics

#ifdef _DEBUG
void CDispMsgView::AssertValid() const
{
	CScrollView::AssertValid();
}

void CDispMsgView::Dump(CDumpContext& dc) const
{
	CScrollView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDispMsgView message handlers

//DEL void CDispMsgView::AddMsg(CMsg *pMsg)
//DEL {
//DEL 	CMsgStrain *pMsgStrain = new CMsgStrain;
//DEL 	pMsgStrain->Message = pMsg;
//DEL 
//DEL     EnterCriticalSection(&Locked);
//DEL 
//DEL 	if ( pTail!=NULL ) {
//DEL 		pTail->pNext = pMsgStrain;
//DEL 		pTail = pMsgStrain;
//DEL 	}else {
//DEL 		pHead = pMsgStrain;
//DEL 		pTail = pMsgStrain;
//DEL 	}
//DEL 
//DEL 	LeaveCriticalSection(&Locked);
//DEL 
//DEL }

//DEL CMsg * CDispMsgView::GetMsg()
//DEL {
//DEL 	EnterCriticalSection(&Locked);
//DEL 
//DEL 	if ( pHead == NULL) {
//DEL 	    LeaveCriticalSection(&Locked);		
//DEL 		return NULL;
//DEL 	}
//DEL 
//DEL 	CMsgStrain *pMsgStrain = pHead;
//DEL 	pHead = pHead->pNext; 
//DEL 	if ( pHead==NULL ) pTail=NULL;
//DEL     CMsg * pMsg = pMsgStrain->Message;
//DEL 
//DEL     LeaveCriticalSection(&Locked);
//DEL 
//DEL 	delete  pMsgStrain;
//DEL     pMsgStrain = NULL;
//DEL 	return pMsg;
//DEL }

⌨️ 快捷键说明

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