CMFCRibbonColorButton automatic color selection seems broken - VS2010
I am hoping someone can explain the functionality of the Automatic button on this control (also the CMFCColorButton). I have an MFC app that has a ribbon. I used the ribbon designer to add a couple of color buttons. The ribbon designer in VS2010 allows for specifying many of the color button's properties at design time. Specifically, the Automatic color, which I have set to a non-black value.
In code, you can also specify the Automatic color with the EnableAutomaticButton() method.
This control seems to work as if the selection of the automatic color always returns the color that Windows thinks should be the automatic color (ie button face, button text, etc ) for the control/text to which it is applied.
My experience with this thing has been that pressing the automatic button always causes the control to set the m_Color member to a value of (COLORREF)-1. Meaning subsequent calls to GetColor() always return this (COLORREF)-1 value, which, when applied to something for coloring, always takes on a "system default" look.
Maybe that is what is supposed to happen, but the I question the ability to actually set a value for the Automatic Color property. What good is it if it is essentially ignored for a "system default"? The fact that you can specify a value for that property (m_ColorAutomatic), but it's ignored seems, to me anyway, a bug.
Here is a link to a demo app that, with one small code change, shows the behavior I am talking about: http://archive.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=vcsamplesmfc&DownloadId=9821
Change the following line in the view.cpp method: OnInitialUpdate():
Build with the change and run it. Make use of the Automatic Button (labeled "Default" in the color popup). For me, the status bar text does NOT change color when pressing the Automatic Button. Again, I am using VS2010. And this demo app uses the CMFCColorButton, which seems to exhibit the same behavior as does CMFCRibbonColorButton.
// change to specify a value of 255 (red) as the automatic color
m_wndTextColor.EnableAutomaticButton (_T("Default"), 255 /*afxGlobalData.clrBtnText*/);
Please tell me this is not just me and this behaves the same for someone out there. It just doesn't feel right to me. Why allow us to specify a color for that property if it's ignored?
Lower level, what's happening is when you press that button, the m_Color member of the control is set to (COLORREF)-1. I contend that it should be set to the value of the m_ColorAutomatic member. By design or bug? I'd just like to understand the reasoning behind the behavior.