【VC开源代码栏目提醒】:网学会员为广大网友收集整理了,Thread_12View.cpp,希望对大家有所帮助!
// Thread_12View.cpp : implementation of the CThread_12View class
//
#include "stdafx.h"
#include "Thread_12.h"
#include "Thread_12Doc.h"
#include "Thread_12View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CThread_12View
IMPLEMENT_DYNCREATE(CThread_12View, CView)
BEGIN_MESSAGE_MAP(CThread_12View, CView)
//{{AFX_MSG_MAP(CThread_12View)
ON_COMMAND(IDM_RECEIVE, OnReceive)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CThread_12View construction/destruction
CThread_12View::CThread_12View()
{
// TODO: add construction code here
}
CThread_12View::~CThread_12View()
{
}
BOOL CThread_12View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CThread_12View drawing
void CThread_12View::OnDraw(CDC* pDC)
{
CThread_12Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CThread_12View printing
BOOL CThread_12View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CThread_12View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CThread_12View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CThread_12View diagnostics
#ifdef _DEBUG
void CThread_12View::AssertValid() const
{
CView::AssertValid();
}
void CThread_12View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CThread_12Doc* CThread_12View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CThread_12Doc)));
return (CThread_12Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CThread_12View message handlers
void CThread_12View::OnReceive()
{
// TODO: Add your command handler code here
HANDLE mailslot;
mailslot=CreateMailslot("\\\\.\\mailslot\\mymailslot",0,MAILSLOT_WAIT_FOREVER,NULL);
//创建邮槽
if(INVALID_HANDLE_VALUE==mailslot)
{
MessageBox("Create fail");
CloseHandle(mailslot);
return;
}
char buf[100];
DWORD dwread;
ReadFile(mailslot,buf,100,&dwread,NULL); //读文件
MessageBox(buf);
CloseHandle(mailslot);
}