📄 mymenuview.cpp
字号:
// MymenuView.cpp : implementation of the CMymenuView class
//
#include "stdafx.h"
#include "Mymenu.h"
#include "MymenuDoc.h"
#include "MymenuView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMymenuView
IMPLEMENT_DYNCREATE(CMymenuView, CView)
BEGIN_MESSAGE_MAP(CMymenuView, CView)
//{{AFX_MSG_MAP(CMymenuView)
ON_WM_CONTEXTMENU()
ON_COMMAND(IDC_BEAR, OnBear)
ON_COMMAND(IDC_TIGER, OnTiger)
ON_COMMAND(IDR_LION, OnLion)
ON_WM_SETCURSOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMymenuView construction/destruction
CMymenuView::CMymenuView()
{
// TODO: add construction code here
location = CPoint(0,0);
}
CMymenuView::~CMymenuView()
{
}
BOOL CMymenuView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMymenuView drawing
void CMymenuView::OnDraw(CDC* pDC)
{
CMymenuDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CPen mypen(PS_SOLID,3,RGB(255,0,0));
CPen* oldpen,ppen;
ppen.CreatePen(PS_SOLID,1,RGB(0,255,0));
CBrush myb(RGB(255,0,0));
CBrush *oldb;
CFont myfont,*oldfont;
myfont.CreateFont(50,0,0,0,0,0,0,0,0,0,0,0,0,"Arial");
oldfont = pDC->SelectObject(&myfont);
// oldpen = pDC->SelectObject(&mypen);
// pDC->SetBkColor(TRANSPARENT);
pDC->SetTextColor(RGB(255,0,0));
// pDC->SelectStockObject(DKGRAY_BRUSH);
pDC->TextOut(location.x,location.y,meg);
pDC->SelectObject(oldfont);
}
/////////////////////////////////////////////////////////////////////////////
// CMymenuView diagnostics
#ifdef _DEBUG
void CMymenuView::AssertValid() const
{
CView::AssertValid();
}
void CMymenuView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMymenuDoc* CMymenuView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMymenuDoc)));
return (CMymenuDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMymenuView message handlers
void CMymenuView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CMenu mymenu;
location = point;
ScreenToClient(&location);
mymenu.LoadMenu(IDR_MYMENU);
CMenu *popM = mymenu.GetSubMenu(0);
popM->TrackPopupMenu(TPM_LEFTALIGN,point.x,point.y,this);
}
void CMymenuView::OnBear()
{
// TODO: Add your command handler code here
meg = "this is a bear";
AfxMessageBox("bear");
InvalidateRect(NULL);
}
void CMymenuView::OnTiger()
{
// TODO: Add your command handler code here
AfxMessageBox("tiger");
meg = "this is a tiger";
InvalidateRect(NULL);
}
void CMymenuView::OnLion()
{
// TODO: Add your command handler code here
AfxMessageBox("lion");
meg = "this is a lion";
InvalidateRect(NULL);
}
BOOL CMymenuView::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
// TODO: Add your message handler code here and/or call default
CWinApp* myapp = AfxGetApp();
HICON myicon = myapp->LoadStandardCursor(IDC_HELP);
SetCursor(myicon);
return TRUE;
// return CView::OnSetCursor(pWnd, nHitTest, message);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -