Repository navigation
SubEdit
Directory actions
More options
Directory actions
More options
SubEdit
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
<!--TO READ THIS HELP FILE, RIGHT-CLICK ON THE FILE NAME IN THE
SOLUTION EXPLORER PANE AND SELECT "VIEW IN BROWSER"-->
<html><head><title>SUBEDIT Attributes Sample: Superclasses a Standard Windows Control</title></head><body><h1>SUBEDIT Attributes Sample: Superclasses a Standard Windows Control</h1><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()"></div><p /><p>The SUBEDIT attributes sample demonstrates how to create an ATL control that superclasses the standard Windows Edit control.</p><p>The SUBEDIT sample is the nonattributed version of this sample.</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Security Note </th></tr><tr><td><p>This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.</p></td></tr></table></div><h1 class="heading">Building and Running the Sample</h1><div id="sectionSection0" class="seeAlsoNoToggleSection"><h4 class="subHeading">To build and run this sample</h4><div class="subSection"><ol><li><p>Open the solution file SubEdit.sln.</p></li><li><p>From the <b>Build</b> menu, click <b>Build</b>.</p></li><li><p>After the sample builds, open AtlEdit.htm in your Web browser and try out the control.</p></li></ol></div><p>You can test out the control in the ActiveX Control Test Container by opening the ATLEdit Class. For details on accessing Test Container and using it to test a control, see <MSHelp:link keywords="626867CF-FE53-4C30-8973-55BB93EF3917" tabindex="0" >Testing Properties and Events with Test Container</MSHelp:link>.</p></div><h1 class="heading">Superclassing a Windows Control</h1><div id="sectionSection1" class="seeAlsoNoToggleSection"><p>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.</p><p>When you use the ATL Controls 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 <b>CContainedWindow</b> to your ActiveX control's class. <b>CContainedWindow::Create</b> then creates a window that superclasses the window class you specified. This window uses <b>CContainedWindow::WindowProc</b> 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.</p></div><h1 class="heading">Examining the Sample Code (AtlEdit.h)</h1><div id="sectionSection2" class="seeAlsoNoToggleSection"><p>The constructor for the <b>CAtlEdit</b> class sets the <b>m_bWindowOnly</b> member variable to <b>TRUE</b>. This ensures the control will never activate as a windowless control.</p><p>The <b>CContainedWindow</b> member variable, <b>m_EditCtrl</b>, is initialized by the <b>CAtlEdit</b> constructor. The <b>CContainedWindow</b> constructor takes three parameters: the name of the window class to be superclassed (in this case, "EDIT"); a pointer to the <b>CAtlEdit</b> class, which contains the message map; and the identifier of the message map that will process <b>m_EditCtrl</b>'s messages. By default, <b>m_EditCtrl</b> uses an alternate message map, declared with the <b>ALT_MSG_MAP</b> macro.</p><p>The default message map declares the names of the handler functions for <b>WM_CREATE</b> and <b>WM_CTLCOLOREDIT</b> messages sent to the <b>CAtlEdit</b> control. The <b>OnCreate</b> handler calls <b>CContainedWindow::Create</b> to create <b>m_EditCtrl</b>'s window. The <b>OnCtlColorEdit</b> handler specifies a new background and text color for <b>m_EditCtrl</b>.</p><p>The alternate message map declares a handler function for <b>WM_CHAR</b> messages sent to <b>m_EditCtrl</b>. This handler only accepts characters, not symbols or numbers, and then passes the <b>WM_CHAR</b> message to the original window procedure defined by the Windows Edit class.</p></div><h1 class="heading">Attributes</h1><div id="sectionSection3" class="seeAlsoNoToggleSection"><p>This sample uses the following attributes:</p><p>coclass, com_interface_entry, default, dual, emitidl, helpstring, implements_category, module, object, pointer_default, progid, registration_script, threading, uuid, version, vi_progid</p></div><h1 class="heading">Keywords</h1><div id="sectionSection4" class="seeAlsoNoToggleSection"><p>This sample uses the following keywords:</p><p>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</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note </th></tr><tr><td><p>Some of the samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task. </p></td></tr></table></div></div></div><div id="footer"><div class="footerLine"></div>
© Microsoft Corporation. All rights reserved. Send <a href="mailto:DevDocs@microsoft.com?subject=Documentation Feedback :SUBEDIT Attributes Sample: Superclasses a Standard Windows Control">comments</a> about this topic to Microsoft.
</div></div></body></html>