码迷,mamicode.com
首页 > 移动开发 > 详细

禁用CMFCRibbonApplicationButton的单击和双击事件

时间:2016-09-14 18:38:25      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

为了禁用CMFCRibbonApplicationButton的单击和双击事件,我重载了CMFCRibbonApplicationButton如下:

1. MyRibbonApplicationButton.h文件内容:

#pragma once

class CMyRibbonApplicationButton :
public CMFCRibbonApplicationButton
{
public:
CMyRibbonApplicationButton();
//~CMyRibbonApplicationButton();

protected:
virtual void OnLButtonDown(CPoint point);
virtual void OnLButtonDblClk(CPoint point);
};

 

2. MyRibbonApplicationButton.cpp文件内容:

 

#include "stdafx.h"
#include "MyRibbonApplicationButton.h"


CMyRibbonApplicationButton::CMyRibbonApplicationButton()
{
}

//CMyRibbonApplicationButton::~CMyRibbonApplicationButton()
//{
//}

// CMyRibbonApplicationButton 成员函数
void CMyRibbonApplicationButton::OnLButtonDblClk(CPoint point)
{
return;
}

void CMyRibbonApplicationButton::OnLButtonDown(CPoint point)
{
return;
}

 

3. 

在CMainFrame的中的OnCreate函数中找到

m_wndRibbonBar.LoadFromResource(IDR_RIBBON);

在这一行的下面添加

CMFCRibbonApplicationButton* pMainButton = m_wndRibbonBar.GetApplicationButton();
delete pMainButton; //删除框架自动生成的RibbonApplicationButton

CMyRibbonApplicationButton* pMyMainButton = new CMyRibbonApplicationButton();
pMyMainButton->SetImage(IDB_MAIN);
m_wndRibbonBar.SetApplicationButton(pMyMainButton, CSize(45, 45));

就可以了。

禁用CMFCRibbonApplicationButton的单击和双击事件

标签:

原文地址:http://www.cnblogs.com/chenzeming/p/5872880.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!