禁用CMFCRibbonApplicationButton的单击和双击事件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了禁用CMFCRibbonApplicationButton的单击和双击事件相关的知识,希望对你有一定的参考价值。
为了禁用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的单击和双击事件的主要内容,如果未能解决你的问题,请参考以下文章