More Wizard Options for Controls

[Previous] [Next]

In addition to the normal options (which you can apply to all COM objects), the ATL Object Wizard gives you several options specific to control creation. First, the ATL Object Wizard lets you subclass your control from a regular control (such as a button control or an edit control). You can specify other options for your control—make the control opaque, give it a solid background, render it invisible at run time, make it act like a button, and so on. In this section, we give you a rundown of the options available in the control's property pages. Figure 10-1 shows the control options available through the ATL Object Wizard's Miscellaneous property page.

Figure 10-1. The ATL Object Wizard's Miscellaneous property page.

Here's a description of each option:

  • Opaque and Solid Background If you want to be sure that none of the container shows behind the control boundaries, select the Opaque checkbox to render your control completely opaque. Choosing this option sets the VIEWSTATUS_OPAQUE bit so that IViewObjectExImpl::GetViewStatus indicates an opaque control to the container. You can also specify a solid background for your control. The Solid Background option sets the VIEWSTATUS_SOLIDBKGND bit so that GetViewStatus indicates the control has a solid background.
  • Add Control Based On Choose this option to cause your control to subclass from one of the standard window classes. The drop-down list contains window class names defined by Windows. When you choose one of these names, the wizard adds a CContainedWindow member variable to your control's class. CContainedWindow::Create will superclass the window class you specify.
  • Invisible At Runtime Choose this option to make your control invisible at run time. You can use invisible controls to perform operations in the background, such as firing events at timed intervals. Picking this option causes the control to flip the OLEMISC_INVISIBLEATRUNTIME bit when it places entries in the Registry.
  • Acts Like Button Choose this option to enable your control to act like a button. In this case, the control will display itself as the default button based on the value of the container's ambient property DisplayAsDefault. If the control's site is marked as a default button, the control draws itself with a thicker frame. Selecting this option causes the control to flip the OLEMISC_ACTSLIKEBUTTON bit when it places entries in the Registry.
  • Acts Like Label Choose this option to enable your control to replace the container's native label. Picking this option causes the control to mark the OLEMISC_ACTSLIKELABEL bit when it places entries in the Registry.
  • Normalize DC Choose this option to have your control create a normalized device context when it is called to draw itself. This standardizes the control's appearance but is less efficient than the standard drawing method. This option generates code to override the OnDrawAdvanced method (instead of the normal OnDraw method).
  • Insertable Choose this option to have your control appear in the Insert Object dialog box of applications such as Microsoft Word and Microsoft Excel. Your control can then be inserted by any application that supports embedded objects through the Insert Object dialog box. Choosing this option adds the Insertable key as part of the control's Registry entries.
  • Windowed Only Choose this option to force your control to be windowed, even in containers that support windowless objects. If you don't select this option, your control will automatically be windowless in containers that support windowless objects and will automatically be windowed in containers that don't support windowless objects. Choosing this option causes the Object Wizard to generate code to set the flag CComControlBase::m_bWindowOnly to TRUE in the constructor. ATL uses this flag to decide whether to query for the container's IOleInPlaceSiteWindowless interface during activation.

You can also decide on your object's stock properties up front. In the Stock Properties page, select the stock properties you want the object to support, such as Caption or Border Color. You can select all the stock properties at once by clicking the >> button. This adds properties to the control's property map.

After you run the ATL COM AppWizard and the Object Wizard, you get a DLL replete with all the hooks necessary to be a COM DLL. The well-known exports that the control exposes include DllGetClassObject, DllCanUnloadNow, DllRegisterServer, and DllUnregisterServer. In addition, you get an object that satisfies the main requirements of COM, including a main incoming interface and a class object.

Once you've started a project using one of the wizards, your next step is to get the control to do something interesting. Let's look at an ActiveX control that actually does some real work.

Inside Atl
Inside ATL (Programming Languages/C)
ISBN: 1572318589
EAN: 2147483647
Year: 1998
Pages: 127 © 2008-2017.
If you may any questions please contact us: