📄 test7view.cpp
字号:
// test7View.cpp : implementation of the CTest7View class
//
#include "stdafx.h"
#include "test7.h"
#include "test7Doc.h"
#include "test7View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTest7View
IMPLEMENT_DYNCREATE(CTest7View, CView)
BEGIN_MESSAGE_MAP(CTest7View, CView)
//{{AFX_MSG_MAP(CTest7View)
ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
ON_WM_LBUTTONDOWN()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CTest7View construction/destruction
CTest7View::CTest7View()
{
// TODO: add construction code here
point1.x=point1.y=0;
}
CTest7View::~CTest7View()
{
}
BOOL CTest7View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CTest7View drawing
void CTest7View::OnDraw(CDC* pDC)
{
CTest7Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CTest7View printing
BOOL CTest7View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CTest7View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CTest7View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CTest7View diagnostics
#ifdef _DEBUG
void CTest7View::AssertValid() const
{
CView::AssertValid();
}
void CTest7View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CTest7Doc* CTest7View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTest7Doc)));
return (CTest7Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CTest7View message handlers
void CTest7View::OnEditPaste()
{
// TODO: Add your command handler code here
char Text[100];
CClientDC dc(this);
if(::OpenClipboard(m_hWnd))
{
HANDLE hData=::GetClipboardData(CF_TEXT);
if(hData!=NULL)
{
LPSTR pData = (LPSTR)::GlobalLock (hData);
if(::lstrlen(pData)<100)
::lstrcpy(Text,pData);
::GlobalUnlock(hData);
}
dc.TextOut(point1.x,point1.y,Text);
::CloseClipboard();
}
}
void CTest7View::OnEditCopy()
{
// TODO: Add your command handler code here
char szText[]= "Hello!My name is Pengyifeng!";
if (::OpenClipboard (m_hWnd))
{
::EmptyClipboard ();
HANDLE hData= ::GlobalAlloc(GMEM_MOVEABLE, ::lstrlen(szText) + 1);
LPSTR pData = (LPSTR)::GlobalLock (hData);
::lstrcpy (pData, szText);
::GlobalUnlock (hData);
::SetClipboardData (CF_TEXT, hData);
::CloseClipboard ();
}
}
void CTest7View::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
point1.x=point.x;
point1.y=point.y;
CView::OnLButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -