默认情况下,应用程序使用Windows 7功能区样式:
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));我想创建一个新的视觉样式,其中我实现了不同的颜色,因此我创建了继承自CMFCVisualManagerOffice2007的类CMyVisualStyle。这是.h:
class CMyVisualStyle : public CMFCVisualManagerOffice2007
{
DECLARE_DYNCREATE(CMyVisualStyle)
public:
CMyVisualStyle();
~CMyVisualStyle();
virtual COLORREF OnDrawRibbonPanel(CDC* pDC, CMFCRibbonPanel* pPanel, CRect rectPanel, CRect rectCaption);
virtual void OnDrawRibbonCategory(CDC* pDC, CMFCRibbonCategory* pCategory, CRect rectCategory);这是.cpp:
#include "stdafx.h"
#include "MyVisualStyle.h"
#define IMPLEMENT_DYNCREATE(CMyVisualStyle, CMFCVisualManagerOffice2007)
CMyVisualStyle::CMyVisualStyle()
{
}
CMyVisualStyle::~CMyVisualStyle()
{
}
COLORREF CMyVisualStyle::OnDrawRibbonPanel(CDC* pDC, CMFCRibbonPanel* pPanel, CRect rectPanel, CRect rectCaption)
{
CBrush br(RGB(0, 0, 255));
pDC->FillRect(rectPanel, &br);
return RGB(0, 255, 0);
}
void CMyVisualStyle::OnDrawRibbonCategory(CDC* pDC, CMFCRibbonCategory* pCategory, CRect rectCategory)
{
CBrush br(RGB(255, 0, 0));
pDC->FillRect(rectCategory, &br);
//return RGB(0, 255, 0);
}我在mainframe.cpp中编辑了这个:
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMyVisualStyle::GetThisClass()));
//CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));但似乎编译器找不到我的类,错误:编译器错误标识符‘RUNTIME_CLASS’:is not a class or namespace name这里的语言语法需要一个类、结构、联合或名称空间名称。
更新:我包含了MyVisualStyle.h,它修复了这个错误。但它似乎并没有改变我的功能区的视觉风格。
发布于 2019-11-28 22:31:08
只需使用
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMyVisualStyle));https://stackoverflow.com/questions/59087697
复制相似问题