📄 textview.cpp
字号:
// TextView.cpp : implementation of the CTextView class
//
#include "stdafx.h"
#include "Text.h"
#include "TextDoc.h"
#include "TextView.h"
#include "Dialog1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTextView
IMPLEMENT_DYNCREATE(CTextView, CView)
BEGIN_MESSAGE_MAP(CTextView, CView)
//{{AFX_MSG_MAP(CTextView)
ON_WM_CHAR()
ON_WM_LBUTTONDOWN()
ON_WM_CANCELMODE()
ON_WM_MOUSEMOVE()
ON_WM_CAPTURECHANGED()
ON_COMMAND(ID_Add, OnAdd)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CTextView construction/destruction
CTextView::CTextView()
{
// TODO: add construction code here
}
CTextView::~CTextView()
{
}
BOOL CTextView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CTextView drawing
void CTextView::OnDraw(CDC* pDC)
{ // TODO: add draw code for native data here
CTextDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
list.Draw(pDC);
}
/////////////////////////////////////////////////////////////////////////////
// CTextView printing
BOOL CTextView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CTextView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CTextView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CTextView diagnostics
#ifdef _DEBUG
void CTextView::AssertValid() const
{
CView::AssertValid();
}
void CTextView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CTextDoc* CTextView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTextDoc)));
return (CTextDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTextView message handlers
void CTextView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CTextDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Text+=nChar;
CView::OnChar(nChar, nRepCnt, nFlags);
Invalidate();
}
void CTextView::OnLButtonDown(UINT nFlags, CPoint point)
{
/* // TODO: Add your message handler code here and/or call default
CPoint cpoint;
cpoint=point;
CDialog1 Dialog;
Dialog.DoModal();
CString str;
str=Dialog.m_str;
pDC->Rectangle(cpoint.x,cpoint.y,cpoint.x+30,cpoint.y+30);
pDC->TextOut(cpoint.x+5,cpoint.y+5,str);
*/ CDC *pDC;
pDC=GetDC();
Dialog1 Dialog;
Dialog.DoModal();
str=Dialog.m_str;
list.Add(str);
list.Draw(pDC);
CView::OnLButtonDown(nFlags, point);
}
void CTextView::OnCancelMode()
{
CView::OnCancelMode();
// TODO: Add your message handler code here
}
void CTextView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//Invalidate();
/* CDC *pDC;
pDC=GetDC();
CString str;
str.Format("[%d,%d]",point.x,point.y);
pDC->TextOut(10,10,str);
*/ CView::OnMouseMove(nFlags, point);
}
void CTextView::OnCaptureChanged(CWnd *pWnd)
{
// TODO: Add your message handler code here
CView::OnCaptureChanged(pWnd);
}
void CTextView::OnAdd()
{
// TODO: Add your command handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -