⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 anonview.cpp

📁 这些源代码
💻 CPP
字号:
// AnonView.cpp : implementation of the CAnonView class
//

#include "stdafx.h"
#include "Anon.h"

#include "AnonDoc.h"
#include "AnonView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAnonView

extern int g_hPipe[2];
extern bool	g_bReceive;

IMPLEMENT_DYNCREATE(CAnonView, CEditView)

BEGIN_MESSAGE_MAP(CAnonView, CEditView)
	//{{AFX_MSG_MAP(CAnonView)
	ON_WM_KEYDOWN()
	ON_WM_KEYUP()
	ON_WM_CHAR()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CEditView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CEditView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAnonView construction/destruction

CAnonView::CAnonView()
{
	// TODO: add construction code here
	if (g_bReceive)
		AfxBeginThread (ReadFromPipe, this);
}

CAnonView::~CAnonView()
{
}

BOOL CAnonView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	BOOL bPreCreated = CEditView::PreCreateWindow(cs);
	cs.style &= ~(ES_AUTOHSCROLL|WS_HSCROLL);	// Enable word-wrapping

	return bPreCreated;
}

/////////////////////////////////////////////////////////////////////////////
// CAnonView drawing

void CAnonView::OnDraw(CDC* pDC)
{
	CAnonDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CAnonView printing

BOOL CAnonView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default CEditView preparation
	return CEditView::OnPreparePrinting(pInfo);
}

void CAnonView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
	// Default CEditView begin printing.
	CEditView::OnBeginPrinting(pDC, pInfo);
}

void CAnonView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
	// Default CEditView end printing
	CEditView::OnEndPrinting(pDC, pInfo);
}

/////////////////////////////////////////////////////////////////////////////
// CAnonView diagnostics

#ifdef _DEBUG
void CAnonView::AssertValid() const
{
	CEditView::AssertValid();
}

void CAnonView::Dump(CDumpContext& dc) const
{
	CEditView::Dump(dc);
}

CAnonDoc* CAnonView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CAnonDoc)));
	return (CAnonDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CAnonView message handlers

void CAnonView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	WriteToPipe (WM_KEYDOWN, nChar, nRepCnt, nFlags);
	CEditView::OnKeyDown(nChar, nRepCnt, nFlags);
}

void CAnonView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	WriteToPipe (WM_KEYUP, nChar, nRepCnt, nFlags);
	CEditView::OnKeyUp(nChar, nRepCnt, nFlags);
}

void CAnonView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	WriteToPipe (WM_CHAR, nChar, nRepCnt, nFlags);
	CEditView::OnChar(nChar, nRepCnt, nFlags);
}

void CAnonView::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	WriteToPipe (WM_SYSKEYDOWN, nChar, nRepCnt, nFlags);
	CEditView::OnSysKeyDown(nChar, nRepCnt, nFlags);
}

void CAnonView::OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	WriteToPipe (WM_SYSKEYUP, nChar, nRepCnt, nFlags);
	CEditView::OnSysKeyUp(nChar, nRepCnt, nFlags);
}

void CAnonView::OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	WriteToPipe (WM_SYSCHAR, nChar, nRepCnt, nFlags);
	CEditView::OnSysChar(nChar, nRepCnt, nFlags);
}

void CAnonView::WriteToPipe(UINT message, UINT nChar, UINT nRepCnt, UINT nFlags)
{
	if (g_bReceive)
		return;
	MSG msg;
	msg.message = message;
	msg.lParam = MAKELONG (nRepCnt, nFlags);
	msg.wParam = nChar;
	msg.time = time (0);
	msg.hwnd = NULL;
	write (g_hPipe[1], (char *) &msg, sizeof (MSG));
}

UINT CAnonView::ReadFromPipe(void *lParam)
{
	CAnonView *pThis = (CAnonView *) lParam;
	while (1)
	{
		MSG msg;
		if (read (g_hPipe[0], &msg, sizeof (MSG)) < 1)
			break;
		pThis->SendMessage (msg.message, msg.wParam, msg.lParam);
	}
	return (0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -