Dear All,
I would like to access to the user selected color in a color pallete added to a Ribbon bar. By now I have created the Ribbon button, added it to the panel, added an event to handle the "click" on that button and overwritten the OnEraseBkgnd(CDC* pDC) in my view class.
I present some code snippets. I at this stage I am not able to access to the background color selected by the suer.
In the view class:
..
//background color message:
ON_COMMAND(ID_RIBBON_RIBBON12,&CHowdenSelectView::OnBackgroundColor)
...
BOOL CHowdenSelectView::OnEraseBkgnd(CDC* pDC)
{
CBrush backBrush(RGB(m_rValue,128,128));
m_rValue+=10;
if(m_rValue>255)
{
m_rValue=0;
}
CBrush *pOldBrush = pDC->SelectObject(&backBrush);
CRect rect;
pDC->GetClipBox(&rect);
pDC->PatBlt(rect.left,rect.top,rect.Width(),rect.Height(),PATCOPY);
pDC->SelectObject(pOldBrush);
return true;}
void CHowdenSelectView::OnBackgroundColor()
{
this->OnEraseBkgnd(this->GetDC());
}
...
In the mainframe:
//view tab
pCategory = m_wndRibbonBar.AddCategory(_T("View"),IDB_FILESMALL, IDB_FILELARGE);
pPanel = pCategory->AddPanel(_T("Visual Style"));
CMFCRibbonColorButton *pColorButton = new CMFCRibbonColorButton (ID_RIBBON_RIBBON12,_T ("Background color"),TRUE,1, -1);//by putting -1 u specify that there is no color
pColorButton->SetDefaultCommand(FALSE);
pColorButton->EnableAutomaticButton(_T("&Automatic"),RGB(0,0,0)); //select default: minute: 13:32.
pColorButton->EnableOtherButton(_T("&More Colors..."),_T("More colors tooltip"));
pPanel->Add(pColorButton);
Could anyone suggest me how to access to the currently selected color in the OnBackgroundColor method? Many thanks and best regards!
oengCC