?? mysocket.cpp
字號:
// MySocket.cpp : implementation file
//
#include "stdafx.h"
#include "UDP.h"
#include "MySocket.h"
#include "MainFrm.h"
#include "UDPView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// MySocket
MySocket::MySocket()
{
//第一個數據用于建立連接,所以接收不到,在此賦值
scrpoint.x=-1;
scrpoint.y=0;
myarray.Add(scrpoint);
}
MySocket::~MySocket()
{
}
// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(MySocket, CAsyncSocket)
//{{AFX_MSG_MAP(MySocket)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif // 0
/////////////////////////////////////////////////////////////////////////////
// MySocket member functions
void MySocket::OnReceive(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
//接收UDP數據
int iRecv=ReceiveFrom((struct mpoint*)&scrpoint,10,szIP,uPort,0);
myarray.Add(scrpoint);//將點保存到數組中
CString mystatus="xxxxxx yyyyyy";
mystatus.Format("x=%d y=%d",scrpoint.x,scrpoint.y);//轉換成字符串
CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();//得到主窗口指針
if(scrpoint.x!=-1){
pFrame->m_wndStatusBar.SetPaneText(0,mystatus);//在狀態欄上顯示
}
CUDPView* pView=( CUDPView*) pFrame->GetActiveView();//得到活動視類指針
pView->Invalidate();//更新屏幕
/////////////////////////////////////////////////////////////////
CAsyncSocket::OnReceive(nErrorCode);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -