You are currently offline, waiting for your internet to reconnect

Converting Between OLE_COLOR and COLORREF Types

Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
This article shows by example how to use the COleControl::TranslateColor()method can be used to convert an OLE_COLOR value into a COLORREF value byusing the cast operator.
More information
The main difference between an OLE_COLOR and a COLORREF is that if anOLE_COLOR has its high-order bit set, the low-order byte is treated as asystem color index. The function OleTranslateColor(), which is called byCOleControl::TranslateColor(), translates the system color index into aCOLORREF when this condition is detected. The following code illustratesconversion between an OLE_COLOR and a COLORREF:
     void CMyOleControl::ConversionTest()   {      OLE_COLOR ocBack = GetBackColor();      // Convert OLE_COLOR to COLORREF      COLORREF clrBack = TranslateColor(ocBack);      // Convert COLORREF to OLE_COLOR      OLE_COLOR ocConverted = (OLE_COLOR)clrBack;   }				
For a complete list of the translations performed by OleTranslateColor(),or for more information about the OLE_COLOR type, please see the "MicrosoftOLE Control Developer's Kit User's Guide and Reference," Appendix D: OLEControls Architecture, under the heading "Standard Color Type."
kbinf 1.00 1.10

Article ID: 131101 - Last Review: 06/22/2014 17:56:00 - Revision: 4.0

  • KB131101