首页 > 移动平台 > 详细

禁用CMFCRibbonApplicationButton的单击和双击事件

时间:2016-09-14 18:35:46      阅读:589      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!