📄 menuview.cpp
字号:
// MenuView.cpp : implementation of the CMenuView class
//
#include "stdafx.h"
#include "Menu.h"
#include "MenuDoc.h"
#include "MenuView.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMenuView
IMPLEMENT_DYNCREATE(CMenuView, CView)
BEGIN_MESSAGE_MAP(CMenuView, CView)
ON_WM_CONTEXTMENU()
//{{AFX_MSG_MAP(CMenuView)
ON_COMMAND(IDM_TEST, OnTest)
ON_WM_RBUTTONDOWN()
ON_COMMAND(IDM_SHOW, OnShow)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CMenuView construction/destruction
CMenuView::CMenuView()
{
// TODO: add construction code here
}
CMenuView::~CMenuView()
{
}
BOOL CMenuView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMenuView drawing
void CMenuView::OnDraw(CDC* pDC)
{
CMenuDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMenuView printing
BOOL CMenuView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMenuView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMenuView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMenuView diagnostics
#ifdef _DEBUG
void CMenuView::AssertValid() const
{
CView::AssertValid();
}
void CMenuView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMenuDoc* CMenuView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMenuDoc)));
return (CMenuDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMenuView message handlers
//DEL void CMenuView::OnTest()
//DEL {
//DEL // TODO: Add your command handler code here
//DEL MessageBox("View Clicked");
//DEL
//DEL }
void CMenuView::OnTest()
{
// TODO: Add your command handler code here
}
void CMenuView::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_MENU_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); }
}
void CMenuView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMenu menu;
menu.LoadMenu(IDR_MENU1);
CMenu* pPopup = menu.GetSubMenu(0);
ClientToScreen(&point);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,GetParent());
CView::OnRButtonDown(nFlags, point);
}
void CMenuView::OnShow()
{
// TODO: Add your command handler code here
MessageBox("View show");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -