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

📄 prop4.cpp

📁 基于omnet++开发的Mf框架下的802.11协议仿真。
💻 CPP
字号:
// Prop4.cpp : implementation file
//

#include "stdafx.h"
#include "table2.h"
#include "Prop4.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CProp4 property page

IMPLEMENT_DYNCREATE(CProp4, CPropertyPage)

CProp4::CProp4() : CPropertyPage(CProp4::IDD)
{
	//{{AFX_DATA_INIT(CProp4)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CProp4::~CProp4()
{
}

void CProp4::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CProp4)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CProp4, CPropertyPage)
	//{{AFX_MSG_MAP(CProp4)
	ON_WM_PAINT()
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CProp4 message handlers

BOOL CProp4::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	t=0;
	m_nOldLen=0;
	addr=0;
	// TODO: Add extra initialization here
	for(int i=0;i<30;i++)
		origin[i]=0;
	pFile=fopen("yasuobi.txt","r");
	Invalidate();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CProp4::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	CPen pen(0,2,RGB(255,0,0));
	//dc.SelectObject(&pen);

	CRect rect;
	GetDlgItem(IDC_GRAPHIC1)->GetWindowRect(&rect);
	ScreenToClient(&rect);
	
	int i;
	for(i=0;i<10;i++)
	{
		dc.MoveTo(rect.left,rect.bottom-i*rect.Height()/10);
		dc.LineTo(rect.right,rect.bottom-i*rect.Height()/10);
	}

		if(!IsUpdate())
	{
		t=(t+2)%3;
	}

	
	if(t==0)
		{
			for(i=0;i<10;i++)
			{
				dc.MoveTo(rect.left+i*rect.Width()/10,rect.bottom);
				dc.LineTo(rect.left+i*rect.Width()/10,rect.top);
				
			}
			t=1;
		}
	else if(t==1)
		{
			for(i=0;i<10;i++)
			{
				dc.MoveTo(rect.left+i*rect.Width()/10+2*rect.Height()/30,rect.bottom);
				dc.LineTo(rect.left+i*rect.Width()/10+2*rect.Height()/30,rect.top);
				
			}
			t=2;
		}
	else 
		{
			for(i=0;i<10;i++)
			{
				dc.MoveTo(rect.left+i*rect.Width()/10+rect.Height()/30,rect.bottom);
				dc.LineTo(rect.left+i*rect.Width()/10+rect.Height()/30,rect.top);
				
			}
			t=0;
		}

	dc.SelectObject(&pen);
	for(i=0;i<29;i++)
	{
		dc.MoveTo(rect.left+i*rect.Width()/30,rect.bottom-origin[i]*rect.Height()/10);
		dc.LineTo(rect.left+(i+1)*rect.Width()/30,rect.bottom-origin[i+1]*rect.Height()/10);
	}

	
	m_nTimer   =   SetTimer(1,   200,0); 
	
		// Do not call CPropertyPage::OnPaint() for painting messages
}


void   CProp4::OnStopTimer()     
   {   
        KillTimer(m_nTimer); 
   }  

void CProp4::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	Invalidate();
	
	CPropertyPage::OnTimer(nIDEvent);
}

int CProp4::IsUpdate()
{
	if(!feof(pFile))
	{
		char ch[3];
		memset(ch,0,3);
		fread(ch,1,3,pFile);
		if(!feof(pFile))
		{
		
			fseek(pFile,2,SEEK_CUR);
		}
		else 
		{	
			fseek(pFile,2,SEEK_CUR);
			//MessageBox("22");
			return 0;
			
		}
		for(int i=0;i<29;i++)
		{
			origin[i]=origin[i+1];
		}
		origin[29]=(double)atof(ch);
		return 1;
	}

	return 0;


/*	fseek(pFile,0,SEEK_END);
	int len=ftell(pFile);
	if(len==m_nOldLen)
	{

	}
	else
	{
		fseek(pFile,-16,SEEK_END);
		char ch[4];
		memset(ch,0,4);
		//rewind(pFile);
		
			fread(ch,1,4,pFile);
		origin[15]=(double)atof(ch);
	

		MessageBox(ch);

		m_nOldLen=len;

	}*/
}



⌨️ 快捷键说明

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