www.pudn.com > SnmpToplog.rar > ShowTuoPuDlg.cpp


// ShowTuoPuDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "MySnmp.h" 
#include "ShowTuoPuDlg.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CShowTuoPuDlg dialog 
 
 
CShowTuoPuDlg::CShowTuoPuDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CShowTuoPuDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CShowTuoPuDlg) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
 
void CShowTuoPuDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CShowTuoPuDlg) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CShowTuoPuDlg, CDialog) 
	//{{AFX_MSG_MAP(CShowTuoPuDlg) 
	ON_WM_PAINT() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CShowTuoPuDlg message handlers 
#include "MySubNet.h" 
void CShowTuoPuDlg::OnPaint()  
{ 
	CPaintDC dc(this); // device context for painting 
	 
	// TODO: Add your message handler code here 
	if(m_pSubNets==NULL) 
		return; 
	////////////////////////////////////////////////////////////////////////// 
	////////////////////////////////////////////////////////////////////////// 
	 
	double pi = 3.1415926535; 
	CDC* pdc=GetDC(); 
	pdc->SetBkMode(TRANSPARENT); 
 
	CRect rect; 
	GetClientRect(&rect); 
	CPoint CenterPos; 
	CenterPos=rect.CenterPoint(); 
	DrawHost(pdc,CenterPos,RGB(255,0,0)); 
	pdc->TextOut(CenterPos.x-30,CenterPos.y,m_strRouteAddress); 
	int count=m_pSubNets->GetSize(); 
	for(int i=0;iGetAt(i); 
		CPoint point; 
		point.x=150*cos(2*pi/count*i)+CenterPos.x; 
		point.y=150*sin(2*pi/count*i)+CenterPos.y; 
		DrawHost(pdc,point,RGB(0,255,0)); 
		CPen pen,*oldp; 
		pen.CreatePen(PS_SOLID,3,RGB(255,0,0)); 
		oldp=pdc->SelectObject(&pen); 
		pdc->MoveTo(CenterPos.x,CenterPos.y); 
		pdc->LineTo(point.x,point.y); 
		pdc->SelectObject(oldp); 
		CMySubNet* pTemp=(CMySubNet*)m_pSubNets->GetAt(i); 
		pdc->TextOut(point.x-30,point.y,pTemp->m_Address); 
		int nCount=pTemp->m_ActiveHosts.GetSize(); 
		////////////////////////////////////////////////////////////////////////// 
//		for(int test=0;test<=20;test++) 
//		{ 
//			CString str; 
//			str.Format("192.168.0.%d",test); 
//			pTemp->m_ActiveHosts.Add(str); 
//		} 
		////////////////////////////////////////////////////////////////////////// 
		 
		for(int j=0;jTextOut(p.x,p.y,pTemp->m_ActiveHosts.GetAt(j)); 
			TRACE("%d --> %s\n",i,pTemp->m_ActiveHosts.GetAt(j)); 
			pdc->MoveTo(point.x,point.y); 
			pdc->LineTo(p.x,p.y); 
		} 
	} 
	// Do not call CDialog::OnPaint() for painting messages 
} 
 
void CShowTuoPuDlg::DrawHost(CDC *pdc, CPoint point,COLORREF crColor) 
{ 
	CBrush brush,*pold; 
	brush.CreateSolidBrush(crColor); 
	pold=pdc->SelectObject(&brush); 
	if(crColor==RGB(0,0,255)) 
		pdc->Rectangle(point.x-5,point.y-5,point.x+5,point.y+5); 
	else 
		pdc->Rectangle(point.x-10,point.y-10,point.x+10,point.y+10); 
	pdc->SelectObject(pold); 
}