?? receiverview.cpp
字號:
// ReceiverView.cpp : implementation of the CReceiverView class
//
#include "stdafx.h"
#include "Receiver.h"
#include "ReceiverDoc.h"
#include "ReceiverView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define PORT 2000
/////////////////////////////////////////////////////////////////////////////
// CReceiverView
IMPLEMENT_DYNCREATE(CReceiverView, CFormView)
BEGIN_MESSAGE_MAP(CReceiverView, CFormView)
//{{AFX_MSG_MAP(CReceiverView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CReceiverView construction/destruction
CReceiverView::CReceiverView()
: CFormView(CReceiverView::IDD)
{
//{{AFX_DATA_INIT(CReceiverView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CReceiverView::~CReceiverView()
{
}
void CReceiverView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CReceiverView)
DDX_Control(pDX, IDC_DATA, m_listData);
//}}AFX_DATA_MAP
}
BOOL CReceiverView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CReceiverView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
// 創建套接字
m_pSocket = new CListeningSocket();
if (m_pSocket->Create(PORT, SOCK_STREAM) == FALSE)
{
AfxMessageBox("創建套接字失敗!");
m_pSocket->Close();
return;
}
// 偵聽成功,等待連接請求
if (m_pSocket->Listen(1) == FALSE)
{
if (m_pSocket->GetLastError() == WSAEWOULDBLOCK)
{
AfxMessageBox("網絡偵聽失敗!");
m_pSocket->Close();
return;
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CReceiverView printing
BOOL CReceiverView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CReceiverView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CReceiverView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CReceiverView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CReceiverView diagnostics
#ifdef _DEBUG
void CReceiverView::AssertValid() const
{
CFormView::AssertValid();
}
void CReceiverView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CReceiverDoc* CReceiverView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CReceiverDoc)));
return (CReceiverDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CReceiverView message handlers
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -