Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
SSW_8_11.doc
Скачиваний:
1
Добавлен:
01.05.2025
Размер:
5 Мб
Скачать
☆

13.5 ActiveX Documents

This article includes details about the steps needed to add ActiveX document object support to your application. There are several paths you can take, depending on the support for ActiveX your application currently has.

Add ActiveX Document Support to a New Application

In AppWizard, you can create a new application with ActiveX document support by choosing Full Server, or Both Container and Server when asked to specify "What compound document support would you like to include?", and selecting the check box for ActiveX document server.

Convert an Existing MFC In-Process Server to an ActiveX Document Server. If your application was created with a version of Visual C++ prior to version 4.2 and is already an in-process server, you can add ActiveX document support by making changes to the following classes:

Class type

Formerly derived from

Change to derive from

In-Place Frame

COleIPFrameWnd

COleDocIPFrameWnd

Item

COleServerItem

CDocObjectServerItem

You will also change how information is entered in the registry, and make several other changes. If your application currently has no ActiveX components support, you can add server support by running AppWizard and integrating the ActiveX component-specific code with your existing application.

Add ActiveX Document Support to an Existing Application That Currently Has No ActiveX Support

ActiveX Controls

An ActiveX control is implemented as an in-process server (typically a small object) that can be used in any OLE container. Note that the full functionality of an ActiveX control is available only when used within an OLE container designed to be aware of ActiveX controls. Currently, Microsoft FoxPro 3.0, Microsoft Access 2.0, Microsoft Visual Basic 4.0, and OLE containers built with MFC in Visual C++ version 4.0 fully support ActiveX controls. This container type, hereafter called a "control container," can operate an ActiveX control by using the control's properties and methods, and receives notifications from the ActiveX control in the form of events. The following figure demonstrates this interaction.

Basic Components of an ActiveX Control

An ActiveX control uses several programmatic elements to interact efficiently with a control container and with the user. These are class COleControl, a set of event-firing functions, and a dispatch map.

Every ActiveX control object you develop inherits a powerful set of features from its MFC base class, COleControl. These features include in-place activation, and Automation logic. COleControl can provide the control object with the same functionality as an MFC window object, plus the ability to fire events. COleControl can also provide windowless controls, which rely on their container for help with some of the functionality a window provides (mouse capture, keyboard focus, scrolling), but offer much faster display.

Because the control class derives from COleControl, it inherits the capability to send, or "fire," messages, called events, to the control container when certain conditions are met. These events are used to notify the control container when something important happens in the control. You can send additional information about an event to the control container by attaching parameters to the event. For more information about ActiveX control events, see the article ActiveX Controls: Events.

The final element is a dispatch map, which is used to expose a set of functions (called methods) and attributes (called properties) to the control user. Properties allow the control container or the control user to manipulate the control in various ways. The user can change the appearance of the control, change certain values of the control, or make requests of the control, such as accessing a specific piece of data that the control maintains. This interface is determined by the control developer and is defined using ClassWizard.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]