⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dymenu~2.cpp

📁 visual c++ 时尚编程百例 全部源代码
💻 CPP
字号:
// DyMenuView.cpp : implementation of the CDyMenuView class
//

#include "stdafx.h"
#include "DyMenu.h"

#include "DyMenuDoc.h"
#include "DyMenuView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDyMenuView

IMPLEMENT_DYNCREATE(CDyMenuView, CView)

BEGIN_MESSAGE_MAP(CDyMenuView, CView)
	//{{AFX_MSG_MAP(CDyMenuView)
	ON_COMMAND(ID_STANDARD, OnStandard)
	ON_COMMAND(ID_EXPAND, OnExpand)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CDyMenuView construction/destruction

CDyMenuView::CDyMenuView()
{
	// TODO: add construction code here

}

CDyMenuView::~CDyMenuView()
{
}

BOOL CDyMenuView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CDyMenuView drawing

void CDyMenuView::OnDraw(CDC* pDC)
{
	CDyMenuDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CDyMenuView printing

BOOL CDyMenuView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CDyMenuView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CDyMenuView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CDyMenuView diagnostics

#ifdef _DEBUG
void CDyMenuView::AssertValid() const
{
	CView::AssertValid();
}

void CDyMenuView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CDyMenuDoc* CDyMenuView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDyMenuDoc)));
	return (CDyMenuDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDyMenuView message handlers

void CDyMenuView::OnStandard() 
{
	CMenu*pAddinMenu,*pTopMenu;
	pTopMenu=AfxGetMainWnd()->GetMenu();
	pAddinMenu=pTopMenu->GetSubMenu(5);
	int i=pAddinMenu->GetMenuItemCount();
	if(5==i)
	{
		i--;
		while(i>1)
		{
			pAddinMenu->RemoveMenu(i,MF_BYPOSITION);
			i--;
		}
	}
	else
	{
		pAddinMenu->DeleteMenu(3,MF_BYPOSITION);
		pAddinMenu->RemoveMenu(2,MF_BYPOSITION);
	}
}
	// TODO: Add your command handler code here
	


void CDyMenuView::OnExpand() 
{
	CMenu *pAddinMenu,*pTopMenu;
	pTopMenu=AfxGetMainWnd()->GetMenu();
	pAddinMenu=pTopMenu->GetSubMenu(5);
	ASSERT(pAddinMenu!=NULL);
	pAddinMenu->AppendMenu(MF_SEPARATOR);
	CString MenuName;
	for(int i=0;i<2;i++)
	{
		MenuName.LoadString(IDS_BLUE+i);
		pAddinMenu->AppendMenu(MF_STRING,IDS_BLUE+i,MenuName);
	}
	
	// TODO: Add your command handler code here
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -