ex3_1view.cpp
来自「mfc实验例题也是高教得配套资料 刚找到得 这部分应该是自学的内容」· C++ 代码 · 共 120 行
CPP
120 行
// Ex3_1View.cpp : implementation of the CEx3_1View class
//
#include "stdafx.h"
#include "Ex3_1.h"
#include "Ex3_1Doc.h"
#include "Ex3_1View.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx3_1View
IMPLEMENT_DYNCREATE(CEx3_1View, CView)
BEGIN_MESSAGE_MAP(CEx3_1View, CView)
ON_WM_CONTEXTMENU()
//{{AFX_MSG_MAP(CEx3_1View)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CEx3_1View construction/destruction
CEx3_1View::CEx3_1View()
{
// TODO: add construction code here
IsFirst=TRUE;
}
CEx3_1View::~CEx3_1View()
{
}
BOOL CEx3_1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEx3_1View drawing
void CEx3_1View::OnDraw(CDC* pDC)
{
CEx3_1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pDC->TextOut(0,0,pDoc->StrName);//pDoc->m_pStu->m_sName);
}
/////////////////////////////////////////////////////////////////////////////
// CEx3_1View diagnostics
#ifdef _DEBUG
void CEx3_1View::AssertValid() const
{
CView::AssertValid();
}
void CEx3_1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CEx3_1Doc* CEx3_1View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx3_1Doc)));
return (CEx3_1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx3_1View message handlers
void CEx3_1View::OnContextMenu(CWnd*, CPoint point)
{
// CG: This block was added by the Pop-up Menu component { if (point.x == -1 && point.y == -1){ //keystroke invocation CRect rect; GetClientRect(rect); ClientToScreen(rect); point = rect.TopLeft(); point.Offset(5, 5); } CMenu menu; VERIFY(menu.LoadMenu(CG_IDR_POPUP_EX3_1_VIEW)); CMenu* pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); }
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?