?? udpview.cpp
字號:
// UDPView.cpp : implementation of the CUDPView class
//
#include "stdafx.h"
#include "UDP.h"
#include "UDPDoc.h"
#include "UDPView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUDPView
IMPLEMENT_DYNCREATE(CUDPView, CView)
BEGIN_MESSAGE_MAP(CUDPView, CView)
//{{AFX_MSG_MAP(CUDPView)
ON_COMMAND(ID_CLEARSCREEN, OnClearscreen)
ON_COMMAND(ID_ShowIPDialog, OnShowIPDialog)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUDPView construction/destruction
CUDPView::CUDPView()
{
// TODO: add construction code here
IsClearnScreen=false;
IsDrawing=false;
}
CUDPView::~CUDPView()
{
}
BOOL CUDPView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
//創(chuàng)建本地套接口
m_sockRecv.Create(5000,SOCK_DGRAM);
/////////////////////////////////////////////////////////////////
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CUDPView drawing
void CUDPView::OnDraw(CDC* pDC)
{
CUDPDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//定義坐標(biāo)系
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowOrg(0,0);
pDC->SetWindowExt(320,240);
pDC->SetViewportOrg(125,75);
pDC->SetViewportExt(480,360);
//畫邊框
/*pDC->MoveTo(0,0);
pDC->LineTo(320,0);
pDC->LineTo(320,240);
pDC->LineTo(0,240);
pDC->LineTo(0,0);*/
//根據(jù)輸入進(jìn)行繪線
for(int i=0;i<m_sockRecv.myarray.GetSize();i++)
{
if(m_sockRecv.myarray[i].x<0){
IsDrawing=false;
}
else{
if(IsDrawing){
pDC->LineTo(m_sockRecv.myarray[i].x,m_sockRecv.myarray[i].y);
}
else{
pDC->MoveTo(m_sockRecv.myarray[i].x,m_sockRecv.myarray[i].y);
}
IsDrawing=true;
}
}
////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////
// CUDPView printing
BOOL CUDPView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CUDPView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CUDPView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CUDPView diagnostics
#ifdef _DEBUG
void CUDPView::AssertValid() const
{
CView::AssertValid();
}
void CUDPView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CUDPDoc* CUDPView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CUDPDoc)));
return (CUDPDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CUDPView message handlers
void CUDPView::OnClearscreen()
{
// TODO: Add your command handler code here
IsClearnScreen=true;
//發(fā)送清屏命令
//ARM端用于接收的端口比用于發(fā)送的端口小一
int iSend=m_sockRecv.SendTo((int*)&IsClearnScreen,sizeof(int),m_sockRecv.uPort-1,m_sockRecv.szIP,0);
m_sockRecv.myarray.RemoveAll();//刪除數(shù)組中所有點
Invalidate();
IsClearnScreen=false;
/////////////////////////////////////////////////////////////////
}
void CUDPView::OnShowIPDialog()
{
// TODO: Add your command handler code here
SetIPDialog.DoModal();
int test=1;
int iSend=m_sockRecv.SendTo((int*)&test,sizeof(int),4998,SetIPDialog.m_IP,0);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -