Reputation: 31
The application is using the Windows 7 ribbon style by default:
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));
i want to create a new Visual Style where i implemented different colors, so i created the class CMyVisualStyle
that inherits from CMFCVisualManagerOffice2007
.
This is the .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);
This is the .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);
}
And i edited this in the the mainframe.cpp:
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMyVisualStyle::GetThisClass()));
//CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));
But it seems like the RUNTIME_CLASS
can't find my class, error:
Compiler Error C2653 'identifier' : is not a class or namespace name The language syntax requires a class, structure, union, or namespace name here.
Update: i included the MyVisualStyle.h
and it fixed the error. But it doesn't seem to change the Visual style of my ribbon bar.
Upvotes: 1
Views: 699
Reputation: 15355
Just use
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMyVisualStyle));
Upvotes: 1