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

📄 keydemoview.cpp

📁 键盘输入程序,接收用户输入,并在窗口显示
💻 CPP
字号:
// KeyDemoView.cpp : implementation of the CKeyDemoView class
//

#include "stdafx.h"
#include "KeyDemo.h"

#include "KeyDemoDoc.h"
#include "KeyDemoView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CKeyDemoView

IMPLEMENT_DYNCREATE(CKeyDemoView, CView)

BEGIN_MESSAGE_MAP(CKeyDemoView, CView)
	//{{AFX_MSG_MAP(CKeyDemoView)
    ON_WM_CHAR()
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CKeyDemoView construction/destruction

CKeyDemoView::CKeyDemoView()
{
	// TODO: add construction code here

}

CKeyDemoView::~CKeyDemoView()
{
}

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

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CKeyDemoView drawing

void CKeyDemoView::OnDraw(CDC* pDC)
{
	CKeyDemoDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	pDC->TextOut(0,0,pDoc->m_text);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CKeyDemoView printing

BOOL CKeyDemoView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CKeyDemoView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CKeyDemoView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CKeyDemoView diagnostics

#ifdef _DEBUG
void CKeyDemoView::AssertValid() const
{
	CView::AssertValid();
}

void CKeyDemoView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CKeyDemoView message handlers

void CKeyDemoView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
	if(nChar<32)
	{
		::MessageBeep(MB_OK);
		return;
	}
	CClientDC ClientDc(this);
	CKeyDemoDoc* pDoc=GetDocument();
	pDoc->m_text+=nChar;
	ClientDc.TextOut(0,0,pDoc->m_text);
	CView::OnChar(nChar, nRepCnt, nFlags);
}

⌨️ 快捷键说明

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