Click to open or copy the SUBEDIT project files.
This sample demonstrates how to create an ATL control that superclasses the standard Windows Edit control.
ATL provides the ability to create a control that superclasses a standard Windows control. Superclassing allows you to create a window class that is based on an existing class but uses a different window procedure. You then create a window based on this new window class. When you superclass a control, messages are first processed by an ATL message map before being sent to the control's original window procedure. This allows you to modify the default behavior of standard Windows controls.
When you use the ATL Object Wizard to create an ActiveX control, you can choose to add a control based on a standard window class. In this case, the wizard adds a member variable of type CContainedWindow to your ActiveX control's class. CContainedWindow::Create then creates a window that superclasses the window class you specified. This window uses CContainedWindow::WindowProc to route its messages through a message map. If a message needs further processing, it is sent to the original window procedure of the window class.
Building the SUBEDIT Control
Download the sample files, build the control, and insert it into a container.
Examining the SUBEDIT Sample Code (AtlEdit.h)
This sample uses the following keywords:
CComCoClass; CComControl; CComModule::GetClassObject; CComModule::GetLockCount; CComModule::Init; CComModule::RegisterServer; CComModule::Term; CComModule::UnregisterServer; CComObjectRoot; CContainedWindow::DefWindowProc; DisableThreadLibraryCalls; GetStockObject; GetWindowRect; IDataObjectImpl; IDispatchImpl; IOleControlImpl; IOleInPlaceActiveObjectImpl; IOleInPlaceObjectWindowlessImpl; IOleInPlaceObjectWindowlessImpl::SetObjectRects; IOleObjectImpl; IPersistStorageImpl; IPersistStreamInitImpl; IProvideClassInfo2Impl; IQuickActivateImpl; ISpecifyPropertyPagesImpl; IViewObjectExImpl; SetBkColor; SetTextColor; SetWindowPos