📄 menutestview.cpp
字号:
// MenuTestView.cpp : implementation of the CMenuTestView class
//
#include "stdafx.h"
#include "MenuTest.h"
#include "MenuTestDoc.h"
#include "MenuTestView.h"
#include "MainFrm.h"
#include "DlgEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMenuTestView
IMPLEMENT_DYNCREATE(CMenuTestView, CView)
BEGIN_MESSAGE_MAP(CMenuTestView, CView)
//{{AFX_MSG_MAP(CMenuTestView)
ON_COMMAND(ID_DRAW_RECT, OnDrawRect)
ON_COMMAND(ID_DRAW_CIRCLE, OnDrawCircle)
ON_UPDATE_COMMAND_UI(ID_DRAW_RECT, OnUpdateDrawRect)
ON_COMMAND(ID_DRAW_ENABLE, OnDrawEnable)
ON_COMMAND(ID_DRAW_DISABLE, OnDrawDisable)
ON_UPDATE_COMMAND_UI(ID_DRAW_DISABLE, OnUpdateDrawDisable)
ON_UPDATE_COMMAND_UI(ID_DRAW_ENABLE, OnUpdateDrawEnable)
ON_COMMAND(ID_EDIT_RECT, OnEditRect)
ON_COMMAND(ID_EDIT_CIRCLE, OnEditCircle)
ON_COMMAND(ID_DRAW_LINE, OnDrawLine)
ON_WM_MOUSEMOVE()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CMenuTestView construction/destruction
CMenuTestView::CMenuTestView()
{
// TODO: add construction code here
m_Enable = TRUE;
}
CMenuTestView::~CMenuTestView()
{
}
BOOL CMenuTestView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMenuTestView drawing
void CMenuTestView::OnDraw(CDC* pDC)
{
CMenuTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMenuTestView printing
BOOL CMenuTestView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMenuTestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMenuTestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMenuTestView diagnostics
#ifdef _DEBUG
void CMenuTestView::AssertValid() const
{
CView::AssertValid();
}
void CMenuTestView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMenuTestDoc* CMenuTestView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMenuTestDoc)));
return (CMenuTestDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMenuTestView message handlers
void CMenuTestView::OnDrawRect()
{
// TODO: Add your command handler code here
CMainFrame *pMainFrame = (CMainFrame *) AfxGetApp()->GetMainWnd();
CClientDC dc(this);
dc.Rectangle(pMainFrame->m_nRectLeft,pMainFrame->m_nRectTop,
pMainFrame->m_nRectRight,pMainFrame->m_nRectBottom);
}
void CMenuTestView::OnDrawCircle()
{
// TODO: Add your command handler code here
CMainFrame *pMainFrame = (CMainFrame *) AfxGetApp()->GetMainWnd();
CClientDC dc(this);
dc.Ellipse(pMainFrame->m_nCircleLeft,pMainFrame->m_nCircleTop,
pMainFrame->m_nCircleRight,pMainFrame->m_nCircleBottom);
}
void CMenuTestView::OnDrawEnable()
{
// TODO: Add your command handler code here
m_Enable = TRUE;
}
void CMenuTestView::OnDrawDisable()
{
// TODO: Add your command handler code here
m_Enable = FALSE;
}
void CMenuTestView::OnUpdateDrawRect(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(m_Enable);
}
void CMenuTestView::OnUpdateDrawDisable(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_Enable ? 0:1);
}
void CMenuTestView::OnUpdateDrawEnable(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_Enable ? 1:0);
}
void CMenuTestView::OnEditRect()
{
// TODO: Add your command handler code here
CDlgEdit dlg(1);
dlg.DoModal();
}
void CMenuTestView::OnEditCircle()
{
// TODO: Add your command handler code here
CDlgEdit dlg(2);
dlg.DoModal();
}
void CMenuTestView::OnDrawLine()
{
// TODO: Add your command handler code here
CMainFrame *pMainFrame = (CMainFrame *) AfxGetApp()->GetMainWnd();
CClientDC dc(this);
dc.MoveTo(20, 20);
dc.LineTo(200, 200);
}
void CMenuTestView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
char PositionString[20];
CMainFrame *MainFrame=(CMainFrame *) AfxGetMainWnd();
sprintf(PositionString,"X:%d",point.x);
MainFrame->m_wndStatusBar.SetPaneText(1,PositionString);
sprintf(PositionString,"y:%d",point.y);
MainFrame->m_wndStatusBar.SetPaneText(2,PositionString);
CView::OnMouseMove(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -