Article ID: 148242 - Last Review: November 21, 2006 - Revision: 3.1 How to change the background color of an OLE control in Visual C++This article was previously published under Q148242 Note Microsoft Visual C++ .NET (2002) supports both the managed code
model that is provided by the Microsoft .NET Framework and the unmanaged native
Microsoft Windows code model. The information in this article applies only to
unmanaged Visual C++ code. On This PageSUMMARY This article describes how to modify the background color
of an OLE control that subclasses a Windows Control. Sample code for an
Edit control is provided. This article also applies to Button, Static, ListBox, and ComboBox controls. MORE INFORMATION
For more information about the exact WM_CTLCOLORxxx message that is sent by each control, click the following article number to view the article in the Microsoft Knowledge Base:
130952
(http://support.microsoft.com/kb/130952/
)
WM_CTLCOLORxxx message changes
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 Example
REFERENCES Refer 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." APPLIES TO
| Article Translations
|

Back to the top
