Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any way to get a handle for the CMFCColorButton so I can get the return color of the selected color from the Ribbon in MFC?
Posted
Updated 4-Mar-12 3:40am
v2

1 solution

(with the help of MSDN and google)

You need to "find" the button by ID (kind of a bummer, but I've not looked further into that) in the handler of the button


// new handler for the button in the ribbon bar. (created when editing the ribbon in the resource editor
C++
//...
ON_COMMAND(ID_BUTTON5, &CMainFrame::OnColorButton)
//...
void CMainFrame::OnColorButton()
{
  // ID_BUTTON5 is the ID of the color button I created in the resource editor.
  CMFCRibbonColorButton* pColorBtn = DYNAMIC_DOWNCAST( CMFCRibbonColorButton, m_wndRibbonBar.FindByID(ID_BUTTON5));
  COLORREF color  = pColorBtn->GetColor();
}


(tried on VS11, I don't have other version at home, so YMMV).
 
Share this answer
 
Comments
DrBones69 4-Mar-12 17:00pm    
Thanks Max! Somewhere in the shuffle I became confused with searching for CMFCColorButton & Ribbon, but should have been searching for CMFCRibbonColorButton. Thanks Again.

-DrB

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900