【VC开源代码栏目提醒】:网学会员鉴于大家对VC开源代码十分关注,论文会员在此为大家搜集整理了“CMenu_11View.cpp”一文,供大家参考学习
// CMenu_11View.cpp : implementation of the CCMenu_11View class
//
#include "stdafx.h"
#include "CMenu_11.h"
#include "CMenu_11Doc.h"
#include "CMenu_11View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCMenu_11View
IMPLEMENT_DYNCREATE(CCMenu_11View, CView)
BEGIN_MESSAGE_MAP(CCMenu_11View, CView)
//{{AFX_MSG_MAP(CCMenu_11View)
ON_WM_CHAR()
ON_COMMAND(IDM_SHOW1, OnShow1)
ON_COMMAND(IDM_SHOW2, OnShow2)
ON_COMMAND(IDM_SHOW3, OnShow3)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CCMenu_11View construction/destruction
CCMenu_11View::CCMenu_11View()
{
// TODO: add construction code here
m_nIndex=-1;
m_strLine="";
}
CCMenu_11View::~CCMenu_11View()
{
}
BOOL CCMenu_11View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCMenu_11View drawing
void CCMenu_11View::OnDraw(CDC* pDC)
{
CCMenu_11Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCMenu_11View printing
BOOL CCMenu_11View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCMenu_11View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCMenu_11View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCMenu_11View diagnostics
#ifdef _DEBUG
void CCMenu_11View::AssertValid() const
{
CView::AssertValid();
}
void CCMenu_11View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCMenu_11Doc* CCMenu_11View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCMenu_11Doc)));
return (CCMenu_11Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCMenu_11View message handlers
void CCMenu_11View::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
if(0x0d==nChar)
{
if(0==++m_nIndex)
{
m_menu.CreatePopupMenu();
GetParent()->GetMenu()->AppendMenu(MF_POPUP,
(UINT)m_menu.m_hMenu,"Show"); //菜单属于框架类
GetParent()->DrawMenuBar();
}
m_menu.AppendMenu(MF_STRING,IDM_SHOW1+m_nIndex,m_strLine.Left(m_strLine.Find(" ")));
m_strArray.Add(m_strLine);
m_strLine.Empty();
Invalidate();
}
else
{
m_strLine+=nChar;
dc.TextOut(0,0,m_strLine);
}
CView::OnChar(nChar, nRepCnt, nFlags);
}
void CCMenu_11View::OnShow1()
{
// TODO: Add your command handler code here
CClientDC dc(this);
dc.TextOut(0,0,m_strArray.GetAt(0));
}
void CCMenu_11View::OnShow2()
{
// TODO: Add your command handler code here
CClientDC dc(this);
dc.TextOut(0,0,m_strArray.GetAt(1));
}
void CCMenu_11View::OnShow3()
{
// TODO: Add your command handler code here
CClientDC dc(this);
dc.TextOut(0,0,m_strArray.GetAt(2));
}
上一篇:
CMenu_11Doc.cpp
下一篇:
高职院理实一体信息技术论文