www.pudn.com > aaa.rar > Display.cpp


// Display.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "aaa.h" 
#include "Display.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CDisplay 
 
CDisplay::CDisplay() 
{ 
   m_wnd=this; 
   num=524; 
   //m_color=RGB(255,0,0);//可以不要,直接用RGB定义颜色 
   m_move=false;// 初始化? 
} 
 
CDisplay::~CDisplay() 
{ 
} 
 
 
BEGIN_MESSAGE_MAP(CDisplay, CStatic) 
	//{{AFX_MSG_MAP(CDisplay) 
	ON_WM_TIMER() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CDisplay message handlers 
 
void CDisplay::datatoscreen(double *y) 
{ 
   getwnd(); 
   for (int i=0;iGetClientRect(rect); 
 nWidth=rect.Width(); 
 nHeight=rect.Height(); 
 
} 
void CDisplay::draw() 
{ 
	CDC *pDC=GetDC();//作用? 
	CBitmap bitmap; 
	CBitmap *pOldBitmap; 
     
	CDC MemDC; 
	CPen pen; 
	CPen* oldpen; 
     
	MemDC.CreateCompatibleDC(pDC);///建立与显示设备兼容的内存设备场境 
	bitmap.CreateCompatibleBitmap(pDC,nWidth,nHeight);///建立与显示设备兼容的位图 
	pOldBitmap=MemDC.SelectObject(&bitmap);//选择位图于场内境 
    //pen.CreatePen(PS_SOLID,1,m_color); 
	pen.CreatePen(PS_DASHDOT,1,RGB(255,0,0));//创建画笔类型 
 
	oldpen=MemDC.SelectObject(&pen); 
    
	MemDC.MoveTo(hh[0].x,hh[0].y); 
	for (int i=0;iBitBlt(0,0,nWidth,nHeight,&MemDC,0,0,SRCCOPY);//函数? 
 
} 
 
 
 
 
 
void CDisplay::OnTimer(UINT nIDEvent)  
{ 
	// TODO: Add your message handler code here and/or call default 
	if (m_move) 
	{ 
		long bk; 
		bk=hh[0].y; 
		for (int i=0;i<524;i++)//创建连续波形 
		{ 
			hh[i].y=hh[i+1].y; 
		} 
		hh[523].y=bk; 
		draw();//作用?显示波形 
	} 
 
	CStatic::OnTimer(nIDEvent); 
}