HOWTO: Handle OCM_CTLCOLORxxx Reflected MessagesLast reviewed: July 2, 1997Article ID: Q148242 |
The information in this article applies to:
SUMMARYThis article shows you how to change the background color of an OLE control that subclasses a Windows Control, with sample code for an Edit control. This article should apply to Button, Static, ListBox, and ComboBox controls as well.
MORE INFORMATIONPlease refer to the following article in the Microsoft Knowledge Base:
ARTICLE_ID : Q130952 TITLE : WM_CTLCOLORxxx Message Changes for Windows 95for more about the exact WM_CTLCOLORxxx message sent by each control. If a control sends the WM_CTLCOLORSTATIC, you have to handle the OCM_CTLCOLORSTATIC message in the OCX and so on. To change the background color of an OLE Control that subclasses an Edit Control, you must handle the OCM_CTLCOLOREDIT(32-bit) messages. These messages are intercepted by the "reflector window" (created for an OLE control that subclasses a Windows control) that reflects them back to the OLE control itself. In response to these reflected messages, you must set the background color (and optionally the foreground color) and return a handle to a brush initialized with the background color.
Step-by-Step ExampleThe sample code in this example illustrates how to handle OCM_CTLCOLOREDIT in order to change the background color of an OLE control that subclasses an Edit control
REFERENCESRefer to technical article “TN062: Message Reflection for Windows Controls” and the article “ActiveX Controls: Sub-classing a Windows Control in Visual C++ Programmer's Guide.” |
Keywords : kbprg MfcOLE kbhowto
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |