ON THE WEB
http://www.microsoft.com/visualc/prodinfo/atlinst.htm[em] Remember, this chapter specifically covers ATL 2.1. If you're using an older version of ATL, you can get the latest version from Microsoft's Web site. If you're using Visual C++ 4.0, 4.1, or 4.2, you must also upgrade to version 4.2b or higher of Visual C++ to use ATL 2.1.
![]()
An OCX is the same thing as a DLL. Before Microsoft started naming everything in sight "Active," OLE controls were named with the OCX extension. Because they're just DLLs, though, the OCX suffix was quietly dropped. You can use either extension in your projects.![]()
![]()
An Internet Explorer control can only be used in Web browsers that support the Internet Explorer control interface. A Full Control, however, can be used in any application that supports ActiveX controls, including Internet Explorer. Use IE controls when you want them to run only in Web browsers; otherwise, use full controls.![]()
![]()
It might seem like Visual C++ is taking an extremely long time to build your ATL control. Because ATL makes heavy use of C++ templates, the compiler has to do quite a bit of extra work, which slows it down. For more information on C++ templates, see "Exploring Templates" in Chapter 21, "Exceptions and Other Power Features."![]()
![]()
For more information about the use of registry script files and their syntax, see the Visual C++ books online subject ?Registry Scripting Examples[md]Active Template Library, Articles.?![]()
![]()
TSTCON32 is deceptively simple; it actually offers a good simulation of a complex container like Imagineer Technical or Microsoft Word. You can save embedded objects, call individual methods of embedded controls, and view logs of events sent to controls[md]and that's just for starters! Check out TSTCON32's online help for full details on its capabilities.![]()
![]()
All optional parameters must be of type VARIANT, and they must fall at the end of the parameter list. Optional parameters are not managed in any way by OLE. It is the control's responsibility to determine whether or not the VARIANT parameter passed to the method contains data and whether or not to do the following:
- If legal data were passed, use the data passed to the method or convert the data to a useful type, if possible.
- If invalid data were passed, ignore the parameter and use the default value if appropriate.
- Inform the user of an error condition.
I
Direction | Description |
in | Parameter is passed from control to container. |
out | Parameter is returned from container to control. |
in, out | Parameter is passed from controlto container, and the container returns a parameter. |
out, retval | Parameter is the return value of the method and is returned from the container to the control. |
![]()
The complete source code and executable file for the ATLControlWin control is located in the Chap31\ATLControlWin folder on the book's CD-ROM.![]()
![]()
The EALIGNMENT enumeration is defined in its own stand-alone include file so that you can use it elsewhere. It's good practice to separate enumerations such as this so that you can easily use them in more than one source file.![]()
![]()
The files ATLCONV.H and ATLCONV.CPP, which can be found in \DevStudio\VC\ATL\include directory, contain a number of helper functions and macros for data conversions, including Unicode-ANSI string converters. Because ATL doesn't require you to use MFC, you can use these routines instead of writing your own.![]()
![]()
Even though the VARIANT varAlignment is defined as [optional] for both the get_CaptionProp and put_CaptionProp functions, only the get_CaptionProp implementation is truly optional. The alignment parameter has to be added as optional because the ATL ClassWizard won't allow you to generate two separate functions that have the same name and ID. The [optional] attribute can be removed from the put_CaptionProp function later without any adverse effect.![]()
![]()
The documentation about the use of the IMPLEMENT_STOCKPROP and IMPLEMENT_BSTR_STOCKPROP macros within your class is somewhat misleading. The macros depend on the CStockPropImpl<?> class, and they cannot simply be added to your control implementation, as is implied by the ATL documentation on support of stock properties.
![]()
Remember to use the guidgen.exe program to create a new UUID for your IDispatch interface. Do not reuse the UUIDs in the sample, because they might collide with other registered UUIDs on your machine.
![]()
See the ATL and ActiveX documentation for information regarding the implementation of the IProvideClassInfo2 interface.
![]()
Overlapped painting and unnecessary drawing[md]drawing areas of the control that do not need to be drawn[md]are the greatest sources of flicker and flash. Try to draw only to the areas of the control that have been invalidated. For example, if your control has a white background and a black border, draw only the white portion where it is going to be seen. Don?t redraw the border, for this causes the control to flash every time it gets a paint message.