MFC功能区栏中的CMFCColorButton控件 [英] CMFCColorButton control in an MFC Ribbon Bar

查看:602
本文介绍了MFC功能区栏中的CMFCColorButton控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以获取CMFCColorButton的句柄,以便可以从MFC的功能区中获取所选颜色的返回颜色吗?

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?

推荐答案

(with MSDN和google的帮助)

您需要在按钮的处理程序中按ID(有点笨拙,但我没有进一步研究)找到"按钮


//功能区栏中按钮的新处理程序. (在资源编辑器中编辑功能区时创建的
(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
//...
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();
}



(在VS11上试用,我在家中没有其他版本,因此YMMV).



(tried on VS11, I don''t have other version at home, so YMMV).


这篇关于MFC功能区栏中的CMFCColorButton控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆