BCG ribbon简单使用(1)

261 篇文章 10 订阅

1、根据新建向导创建一个项目,然后清空MainFrm某些内容,留下简单的几个方法:

头文件中剩余:

// MainFrm.h : interface of the CMainFrame class
//


#pragma once

class CMainFrame : public CBCGPMDIFrameWnd
{
    DECLARE_DYNAMIC(CMainFrame)
public:
    CMainFrame();

// Attributes
public:

// Operations
public:

// Overrides
public:
    virtual BOOL PreCreateWindow(CREATESTRUCT& cs);

// Implementation
public:
    virtual ~CMainFrame();
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext& dc) const;
#endif

protected:  // control bar embedded members
    CBCGPStatusBar            m_wndStatusBar;
    CBCGPMenuBar            m_wndMenuBar;
    CBCGPToolBar            m_wndToolBar;
    CBCGPRibbonDialogBar    m_wndPane;

// Generated message map functions
protected:
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    
    afx_msg void OnClose();
    DECLARE_MESSAGE_MAP()
};
 

2、实现文件中剩余:

// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "ribbonSample1.h"

#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CMainFrame

IMPLEMENT_DYNAMIC(CMainFrame, CBCGPMDIFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CBCGPMDIFrameWnd)
    ON_WM_CREATE()
    ON_WM_CLOSE()
END_MESSAGE_MAP()

static UINT indicators[] =
{
    ID_SEPARATOR,           // status line indicator
    ID_INDICATOR_CAPS,
    ID_INDICATOR_NUM,
    ID_INDICATOR_SCRL,
};

// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
    // TODO: add member initialization code here
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CBCGPMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
    if( !CBCGPMDIFrameWnd::PreCreateWindow(cs) )
        return FALSE;
    // TODO: Modify the Window class or styles here by modifying
    //  the CREATESTRUCT cs

    return TRUE;
}


// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
    CBCGPMDIFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
    CBCGPMDIFrameWnd::Dump(dc);
}

#endif //_DEBUG


// CMainFrame message handlers

void CMainFrame::OnClose() 
{
    SaveMDIState(theApp.GetRegSectionPath());
    CBCGPMDIFrameWnd::OnClose();
}

接下来向方法里面添加内容:


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CBCGPMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    //这里清空整个菜单
    CBCGPToolBar::EnableQuickCustomization();
    if (!m_wndMenuBar.Create(this))
    {
        TRACE0("Failed to create menubar\n");
        return -1;      // fail to create
    }

    return ;
}

效果如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值