现在的位置: 首页 > 综合 > 正文

VS2010学习笔记–Ribbon界面

2014年07月25日 ⁄ 综合 ⁄ 共 2136字 ⁄ 字号 评论关闭

使用功能区界面风格

#include "stdafx.h"
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
// ATL 项目中进行定义,并允许与该项目共享文档代码。
#ifndef SHARED_HANDLERS
#include "HelloRibbon.h"
#endif

#include "HelloRibbonDoc.h"
#include "HelloRibbonView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CHelloRibbonView

IMPLEMENT_DYNCREATE(CHelloRibbonView, CView)

BEGIN_MESSAGE_MAP(CHelloRibbonView, CView)
	// 标准打印命令
	ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CHelloRibbonView::OnFilePrintPreview)
	ON_WM_CONTEXTMENU()
	ON_WM_RBUTTONUP()
	ON_COMMAND(ID_BUTTON3, &CHelloRibbonView::OnButton3)
END_MESSAGE_MAP()

// CHelloRibbonView 构造/析构

CHelloRibbonView::CHelloRibbonView()
{
	// TODO: 在此处添加构造代码

}

CHelloRibbonView::~CHelloRibbonView()
{
}

BOOL CHelloRibbonView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: 在此处通过修改
	//  CREATESTRUCT cs 来修改窗口类或样式

	return CView::PreCreateWindow(cs);
}

// CHelloRibbonView 绘制

void CHelloRibbonView::OnDraw(CDC* /*pDC*/)
{
	CHelloRibbonDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: 在此处为本机数据添加绘制代码
}


// CHelloRibbonView 打印


void CHelloRibbonView::OnFilePrintPreview()
{
#ifndef SHARED_HANDLERS
	AFXPrintPreview(this);
#endif
}

BOOL CHelloRibbonView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// 默认准备
	return DoPreparePrinting(pInfo);
}

void CHelloRibbonView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 添加额外的打印前进行的初始化过程
}

void CHelloRibbonView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: 添加打印后进行的清理过程
}

void CHelloRibbonView::OnRButtonUp(UINT /* nFlags */, CPoint point)
{
	ClientToScreen(&point);
	OnContextMenu(this, point);
}

void CHelloRibbonView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
{
#ifndef SHARED_HANDLERS
	theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
#endif
}


// CHelloRibbonView 诊断

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

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

CHelloRibbonDoc* CHelloRibbonView::GetDocument() const // 非调试版本是内联的
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHelloRibbonDoc)));
	return (CHelloRibbonDoc*)m_pDocument;
}
#endif //_DEBUG


// CHelloRibbonView 消息处理程序


void CHelloRibbonView::OnButton3()
{
		AfxMessageBox(_T("ZTX,我爱你!O(∩_∩)O~"));
}

 

抱歉!评论已关闭.